签到码页面
This commit is contained in:
+110
-17
@@ -2,6 +2,8 @@
|
||||
import _ from '../../commons/js/commons'
|
||||
const timer = require('../../commons/js/lib/wxTimer');
|
||||
var wxTimer = null
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -16,42 +18,133 @@ Page({
|
||||
showHomeIcon: true
|
||||
},
|
||||
qrcode_img: 'http://qnimg.banping.com/20240511/171539407575215900.png',
|
||||
qrcode_count_time: 30
|
||||
qrcode_count_time: 30,
|
||||
wxTimerList: {},
|
||||
wxTimer: null,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
let that = this
|
||||
wx.getScreenBrightness({
|
||||
success: (res)=>{
|
||||
that.setData({
|
||||
ori_screen_bright: res.value
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
this.postMpQrcode()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
|
||||
onHide(){
|
||||
if (wxTimer) {
|
||||
wxTimer.stop();
|
||||
wxTimer = null
|
||||
}
|
||||
this.setData({
|
||||
wxTimerList: {},
|
||||
wxTimer: null,
|
||||
})
|
||||
this.resetScreenBright()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
if (wxTimer) {
|
||||
wxTimer.stop();
|
||||
wxTimer = null
|
||||
}
|
||||
this.setData({
|
||||
wxTimerList: {},
|
||||
wxTimer: null,
|
||||
})
|
||||
this.resetScreenBright()
|
||||
},
|
||||
|
||||
}
|
||||
/**
|
||||
* 接口请求小程序码
|
||||
*/
|
||||
postMpQrcode(){
|
||||
if(this.loading) return
|
||||
wx.showLoading({
|
||||
title: '重新生成中...',
|
||||
mask: true
|
||||
})
|
||||
if (wxTimer) {
|
||||
wxTimer.stop();
|
||||
wxTimer = null
|
||||
}
|
||||
this.setData({
|
||||
wxTimerList: {},
|
||||
wxTimer: null,
|
||||
loading: true
|
||||
})
|
||||
|
||||
/////接口方法
|
||||
this.setData({
|
||||
qrcode_img: this.data.qrcode_img,
|
||||
loading:false
|
||||
},()=>{
|
||||
wx.hideLoading()
|
||||
this.getTimes(this.data.qrcode_count_time).then(()=>{
|
||||
this.postMpQrcode()
|
||||
})
|
||||
this.setScreenBright()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 设置亮度
|
||||
*/
|
||||
setScreenBright(){
|
||||
wx.setScreenBrightness({value: 1 })
|
||||
},
|
||||
|
||||
/**
|
||||
* 恢复亮度
|
||||
*/
|
||||
resetScreenBright(){
|
||||
wx.setScreenBrightness({value: this.data.ori_screen_bright })
|
||||
},
|
||||
|
||||
/**
|
||||
* 生成倒计时
|
||||
*/
|
||||
getTimes(seconds) {
|
||||
let that = this
|
||||
return new Promise(function (resolve, reject) {
|
||||
wxTimer = new timer({
|
||||
name: 'wxTimer',
|
||||
leftTime: seconds,
|
||||
complete: function () {
|
||||
setTimeout(() => {
|
||||
that.setData({
|
||||
// 'submitFlag': false,
|
||||
wxTimerList: {}
|
||||
})
|
||||
resolve()
|
||||
}, 1000);
|
||||
},
|
||||
})
|
||||
wxTimer.start(that);
|
||||
})
|
||||
},
|
||||
|
||||
//推送链接
|
||||
pushLink(e){
|
||||
if(e.currentTarget.dataset.url){
|
||||
_.$router.openUrlScheme(e.currentTarget.dataset.url)
|
||||
}
|
||||
},
|
||||
|
||||
})
|
||||
@@ -18,7 +18,7 @@
|
||||
<view class="text-center">
|
||||
<image class="img-400x400" src="{{qrcode_img}}" />
|
||||
<view class="text-center font-28 fn-flex fn-flex-center fn-flex-middle mt25">
|
||||
<text>30秒后失效</text><view class="ml15 font-24" style="color:#36f">立即刷新</view>
|
||||
<text>{{wxTimerList.wxTimer.tim||0}}秒后失效</text><view class="ml15 font-24" style="color:#36f" bindtap="postMpQrcode">立即刷新</view>
|
||||
</view>
|
||||
<view class="font-20 mt25" style="color:#f10">客户点击签到,授权手机号及地理位置方可签到成功</view>
|
||||
</view>
|
||||
@@ -26,7 +26,7 @@
|
||||
</view>
|
||||
|
||||
<view class="text-center mt30 font-34">本期到店礼</view>
|
||||
<view class="ml30 mr30 mt30 pb30">
|
||||
<view class="ml30 mr30 mt30 pb30" data-url="" bindtap="pushLink">
|
||||
<image mode="widthFix" style="width:100%;" src="http://qnimg.banping.com/20230523/f2b79e3e6108a5816ebfcc0c5c5d51723431a598.png" />
|
||||
</view>
|
||||
</view>
|
||||
Reference in New Issue
Block a user