choice_guide.js
3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var a = getApp(),
os = a.globalData.setting,
util = require("../../../../utils/util.js"),
ut = util;
Page({
data: {
url: os.url,
iurl: os.imghost,
total: 0, //数据的总量
ismore: 0,//数据是否加载完毕
page:1,
pageSize:10,
isload:0,
show_pop:0,
sele_item:null,
input_val:null,
is_back:0
},
//------初始化加载----------
onLoad: function(t) {
if(t.is_back){
this.data.is_back=t.is_back
}
},
onShow: function() {
getApp().check_can_share();
this.data.ismore=0;this.data.isload=0;
this.setData({list:null});
this.get_list();
},
//--点击分享事件---
onShareAppMessage: function(t) {
getApp().globalData.no_clear=1
return o.share;
},
get_list: function() {
var th = this, e = th;
var r_data={
storeId: os.stoid,
pickupId: a.globalData.userInfo.pickup_id,
page: th.data.page,
pageSize: th.data.pageSize
};
//关键字搜索
if(this.data.input_val){
r_data.KeyWord= encodeURIComponent(this.data.input_val);
}
getApp().request.promiseGet("/api/weshop/users/staff/page", {
data:r_data
}).then(res => {
th.setData({isload:1});
if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0) {
th.data.page++;//当前页数+1
var arr1 = th.data.list;//获取明细数组
var arr2 = res.data.data.pageData;//获取当前查询数据
if(!arr1) arr1=[];
var arr3 = [...arr1, ...arr2];//把当前查询数组拼接到原本数组后面
var ismore = 0;
if (arr3.length == res.data.data.total) ismore = 1 //数据已加载完判断
th.setData({
list: arr3,
total: res.data.data.total,
ismore: ismore,
})
}
})
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
if (this.data.total <= this.data.pageSize) return;
if (this.data.ismore) {
t.my_warnning("加载完啦!", 0, this);return
};
this.get_list();
},
//返回
back:function () {
wx.navigateBack({ delta: 1})
},
pop_sele:function (e) {
var index=e.currentTarget.dataset.index;
var item=this.data.list[index];
this.setData({show_pop:1,sele_item:item});
},
close_pop:function () {
this.setData({show_pop:0});
},
//选择了导购,就跳转到会员中心页面
go_user_info:function () {
var item=this.data.sele_item;
getApp().globalData.choice_guide=item;
if( this.data.is_back)
wx.navigateBack({ delta: 1 })
else
getApp().goto("/packageG/pages/user/userinfo/userinfo");
},
img_err:function (e) {
var txt=e.currentTarget.dataset.err_img;
this.setData({[txt]:this.data.iurl+'/miniapp/images/no-head.jpg'});
},
get_input_val:function(e){
var value=e.detail.value;
this.data.input_val=value;
},
sear:function(){
this.data.ismore=0;this.data.page=1;
this.setData({isload:0});
this.setData({list:null});
this.get_list();
}
});