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.
112 lines
3.3 KiB
112 lines
3.3 KiB
var api = require('../../utils/api.js')
|
|
var global = require('../../utils/config.js')
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
gridId: '',
|
|
postId:'',
|
|
gridName: '',
|
|
gridNameArr: [],
|
|
formid: '',
|
|
resToken: '',
|
|
resGridName: '',
|
|
inviteUserId: '',
|
|
url:'',
|
|
countDownNum:3,
|
|
timer: ''//定时器名字
|
|
},
|
|
onLoad: function (options) {
|
|
let that = this
|
|
// 上级页面传递过来的gid
|
|
var code = decodeURIComponent(options.G) + '-' + decodeURIComponent(options.P)
|
|
console.log(code)
|
|
api.getDeptInfoByMaCode(code).then(function (res) {
|
|
that.setData({
|
|
gridId: decodeURIComponent(options.G),
|
|
postId: res.data.thirdSentryPostId
|
|
})
|
|
})
|
|
|
|
|
|
that.getToken(decodeURIComponent(options.G))
|
|
// that.getGridName(decodeURIComponent(options.G))
|
|
that.settime()
|
|
|
|
that.countDown()
|
|
},
|
|
countDown: function () {
|
|
let that = this;
|
|
let countDownNum = that.data.countDownNum;//获取倒计时初始值
|
|
//如果将定时器设置在外面,那么用户就看不到countDownNum的数值动态变化,所以要把定时器存进data里面
|
|
that.setData({
|
|
timer: setInterval(function () {//这里把setInterval赋值给变量名为timer的变量
|
|
//每隔一秒countDownNum就减一,实现同步
|
|
countDownNum--;
|
|
//然后把countDownNum存进data,好让用户知道时间在倒计着
|
|
that.setData({
|
|
countDownNum: countDownNum
|
|
})
|
|
//在倒计时还未到0时,这中间可以做其他的事情,按项目需求来
|
|
if (countDownNum == 0) {
|
|
//这里特别要注意,计时器是始终一直在走的,如果你的时间为0,那么就要关掉定时器!不然相当耗性能
|
|
//因为timer是存在data里面的,所以在关掉时,也要在data里取出后再关闭
|
|
clearInterval(that.data.timer);
|
|
//关闭定时器之后,可作其他处理codes go here
|
|
}
|
|
}, 1000)
|
|
})
|
|
},
|
|
getToken: function (gid) {
|
|
let that = this
|
|
wx.login({
|
|
success(res) {
|
|
if (res.code) {
|
|
console.log('微信CODE: ' + res.code)
|
|
let wxCode = res.code
|
|
const para = {
|
|
inviteUserId: that.data.inviteUserId,
|
|
gridId: gid,
|
|
wxCode: res.code
|
|
}
|
|
api.getTokenV2(para).then(function (res) {
|
|
// global.Token = res.data.token
|
|
wx.removeStorageSync('token')
|
|
wx.setStorageSync('token', res.data.token)
|
|
// that.setData({
|
|
// resToken: res.data.token,
|
|
// resGridName: res.data.grid
|
|
// })
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
// getGridName: function (gid) {//不要了 欢迎使用疫情防控登记系统
|
|
// let that = this
|
|
// api.getCompleteName(gid).then(function (res) {
|
|
// console.log(res.data)
|
|
// wx.setStorage({
|
|
// key: "gridName",
|
|
// data: res.data
|
|
// })
|
|
// that.setData({
|
|
// gridName: res.data,
|
|
// gridNameArr: res.data.split('/')
|
|
// })
|
|
// })
|
|
// },
|
|
|
|
settime:function(){
|
|
let that = this
|
|
setTimeout(function () {
|
|
wx.redirectTo({
|
|
url: `./detail/detail?postId=${that.data.postId}`
|
|
})
|
|
}, 3000)
|
|
},
|
|
bindGetUserInfo: function (e) {
|
|
wx.redirectTo({
|
|
url: `./detail/detail?postId=${this.data.postId}`
|
|
})
|
|
}
|
|
})
|