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: '',
}
},
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 @@
<style lang="scss">
@import "./homepage.scss";
</style>
</style>

View File

@ -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)
// }
// });
// }
// },
// });
// }
// }
// })
},
}
}

View File

@ -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 {
// //因为没有选择总是保持,所以需要调起授权弹窗再次授权
// }
// }
// })
},
}
})