From 732422d7138674ab2e375117def4351a5b59e271 Mon Sep 17 00:00:00 2001 From: yxq Date: Tue, 2 Jul 2024 14:09:22 +0800 Subject: [PATCH] =?UTF-8?q?h5=20=E8=80=83=E5=8B=A4=E6=89=93=E5=8D=A1?= =?UTF-8?q?=E6=95=B4=E4=BD=93=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LearunApp-2.2.0/App.vue | 10 +- .../LearunApp-2.2.0/common/wxFn.js | 38 ++- .../LearunApp-2.2.0/config.js | 2 +- .../LearunApp-2.2.0/manifest.json | 28 ++- .../pages/AttendanceCard/list.vue | 216 +++++++--------- .../pages/AttendanceCardTeacher/list.vue | 232 ++++++++---------- .../LearunApp-2.2.0/vue.config.js | 2 +- 7 files changed, 233 insertions(+), 295 deletions(-) diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/App.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/App.vue index f5834595c..22441d052 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/App.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/App.vue @@ -6,20 +6,12 @@ async onLaunch(param) { // 版本更新 - var newVer = '1.0.2'; + var newVer = '1.1.2'; var oldVer = localStorage.getItem('version');     if (newVer != oldVer) { localStorage.setItem('version', newVer); this.JUMP_TO("/") } - // 加载百度地图资源 - let ak = this.GET_AK() - var script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = - 'https://api.map.baidu.com/api?v=1.0&type=webgl&ak=' + ak + - '&callback=' + 'initMap'; - document.head.appendChild(script); // 在App.vue文件中获取到页面到URL (初始化WXsdj) window.localStorage.setItem('scanUrl',location.href.split('#')[0]) diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/wxFn.js b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/wxFn.js index 35be97152..dfe25857b 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/wxFn.js +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/common/wxFn.js @@ -1,12 +1,10 @@ +window.wx = null +window.wxInit = false import wx from '@/common/js/weixin-js-sdk.js'; +window.wx = wx // 参考文档 https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html export default { methods: { - data(){ - return { - wxInit:false - } - }, // 初始化wx initWx(arr = ["getLocation"]) { const promise = new Promise((resolve, reject) => { @@ -28,15 +26,28 @@ export default { signature: success.certificate, // 必填,签名 jsApiList: arr // 必填,需要使用的JS接口列表 }); + // 公众平台测试账号本地调试使用 + // console.log({nonceStr: success.noncestr,timestamp: success.timestamp,url}) + // wx.config({ + // debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 + // appId: 'wx2aa8dcf3603f77b5', // 必填,公众号的唯一标识 + // timestamp: '1719897639109', // 必填,生成签名的时间戳 + // nonceStr: "202407011704072775", // 必填,生成签名的随机串 + // signature: "af7666f9ed1355756b80561cf7b358fb603f7963", // 必填,签名 + // jsApiList: arr // 必填,需要使用的JS接口列表 + // }); wx.ready(() => { - this.wxInit = true - // this.TOAST("wx初始化成功") + window.wxInit = true resolve(true) }) - wx.error(() => { + wx.error((error) => { + // alert(JSON.stringify(error)) this.TOAST("wx初始化失败") resolve(false) }) + setTimeout(()=>{ + resolve("wx初始化超时") + },5000) }) }) return promise @@ -44,9 +55,10 @@ export default { // 获取定位 async getLocation() { return new Promise(async (resolve) => { - if (!this.wxInit) { + if (!window.wxInit) { let res = await this.initWx(["getLocation"]) - if(!res){ + if(!res||res=='wx初始化超时'){ + res&&this.TOAST(res) resolve(false) return } @@ -54,6 +66,7 @@ export default { if(!wx.getLocation){ this.TOAST("获取定位失败") resolve(false) + return } wx.getLocation({ type: "gcj02", // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' @@ -68,6 +81,7 @@ export default { }) }, fail: (error) => { + // alert(JSON.stringify(error)) this.TOAST("获取定位失败!") resolve(false) } @@ -77,7 +91,7 @@ export default { // 拍照 async chooseImage() { return new Promise(async (resolve) => { - if (!this.wxInit) { + if (!window.wxInit) { let res = await this.initWx(["chooseImage"]) if(!res){ resolve(false) @@ -106,7 +120,7 @@ export default { // 预览图片 async previewImage(url,urlArr) { return new Promise(async (resolve) => { - if (!this.wxInit) { + if (!window.wxInit) { let res = await this.initWx(["previewImage"]) if(!res){ resolve(false) diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/config.js b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/config.js index 1a67a30e9..66516c689 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/config.js +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/config.js @@ -2,7 +2,7 @@ export default { // 登录页显示的公司名称 "company": "数字化智慧校园", // App 版本号 - "appVersion": "1.0.0", + "appVersion": "1.1.2", // 是否允许用户注册 "enableSignUp": true, //请求数据的接口地址;可以配置多个,开发环境下登录页会出现选择菜单供您选择 diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/manifest.json b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/manifest.json index be4296f28..e004d90f4 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/manifest.json +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/manifest.json @@ -165,16 +165,24 @@ } }, "h5" : { - // "devServer": { - // "proxy" : { - // "/api" : { - // "target" : "http://192.168.10.58:8011/", //自己项目接口域名 - // "changeOrigin" : true, //是否跨域 - // // "secure" : true, // 设置支持https协议的代理 - // "pathRewrite": {"^/api":""} //api路径重定向,根据具体情况调整,也可不写 - // } - // } - // }, + "devServer" : { + "proxy" : { + // "/api" : { + // "target" : "http://192.168.10.58:8011/", //自己项目接口域名 + // "changeOrigin" : true, //是否跨域 + // // "secure" : true, // 设置支持https协议的代理 + // "pathRewrite": {"^/api":""} //api路径重定向,根据具体情况调整,也可不写 + // }, + "/baiduapi" : { + "target" : "https://api.map.baidu.com/", + "changeOrigin" : true, + "secure" : true, // 设置支持https协议的代理 + "pathRewrite" : { + "^/baiduapi" : "" + } //api路径重定向,根据具体情况调整,也可不写 + } + } + }, "uniStatistics" : { "enable" : false }, diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/AttendanceCard/list.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/AttendanceCard/list.vue index 5a85b4a54..9e6117410 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/AttendanceCard/list.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/AttendanceCard/list.vue @@ -40,7 +40,6 @@ -