diff --git a/miniprogram/pages/user/sign/index.js b/miniprogram/pages/user/sign/index.js index 64c1fc3506fd63372a760bdb289af5cd1f5d018f..4f28346f37969cf065fd4ce899324247a6b70201 100644 --- a/miniprogram/pages/user/sign/index.js +++ b/miniprogram/pages/user/sign/index.js @@ -7,7 +7,7 @@ var util = require('../../../utils/time.js'); let app = getApp() -const key =app. globalData.key +const key = app.globalData.key Page({ /** @@ -45,12 +45,12 @@ Page({ wx.requestSubscribeMessage({ tmplIds: ['bRnTQ46RrclaDPUWMWcuViqJmO3vfaolXzT9JVhUGJc'], - success (res) { + success(res) { for (var i = 0; i < dateArr.length; i++) { - console.log(nowdate ) - if (Number(dateArr[i].isToday) ==Number(nowdate) ) { + console.log(nowdate) + if (Number(dateArr[i].isToday) == Number(nowdate)) { dateArr[i].choose = true; - + if (wx.getStorageSync("userid")) { console.log("asd") db.collection('user').doc(wx.getStorageSync("userid")).update({ @@ -65,9 +65,9 @@ Page({ title: '签到成功', icon: 'none', }) - db.collection('user').doc(wx.getStorageSync("userid")).get().then(res=>{ + db.collection('user').doc(wx.getStorageSync("userid")).get().then(res => { - function getCurrentTime () { + function getCurrentTime() { let date = new Date() let Y = date.getFullYear() let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1) @@ -86,7 +86,7 @@ Page({ name: res.data.nickName, date: getCurrentTime(), }, - success: function(res) { + success: function (res) { console.log(res.result.sum) // 3 }, fail: console.error @@ -112,9 +112,9 @@ Page({ }) } - }) + }) + - }, // 签到过 @@ -133,14 +133,15 @@ Page({ let t = this; if (wx.getStorageSync("userid")) { db.collection('user').doc(wx.getStorageSync("userid")).get().then(res => { + wx.hideLoading() let yesdate = res.data.sign_data let dateArr = t.data.dateArr; let now = new Date(); let year = now.getFullYear(); let month = now.getMonth() + 1 < 10 ? "0" + String(now.getMonth() + 1) : now.getMonth() + 1; - let day = now.getDate()+ 1 < 10 ? "0" + String( now.getDate()) : now.getDate() ; - let newdoy = '' + year + month + day - if(res.data.sign_data){ + let day = now.getDate() + 1 < 10 ? "0" + String(now.getDate()) : now.getDate(); + let newdoy = '' + year + month + day + if (res.data.sign_data) { res.data.sign_data.forEach(function (e) { if (Number(e) == Number(newdoy)) { t.setData({ @@ -149,7 +150,7 @@ Page({ } }); } - + for (var i = 0; i < dateArr.length; i++) { for (var j = 0; j < yesdate.length; j++) { if (dateArr[i].isToday == yesdate[j]) { @@ -322,12 +323,16 @@ Page({ } }, onLoad: function (options) { + wx.showLoading({ + title: '加载中…', + mask: true + }) let t = this; let now = new Date(); let year = now.getFullYear(); let month = now.getMonth() + 1 < 10 ? "0" + String(now.getMonth() + 1) : now.getMonth() + 1; - let day = now.getDate()+ 1 < 10 ? "0" + String( now.getDate()) : now.getDate() ; - var time = year + '年' + month + '月' + day + '日'; + let day = now.getDate() + 1 < 10 ? "0" + String(now.getDate()) : now.getDate(); + var time = year + '年' + month + '月' + day + '日'; this.time_get() var time2 = util.formatTime(new Date()); @@ -351,7 +356,7 @@ Page({ * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { - function getCurrentTime () { + function getCurrentTime() { let date = new Date() let Y = date.getFullYear() let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)