index.js
4.12 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
var o=getApp().globalData.setting;
Page({
data:{
is_get_local_ok:0,
is_gps:0,
lat:null,
lon:null,
page:1,
cat_list:null,
pick_list:null,
url:o.imghost,
is_no_more:0,
key_word:'', //关键字搜索
cat_id:0, //分类ID
islading:0,
},
onShow:function(){
},
//调用视频接口
onLoad:function(e){
var th=this;
wx.getLocation({
type: 'gcj02',
success: function(res) {
th.data.lat = res.latitude;
th.data.lon = res.longitude;
th.data.is_get_local_ok = 1;
},
fail: function(res) {
th.data.is_get_local_ok = 1;
if (res.errCode == 2) {
getApp().confirmBox("请开启GPS定位", null, 25000, !1);
}
}
})
//--获取门店分类---
getApp().request.get("/api/weshop/storagecategory/page", {
data: {
store_id: o.stoid,
is_show: 1,
pageSize: 300
},
success:function(res){
if(res.data.code==0){
th.setData({cat_list:res.data.data.pageData})
}
},
})
this.get_sto();
},
//---------拿出门店分类和门店------------
get_sto() {
var th = this;
var timer_get = setInterval(function() {
if (th.data.is_get_local_ok == 0) return false;
clearInterval(timer_get);
th.get_list();
}, 500)
},
get_list:function(){
if(this.data.is_no_more==1) return false;
if(this.data.islading==1) return false;
this.data.islading=1;
var th=this,req = getApp().request;
var dd = {
store_id: o.stoid,
isstop: 0,
pageSize: 10,
page:th.data.page
}
if(th.data.key_word!="" && th.data.key_word!=undefined) {
dd.keyword=th.data.key_word;
}
if(th.data.cat_id){
dd.category_id=th.data.cat_id;
}
wx.showLoading();
//----------获取门店---------
req.promiseGet("/api/weshop/pickup/list", {
data: dd,
}).then(res => {
this.data.islading=0;
wx.hideLoading();
if(res.data.code==0){
if(res.data.data.pageData.length<=0){
th.data.is_no_more=1; return false;
}
th.data.page=dd.page+1
var pick_list=th.data.pick_list;
if(!pick_list) pick_list=[];
pick_list=pick_list.concat(res.data.data.pageData);
th.setData({
pick_list:pick_list
})
}
})
},
//---加载更多是靠这个函数----
onReachBottom: function() {
this.get_list();
},
lose_focus:function(e){
var key_word = e.detail.value;
this.data.key_word=key_word;
},
phone:function(e){
var index=e.currentTarget.dataset.index;
var item=this.data.pick_list[index];
wx.makePhoneCall({
phoneNumber: item.pickup_phone,
})
},
//分类的下拉
bindPickerChange: function (e) {
var index = e.detail.value;//这里会获取他的索引值
var self = this;
var list = self.data.cat_list;
var item = list[index];
this.data.cat_id=item['cat_id'];
self.setData({
periodsname: item['cat_name'],
cid: item['cat_id']
})
this.data.page=1;
this.data.is_no_more=0;
this.setData({ pick_list:null})
this.get_list();
},
//搜索关键字
sear:function(){
this.data.page=1;
this.data.is_no_more=0;
this.setData({ pick_list:null})
this.get_list();
},
map: function (e) {
var index = e.currentTarget.dataset.index;//这里会获取他的索引值
var self = this;
var list = self.data.pick_list;
var item = list[index];
wx.openLocation({
//当前经纬度
latitude: parseFloat(item.lat),
longitude: parseFloat(item.lon),
//缩放级别默认28
scale: 28,
//位置名
name:item.pickup_name,
//详细地址
address: item.pickup_address,
//成功打印信息
success: function(res) {},
//失败打印信息
fail: function(err) {},
//完成打印信息
complete: function(info){},
})
},
})