From 49cc34fb07369c2e3daa51f915a52a35c0a8a16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BE=89?= <814457906@qq.com> Date: Mon, 17 Jun 2024 16:33:34 +0800 Subject: [PATCH] xg --- pages/homepage/homepage.vue | 22 +++++++++-- pagesC/wxSport/wxSport.vue | 74 +++++++++++++++++++------------------ store/index.js | 19 +++++----- 3 files changed, 67 insertions(+), 48 deletions(-) diff --git a/pages/homepage/homepage.vue b/pages/homepage/homepage.vue index acbe013..65393f2 100644 --- a/pages/homepage/homepage.vue +++ b/pages/homepage/homepage.vue @@ -131,7 +131,11 @@ countyName: '', } }, - onLoad() {}, + onLoad() { + if (uni.getStorageSync('userinfo')) { + this.wxSportDecryptinfo(); + } + }, onShow() { this.baseurl = baseurl this.userinfo = uni.getStorageSync('userinfo') @@ -143,7 +147,6 @@ } if (uni.getStorageSync('userinfo')) { this.detailinfo(); - this.wxSportDecryptinfo(); } }, methods: { @@ -189,6 +192,19 @@ } } }); + } else { + wx.showModal({ + title: '提示', + content: '获取微信运动步数,需要开启此权限', + success: function(resp) { + if (resp.confirm) { + //跳转去设置 + wx.openSetting({ + success: function(respp) {} + }) + } + } + }) } } }) @@ -472,4 +488,4 @@ + \ No newline at end of file diff --git a/pagesC/wxSport/wxSport.vue b/pagesC/wxSport/wxSport.vue index fed722c..9b8ebc3 100644 --- a/pagesC/wxSport/wxSport.vue +++ b/pagesC/wxSport/wxSport.vue @@ -117,46 +117,48 @@ }, getStepInfo() { let that = this - wx.getSetting({ - success: function(res) { - // 未开启微信运动授权 - if (!res.authSetting['scope.werun']) { - wx.showModal({ - title: '提示', - content: '获取微信运动步数,需要开启计步权限', - success: function(resp) { - if (resp.confirm) { - //跳转去设置 - wx.openSetting({ - success: function(respp) {} - }) - } - } - }) - } else { - wx.login({ - success: function(loginres) { - if (loginres.code) { - wx.getWeRunData({ - success: function(WeRunDatares) { - that.wxSport(loginres, - WeRunDatares) - } - }); - } - }, - fail: function(err) { - wx.showModal({ - title: '提示', - content: '未开通微信运动,请关注“微信运动”公众号后重试', - showCancel: false, - confirmText: '知道了' - }) + wx.login({ + success: function(loginres) { + if (loginres.code) { + wx.getWeRunData({ + success: function(WeRunDatares) { + that.wxSport(loginres, WeRunDatares) } }); } } - }) + }); + // wx.getSetting({ + // success: function(res) { + // // 未开启微信运动授权 + // if (!res.authSetting['scope.werun']) { + // wx.showModal({ + // title: '提示', + // content: '获取微信运动步数,需要开启计步权限', + // success: function(resp) { + // if (resp.confirm) { + // //跳转去设置 + // wx.openSetting({ + // success: function(respp) {} + // }) + // } + // } + // }) + // } else { + // wx.login({ + // success: function(loginres) { + // if (loginres.code) { + // wx.getWeRunData({ + // success: function(WeRunDatares) { + // that.wxSport(loginres,WeRunDatares) + // } + // }); + // } + // }, + // }); + // } + // } + // }) }, } } diff --git a/store/index.js b/store/index.js index 4971f5d..eb03bc4 100644 --- a/store/index.js +++ b/store/index.js @@ -112,15 +112,16 @@ const store = new Vuex.Store({ // 是否设置过授权 openPopup(contxt) { // 获取用户的当前设置,判断是否点击了“总是保持以上,不在询问” - wx.getSetting({ - withSubscriptions: true, // 是否获取用户订阅消息的订阅状态,默认false不返回 - success(res) { - if (res.authSetting['scope.subscribeMessage']) {} else { - //因为没有选择总是保持,所以需要调起授权弹窗再次授权 - contxt.commit('subscribesuccess') - } - } - }) + contxt.commit('subscribesuccess') + // wx.getSetting({ + // withSubscriptions: true, // 是否获取用户订阅消息的订阅状态,默认false不返回 + // success(res) { + // console.log(res) + // if (res.authSetting['scope.subscribeMessage']) {} else { + // //因为没有选择总是保持,所以需要调起授权弹窗再次授权 + // } + // } + // }) }, } })