From d9567e2a45db069f60f3c4e186e13cd2a66b3822 Mon Sep 17 00:00:00 2001
From: maclien <421129572@qq.com>
Date: Sun, 26 May 2024 21:29:46 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E7=A0=81=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/signup/code.js | 127 +++++++++++++++++++++++++++++++++++------
pages/signup/code.wxml | 4 +-
2 files changed, 112 insertions(+), 19 deletions(-)
diff --git a/pages/signup/code.js b/pages/signup/code.js
index fe2d1bd..f5ef66d 100644
--- a/pages/signup/code.js
+++ b/pages/signup/code.js
@@ -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)
+ }
+ },
})
\ No newline at end of file
diff --git a/pages/signup/code.wxml b/pages/signup/code.wxml
index d84fd5b..4b7706f 100644
--- a/pages/signup/code.wxml
+++ b/pages/signup/code.wxml
@@ -18,7 +18,7 @@
- 30秒后失效立即刷新
+ {{wxTimerList.wxTimer.tim||0}}秒后失效立即刷新
客户点击签到,授权手机号及地理位置方可签到成功
@@ -26,7 +26,7 @@
本期到店礼
-
+
\ No newline at end of file