🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
* 参考 ~~~ 小程序 : pages/my/fav/fav ~~~ * js ~~~ Page({ data: { PIN: 1, list: [], list_cache: [], next: 1, height: null, down_note: '', //>加载文字 isFresh:true, //>刷新开关 triggered: false, //>刷新状态 check_id: '', //>选中索引 }, onLoad: function (options) { let arr = {}; arr.height = wx.getSystemInfoSync().windowHeight+'px'; this.setData(arr); setTimeout(() => { this.up(); }, 1000); }, //>加载数据 load_data() { let that = this; let data = {}; data.u_id = this.data.u_id; data.PIN = this.data.PIN; app.globalData.net('wx_applet/shipinhao/manage/fav_list',data).then(res=>{ if(res.succeed == 0){ wx.showModal({ title: '提示', content: res.msg, showCancel:false }); that.setData({triggered:false}); return false; } let arr = {}; arr.next = res.next; arr.PIN = res.PIN; arr.list_cache = res.list; arr.down_note = res.list.length <= 0 ? (res.option == 1 ? '暂无数据' : '我是有底线的~') : ''; that.setData(arr); that.load_list(); }); }, //>显示列表 load_list(){ let arr = {}; let list_cache = this.data.list_cache; if(list_cache.length <= 0){ arr.triggered = false; this.setData(arr); return false; } let list = this.data.list; list.push(list_cache[0]); list_cache.shift(list_cache[0]); arr.list = list; arr.list_cache = list_cache; this.setData(arr); setTimeout(() => { this.load_list(); }, 100); }, //>刷新 up() { let arr = {}; arr.PIN = 1; arr.triggered = true; arr.list = []; this.setData(arr); this.load_data(); }, //>上拉加载 down() { let arr = {}; arr.PIN = this.data.next; arr.down_note = '加载中'; this.setData(arr); this.load_data(); }, }); ~~~