12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- var app = getApp();
- Page({
- data: {
- cartGoods: [],
- cartTotal: {
- "goodsCount": 0,
- "goodsAmount": 0.00,
- "checkedGoodsCount": 0,
- "checkedGoodsAmount": 0.00
- },
- isEditCart: false,
- checkedAllStatus: true,
- editCartList: [],
- chatList: [],
- offsetTime: null,
- size: 10,
- },
- onLoad: function(options) {
- // 页面初始化 options为页面跳转所带来的参数
- },
- onReady: function() {
- // 页面渲染完成
- },
- onShow: function() {
- // 页面显示
- let now = new Date();
- console.log(now.toISOString())
- this.setData({
- offsetTime: now.toISOString()
- })
- this.getChatList();
- },
- onHide: function() {
- // 页面隐藏
- },
- onUnload: function() {
- // 页面关闭
- },
- getChatList: function() {
- let that = this;
- util.request(api.ChatIndex, {
- size: this.data.size,
- offsetTime: this.data.offsetTime
- }).then(function(res) {
- if (res.errno === 0) {
- console.log(res.data);
- that.setData({
- chatList: that.data.chatList.concat(res.data),
- });
- } else {
- console.log(res)
- }
- })
- },
- onPullDownRefresh: function () {
- console.log("上拉刷新")
- this.setData({
- chatList: [],
- offsetTime: null,
- size: 10,
- })
- this.onShow()
- setTimeout(function callback() {
- wx.stopPullDownRefresh()
- }, 500)
- },
- onReachBottom: function () {
- console.log("拉到底")
- let chatList = this.data.chatList;
- let offsetTime = chatList[chatList.length - 1].offsetTime;
- this.setData({
- offsetTime: offsetTime,
- })
- this.getChatList()
- },
- })
|