Showing
9 changed files
with
673 additions
and
26 deletions
| 1 | // components/2.0/filter/location.js | 1 | // components/2.0/filter/location.js |
| 2 | -import DA from '../../../pages/reserve/data'; | 2 | +import DA from '../../../pages/reserve/data' |
| 3 | import util from '../../../utils/util' | 3 | import util from '../../../utils/util' |
| 4 | +import QQMapWX from '../../../utils/qqmap-wx-jssdk.js' | ||
| 5 | +const qqmapsdk = new QQMapWX({ | ||
| 6 | + key: 'SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ' | ||
| 7 | +}); | ||
| 8 | +const CACHE_LOCALTION_KEY='CACHE_LOCALTION_KEY' | ||
| 4 | Component({ | 9 | Component({ |
| 5 | /** | 10 | /** |
| 6 | * 组件的属性列表 | 11 | * 组件的属性列表 |
| 7 | */ | 12 | */ |
| 8 | properties: { | 13 | properties: { |
| 9 | - | 14 | + code:String, |
| 10 | }, | 15 | }, |
| 11 | 16 | ||
| 12 | /** | 17 | /** |
| 13 | * 组件的初始数据 | 18 | * 组件的初始数据 |
| 14 | */ | 19 | */ |
| 15 | data: { | 20 | data: { |
| 16 | - | 21 | + address:'', |
| 22 | + activeCity:{}, | ||
| 23 | + hasShow:false, | ||
| 17 | }, | 24 | }, |
| 18 | attached(){ | 25 | attached(){ |
| 19 | this.init() | 26 | this.init() |
| 20 | - this.position={} | ||
| 21 | - this.selectComponent('#getpos').getPos(); | 27 | + |
| 22 | }, | 28 | }, |
| 23 | /** | 29 | /** |
| 24 | * 组件的方法列表 | 30 | * 组件的方法列表 |
| 25 | */ | 31 | */ |
| 26 | methods: { | 32 | methods: { |
| 27 | async init(){ | 33 | async init(){ |
| 34 | + this.position={} | ||
| 35 | + this.isAddr=false | ||
| 36 | + this.citys=await DA.getCitys() | ||
| 37 | + this.setData({ | ||
| 38 | + citys: this.citys | ||
| 39 | + }) | ||
| 40 | + this.selectComponent('#getpos').getPos(); | ||
| 41 | + }, | ||
| 42 | + rePos(e){ | ||
| 43 | + this.isAddr=util.attr(e,'isAddr') | ||
| 44 | + this.selectComponent('#getpos').getPos(); | ||
| 45 | + }, | ||
| 46 | + hide(){ | ||
| 47 | + this.setData({ | ||
| 48 | + hasShow:false, | ||
| 49 | + }) | ||
| 50 | + }, | ||
| 51 | + show(){ | ||
| 52 | + this.setData({ | ||
| 53 | + hasShow:true, | ||
| 54 | + }) | ||
| 55 | + }, | ||
| 56 | + event(data){ | ||
| 57 | + this.triggerEvent('event',data) | ||
| 58 | + util.cache('CACHE_LOCALTION_KEY',data) | ||
| 59 | + }, | ||
| 60 | + checkedCity(e){ | ||
| 61 | + let activeCity=this.citys[util.attr(e,'index')] | ||
| 28 | this.setData({ | 62 | this.setData({ |
| 29 | - citys: await DA.getCitys() | 63 | + activeCity:activeCity, |
| 30 | }) | 64 | }) |
| 65 | + this.event({city:activeCity,address:this.position.address,isAddr:false}) | ||
| 31 | }, | 66 | }, |
| 32 | onpos(e) { | 67 | onpos(e) { |
| 33 | let res = e.detail; | 68 | let res = e.detail; |
| 34 | console.log('onpos.res', res); | 69 | console.log('onpos.res', res); |
| 35 | this.position.latitude = res.latitude; | 70 | this.position.latitude = res.latitude; |
| 36 | this.position.longitude = res.longitude; | 71 | this.position.longitude = res.longitude; |
| 72 | + qqmapsdk.reverseGeocoder({ | ||
| 73 | + location: { | ||
| 74 | + latitude: res.latitude, | ||
| 75 | + longitude: res.longitude | ||
| 76 | + }, | ||
| 77 | + success:(res)=>{ | ||
| 78 | + if(res.status!=0) return; | ||
| 79 | + console.log('qqmapsdk.reverseGeocoder',res.result) | ||
| 80 | + this.position.address_component= res.result.address_component | ||
| 81 | + this.position.address=res.result.address | ||
| 82 | + let activeCity={} | ||
| 83 | + if(!this.data.code){ | ||
| 84 | + this.citys.some(ci=>{ | ||
| 85 | + if(ci.name==this.position.address_component.city){ | ||
| 86 | + activeCity=ci | ||
| 87 | + return true | ||
| 88 | + } | ||
| 89 | + }) | ||
| 90 | + }else{ | ||
| 91 | + this.citys.some(ci=>{ | ||
| 92 | + if(ci.code==this.data.code){ | ||
| 93 | + activeCity=ci | ||
| 94 | + return true | ||
| 95 | + } | ||
| 96 | + }) | ||
| 97 | + } | ||
| 98 | + this.setData({ | ||
| 99 | + activeCity:activeCity, | ||
| 100 | + address:this.position.address | ||
| 101 | + }) | ||
| 102 | + this.event({city:activeCity,address:this.position.address,isAddr:this.isAddr}) | ||
| 103 | + if(this.isAddr){//点击地址 | ||
| 104 | + this.hide() | ||
| 105 | + } | ||
| 106 | + }, | ||
| 107 | + }) | ||
| 108 | + | ||
| 37 | }, | 109 | }, |
| 38 | } | 110 | } |
| 39 | }) | 111 | }) |
| 1 | <!--components/2.0/filter/location.wxml--> | 1 | <!--components/2.0/filter/location.wxml--> |
| 2 | -<view class="view cu-modal bottom-modal {{!hasShow?'show':''}}" bindtap="hide"> | 2 | +<view class="view cu-modal bottom-modal {{hasShow?'show':''}}" bindtap="hide"> |
| 3 | <view class="cu-dialog confirm bg-white " catchtap="catchtap" style="border-radius: 40rpx 40rpx 0px 0px;"> | 3 | <view class="cu-dialog confirm bg-white " catchtap="catchtap" style="border-radius: 40rpx 40rpx 0px 0px;"> |
| 4 | <view class="padding-lg"> | 4 | <view class="padding-lg"> |
| 5 | <view class="view txt-32-h"> | 5 | <view class="view txt-32-h"> |
| @@ -7,29 +7,31 @@ | @@ -7,29 +7,31 @@ | ||
| 7 | </view> | 7 | </view> |
| 8 | <view class="flex margin-tb-lg"> | 8 | <view class="flex margin-tb-lg"> |
| 9 | <view class="flex-treble text-bold txt-34-h flex justify-start">我的位置</view> | 9 | <view class="flex-treble text-bold txt-34-h flex justify-start">我的位置</view> |
| 10 | - <view class="flex justify-end align-center"> | 10 | + <view class="flex justify-end align-center" bindtap="rePos"> |
| 11 | <image src="http://nosqn.colorcun.com/search/s%20%289%29.png" style="width: 28rpx;height: 28rpx;"></image> | 11 | <image src="http://nosqn.colorcun.com/search/s%20%289%29.png" style="width: 28rpx;height: 28rpx;"></image> |
| 12 | <view class="margin-left-sm text-blue txt-26-h">重新定位</view> | 12 | <view class="margin-left-sm text-blue txt-26-h">重新定位</view> |
| 13 | </view> | 13 | </view> |
| 14 | </view> | 14 | </view> |
| 15 | - <view wx:if="{{true}}" class="flex justify-start align-start"> | 15 | + <view wx:if="{{address}}" class="flex justify-start align-start" bindtap="rePos" data-is-addr="{{true}}"> |
| 16 | <image src="http://nosqn.colorcun.com/search/s%20%2810%29.png" | 16 | <image src="http://nosqn.colorcun.com/search/s%20%2810%29.png" |
| 17 | style="width: 26rpx;height: 30rpx;margin-top: 6rpx;"></image> | 17 | style="width: 26rpx;height: 30rpx;margin-top: 6rpx;"></image> |
| 18 | - <view class="text-30 margin-left-sm flex-treble text-left">的说法是电风扇东风风神懂法守法水电费水电费水电费水电费水电费水电费水电费</view> | 18 | + <view class="text-30 margin-left-sm flex-treble text-left">{{address}}</view> |
| 19 | </view> | 19 | </view> |
| 20 | <view wx:else="" class="text-30 flex-treble text-center">未获取到位置</view> | 20 | <view wx:else="" class="text-30 flex-treble text-center">未获取到位置</view> |
| 21 | - <view class="view margin-bottom-xl margin-top-lg grid col-4 city-view"> | ||
| 22 | - <view class="view flex justify-center city-city" wx:for="{{citys}}" wx:key="citys"> | ||
| 23 | - <view class="view city">{{item.name}}</view> | 21 | + <view class="view margin-top-lg grid col-4 city-view"> |
| 22 | + <view class="view flex justify-center city-city" | ||
| 23 | + bindtap="checkedCity" data-index="{{index}}" | ||
| 24 | + wx:for="{{citys}}" wx:key="citys"> | ||
| 25 | + <view class="view city {{activeCity.code==item.code?'active':''}}">{{item.name}}</view> | ||
| 24 | </view> | 26 | </view> |
| 25 | </view> | 27 | </view> |
| 26 | - <view class="flex justify-center margin-bottom-lg margin-top"> | ||
| 27 | - <button class="view cu-btn margin-right-xl round bg-ghostWhite" wx:if="{{opt.cancelText}}" | ||
| 28 | - bindtap="tapButton" data-type="cancel" | ||
| 29 | - style="color:{{opt.cancelColor}};">{{opt.cancelText}}</button> | ||
| 30 | - <button class="view cu-btn round bg-blue" | ||
| 31 | - bindtap="tapButton" data-type="confirm" | ||
| 32 | - style="color:{{opt.confirmColor}};">{{opt.confirmText}}</button> | 28 | + <view class="txt-24-h text-gray margin-bottom-lg ">更多城市敬请期待…</view> |
| 29 | + <view class="flex justify-center padding-top-lg"> | ||
| 30 | + <button class="view cu-btn round bg-ghostWhite txt-34-h" | ||
| 31 | + style="width: 100%;color:#666666; height: 80rpx;" | ||
| 32 | + bindtap="hide"> | ||
| 33 | + 取消 | ||
| 34 | + </button> | ||
| 33 | </view> | 35 | </view> |
| 34 | </view> | 36 | </view> |
| 35 | </view> | 37 | </view> |
| @@ -14,10 +14,6 @@ | @@ -14,10 +14,6 @@ | ||
| 14 | line-height: 84rpx; | 14 | line-height: 84rpx; |
| 15 | margin-bottom: 40rpx; | 15 | margin-bottom: 40rpx; |
| 16 | } | 16 | } |
| 17 | -.city-view .city-city:nth-child(4n+0){ | ||
| 18 | - background-color: #1AAD19; | ||
| 19 | - justify-items: flex-end; | ||
| 20 | -} | ||
| 21 | .city.active{ | 17 | .city.active{ |
| 22 | color: #42A5FF; | 18 | color: #42A5FF; |
| 23 | background: #E6F3FF; | 19 | background: #E6F3FF; |
| @@ -5,7 +5,7 @@ Page({ | @@ -5,7 +5,7 @@ Page({ | ||
| 5 | * 页面的初始数据 | 5 | * 页面的初始数据 |
| 6 | */ | 6 | */ |
| 7 | data: { | 7 | data: { |
| 8 | - | 8 | + location:'获取中...' |
| 9 | }, | 9 | }, |
| 10 | 10 | ||
| 11 | /** | 11 | /** |
| @@ -78,7 +78,14 @@ Page({ | @@ -78,7 +78,14 @@ Page({ | ||
| 78 | //setTimeout(()=>{this.getList();},0) | 78 | //setTimeout(()=>{this.getList();},0) |
| 79 | this.selectComponent('#search-how').hide(); | 79 | this.selectComponent('#search-how').hide(); |
| 80 | }, | 80 | }, |
| 81 | + dispalyLocation(){ | ||
| 82 | + this.selectComponent('#location').show(); | ||
| 83 | + }, | ||
| 81 | locationEvent(e){ | 84 | locationEvent(e){ |
| 82 | console.log('locationEvent',e.detail) | 85 | console.log('locationEvent',e.detail) |
| 86 | + this.city=e.detail.city | ||
| 87 | + this.setData({ | ||
| 88 | + location:e.detail.isAddr?e.detail.address:e.detail.city.name | ||
| 89 | + }) | ||
| 83 | } | 90 | } |
| 84 | }) | 91 | }) |
| @@ -6,7 +6,10 @@ | @@ -6,7 +6,10 @@ | ||
| 6 | </view> | 6 | </view> |
| 7 | <view class="view search margin-lr padding-top-0 padding-lr-lg padding-bottom-lg"> | 7 | <view class="view search margin-lr padding-top-0 padding-lr-lg padding-bottom-lg"> |
| 8 | <view class="view solid-bottom flex justify-around align-center" style="height: 110rpx;"> | 8 | <view class="view solid-bottom flex justify-around align-center" style="height: 110rpx;"> |
| 9 | - <view class="view flex-treble text-bold text-xl text-cut margin-right-lg">ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss</view> | 9 | + <view bindtap="dispalyLocation" |
| 10 | + class="view flex-treble text-bold text-xl text-cut margin-right-lg"> | ||
| 11 | + {{location}} | ||
| 12 | + </view> | ||
| 10 | <view class="view flex flex-direction align-center justify-center"> | 13 | <view class="view flex flex-direction align-center justify-center"> |
| 11 | <view class="view posicon"></view> | 14 | <view class="view posicon"></view> |
| 12 | <view class="view text-blue txt-24-h" style="margin-top: 4rpx;">我的位置</view> | 15 | <view class="view text-blue txt-24-h" style="margin-top: 4rpx;">我的位置</view> |
pages/reserve/searchKeyword.js
0 → 100644
| 1 | +// pages/reserve/search.js\ | ||
| 2 | +const map_key='SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ' | ||
| 3 | +// 引入SDK核心类 | ||
| 4 | +var QQMapWX = require('../../utils/qqmap-wx-jssdk'); | ||
| 5 | +// 实例化API核心类 | ||
| 6 | +var qqmapsdk = new QQMapWX({ | ||
| 7 | + key:map_key // 必填 | ||
| 8 | +}); | ||
| 9 | +import util from '../../utils/util'; | ||
| 10 | +import App from '../../utils/api'; | ||
| 11 | +import PubSub from '../../utils/PubSub' | ||
| 12 | +Page({ | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 页面的初始数据 | ||
| 16 | + */ | ||
| 17 | + data: { | ||
| 18 | + history:[], | ||
| 19 | + suggestion:[], | ||
| 20 | + hasSellerMore:false, | ||
| 21 | + keyword:'', | ||
| 22 | + sellerSplit:-1, | ||
| 23 | + navHeight:100, | ||
| 24 | + }, | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 生命周期函数--监听页面加载 | ||
| 28 | + */ | ||
| 29 | + onLoad: function (options) { | ||
| 30 | + this.selectComponent('#getpos').getPos(); | ||
| 31 | + }, | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 生命周期函数--监听页面初次渲染完成 | ||
| 35 | + */ | ||
| 36 | + onReady: function () { | ||
| 37 | + | ||
| 38 | + }, | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 生命周期函数--监听页面显示 | ||
| 42 | + */ | ||
| 43 | + onShow: function () { | ||
| 44 | + PubSub.emit('custom-tab-bar') | ||
| 45 | + this.getHistory(); | ||
| 46 | + this.setData({ | ||
| 47 | + navHeight:this.selectComponent('#nav').getHeight() | ||
| 48 | + }) | ||
| 49 | + | ||
| 50 | + }, | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 生命周期函数--监听页面隐藏 | ||
| 54 | + */ | ||
| 55 | + onHide: function () { | ||
| 56 | + | ||
| 57 | + }, | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 生命周期函数--监听页面卸载 | ||
| 61 | + */ | ||
| 62 | + onUnload: function () { | ||
| 63 | + | ||
| 64 | + }, | ||
| 65 | + getHistory(){ | ||
| 66 | + App.Customer.GetHistorySearch().then(res=>{ | ||
| 67 | + let mks=[] | ||
| 68 | + res.data.forEach(h=>{ | ||
| 69 | + mks.push({ // 获取返回结果,放到mks数组中 | ||
| 70 | + title: h.name, | ||
| 71 | + id: h.sid, | ||
| 72 | + addr: '', | ||
| 73 | + city: '', | ||
| 74 | + district: 0, | ||
| 75 | + latitude: h.latitude, | ||
| 76 | + longitude: h.longitude, | ||
| 77 | + type:h.type==1?-1:h.type, | ||
| 78 | + }) | ||
| 79 | + }) | ||
| 80 | + this.setData({ | ||
| 81 | + history:mks | ||
| 82 | + }) | ||
| 83 | + }) | ||
| 84 | + }, | ||
| 85 | + //在Page({})中使用下列代码 | ||
| 86 | + //数据回填方法 | ||
| 87 | + backfill: function (e) { | ||
| 88 | + var id = e.currentTarget.id; | ||
| 89 | + for (var i = 0; i < this.data.suggestion.length; i++) { | ||
| 90 | + if (i == id) { | ||
| 91 | + console.log('backfill,this.data.suggestion[i]:',this.data.suggestion[i]) | ||
| 92 | + // let pages = getCurrentPages(); | ||
| 93 | + // let p = pages[pages.length - 2]; | ||
| 94 | + // p.setSuggestion(this.data.suggestion[i]) | ||
| 95 | + //util.cache('suggestion',this.data.suggestion[i]); | ||
| 96 | + this.setData({ | ||
| 97 | + backfill: this.data.suggestion[i].title | ||
| 98 | + }); | ||
| 99 | + this.setSuggestion({fun:'setSuggestion',suggestion:this.data.suggestion[i]}) | ||
| 100 | + wx.navigateBack(); | ||
| 101 | + break; | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + }, | ||
| 105 | + inputVal:'', | ||
| 106 | + //触发关键词输入提示事件 | ||
| 107 | + getsuggest: function (e) { | ||
| 108 | + //调用关键词提示接口 | ||
| 109 | + this.inputVal=e.detail.value; | ||
| 110 | + if(this.inputVal.length<1){ | ||
| 111 | + return this.setData({ | ||
| 112 | + suggestion: [], | ||
| 113 | + keyword:'' | ||
| 114 | + }) | ||
| 115 | + } | ||
| 116 | + let prarms={ | ||
| 117 | + keyword:this.inputVal, | ||
| 118 | + region:this.location.city||'', | ||
| 119 | + region_fix:0, | ||
| 120 | + page_size:20, | ||
| 121 | + page_index:1, | ||
| 122 | + key:map_key, | ||
| 123 | + } | ||
| 124 | + if(this.location.latitude){ | ||
| 125 | + prarms.location=this.location.latitude+','+this.location.longitude | ||
| 126 | + } | ||
| 127 | + App.Customer.KeywordTips(prarms).then(res=>{ | ||
| 128 | + if(this.inputVal.length<1){ | ||
| 129 | + return this.setData({ | ||
| 130 | + suggestion: [] | ||
| 131 | + }) | ||
| 132 | + } | ||
| 133 | + var sug = [],hasSellerMore=false,sellerSplit=-1 | ||
| 134 | + try{ | ||
| 135 | + res.data=res.data.data | ||
| 136 | + if(res.data instanceof Array){ | ||
| 137 | + for (var i = 0; i < res.data.length; i++) { | ||
| 138 | + if(i==2 && res.data[i].type==-1){ | ||
| 139 | + hasSellerMore=true | ||
| 140 | + continue; | ||
| 141 | + } | ||
| 142 | + if((i==1 || i==2) && res.data[i-1].type==-1 && res.data[i].type!=-1){ | ||
| 143 | + sellerSplit=i-1 | ||
| 144 | + } | ||
| 145 | + let item=res.data[i] | ||
| 146 | + item.latitude=item.location.lat | ||
| 147 | + item.longitude=item.location.lng | ||
| 148 | + item.addr=item.address | ||
| 149 | + item.titles=item.title.match(new RegExp('(.*)('+this.inputVal+')(.*)')) | ||
| 150 | + sug.push(item); | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + }catch(e){} | ||
| 154 | + this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示 | ||
| 155 | + suggestion: sug, | ||
| 156 | + hasSellerMore:hasSellerMore, | ||
| 157 | + keyword:this.inputVal, | ||
| 158 | + sellerSplit:sellerSplit, | ||
| 159 | + }); | ||
| 160 | + }) | ||
| 161 | + }, | ||
| 162 | + nearby_search: function () { | ||
| 163 | + App.Customer.SearchMap({ | ||
| 164 | + boundary:'region('+this.location.city+',1)', | ||
| 165 | + //boundary:'nearby('+this.location.latitude+','+this.location.longitude+',1000,1)', | ||
| 166 | + location:this.location.latitude+','+this.location.longitude, | ||
| 167 | + keyword:this.inputVal, | ||
| 168 | + page_size:20, | ||
| 169 | + page_index:1, | ||
| 170 | + orderby:'_distance', | ||
| 171 | + key:map_key, | ||
| 172 | + }).then(res=>{ | ||
| 173 | + var mks = [] | ||
| 174 | + for (var i = 0; i < res.data.length; i++) { | ||
| 175 | + mks.push({ // 获取返回结果,放到mks数组中 | ||
| 176 | + title: res.data[i].title, | ||
| 177 | + id: res.data[i].id, | ||
| 178 | + addr: res.data[i].address, | ||
| 179 | + city: res.data[i].city, | ||
| 180 | + district: res.data[i].district, | ||
| 181 | + latitude: res.data[i].location.lat, | ||
| 182 | + longitude: res.data[i].location.lng, | ||
| 183 | + type:res.data[i].type, | ||
| 184 | + category:res.data[i].category, | ||
| 185 | + }) | ||
| 186 | + } | ||
| 187 | + this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示 | ||
| 188 | + suggestion:mks, | ||
| 189 | + }); | ||
| 190 | + }) | ||
| 191 | + }, | ||
| 192 | + location:'', | ||
| 193 | + onpos(e){ | ||
| 194 | + console.log(e); | ||
| 195 | + this.location=e.detail | ||
| 196 | + this.GetRecommendSellerLists() | ||
| 197 | + this.getCity() | ||
| 198 | + }, | ||
| 199 | + getCity(){ | ||
| 200 | + qqmapsdk.reverseGeocoder({ | ||
| 201 | + location:this.location, | ||
| 202 | + success:(res)=>{ | ||
| 203 | + this.location['city']=''; | ||
| 204 | + if(res.status==0){ | ||
| 205 | + this.location['city']=res.result.ad_info.city | ||
| 206 | + } | ||
| 207 | + }, | ||
| 208 | + }) | ||
| 209 | + }, | ||
| 210 | + gotoList(){ | ||
| 211 | + wx.navigateTo({ | ||
| 212 | + url:util.http_build_query({ | ||
| 213 | + lat:this.location.latitude, | ||
| 214 | + lng:this.location.longitude, | ||
| 215 | + keyword:this.inputVal, | ||
| 216 | + multiIndex:0, | ||
| 217 | + },'./indexList') | ||
| 218 | + }) | ||
| 219 | + }, | ||
| 220 | + searchItemClick(e){ | ||
| 221 | + //console.log('searchItemClick',e) | ||
| 222 | + let item=e.detail.data | ||
| 223 | + if(e.detail.act=='detail'){ | ||
| 224 | + if(item.type==-1){ | ||
| 225 | + wx.navigateTo({ | ||
| 226 | + url:util.http_build_query({ | ||
| 227 | + id:item.id, | ||
| 228 | + },'./detail') | ||
| 229 | + }) | ||
| 230 | + }else{ | ||
| 231 | + //let pages = getCurrentPages(); | ||
| 232 | + //let p = pages[pages.length - 2]; | ||
| 233 | + //p.setSuggestion(item) | ||
| 234 | + this.setSuggestion({fun:'setSuggestion',suggestion:item}) | ||
| 235 | + this.setData({ | ||
| 236 | + backfill: item.title | ||
| 237 | + }); | ||
| 238 | + wx.navigateBack(); | ||
| 239 | + } | ||
| 240 | + }else{ | ||
| 241 | + wx.navigateTo({ | ||
| 242 | + url:util.http_build_query({ | ||
| 243 | + id:item.id, | ||
| 244 | + activeTab:'reserve', | ||
| 245 | + },'./detail') | ||
| 246 | + }) | ||
| 247 | + } | ||
| 248 | + }, | ||
| 249 | + historyEmpty(){ | ||
| 250 | + App.Customer.DelHistorySearch().then(()=>{ | ||
| 251 | + App.Customer.GetHistorySearch({},'clear') | ||
| 252 | + this.setData({ | ||
| 253 | + history:[] | ||
| 254 | + }) | ||
| 255 | + }) | ||
| 256 | + }, | ||
| 257 | + clearKeyword(){ | ||
| 258 | + this.setData({ | ||
| 259 | + keyword:'', | ||
| 260 | + suggestion:[], | ||
| 261 | + }) | ||
| 262 | + }, | ||
| 263 | + GetRecommendSellerLists(){ | ||
| 264 | + if(!this.location.latitude) return; | ||
| 265 | + let param={} | ||
| 266 | + param={ | ||
| 267 | + lat:this.location.latitude, | ||
| 268 | + lng:this.location.longitude | ||
| 269 | + } | ||
| 270 | + App.Customer.GetRecommendSellerLists(param).then(res=>{ | ||
| 271 | + this.setData({ | ||
| 272 | + rsl:res.data | ||
| 273 | + }) | ||
| 274 | + }) | ||
| 275 | + }, | ||
| 276 | + hasGoto:false, | ||
| 277 | + bindtransition(e){ | ||
| 278 | + console.log(e) | ||
| 279 | + if('change'==e.type){ | ||
| 280 | + this.hasGoto=false | ||
| 281 | + } | ||
| 282 | + if('animationfinish'==e.type){ | ||
| 283 | + if(this.hasGoto && (e.detail.current+1)==this.data.rsl.length){ | ||
| 284 | + wx.switchTab({ | ||
| 285 | + url: '/pages/reserve/index' | ||
| 286 | + }) | ||
| 287 | + return; | ||
| 288 | + }else{ | ||
| 289 | + this.hasGoto=true | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + }, | ||
| 293 | + gotoSellerDetail(e){ | ||
| 294 | + let url='/pages/reserve/detail?id='+e.currentTarget.id | ||
| 295 | + wx.navigateTo({ | ||
| 296 | + url:url, | ||
| 297 | + }) | ||
| 298 | + }, | ||
| 299 | + sbtrEvent(e){ | ||
| 300 | + console.log(e); | ||
| 301 | + if(e.detail.act=='oncall'){ | ||
| 302 | + this.selectComponent('#as').show(e.detail.seller); | ||
| 303 | + } | ||
| 304 | + }, | ||
| 305 | + setSuggestion(data){//只通知前页变更数据 | ||
| 306 | + /* | ||
| 307 | + let pages = getCurrentPages(); | ||
| 308 | + let p = pages[pages.length - 2]; | ||
| 309 | + if(p.route=='pages/reserve/index'){ | ||
| 310 | + PubSub.emit('searchParam',data) | ||
| 311 | + }else{ | ||
| 312 | + PubSub.emit('searchParamList',data) | ||
| 313 | + } | ||
| 314 | + */ | ||
| 315 | + let suggestion=data.suggestion | ||
| 316 | + wx.navigateTo({ | ||
| 317 | + url:util.http_build_query({ | ||
| 318 | + hasSuggestion:1, | ||
| 319 | + keyword:suggestion.title, | ||
| 320 | + lat:suggestion.latitude, | ||
| 321 | + lng:suggestion.longitude, | ||
| 322 | + centre_pos:`${suggestion.latitude},${suggestion.longitude}`, | ||
| 323 | + multiIndex:0, | ||
| 324 | + },'/pages/reserve/indexList') | ||
| 325 | + }) | ||
| 326 | + }, | ||
| 327 | +}) |
pages/reserve/searchKeyword.json
0 → 100644
| 1 | +{ | ||
| 2 | + "navigationBarBackgroundColor": "#ffffff", | ||
| 3 | + "navigationBarTextStyle": "black", | ||
| 4 | + "navigationBarTitleText":"周到安排", | ||
| 5 | + "usingComponents": { | ||
| 6 | + "formids":"/components/formids/formids", | ||
| 7 | + "getpos":"/components/userinfo/getpos", | ||
| 8 | + "nav":"/components/nav/nav", | ||
| 9 | + "search-item":"/components/reserve/search/item", | ||
| 10 | + "as-phone":"/components/actionSheet/phone", | ||
| 11 | + "sb-tr":"/components/reserve/seller-box-transverse/seller-box" | ||
| 12 | + } | ||
| 13 | +} |
pages/reserve/searchKeyword.wxml
0 → 100644
| 1 | +<!--pages/reserve/search.wxml--> | ||
| 2 | +<nav id="nav">搜索</nav> | ||
| 3 | +<view class="searchAddrView" style="height: {{navHeight+40}}px;"> | ||
| 4 | + <view class="searchAddr flex-ll" style="margin-top: {{navHeight+5}}px;"> | ||
| 5 | + <image class="icon" src="http://nosqn.colorcun.com/custom/lite-online/image/search26.png"></image> | ||
| 6 | + <input style="width: 100%;" placeholder="输入餐厅名或地名,快速订包间" | ||
| 7 | + type="text" confirm-type="done" | ||
| 8 | + focus | ||
| 9 | + bindinput="getsuggest" value="{{keyword}}"/> | ||
| 10 | + <image class="icon icon-del" wx:if="{{keyword.length>0}}" | ||
| 11 | + catchtap="clearKeyword" | ||
| 12 | + src="http://nosqn.colorcun.com/reserve/images/del.png"></image> | ||
| 13 | + </view> | ||
| 14 | +</view> | ||
| 15 | +<view class="pages"> | ||
| 16 | + <view class="res-view"> | ||
| 17 | + <!--绑定回填事件--> | ||
| 18 | + <block wx:for="{{suggestion}}" wx:key="index" | ||
| 19 | + bindtap="backfill" id="{{index}}"> | ||
| 20 | + <search-item item="{{item}}" keyword="{{keyword}}" bindclick="searchItemClick"></search-item> | ||
| 21 | + <view wx:if="{{index==1 && hasSellerMore}}" class="see-more" bindtap="gotoList"></view> | ||
| 22 | + <view wx:if="{{index==sellerSplit && sellerSplit>-1}}" class="see-split"></view> | ||
| 23 | + </block> | ||
| 24 | + <view class="see-more bottom" wx:if="{{suggestion.length>0}}"></view> | ||
| 25 | + </view> | ||
| 26 | +</view> | ||
| 27 | +<view class="history" wx:if="{{suggestion.length<1}}"> | ||
| 28 | + <view wx:if="{{keyword.length>0}}"> | ||
| 29 | + <view class="flex-vc empty"> | ||
| 30 | + <block wx:if="{{!hasFirstShow}}"> | ||
| 31 | + <image src="http://nosqn.colorcun.com/custom/lite-online/image/follow-empty.png"></image> | ||
| 32 | + <view class="empty-t1">抱歉,没有找到符合的内容</view> | ||
| 33 | + <view class="empty-t2">试试搜搜别的</view> | ||
| 34 | + </block> | ||
| 35 | + </view> | ||
| 36 | + <view class="rsl-block" wx:if="{{rsl.length>0}}"> | ||
| 37 | + <view class="line-push">为你推荐</view> | ||
| 38 | + <view class="transverse-list"> | ||
| 39 | + <swiper | ||
| 40 | + indicator-dots="{{false}}" autoplay="{{false}}" circular="{{false}}" vertical="{{false}}" | ||
| 41 | + interval="2000" duration="500" | ||
| 42 | + previous-margin="{{15}}px" next-margin="{{15}}px" style="height: 350rpx;" | ||
| 43 | + current="{{current}}" bindchange="bindtransition" bindanimationfinish="bindtransition"> | ||
| 44 | + <block wx:for="{{rsl}}" wx:key="rsl.key"> | ||
| 45 | + <swiper-item bindtap="gotoSellerDetail" id="{{item.id}}"> | ||
| 46 | + <view class="seller" id="seller-{{item.id}}"> | ||
| 47 | + <sb-tr seller="{{item}}" | ||
| 48 | + hasInSwiper bindevent="sbtrEvent" | ||
| 49 | + hasActivityTags="{{false}}" | ||
| 50 | + hasActivityShort="{{true}}" | ||
| 51 | + hasBrand="true" hasActivityTese="true" | ||
| 52 | + hasSlogan="{{false}}"></sb-tr> | ||
| 53 | + </view> | ||
| 54 | + </swiper-item> | ||
| 55 | + </block> | ||
| 56 | + </swiper> | ||
| 57 | + </view> | ||
| 58 | + </view> | ||
| 59 | + </view> | ||
| 60 | + <view class="pages" wx:elif="{{history.length>0}}"> | ||
| 61 | + <view class="flex-lr"> | ||
| 62 | + <view class="history-title">最近搜索</view> | ||
| 63 | + <view class="history-empty" bindtap="historyEmpty"></view> | ||
| 64 | + </view> | ||
| 65 | + <view class="history-list"> | ||
| 66 | + <block wx:for="{{history}}" wx:key="history.key"> | ||
| 67 | + <search-item item="{{item}}" hasHistory bindclick="searchItemClick"></search-item> | ||
| 68 | + </block> | ||
| 69 | + </view> | ||
| 70 | + </view> | ||
| 71 | +</view> | ||
| 72 | +<getpos bindpos="onpos" id="getpos" hasAllowFail></getpos> | ||
| 73 | +<as-phone id="as"></as-phone> |
pages/reserve/searchKeyword.wxss
0 → 100644
| 1 | +/* pages/reserve/search.wxss */ | ||
| 2 | +.pages{ | ||
| 3 | + width: 90%; | ||
| 4 | + margin: 5% auto; | ||
| 5 | + color:#353535; | ||
| 6 | +} | ||
| 7 | +.searchAddrView{ | ||
| 8 | + position: fixed; | ||
| 9 | + top:0rpx; | ||
| 10 | + width: 100%; | ||
| 11 | + height: 240rpx; | ||
| 12 | + background-color: #ffffff; | ||
| 13 | + z-index: 9; | ||
| 14 | +} | ||
| 15 | +.searchAddr { | ||
| 16 | + width: 90%; | ||
| 17 | + height: 60rpx; | ||
| 18 | + background-color: #F5F5F5; | ||
| 19 | + border-radius: 30rpx; | ||
| 20 | + line-height: 60rpx; | ||
| 21 | + color:#999999; | ||
| 22 | + line-height: 60rpx; | ||
| 23 | + font-size: 28rpx; | ||
| 24 | + margin:0 auto; | ||
| 25 | +} | ||
| 26 | +.searchAddr .icon{ | ||
| 27 | + min-width: 26rpx; | ||
| 28 | + width:26rpx; | ||
| 29 | + height: 26rpx; | ||
| 30 | + margin: 0 20rpx; | ||
| 31 | +} | ||
| 32 | +.searchAddr .icon-del{ | ||
| 33 | + min-width: 28rpx; | ||
| 34 | + width: 28rpx; | ||
| 35 | + height: 28rpx; | ||
| 36 | +} | ||
| 37 | +.res-view{ | ||
| 38 | + margin-top: 120rpx; | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +.search-but{ | ||
| 42 | + min-width: 140rpx; | ||
| 43 | + color:#000000; | ||
| 44 | + border-left: 2rpx solid #cccccc; | ||
| 45 | + text-align: center; | ||
| 46 | + height: 32rpx; | ||
| 47 | + line-height: 32rpx; | ||
| 48 | + | ||
| 49 | +} | ||
| 50 | +.history{ | ||
| 51 | + margin-top: 140rpx; | ||
| 52 | +} | ||
| 53 | +.history .history-title{ | ||
| 54 | + font-size: 28rpx; | ||
| 55 | + color:#353535; | ||
| 56 | + height: 40rpx; | ||
| 57 | + line-height: 40rpx; | ||
| 58 | + font-weight:600; | ||
| 59 | + margin-bottom: 20rpx; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +.see-more{ | ||
| 63 | + width: 100%; | ||
| 64 | + height: 34rpx; | ||
| 65 | + position: relative; | ||
| 66 | + margin-bottom: 40rpx; | ||
| 67 | + margin-top: 40rpx; | ||
| 68 | +} | ||
| 69 | +.see-more:before{ | ||
| 70 | + content: ""; | ||
| 71 | + width: 100%; | ||
| 72 | + height: 2rpx; | ||
| 73 | + background-color: #F5F5F5; | ||
| 74 | + position: absolute; | ||
| 75 | + left: 0; | ||
| 76 | + top:17rpx; | ||
| 77 | +} | ||
| 78 | +.see-more:after{ | ||
| 79 | + content: "查看更多"; | ||
| 80 | + width:136rpx; | ||
| 81 | + height:34rpx; | ||
| 82 | + font-size:24rpx; | ||
| 83 | + color:rgba(153,153,153,1); | ||
| 84 | + line-height:34rpx; | ||
| 85 | + background-color: #fefefe; | ||
| 86 | + position: absolute; | ||
| 87 | + display: block; | ||
| 88 | + left:calc(50% - 68rpx); | ||
| 89 | + top:0; | ||
| 90 | + text-align: center; | ||
| 91 | +} | ||
| 92 | +.see-more.bottom:after{ | ||
| 93 | + width:200rpx; | ||
| 94 | + content: "我是有底线的"; | ||
| 95 | + left:calc(50% - 100rpx); | ||
| 96 | +} | ||
| 97 | +.see-more.bottom{ | ||
| 98 | + padding-bottom: 40rpx; | ||
| 99 | +} | ||
| 100 | +.see-split{ | ||
| 101 | + width: 100%; | ||
| 102 | + height: 20rpx; | ||
| 103 | +} | ||
| 104 | +.history-empty{ | ||
| 105 | + width: 28rpx; | ||
| 106 | + height: 28rpx; | ||
| 107 | + background-image: url("http://nosqn.colorcun.com/reserve/images/empty.png"); | ||
| 108 | + background-size: 100% 100%; | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +.empty{margin-top: 150rpx; color: #353535} | ||
| 112 | +.empty image{ | ||
| 113 | + width: 191px; | ||
| 114 | + height: 158px; | ||
| 115 | +} | ||
| 116 | +.empty .empty-t1{ | ||
| 117 | + font-size: 28rpx; | ||
| 118 | + margin-top: 60rpx; | ||
| 119 | + height:40px; | ||
| 120 | + line-height:40px; | ||
| 121 | +} | ||
| 122 | +.empty .empty-t2{ | ||
| 123 | + font-size: 28rpx; | ||
| 124 | + margin-top: 20rpx; | ||
| 125 | + height:40px; | ||
| 126 | + line-height:40px; | ||
| 127 | +} | ||
| 128 | + | ||
| 129 | +.line-push{ | ||
| 130 | + background-image: url("http://nosqn.colorcun.com/reserve/images/line-push.png"); | ||
| 131 | + width: 328rpx; | ||
| 132 | + height: 42rpx; | ||
| 133 | + background-size: 100% 24rpx; | ||
| 134 | + margin: 0 auto; | ||
| 135 | + font-size:30rpx; | ||
| 136 | + color: #C0A369; | ||
| 137 | + line-height: 24rpx; | ||
| 138 | + background-repeat: no-repeat; | ||
| 139 | + text-align: center; | ||
| 140 | + margin-bottom: 60rpx; | ||
| 141 | +} | ||
| 142 | +.rsl-block{ | ||
| 143 | + position: fixed; | ||
| 144 | + bottom: 0rpx; | ||
| 145 | + width: 100%; | ||
| 146 | +} | ||
| 147 | +.transverse-list{ | ||
| 148 | + background-color: #fefefe; | ||
| 149 | + width: 100%; | ||
| 150 | +} | ||
| 151 | +.transverse-list .seller{ | ||
| 152 | + width: 98%; | ||
| 153 | + margin: 0 auto; | ||
| 154 | +} |
-
Please register or login to post a comment