// pages/signIn/index.js import SignIn from '../../../api/signIn' Page({ /** * 页面的初始数据 */ data: { showPage: false, activity: {}, signInNodes: [{ pos : 1 }, { pos: 2 }, { pos: 3 }, { pos : 4 }, { pos: 5 }, { pos: 6 }], lastSignInNode: { pos: 7 } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { SignIn.getActivityData("").then(res => { console.log(res) if (res.code == 200) { this.setData({ activity: res.data }) this.mapToView(res.data) } }).catch(_ => { }).finally(_ => { this.setData({ showPage: true }) }) this.setPageStyle(); }, setPageStyle() { let dwObj = wx.getMenuButtonBoundingClientRect() let navHeight_ = (dwObj.top + dwObj.height) let capsuleTop_ = dwObj.top let windowHeight = wx.getSystemInfoSync().windowHeight this.setData({ navHeight: navHeight_, capsuleTop:capsuleTop_, capHeight: dwObj.height, bodyHeight: windowHeight - navHeight_, }); }, mapToView(data) { if (data.dayAwardList && data.dayAwardList.length > 0) { data.dayAwardList.forEach(item => { if (item.dayNo == 7) { Object.assign(this.data.lastSignInNode, item); } else { if (this.data.signInNodes[item.dayNo - 1]) { Object.assign(this.data.signInNodes[item.dayNo - 1], item) } } }); this.setData({ signInNodes: this.data.signInNodes, lastSignInNode: this.data.lastSignInNode }) } }, tapSignIn: function() { SignIn.triggerSignIn(5, "16602120168").then(res => { console.log(res) }).catch(_ => {}) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })