1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

修改包名;生成二维码功能逻辑调整

This commit is contained in:
2022-11-05 18:24:05 +08:00
parent 37fac90066
commit 9bd12755fe
45 changed files with 184 additions and 154 deletions

View File

@@ -5,8 +5,8 @@ const baseUrl = app.globalData.baseUrl
var util = require('../../utils/util.js');
Page({
data: {
imgUrl: '../../img/code.jpg',
stuId: '',
imgUrl: '',
stuId: wx.getStorageSync('stuId'),
name: wx.getStorageSync('name'),
isHealth: 0,
},
@@ -14,36 +14,37 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
stuId: wx.getStorageSync('stuId'),
name: wx.getStorageSync('name')
})
this.onShow()
console.log("onLoad")
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
console.log("onReady")
},
onPullDownRefresh: function () {
console.log("onPullDownRefresh");
},
onRefresh: function () {
console.log("onRefresh");
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
console.log("onShow");
this.updateQrCode();
},
updateQrCode: function () {
this.setData({
stuId: wx.getStorageSync('stuId'),
name: wx.getStorageSync('name')
})
setInterval(() => {
var time = util.formatTime(new Date())
//为页面中time赋值
this.setData({
time: time
})
}, 1000);
if (wx.getStorageSync("state") == this.formatDate(new Date())) {
this.setData({
isHealth: 1
@@ -53,6 +54,9 @@ Page({
isHealth: 0
})
}
wx.showLoading({
title: '请稍候'
})
wx.request({
url: `${baseUrl}/code/showCode`,
data: {
@@ -60,9 +64,36 @@ Page({
name: this.data.name,
isHealth: this.data.isHealth
},
success: function (d) {}
success: (data) => {
console.log(data)
this.setData({
imgUrl: '../../img/greenCode.png'
})
wx.hideLoading()
wx.showToast({
title: '加载成功',
icon: 'none',
duration: 800
})
setInterval(() => {
var time = util.formatTime(new Date())
//为页面中time赋值
this.setData({
time: time
})
}, 1000);
},
fail: (error) => {
console.log(error)
wx.hideLoading()
wx.showModal({
title: '加载失败',
showCancel: false
})
},
})
},
formatDate: function (date) {
let year = date.getFullYear()
let month = date.getMonth() + 1

View File

@@ -1,6 +1,5 @@
<view style="text-align: center;margin-top: 100px;">
<image src="{{imgUrl}}"></image>
<view><text class="user-motto">{{stuId}}</text></view>
<view><text class="user-motto">{{name}}</text></view>
<view><text class="user-motto">{{time}}</text></view>
<view><text>{{stuId}} {{name}}</text></view>
<image id="qrcode" src="{{imgUrl}}"></image>
<view><text class="time-text">{{time}}</text></view>
</view>

View File

@@ -1 +1,9 @@
/* pages/home/code.wxss */
/* pages/home/code.wxss */
.time-text {
font-weight: bold;
}
#qrcode {
width: 70vw;
height: 70vw;
}