Commit 14f061ce by 穆启卓

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

二维码进小程序弹窗加了个取消按钮,
改了个授权步数没显示的bug
parent 90225ba4
......@@ -3,13 +3,67 @@ let getAuthLoading = false;
Page({
data: {
userAuth: false,
stepAuth: false
stepAuth: false,
stepGoSetting: true, // 步数授权是否变成直接去openSetting页的按钮
},
onLoad() {
this.setData({
userAuth: app.globalData.userAuth,
stepAuth: app.globalData.stepAuth
wx.getSetting({
success:(res) => {
// 用户信息是否授权
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({
this.checkAuth();
} else {
console.log('getUserAuth:fail', event)
wx.showModal({
content: '授权失败,请重新点击按钮发起授权',
showCancel: false
wx.showToast({
title: '授权失败,请重新点击按钮发起授权',
icon: 'none',
duration: 1500
});
}
setTimeout(() => {
......@@ -48,39 +103,8 @@ Page({
this.checkAuth();
},
fail:() => {
// 调起用户授权窗口失败,因为用户曾经拒绝过,而且在这里不能直接去到openSetting页,需要通过一个弹窗中转过去
wx.showModal({
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();
}
});
}
this.setData({
stepGoSetting: true
});
},
complete: () => {
......
......@@ -19,5 +19,6 @@
</view>
</view>
<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>
\ No newline at end of file
......@@ -16,7 +16,7 @@ Page({
scene: 1001
},
onLoad() {
onShow() {
this.setData({
scene: app.globalData.scene
});
......@@ -138,6 +138,9 @@ Page({
scope: 'scope.werun',
success:() => { // 授权成功
app.globalData.stepAuth = true;
this.setData({
stepAuth: true
});
if (reCheck) {
this.data.reCheck = true;
this.clickStepData();
......
......@@ -59,7 +59,7 @@
<view class="popup-content" wx:if="{{scene === 1048}}">{{currentSteps>=targetSteps?'恭喜你今日步数已达标,将返回比赛详情页':'提交今日步数成功,将返回比赛详情页'}}</view>
<view class="popup-content" wx:else>{{currentSteps>=targetSteps?'恭喜你今日步数已达标,去比赛详情页同步状态吧':'提交今日步数成功,去继续行走吧'}}</view>
<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>
<view class="confirm-btn" bindtap="changeShowPopup" wx:else>确定</view>
</view>
......
......@@ -12,7 +12,7 @@
"autoAudits": false
},
"compileType": "miniprogram",
"libVersion": "2.6.2",
"libVersion": "2.6.5",
"appid": "wx035eac0d4d63b3e4",
"projectname": "walk_daka",
"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