// pages/record/index.js const app = getApp(); Page({ /** * 页面的初始数据 */ Page: 1, Size: 5, data: { list: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.setNavigationBarTitle({ title: app.globalData.selectQuestion.name }) this.getData(); }, getData() { const that = this; wx.showLoading(); wx.cloud.callFunction({ name: "quickstartFunctions", data: { type: "getQuestionRecord", data: { queId: app.globalData.selectQuestion._id, Page: this.Page, Size: this.Size } } }).then(res => { if (res.result.code !== 0) return wx.showToast({ title: '网络繁忙', }) let oldli = that.data.list || []; let li = res.result.data || []; li = li.map(v => { return { ...v, startTime: this.formatTime(v.startTime), endTime: this.formatTime(v.endTime), } }) that.setData({ list: [...oldli, ...li] }) wx.hideLoading() }).catch(err => { console.log(err) wx.hideLoading() }) }, formatTime(T) { let date = new Date(T); let y = date.getFullYear(); let m = date.getMonth() * 1 + 1; let d = date.getDate(); let h = date.getHours(); let min = date.getMinutes() * 1 + 1; let s = date.getSeconds(); let out = y; m > 9 ? out += '-' + m : out += '-0' + m; d > 9 ? out += '-' + d + ' ' : out += '-0' + d + ' '; h > 9 ? out += h + ":" : out += h + ':'; min > 9 ? out += min + ":" : out += '0' + min + ':'; s > 9 ? out += s : out += '0' + s; return out; }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { this.Page++; this.getData(); }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })