This commit is contained in:
2024-06-17 16:33:34 +08:00
parent 3ec0cbd5c8
commit 49cc34fb07
3 changed files with 67 additions and 48 deletions

View File

@ -131,7 +131,11 @@
countyName: '', countyName: '',
} }
}, },
onLoad() {}, onLoad() {
if (uni.getStorageSync('userinfo')) {
this.wxSportDecryptinfo();
}
},
onShow() { onShow() {
this.baseurl = baseurl this.baseurl = baseurl
this.userinfo = uni.getStorageSync('userinfo') this.userinfo = uni.getStorageSync('userinfo')
@ -143,7 +147,6 @@
} }
if (uni.getStorageSync('userinfo')) { if (uni.getStorageSync('userinfo')) {
this.detailinfo(); this.detailinfo();
this.wxSportDecryptinfo();
} }
}, },
methods: { methods: {
@ -189,6 +192,19 @@
} }
} }
}); });
} else {
wx.showModal({
title: '提示',
content: '获取微信运动步数,需要开启此权限',
success: function(resp) {
if (resp.confirm) {
//
wx.openSetting({
success: function(respp) {}
})
}
}
})
} }
} }
}) })

View File

@ -117,46 +117,48 @@
}, },
getStepInfo() { getStepInfo() {
let that = this let that = this
wx.getSetting({ wx.login({
success: function(res) { success: function(loginres) {
// if (loginres.code) {
if (!res.authSetting['scope.werun']) { wx.getWeRunData({
wx.showModal({ success: function(WeRunDatares) {
title: '提示', that.wxSport(loginres, WeRunDatares)
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.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)
// }
// });
// }
// },
// });
// }
// }
// })
}, },
} }
} }

View File

@ -112,15 +112,16 @@ const store = new Vuex.Store({
// 是否设置过授权 // 是否设置过授权
openPopup(contxt) { openPopup(contxt) {
// 获取用户的当前设置,判断是否点击了“总是保持以上,不在询问” // 获取用户的当前设置,判断是否点击了“总是保持以上,不在询问”
wx.getSetting({ contxt.commit('subscribesuccess')
withSubscriptions: true, // 是否获取用户订阅消息的订阅状态默认false不返回 // wx.getSetting({
success(res) { // withSubscriptions: true, // 是否获取用户订阅消息的订阅状态默认false不返回
if (res.authSetting['scope.subscribeMessage']) {} else { // success(res) {
//因为没有选择总是保持,所以需要调起授权弹窗再次授权 // console.log(res)
contxt.commit('subscribesuccess') // if (res.authSetting['scope.subscribeMessage']) {} else {
} // //因为没有选择总是保持,所以需要调起授权弹窗再次授权
} // }
}) // }
// })
}, },
} }
}) })