Commit 90225ba4 by 穆启卓

弹窗

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