💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
* 在调用页的json中的usingComponents加入 ~~~ "scroll":"/components/scroll/index" ~~~ * 在wxml中模板位置里面放入 ~~~ <scroll remove="{{remove}}" up_status="{{up_status}}" down_note="{{down_note}}" bind:up="up" bind:down="down"> <view class="list" wx:for="{{list}}" wx:key="index"> </view> </scroll> ~~~ * 设置js执行脚本 * data部分 ~~~ PIN: 1, list: [], list_cache: [], next: 1, down_note: '', remove: 0, up_status: false, loading: 0, ~~~ * onLoad部分 ~~~ let arr = {}; this.setData(arr); this.up(); ~~~ * up刷新方法部分 ~~~ up(){ if(this.data.loading == 1){ return false; } let arr = {}; arr.PIN = 1; arr.up_status = true; arr.list = []; arr.loading = 1; this.setData(arr); this.load_data(); }, ~~~ * down加载方法部分 ~~~ down() { if(this.data.PIN == this.data.next){ return false; } if(this.data.loading == 1){ return false; } let arr = {}; arr.PIN = this.data.next; arr.down_note = '加载中'; arr.loading = 1; this.setData(arr); this.load_data(); }, ~~~ * load_data通信数据方法部分 ~~~ load_data() { let that = this; let data = {}; data.PIN = this.data.PIN; app.globalData.net('url',data).then(res => { let arr = {}; arr.option = res.option; 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); setTimeout(() => { that.load_list(); }, 1000); }); }, ~~~ * load_list渲染数据方法部分 ~~~ load_list(){ let arr = {}; let list_cache = this.data.list_cache; if(list_cache.length <= 0){ arr.up_status = false; arr.loading = 0; 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); }, ~~~