Commit 90225ba4 by 穆启卓

弹窗

parent d0d98f67
...@@ -5,20 +5,23 @@ Page({ ...@@ -5,20 +5,23 @@ Page({
userAuth: false, // 用户信息授权(为了拿unionId) userAuth: false, // 用户信息授权(为了拿unionId)
unionAuth: false, // unionId授权: 如果为false是需要授权,true是不需要 unionAuth: false, // unionId授权: 如果为false是需要授权,true是不需要
stepAuth: false, // 步数授权 stepAuth: false, // 步数授权
// commitStepPopupShow: false, // 同步步数成功弹窗 commitStepPopupShow: false, // 同步步数成功弹窗
activityExplainShow: false, // 活动说明弹窗 activityExplainShow: false, // 活动说明弹窗
currentSteps: 0, currentSteps: 0,
targetSteps: 0, targetSteps: 0,
stepRecordList: [], stepRecordList: [],
showGetUserInfo: false, showGetUserInfo: false,
isFirstReq: true isFirstReq: true,
reCheck: false,
scene: 1001
}, },
onLoad() { onLoad() {
this.setData({
scene: app.globalData.scene
});
this.getPageData(); this.getPageData();
}, },
onShow() {
},
getPageData() { getPageData() {
// 1、第一步,先判断用户信息和步数是否授过权 // 1、第一步,先判断用户信息和步数是否授过权
...@@ -102,11 +105,10 @@ Page({ ...@@ -102,11 +105,10 @@ Page({
currentSteps: (resData && resData[0]) ? resData[0].step : 0, currentSteps: (resData && resData[0]) ? resData[0].step : 0,
stepRecordList: resData stepRecordList: resData
}); });
wx.setStorageSync('getStepLoading', Date.now()); // wx.showModal({
wx.showModal({ // content: '获取微信运动步数成功',
content: '获取微信运动步数成功', // showCancel: false
showCancel: false // });
});
} }
}); });
} }
...@@ -121,9 +123,9 @@ Page({ ...@@ -121,9 +123,9 @@ Page({
}, },
// 用户点击提交步数打卡1(处理授权情况) // 用户点击提交步数打卡1(处理授权情况)
clickStepData(resCheck = false) { clickStepData() {
console.log('clickStepData') console.log('clickStepData')
if (!resCheck && !this.data.isFirstReq && wx.getStorageSync('getStepLoading') && Date.now() - wx.getStorageSync('getStepLoading') < 60000) { if (!this.data.reCheck && !this.data.isFirstReq && wx.getStorageSync('getStepLoading') && Date.now() - wx.getStorageSync('getStepLoading') < 60000) {
wx.showToast({ wx.showToast({
title: '已是最新步数,建议前往微信运动获取最新步数再返回同步', title: '已是最新步数,建议前往微信运动获取最新步数再返回同步',
icon: 'none', icon: 'none',
...@@ -131,13 +133,17 @@ Page({ ...@@ -131,13 +133,17 @@ Page({
}); });
return; return;
} }
let needStepAuth = (resCheck) => { let needStepAuth = (reCheck) => {
wx.authorize({ // 调起授权窗口 wx.authorize({ // 调起授权窗口
scope: 'scope.werun', scope: 'scope.werun',
success:() => { // 授权成功 success:() => { // 授权成功
app.globalData.stepAuth = true; app.globalData.stepAuth = true;
if (resCheck) this.clickStepData(true); if (reCheck) {
else this.getClickStepData(); this.data.reCheck = true;
this.clickStepData();
} else {
this.getClickStepData();
}
}, },
fail:(err) => { // 授权失败,因为用户拒绝或者用户曾经拒绝过,而且在这里不能直接去到openSetting页,需要通过一个弹窗中转过去 fail:(err) => { // 授权失败,因为用户拒绝或者用户曾经拒绝过,而且在这里不能直接去到openSetting页,需要通过一个弹窗中转过去
this.authorizationFail(); this.authorizationFail();
...@@ -204,17 +210,20 @@ Page({ ...@@ -204,17 +210,20 @@ Page({
item.status = 0; // 未参与打卡 item.status = 0; // 未参与打卡
} }
}); });
console.log(resData.step_data)
this.setData({ this.setData({
currentSteps: (resData.step_data && resData.step_data[0]) ? resData.step_data[0].step : 0, currentSteps: (resData.step_data && resData.step_data[0]) ? resData.step_data[0].step : 0,
targetSteps: resData.total_step, targetSteps: resData.total_step,
stepRecordList: resData.step_data stepRecordList: resData.step_data
}); });
wx.setStorageSync('getStepLoading', Date.now()); wx.setStorageSync('getStepLoading', Date.now());
wx.showModal({ // wx.showModal({
content: '获取微信运动步数成功', // content: '获取微信运动步数成功',
showCancel: false // showCancel: false
}); // });
// 避免没有目标步数,不好比较是否达标
if (this.data.targetSteps > 0) {
this.changeShowPopup();
}
} }
}); });
}, },
...@@ -357,12 +366,12 @@ Page({ ...@@ -357,12 +366,12 @@ Page({
// }); // });
// }, // },
// // 同步步数成功弹窗 // 同步步数成功弹窗
// changeShowPopup() { changeShowPopup() {
// this.setData({ this.setData({
// commitStepPopupShow: !this.data.commitStepPopupShow commitStepPopupShow: !this.data.commitStepPopupShow
// }); });
// }, },
// goAuthorizationPage() { // goAuthorizationPage() {
// console.log(`/pages/authorization/authorization?userAuth=${this.data.userAuth}&stepAuth=${this.data.stepAuth}`) // console.log(`/pages/authorization/authorization?userAuth=${this.data.userAuth}&stepAuth=${this.data.stepAuth}`)
......
...@@ -54,12 +54,14 @@ ...@@ -54,12 +54,14 @@
</view> </view>
</view> </view>
<!-- 同步步数成功弹窗 --> <!-- 同步步数成功弹窗 -->
<!-- <view class="commit-step-popup-bg" wx:if="{{commitStepPopupShow}}"> <view class="commit-step-popup-bg" wx:if="{{commitStepPopupShow}}">
<view class="commit-step-popup"> <view class="commit-step-popup">
<view class="popup-content">步数数据同步成功,是否需要退出小程序?</view> <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="popup-btn-container">
<view class="cancel-btn" bindtap="changeShowPopup">取消</view> <!-- <view class="cancel-btn" bindtap="changeShowPopup">取消</view> -->
<navigator class="confirm-btn" hover-class="none" open-type="exit" target="miniProgram">确定</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> </view>
</view> </view>
</view> --> </view>
\ No newline at end of file \ No newline at end of file
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
"list": [] "list": []
}, },
"miniprogram": { "miniprogram": {
"current": 0, "current": 1,
"list": [ "list": [
{ {
"id": -1, "id": -1,
...@@ -72,6 +72,13 @@ ...@@ -72,6 +72,13 @@
"pathName": "pages/authorization/authorization", "pathName": "pages/authorization/authorization",
"query": "", "query": "",
"scene": null "scene": null
},
{
"id": -1,
"name": "index1048",
"pathName": "pages/index/index",
"query": "",
"scene": 1048
} }
] ]
} }
......
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