123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- // pages/my_fans/index.js
- import { spreadPeople } from '../../api/user.js';
- import util from '../../utils/util.js';
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- parameter: {
- 'navbar': '1',
- 'return': '1',
- 'title': '我的粉丝',
- },
- loading: false,//是否加载中
- loadend: false,//是否加载完毕
- loadTitle: '加载更多',//提示语
- orderStatus: 0,//订单状态
- orderList:[],//订单数组
- page: 1,
- limit: 10,
- loading: false,//是否加载中
- loadend: false,//是否加载完毕
- },
- onLoadFun: function () {
- this.getOrderList();
- },
- /**
- * 事件回调
- *
- */
- onChangeFun:function(e){
- let opt = e.detail;
- let action = opt.action || null;
- let value = opt.value != undefined ? opt.value : null;
- (action && this[action]) && this[action](value);
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 切换类型
- */
- statusClick: function (e) {
- var status = e.currentTarget.dataset.status;
- if (status == this.data.orderStatus) return;
- this.setData({ orderStatus: status, loadend: false, page: 1, orderList: [] });
- this.getOrderList();
- },
- /**
- * 获取订单列表
- */
- getOrderList: function () {
- var that = this;
- if (that.data.loadend) return;
- if (that.data.loading) return;
- that.setData({ loading: true, loadTitle: "" });
- spreadPeople({
- type: that.data.orderStatus,
- page: that.data.page,
- limit: that.data.limit,
- }).then(res => {
- var list = res.data.list || [];
- var loadend = list.length < that.data.limit;
- that.data.orderList = app.SplitArray(list, that.data.orderList);
- that.setData({
- orderList: that.data.orderList,
- loadend: loadend,
- loading: false,
- loadTitle: loadend ? "我也是有底线的" : '加载更多',
- page: that.data.page + 1,
- });
- }).catch(err => {
- that.setData({ loading: false, loadTitle: "加载更多" });
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- this.getOrderList();
- }
- })
|