You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.4 KiB
69 lines
1.4 KiB
// subpages/heart/pages/scanCodeSignin/scanCodeSignin.js
|
|
import { getActInfo, signIn } from '../../../../utils/api'
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
actId: '',
|
|
actInfo: {}, //活动信息
|
|
dialogVisible: false, //提示框
|
|
lock: false, //debounce
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.setData({
|
|
actId: options.id
|
|
})
|
|
this.getActInfo()
|
|
},
|
|
|
|
//获取活动信息
|
|
getActInfo () {
|
|
let para = {
|
|
qrCodeId: this.data.actId
|
|
}
|
|
getActInfo(para).then(res => {
|
|
this.setData({
|
|
actInfo: res.data
|
|
})
|
|
})
|
|
},
|
|
//签到
|
|
signin () {
|
|
if (this.data.lock) {
|
|
wx.showToast({
|
|
title: '签到中...',
|
|
icon: 'loading',
|
|
duration: 2000
|
|
})
|
|
return
|
|
}
|
|
this.data.lock = true
|
|
console.log('签到状态:', this.data.actInfo.signInStatus)
|
|
if (this.data.actInfo.signInStatus == 0) {
|
|
let para = {
|
|
actId: this.data.actInfo.id
|
|
}
|
|
signIn(para).then(res => {
|
|
console.log(res.data)
|
|
if(res.code == 0) {
|
|
this.setData({
|
|
dialogVisible: !this.data.dialogVisible
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
this.data.lock = false
|
|
})
|
|
}
|
|
},
|
|
//
|
|
closeDialog () {
|
|
wx.navigateBack()
|
|
},
|
|
})
|