Commit 14f061ce by 穆启卓

授权页加了个直接去setting页的按钮,

二维码进小程序弹窗加了个取消按钮,
改了个授权步数没显示的bug
parent 90225ba4
...@@ -3,13 +3,67 @@ let getAuthLoading = false; ...@@ -3,13 +3,67 @@ let getAuthLoading = false;
Page({ Page({
data: { data: {
userAuth: false, userAuth: false,
stepAuth: false stepAuth: false,
stepGoSetting: true, // 步数授权是否变成直接去openSetting页的按钮
}, },
onLoad() { onLoad() {
this.setData({ wx.getSetting({
userAuth: app.globalData.userAuth, success:(res) => {
stepAuth: app.globalData.stepAuth // 用户信息是否授权
if (res.authSetting['scope.userInfo']) { // 已授权
app.globalData.userAuth = true;
} else { // 未授权
app.globalData.userAuth = false;
}
// 微信步数是否授权
let stepGoSetting = true;
if (res.authSetting['scope.werun'] === undefined) { // 未弹出过授权
app.globalData.stepAuth = false;
stepGoSetting = false;
} else if (res.authSetting['scope.werun'] === false) { // 拒绝过授权
app.globalData.stepAuth = false;
} else if (res.authSetting['scope.werun'] === true) { // 已授权
app.globalData.stepAuth = true;
} else { // 未知情况
app.globalData.stepAuth = false;
}
this.setData({
userAuth: app.globalData.userAuth,
stepAuth: app.globalData.stepAuth,
stepGoSetting: stepGoSetting
});
}
});
},
goSetting() {
wx.openSetting({
success:(res) => {
if (res.authSetting['scope.userInfo']) {
app.globalData.userAuth = true;
this.setData({
userAuth: true
});
} else {
app.globalData.userAuth = false;
this.setData({
userAuth: false
});
}
if (res.authSetting['scope.werun']) {
app.globalData.stepAuth = true;
this.setData({
stepAuth: true
});
} else {
app.globalData.stepAuth = false;
this.setData({
stepAuth: false
});
}
this.checkAuth();
}
}); });
}, },
...@@ -25,9 +79,10 @@ Page({ ...@@ -25,9 +79,10 @@ Page({
this.checkAuth(); this.checkAuth();
} else { } else {
console.log('getUserAuth:fail', event) console.log('getUserAuth:fail', event)
wx.showModal({ wx.showToast({
content: '授权失败,请重新点击按钮发起授权', title: '授权失败,请重新点击按钮发起授权',
showCancel: false icon: 'none',
duration: 1500
}); });
} }
setTimeout(() => { setTimeout(() => {
...@@ -48,39 +103,8 @@ Page({ ...@@ -48,39 +103,8 @@ Page({
this.checkAuth(); this.checkAuth();
}, },
fail:() => { fail:() => {
// 调起用户授权窗口失败,因为用户曾经拒绝过,而且在这里不能直接去到openSetting页,需要通过一个弹窗中转过去 this.setData({
wx.showModal({ stepGoSetting: true
content: '授权失败,请在接下来的页面中同意授权',
showCancel: false,
success:() => {
wx.openSetting({
success:(res) => {
if (res.authSetting['scope.userInfo']) {
app.globalData.userAuth = true;
this.setData({
userAuth: true
});
} else {
app.globalData.userAuth = false;
this.setData({
userAuth: false
});
}
if (res.authSetting['scope.werun']) {
app.globalData.stepAuth = true;
this.setData({
stepAuth: true
});
} else {
app.globalData.stepAuth = false;
this.setData({
stepAuth: false
});
}
this.checkAuth();
}
});
}
}); });
}, },
complete: () => { complete: () => {
......
...@@ -19,5 +19,6 @@ ...@@ -19,5 +19,6 @@
</view> </view>
</view> </view>
<button class="authorization-btn clear-btn" plain open-type="getUserInfo" bindgetuserinfo="getUserAuth" wx:if="{{!userAuth}}">第一步,授权公开信息</button> <button class="authorization-btn clear-btn" plain open-type="getUserInfo" bindgetuserinfo="getUserAuth" wx:if="{{!userAuth}}">第一步,授权公开信息</button>
<view class="authorization-btn" bindtap="getStepAuth" wx:elif="{{!stepAuth}}">第二步,授权微信运动步数</view> <view class="authorization-btn" bindtap="getStepAuth" wx:elif="{{!stepAuth && !stepGoSetting}}">第二步,授权微信运动步数</view>
<view class="authorization-btn" bindtap="goSetting" wx:elif="{{!stepAuth && stepGoSetting}}">第二步,授权微信运动步数</view>
</view> </view>
\ No newline at end of file
...@@ -16,7 +16,7 @@ Page({ ...@@ -16,7 +16,7 @@ Page({
scene: 1001 scene: 1001
}, },
onLoad() { onShow() {
this.setData({ this.setData({
scene: app.globalData.scene scene: app.globalData.scene
}); });
...@@ -138,6 +138,9 @@ Page({ ...@@ -138,6 +138,9 @@ Page({
scope: 'scope.werun', scope: 'scope.werun',
success:() => { // 授权成功 success:() => { // 授权成功
app.globalData.stepAuth = true; app.globalData.stepAuth = true;
this.setData({
stepAuth: true
});
if (reCheck) { if (reCheck) {
this.data.reCheck = true; this.data.reCheck = true;
this.clickStepData(); this.clickStepData();
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<view class="popup-content" wx:if="{{scene === 1048}}">{{currentSteps>=targetSteps?'恭喜你今日步数已达标,将返回比赛详情页':'提交今日步数成功,将返回比赛详情页'}}</view> <view class="popup-content" wx:if="{{scene === 1048}}">{{currentSteps>=targetSteps?'恭喜你今日步数已达标,将返回比赛详情页':'提交今日步数成功,将返回比赛详情页'}}</view>
<view class="popup-content" wx:else>{{currentSteps>=targetSteps?'恭喜你今日步数已达标,去比赛详情页同步状态吧':'提交今日步数成功,去继续行走吧'}}</view> <view class="popup-content" wx:else>{{currentSteps>=targetSteps?'恭喜你今日步数已达标,去比赛详情页同步状态吧':'提交今日步数成功,去继续行走吧'}}</view>
<view class="popup-btn-container"> <view class="popup-btn-container">
<!-- <view class="cancel-btn" bindtap="changeShowPopup">取消</view> --> <view class="cancel-btn" bindtap="changeShowPopup" wx:if="{{scene === 1048}}">取消</view>
<navigator class="confirm-btn" hover-class="none" open-type="exit" target="miniProgram" wx:if="{{scene === 1048}}">确定</navigator> <navigator class="confirm-btn" hover-class="none" open-type="exit" target="miniProgram" wx:if="{{scene === 1048}}">确定</navigator>
<view class="confirm-btn" bindtap="changeShowPopup" wx:else>确定</view> <view class="confirm-btn" bindtap="changeShowPopup" wx:else>确定</view>
</view> </view>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"autoAudits": false "autoAudits": false
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.6.2", "libVersion": "2.6.5",
"appid": "wx035eac0d4d63b3e4", "appid": "wx035eac0d4d63b3e4",
"projectname": "walk_daka", "projectname": "walk_daka",
"debugOptions": { "debugOptions": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment