yuminge-app/yun-min-program-plugin-master/packageG/mycomponent/tabcontrol/tabcontrol.js

114 lines
2.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// packageE/tabcontrol/tabcontrol.js
var app = getApp();
Component({
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',
U_tabcontrol: true,
isLast: false,
active: 0,
show_text: '加载中...',
show_page: true
},
lifetimes: {
// 生命周期函数可以为函数或一个在methods段中定义的方法名
attached() {
},
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: {
//获取数据
getNetData(index) {
let that = this;
this.setData({
show_page: false,
show_text: '加载中...',
active: index
});
let json = {
decorate_id: this.data.page_id,
component_id: this.data.component_id,
component_key: "U_tabcontrol",
component_info: JSON.stringify({ list_key: index })
};
let urlStr = app.getNetAddresss("home-page.get-decorate-page");
app._getNetWork({
url: urlStr,
data: json,
success: (resdata) => {
var res = resdata.data;
if (res.result == 1) {
that.setData({
['datas.list[' + index + '].remote_data']: res.data[0].remote_data,
show_page: true,
});
} else {
that.setData({
show_page: false,
show_text: '后台没有设置数据或数据报错'
});
}
},
fail: function(res) {
console.log(res);
}
});
},
onClick(e) {
let index = e.detail.index;
this.getNetData(index);
},
}
});