From 2f09ae181d9524384daa11b66b0566af54d8f0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=BE=E9=98=B3?= <996666908@qq.com> Date: Sat, 12 Jun 2021 13:40:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!3=20:?= =?UTF-8?q?=20=E3=80=90=E8=BD=BB=E9=87=8F=E7=BA=A7=20PR=E3=80=91=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BF=AB=E9=80=9F=E7=82=B9=E5=87=BB=E5=8F=AF?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=A4=9A=E6=AC=A1=E7=AD=BE=E5=88=B0=E7=9A=84?= =?UTF-8?q?bug'?= 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, 17 insertions(+), 22 deletions(-) diff --git a/miniprogram/pages/user/sign/index.js b/miniprogram/pages/user/sign/index.js index 4f28346..64c1fc3 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,15 +133,14 @@ 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({ @@ -150,7 +149,7 @@ Page({ } }); } - + for (var i = 0; i < dateArr.length; i++) { for (var j = 0; j < yesdate.length; j++) { if (dateArr[i].isToday == yesdate[j]) { @@ -323,16 +322,12 @@ 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()); @@ -356,7 +351,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