1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- const util = require('../../../utils/util.js');
- const app = getApp();
- Page({
- data: {
- recordId : "",
- isLoadMore: true,
- pageSize: 20,
- pageIndex: 1,
- info:[]
- },
- onLoad: function (options) {
- this.setData({ recordId : options.id });
- this.getInfo(true);
- },
- binderror(e) {
- var records = this.data.info, index = e.currentTarget.dataset.index;
- info[index].avatar = '/images/default_logo.jpg'
- this.setData({ records });
- },
- getInfo(load){
- let self = this;
- util.ajax({
- func: "coin/inviter/records",
- data: { "recordId": self.data.recordId, "pageIndex": self.data.pageIndex, "pageSize": self.data.pageSize},
- load: load
- },function (res) {
- if (res.code == 0){
- let isLoadMore = true;
- let newData = res.data.records;
- let oldData = !load ? newData : [...self.data.info, ...newData];
- if (oldData.length >= self.data.pageSize) isLoadMore = false;
- for (let i = 0; i < oldData.length - 1; i++) {
- oldData[i].priceStats = (oldData[i].price.indexOf("-") == -1 ? 0 : 1);
- }
- self.setData({ info: oldData, isLoadMore: isLoadMore });
- }else
- util.showTips(res.reason);
- });
- },
- onPullDownRefresh() {
- var self = this;
- wx.showNavigationBarLoading();
- setTimeout(function () {
- self.setData({ pageIndex: 1 });
- self.getInfo(false);
- wx.hideNavigationBarLoading();
- wx.stopPullDownRefresh();
- }, 1000);
- },
- onReachBottom() {
- var self = this;
- if (self.data.isLoadMore == false) return false;
- setTimeout(function () {
- self.setData({ pageIndex: self.data.pageIndex + 1 });
- self.getInfo(true);
- }, 1000);
- }
- })
|