Showing
4 changed files
with
133 additions
and
37 deletions
| @@ -100,7 +100,8 @@ Page({ | @@ -100,7 +100,8 @@ Page({ | ||
| 100 | this.inputVal=e.detail.value; | 100 | this.inputVal=e.detail.value; |
| 101 | if(this.inputVal.length<1){ | 101 | if(this.inputVal.length<1){ |
| 102 | return this.setData({ | 102 | return this.setData({ |
| 103 | - suggestion: [] | 103 | + suggestion: [], |
| 104 | + keyword:'' | ||
| 104 | }) | 105 | }) |
| 105 | } | 106 | } |
| 106 | App.Customer.KeywordTips({ | 107 | App.Customer.KeywordTips({ |
| @@ -117,23 +118,27 @@ Page({ | @@ -117,23 +118,27 @@ Page({ | ||
| 117 | suggestion: [] | 118 | suggestion: [] |
| 118 | }) | 119 | }) |
| 119 | } | 120 | } |
| 120 | - res.data=res.data.data | ||
| 121 | var sug = [],hasSellerMore=false,sellerSplit=-1 | 121 | var sug = [],hasSellerMore=false,sellerSplit=-1 |
| 122 | - for (var i = 0; i < res.data.length; i++) { | ||
| 123 | - if(i==2 && res.data[i].type==-1){ | ||
| 124 | - hasSellerMore=true | ||
| 125 | - continue; | ||
| 126 | - } | ||
| 127 | - if((i==1 || i==2) && res.data[i-1].type==-1 && res.data[i].type!=-1){ | ||
| 128 | - sellerSplit=i-1 | 122 | + try{ |
| 123 | + res.data=res.data.data | ||
| 124 | + if(res.data instanceof Array){ | ||
| 125 | + for (var i = 0; i < res.data.length; i++) { | ||
| 126 | + if(i==2 && res.data[i].type==-1){ | ||
| 127 | + hasSellerMore=true | ||
| 128 | + continue; | ||
| 129 | + } | ||
| 130 | + if((i==1 || i==2) && res.data[i-1].type==-1 && res.data[i].type!=-1){ | ||
| 131 | + sellerSplit=i-1 | ||
| 132 | + } | ||
| 133 | + let item=res.data[i] | ||
| 134 | + item.latitude=item.location.lat | ||
| 135 | + item.longitude=item.location.lng | ||
| 136 | + item.addr=item.address | ||
| 137 | + item.titles=item.title.match(new RegExp('(.*)('+this.inputVal+')(.*)')) | ||
| 138 | + sug.push(item); | ||
| 139 | + } | ||
| 129 | } | 140 | } |
| 130 | - let item=res.data[i] | ||
| 131 | - item.latitude=item.location.lat | ||
| 132 | - item.longitude=item.location.lng | ||
| 133 | - item.addr=item.address | ||
| 134 | - item.titles=item.title.match(new RegExp('(.*)('+this.inputVal+')(.*)')) | ||
| 135 | - sug.push(item); | ||
| 136 | - } | 141 | + }catch(e){} |
| 137 | this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示 | 142 | this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示 |
| 138 | suggestion: sug, | 143 | suggestion: sug, |
| 139 | hasSellerMore:hasSellerMore, | 144 | hasSellerMore:hasSellerMore, |
| @@ -178,6 +183,7 @@ Page({ | @@ -178,6 +183,7 @@ Page({ | ||
| 178 | console.log('wx.getLocation.then', res); | 183 | console.log('wx.getLocation.then', res); |
| 179 | this.location=res | 184 | this.location=res |
| 180 | this.getCity() | 185 | this.getCity() |
| 186 | + this.GetRecommendSellerLists() | ||
| 181 | }).catch((e) => { | 187 | }).catch((e) => { |
| 182 | console.log('wx.getLocation.catch', e); | 188 | console.log('wx.getLocation.catch', e); |
| 183 | if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) { | 189 | if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) { |
| @@ -271,5 +277,19 @@ Page({ | @@ -271,5 +277,19 @@ Page({ | ||
| 271 | keyword:'', | 277 | keyword:'', |
| 272 | suggestion:[], | 278 | suggestion:[], |
| 273 | }) | 279 | }) |
| 274 | - } | 280 | + }, |
| 281 | + GetRecommendSellerLists(){ | ||
| 282 | + let param={} | ||
| 283 | + if(this.location){ | ||
| 284 | + param={ | ||
| 285 | + lat:this.location.latitude, | ||
| 286 | + lng:this.location.longitude | ||
| 287 | + } | ||
| 288 | + } | ||
| 289 | + App.Customer.GetRecommendSellerLists(param).then(res=>{ | ||
| 290 | + this.setData({ | ||
| 291 | + rsl:res.data | ||
| 292 | + }) | ||
| 293 | + }) | ||
| 294 | + }, | ||
| 275 | }) | 295 | }) |
| @@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
| 5 | "usingComponents": { | 5 | "usingComponents": { |
| 6 | "formids":"/components/formids/formids", | 6 | "formids":"/components/formids/formids", |
| 7 | "nav":"/components/nav/nav", | 7 | "nav":"/components/nav/nav", |
| 8 | - "search-item":"/components/reserve/search/item" | 8 | + "search-item":"/components/reserve/search/item", |
| 9 | + "sb-tr":"/components/reserve/seller-box-transverse/seller-box" | ||
| 9 | } | 10 | } |
| 10 | } | 11 | } |
| 1 | <!--pages/reserve/search.wxml--> | 1 | <!--pages/reserve/search.wxml--> |
| 2 | <nav>搜索</nav> | 2 | <nav>搜索</nav> |
| 3 | -<view class="pages"> | ||
| 4 | - <view class="searchAddrView"> | ||
| 5 | - <view class="searchAddr flex-ll"> | ||
| 6 | - <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></image> | ||
| 7 | - <input style="width: 100%;" placeholder="输入餐厅名或地名,快速订包间" | ||
| 8 | - type="text" confirm-type="done" | ||
| 9 | - focus | ||
| 10 | - bindinput="getsuggest" value="{{keyword}}"/> | ||
| 11 | - <image class="icon icon-del" wx:if="{{keyword.length>0}}" | ||
| 12 | - catchtap="clearKeyword" | ||
| 13 | - src="http://qn.colorcun.com/reserve/images/del.png"></image> | ||
| 14 | - </view> | 3 | +<view class="searchAddrView"> |
| 4 | + <view class="searchAddr flex-ll"> | ||
| 5 | + <image class="icon" src="http://qn.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://qn.colorcun.com/reserve/images/del.png"></image> | ||
| 15 | </view> | 13 | </view> |
| 14 | +</view> | ||
| 15 | +<view class="pages"> | ||
| 16 | <view class="res-view"> | 16 | <view class="res-view"> |
| 17 | <!--绑定回填事件--> | 17 | <!--绑定回填事件--> |
| 18 | <block wx:for="{{suggestion}}" wx:key="index" | 18 | <block wx:for="{{suggestion}}" wx:key="index" |
| @@ -24,8 +24,39 @@ | @@ -24,8 +24,39 @@ | ||
| 24 | <view class="see-more bottom" wx:if="{{suggestion.length>0}}"></view> | 24 | <view class="see-more bottom" wx:if="{{suggestion.length>0}}"></view> |
| 25 | </view> | 25 | </view> |
| 26 | </view> | 26 | </view> |
| 27 | -<view class="history" wx:if="{{history.length>0 && suggestion.length<1}}"> | ||
| 28 | - <view class="pages"> | 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://qn.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"> | ||
| 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 | + hasActivityTags="{{false}}" | ||
| 49 | + hasActivityShort="{{true}}" | ||
| 50 | + hasBrand="true" hasActivityTese="true" | ||
| 51 | + hasSlogan="{{false}}"></sb-tr> | ||
| 52 | + </view> | ||
| 53 | + </swiper-item> | ||
| 54 | + </block> | ||
| 55 | + </swiper> | ||
| 56 | + </view> | ||
| 57 | + </view> | ||
| 58 | + </view> | ||
| 59 | + <view class="pages" wx:elif="{{history.length>0}}"> | ||
| 29 | <view class="flex-lr"> | 60 | <view class="flex-lr"> |
| 30 | <view class="history-title">最近搜索</view> | 61 | <view class="history-title">最近搜索</view> |
| 31 | <view class="history-empty" bindtap="historyEmpty"></view> | 62 | <view class="history-empty" bindtap="historyEmpty"></view> |
| @@ -7,15 +7,14 @@ | @@ -7,15 +7,14 @@ | ||
| 7 | .searchAddrView{ | 7 | .searchAddrView{ |
| 8 | position: fixed; | 8 | position: fixed; |
| 9 | top:100rpx; | 9 | top:100rpx; |
| 10 | - width: 110%; | ||
| 11 | - height: 110rpx; | 10 | + width: 100%; |
| 11 | + height: 120rpx; | ||
| 12 | background-color: #fefefe; | 12 | background-color: #fefefe; |
| 13 | z-index: 9; | 13 | z-index: 9; |
| 14 | - margin-left: -5%; | ||
| 15 | } | 14 | } |
| 16 | .searchAddr { | 15 | .searchAddr { |
| 17 | position: fixed; | 16 | position: fixed; |
| 18 | - top:150rpx; | 17 | + top:140rpx; |
| 19 | width: 90%; | 18 | width: 90%; |
| 20 | height: 60rpx; | 19 | height: 60rpx; |
| 21 | background-color: #F5F5F5; | 20 | background-color: #F5F5F5; |
| @@ -39,7 +38,7 @@ | @@ -39,7 +38,7 @@ | ||
| 39 | height: 28rpx; | 38 | height: 28rpx; |
| 40 | } | 39 | } |
| 41 | .res-view{ | 40 | .res-view{ |
| 42 | - margin-top: 110rpx; | 41 | + margin-top: 120rpx; |
| 43 | } | 42 | } |
| 44 | 43 | ||
| 45 | .search-but{ | 44 | .search-but{ |
| @@ -110,4 +109,49 @@ | @@ -110,4 +109,49 @@ | ||
| 110 | height: 28rpx; | 109 | height: 28rpx; |
| 111 | background-image: url("http://qn.colorcun.com/reserve/images/empty.png"); | 110 | background-image: url("http://qn.colorcun.com/reserve/images/empty.png"); |
| 112 | background-size: 100% 100%; | 111 | background-size: 100% 100%; |
| 112 | +} | ||
| 113 | + | ||
| 114 | +.empty{margin-top: 150rpx; color: #353535} | ||
| 115 | +.empty image{ | ||
| 116 | + width: 191px; | ||
| 117 | + height: 158px; | ||
| 118 | +} | ||
| 119 | +.empty .empty-t1{ | ||
| 120 | + font-size: 28rpx; | ||
| 121 | + margin-top: 60rpx; | ||
| 122 | + height:40px; | ||
| 123 | + line-height:40px; | ||
| 124 | +} | ||
| 125 | +.empty .empty-t2{ | ||
| 126 | + font-size: 28rpx; | ||
| 127 | + margin-top: 20rpx; | ||
| 128 | + height:40px; | ||
| 129 | + line-height:40px; | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +.line-push{ | ||
| 133 | + background-image: url("http://qn.colorcun.com/reserve/images/line-push.png"); | ||
| 134 | + width: 328rpx; | ||
| 135 | + height: 42rpx; | ||
| 136 | + background-size: 100% 24rpx; | ||
| 137 | + margin: 0 auto; | ||
| 138 | + font-size:30rpx; | ||
| 139 | + color: #C0A369; | ||
| 140 | + line-height: 24rpx; | ||
| 141 | + background-repeat: no-repeat; | ||
| 142 | + text-align: center; | ||
| 143 | + margin-bottom: 60rpx; | ||
| 144 | +} | ||
| 145 | +.rsl-block{ | ||
| 146 | + position: fixed; | ||
| 147 | + bottom: 0rpx; | ||
| 148 | + width: 100%; | ||
| 149 | +} | ||
| 150 | +.transverse-list{ | ||
| 151 | + background-color: #fefefe; | ||
| 152 | + width: 100%; | ||
| 153 | +} | ||
| 154 | +.transverse-list .seller{ | ||
| 155 | + width: 98%; | ||
| 156 | + margin: 0 auto; | ||
| 113 | } | 157 | } |
-
Please register or login to post a comment