95 lines
2.0 KiB
JavaScript
95 lines
2.0 KiB
JavaScript
// packageE/tabcontrol/tabcontrol.js
|
||
var cpsApi = require("../../cps/component/cpsApi");
|
||
Component({
|
||
behaviors: [cpsApi],
|
||
properties: {
|
||
datas: {
|
||
type: null
|
||
},
|
||
component_id: {
|
||
type: null
|
||
},
|
||
page_id: {
|
||
type: null
|
||
},
|
||
btnFlag: {
|
||
type: null
|
||
},
|
||
bottomShowBol: {
|
||
type: null
|
||
},
|
||
index: {
|
||
type: null
|
||
},
|
||
bottomShowBolIndex: {
|
||
type: null
|
||
},
|
||
},
|
||
// 私有数据,可用于模板渲染
|
||
data: {
|
||
emptyImage: 'https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png',
|
||
clientWidth: '375',
|
||
isLast: false,
|
||
|
||
active: 0,
|
||
show_text: '加载中...',
|
||
show_page: true
|
||
},
|
||
|
||
lifetimes: {
|
||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||
attached() {
|
||
this.getCPSLogin();
|
||
},
|
||
moved() {},
|
||
detached() {},
|
||
},
|
||
|
||
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
||
attached() {},
|
||
// 此处attached的声明会被lifetimes字段中的声明覆盖
|
||
ready() {
|
||
this.setData({
|
||
clientWidth: wx.getSystemInfoSync().windowWidth,
|
||
});
|
||
|
||
if (this.data.bottomShowBolIndex == this.data.index) {
|
||
this.setData({
|
||
isLast: true
|
||
});
|
||
}
|
||
},
|
||
|
||
pageLifetimes: {
|
||
// 组件所在页面的生命周期函数
|
||
show() {},
|
||
hide() {},
|
||
resize() {},
|
||
},
|
||
methods: {
|
||
getMoreData() {
|
||
this.setData({
|
||
page: this.data.page += 1,
|
||
});
|
||
this.getCPSGood(this.data.active, this.data.datas.list[this.data.active].text, 'more');
|
||
},
|
||
//获取数据
|
||
onClick(e) {
|
||
let index = e.detail.index;
|
||
this.setData({
|
||
active: index,
|
||
page: 1,
|
||
isLoadMore: true
|
||
});
|
||
this.getCPSGood(index, this.data.datas.list[index].text);
|
||
},
|
||
},
|
||
observers: {
|
||
bottomShowBol: function (flag) {
|
||
// 选项卡this.isLast判断商品列表是最后一个组件
|
||
if (flag && this.data.isLast && this.data.isLoadMore) {
|
||
this.getMoreData();
|
||
}
|
||
},
|
||
},
|
||
}); |