Commit 98fec0f9c9e36a49345caecaac4096fd9e34bc2d
1 parent
b22e0a66
门店列表的功能实现
Showing
4 changed files
with
267 additions
and
0 deletions
pages/store/index.js
0 → 100644
1 | +var o=getApp().globalData.setting; | |
2 | +Page({ | |
3 | + data:{ | |
4 | + is_get_local_ok:0, | |
5 | + is_gps:0, | |
6 | + lat:null, | |
7 | + lon:null, | |
8 | + page:1, | |
9 | + cat_list:null, | |
10 | + pick_list:null, | |
11 | + url:o.imghost, | |
12 | + is_no_more:0, | |
13 | + key_word:'', //关键字搜索 | |
14 | + cat_id:0, //分类ID | |
15 | + }, | |
16 | + | |
17 | + onShow:function(){ | |
18 | + | |
19 | + }, | |
20 | + | |
21 | + //调用视频接口 | |
22 | + onLoad:function(e){ | |
23 | + var th=this; | |
24 | + wx.getLocation({ | |
25 | + type: 'wgs84', | |
26 | + success: function(res) { | |
27 | + th.data.lat = res.latitude; | |
28 | + th.data.lon = res.longitude; | |
29 | + th.data.is_get_local_ok = 1; | |
30 | + }, | |
31 | + fail: function(res) { | |
32 | + th.data.is_get_local_ok = 1; | |
33 | + if (res.errCode == 2) { | |
34 | + getApp().confirmBox("请开启GPS定位", null, 25000, !1); | |
35 | + } | |
36 | + | |
37 | + } | |
38 | + }) | |
39 | + //--获取门店分类--- | |
40 | + getApp().request.get("/api/weshop/storagecategory/page", { | |
41 | + data: { | |
42 | + store_id: o.stoid, | |
43 | + is_show: 1, | |
44 | + pageSize: 300 | |
45 | + }, | |
46 | + success:function(res){ | |
47 | + if(res.data.code==0){ | |
48 | + th.setData({cat_list:res.data.data.pageData}) | |
49 | + } | |
50 | + }, | |
51 | + }) | |
52 | + this.get_sto(); | |
53 | + }, | |
54 | + | |
55 | + //---------拿出门店分类和门店------------ | |
56 | + get_sto() { | |
57 | + var th = this; | |
58 | + var timer_get = setInterval(function() { | |
59 | + if (th.data.is_get_local_ok == 0) return false; | |
60 | + clearInterval(timer_get); | |
61 | + th.get_list(); | |
62 | + }, 500) | |
63 | + | |
64 | + }, | |
65 | + | |
66 | + get_list:function(){ | |
67 | + if(this.data.is_no_more==1) return false; | |
68 | + var th=this,req = getApp().request; | |
69 | + var dd = { | |
70 | + store_id: o.stoid, | |
71 | + isstop: 0, | |
72 | + pageSize: 10, | |
73 | + page:th.data.page | |
74 | + } | |
75 | + if(th.data.key_word!="" && th.data.key_word!=undefined) { | |
76 | + dd.keyword=th.data.key_word; | |
77 | + } | |
78 | + if(th.data.cat_id){ | |
79 | + dd.category_id=th.data.cat_id; | |
80 | + } | |
81 | + | |
82 | + wx.showLoading(); | |
83 | + //----------获取门店--------- | |
84 | + req.promiseGet("/api/weshop/pickup/list", { | |
85 | + data: dd, | |
86 | + }).then(res => { | |
87 | + wx.hideLoading(); | |
88 | + if(res.data.code==0){ | |
89 | + if(res.data.data.pageData.length<=0){ | |
90 | + th.data.is_no_more=1; return false; | |
91 | + } | |
92 | + | |
93 | + th.data.page=dd.page+1 | |
94 | + var pick_list=th.data.pick_list; | |
95 | + if(!pick_list) pick_list=[]; | |
96 | + pick_list=pick_list.concat(res.data.data.pageData); | |
97 | + th.setData({ | |
98 | + pick_list:pick_list | |
99 | + }) | |
100 | + } | |
101 | + }) | |
102 | + }, | |
103 | + | |
104 | + //---加载更多是靠这个函数---- | |
105 | + onReachBottom: function() { | |
106 | + this.get_list(); | |
107 | + }, | |
108 | + | |
109 | + lose_focus:function(e){ | |
110 | + var key_word = e.detail.value; | |
111 | + this.data.key_word=key_word; | |
112 | + }, | |
113 | + | |
114 | + | |
115 | + phone:function(e){ | |
116 | + var index=e.currentTarget.dataset.index; | |
117 | + var item=this.data.pick_list[index]; | |
118 | + wx.makePhoneCall({ | |
119 | + phoneNumber: item.pickup_phone, | |
120 | + }) | |
121 | + }, | |
122 | + | |
123 | + //分类的下拉 | |
124 | + bindPickerChange: function (e) { | |
125 | + var index = e.detail.value;//这里会获取他的索引值 | |
126 | + var self = this; | |
127 | + var list = self.data.cat_list; | |
128 | + var item = list[index]; | |
129 | + this.data.cat_id=item['cat_id']; | |
130 | + self.setData({ | |
131 | + periodsname: item['cat_name'], | |
132 | + cid: item['cat_id'] | |
133 | + }) | |
134 | + this.data.page=1; | |
135 | + this.setData({ pick_list:null}) | |
136 | + this.get_list(); | |
137 | + | |
138 | + }, | |
139 | + | |
140 | + //搜索关键字 | |
141 | + sear:function(){ | |
142 | + this.data.page=1; | |
143 | + this.setData({ pick_list:null}) | |
144 | + this.get_list(); | |
145 | + }, | |
146 | + | |
147 | + | |
148 | + map: function (e) { | |
149 | + var index = e.currentTarget.dataset.index;//这里会获取他的索引值 | |
150 | + var self = this; | |
151 | + var list = self.data.pick_list; | |
152 | + var item = list[index]; | |
153 | + | |
154 | + wx.openLocation({ | |
155 | + //当前经纬度 | |
156 | + latitude: parseFloat(item.lat), | |
157 | + longitude: parseFloat(item.lon), | |
158 | + //缩放级别默认28 | |
159 | + scale: 28, | |
160 | + //位置名 | |
161 | + name:item.pickup_name, | |
162 | + //详细地址 | |
163 | + address: item.pickup_address, | |
164 | + //成功打印信息 | |
165 | + success: function(res) {}, | |
166 | + //失败打印信息 | |
167 | + fail: function(err) {}, | |
168 | + //完成打印信息 | |
169 | + complete: function(info){}, | |
170 | + }) | |
171 | + }, | |
172 | + | |
173 | + | |
174 | + | |
175 | + | |
176 | +}) | |
0 | 177 | \ No newline at end of file | ... | ... |
pages/store/index.json
0 → 100644
pages/store/index.wxml
0 → 100644
1 | +<view class="bcolor flex jc_sb"> | |
2 | + <view class="sear_inp"> | |
3 | + <view class="sear_btn" bindtap='sear'> | |
4 | + <image src="{{url}}/miniapp/images/search.png" style="width: 30rpx; height: 30rpx; margin-left: 10rpx;"></image> | |
5 | + </view> | |
6 | + <input bindinput ="lose_focus" class="fs28" value=""/> | |
7 | + </view> | |
8 | + <view class="select"> | |
9 | + <picker bindchange="bindPickerChange" value="{{index}}" range="{{cat_list}}" range-key='cat_name'> | |
10 | + <view class="course_icon">{{periodsname?periodsname:"选择分类"}}</view> | |
11 | + </picker> | |
12 | + </view> | |
13 | +</view> | |
14 | +<view> | |
15 | + <view class="box" wx:for="{{pick_list}}"> | |
16 | + <!-- 门店名称 --> | |
17 | + <view class="pickname">{{item.pickup_name}}</view> | |
18 | + <!-- 电话 --> | |
19 | + <view class="mt flex jc_sb" bindtap="phone" data-index="{{index}}" > | |
20 | + <!-- 左边电话 --> | |
21 | + <view>{{item.pickup_phone}}</view> | |
22 | + <!-- 右边按钮 --> | |
23 | + <view class="buttonclass"><image src='{{url}}/miniapp/images/storelist/store_phone.png' class="fmob"></image>一键拔号</view> | |
24 | + </view> | |
25 | + <!-- 电话 --> | |
26 | + <view class="mt flex jc_sb" bindtap="map" data-index="{{index}}"> | |
27 | + <!-- 左边电话 --> | |
28 | + <view class="addr">{{item.fulladdress}}</view> | |
29 | + <!-- 右边按钮 --> | |
30 | + <view class="buttonclass"><image src='{{url}}/miniapp/images/storelist/store_addr.png' class="faddr"></image>地图导航</view> | |
31 | + </view> | |
32 | + </view> | |
33 | +</view> | |
34 | + | |
35 | +<!-- 制作一个圆球导航 --> | |
36 | +<nav_box></nav_box> | |
0 | 37 | \ No newline at end of file | ... | ... |
pages/store/index.wxss
0 → 100644
1 | +.box{ | |
2 | + padding: 10px; | |
3 | + border-bottom: 10px solid #f5f5f5; | |
4 | + color: #000000; | |
5 | +} | |
6 | +.box .pickname { | |
7 | + font-size: 32rpx; | |
8 | + line-height: 80rpx; | |
9 | + border-bottom: 1rpx solid #EEEEEE; | |
10 | +} | |
11 | + | |
12 | +.box .mt { | |
13 | + margin-top: 20rpx; | |
14 | +} | |
15 | +.addr{ width: 75%;color: #848484;} | |
16 | +.buttonclass { | |
17 | + width: 160rpx; | |
18 | + height: 60rpx; | |
19 | + line-height: 60rpx; | |
20 | + text-align: center; | |
21 | + border: solid 1px #c3172d; | |
22 | + border-radius: 20rpx; | |
23 | + font-size: 28rpx; | |
24 | + color: #c3172d; | |
25 | +} | |
26 | +.fmob | |
27 | +{width: 28rpx; | |
28 | +height: 32rpx; | |
29 | +margin-right: 10rpx; | |
30 | +top: 4rpx; | |
31 | +position: relative; | |
32 | +} | |
33 | + | |
34 | +.faddr{ | |
35 | +width: 26rpx; | |
36 | +height: 32rpx; | |
37 | +margin-right: 6rpx; | |
38 | +top: 4rpx; | |
39 | +position: relative; | |
40 | +} | |
41 | + | |
42 | +.bcolor{background-color: #f5f5f5; height: 126rpx;} | |
43 | + | |
44 | +.sear_inp{width: 490rpx; background-color:#eaeaea; height: 80rpx; border-radius:5rpx; margin: 25rpx;} | |
45 | +.sear_inp input{ position: relative; top:10rpx;width: 400rpx; display: inline-block;} | |
46 | +.select{height: 80rpx; width: 220rpx;background-color:#eaeaea; margin:25rpx; font-size: 28rpx; line-height: 80rpx;text-align: center } | |
47 | +.sear_btn{ width: 50rpx; height: 100%; display: inline-block;} | |
48 | + | ... | ... |