From d71deb6aaf17080340409a4f74fb7c69873b788e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=95=BF=E5=AE=89?= Date: Fri, 11 Jun 2021 03:18:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BF=AB=E9=80=9F=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E5=8F=AF=E5=AE=9E=E7=8E=B0=E5=A4=9A=E6=AC=A1=E7=AD=BE?= =?UTF-8?q?=E5=88=B0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/pages/user/sign/index.js | 39 ++++++++++++++++------------ 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/miniprogram/pages/user/sign/index.js b/miniprogram/pages/user/sign/index.js index 64c1fc3..4f28346 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) -- Gitee