diff --git a/pages/store/index.js b/pages/store/index.js new file mode 100644 index 0000000..3dbea01 --- /dev/null +++ b/pages/store/index.js @@ -0,0 +1,176 @@ +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 + }, + + onShow:function(){ + + }, + + //调用视频接口 + onLoad:function(e){ + var th=this; + wx.getLocation({ + type: 'wgs84', + 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; + 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 => { + 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.setData({ pick_list:null}) + this.get_list(); + + }, + + //搜索关键字 + sear:function(){ + this.data.page=1; + 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){}, + }) + }, + + + + +}) \ No newline at end of file diff --git a/pages/store/index.json b/pages/store/index.json new file mode 100644 index 0000000..8c3566f --- /dev/null +++ b/pages/store/index.json @@ -0,0 +1,7 @@ +{ + "navigationBarTitleText": "门店列表", + "enablePullDownRefresh": false, + "usingComponents": { + "nav_box": "/components/nav_box/nav_box" + } +} \ No newline at end of file diff --git a/pages/store/index.wxml b/pages/store/index.wxml new file mode 100644 index 0000000..e780603 --- /dev/null +++ b/pages/store/index.wxml @@ -0,0 +1,36 @@ + + + + + + + + + + {{periodsname?periodsname:"选择分类"}} + + + + + + + {{item.pickup_name}} + + + + {{item.pickup_phone}} + + 一键拔号 + + + + + {{item.fulladdress}} + + 地图导航 + + + + + + \ No newline at end of file diff --git a/pages/store/index.wxss b/pages/store/index.wxss new file mode 100644 index 0000000..23dab93 --- /dev/null +++ b/pages/store/index.wxss @@ -0,0 +1,48 @@ +.box{ + padding: 10px; + border-bottom: 10px solid #f5f5f5; + color: #000000; +} +.box .pickname { + font-size: 32rpx; + line-height: 80rpx; + border-bottom: 1rpx solid #EEEEEE; +} + +.box .mt { + margin-top: 20rpx; +} +.addr{ width: 75%;color: #848484;} +.buttonclass { + width: 160rpx; + height: 60rpx; + line-height: 60rpx; + text-align: center; + border: solid 1px #c3172d; + border-radius: 20rpx; + font-size: 28rpx; + color: #c3172d; +} +.fmob +{width: 28rpx; +height: 32rpx; +margin-right: 10rpx; +top: 4rpx; +position: relative; +} + +.faddr{ +width: 26rpx; +height: 32rpx; +margin-right: 6rpx; +top: 4rpx; +position: relative; +} + +.bcolor{background-color: #f5f5f5; height: 126rpx;} + +.sear_inp{width: 490rpx; background-color:#eaeaea; height: 80rpx; border-radius:5rpx; margin: 25rpx;} +.sear_inp input{ position: relative; top:10rpx;width: 400rpx; display: inline-block;} +.select{height: 80rpx; width: 220rpx;background-color:#eaeaea; margin:25rpx; font-size: 28rpx; line-height: 80rpx;text-align: center } +.sear_btn{ width: 50rpx; height: 100%; display: inline-block;} +