123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- // 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 () {
- }
- })
|