Commit 7cdb2e5baaba34070bc8c8d557526bce56450a42

Authored by vking
1 parent 9dd08832

search

... ... @@ -100,7 +100,8 @@ Page({
this.inputVal=e.detail.value;
if(this.inputVal.length<1){
return this.setData({
suggestion: []
suggestion: [],
keyword:''
})
}
App.Customer.KeywordTips({
... ... @@ -117,23 +118,27 @@ Page({
suggestion: []
})
}
res.data=res.data.data
var sug = [],hasSellerMore=false,sellerSplit=-1
for (var i = 0; i < res.data.length; i++) {
if(i==2 && res.data[i].type==-1){
hasSellerMore=true
continue;
}
if((i==1 || i==2) && res.data[i-1].type==-1 && res.data[i].type!=-1){
sellerSplit=i-1
try{
res.data=res.data.data
if(res.data instanceof Array){
for (var i = 0; i < res.data.length; i++) {
if(i==2 && res.data[i].type==-1){
hasSellerMore=true
continue;
}
if((i==1 || i==2) && res.data[i-1].type==-1 && res.data[i].type!=-1){
sellerSplit=i-1
}
let item=res.data[i]
item.latitude=item.location.lat
item.longitude=item.location.lng
item.addr=item.address
item.titles=item.title.match(new RegExp('(.*)('+this.inputVal+')(.*)'))
sug.push(item);
}
}
let item=res.data[i]
item.latitude=item.location.lat
item.longitude=item.location.lng
item.addr=item.address
item.titles=item.title.match(new RegExp('(.*)('+this.inputVal+')(.*)'))
sug.push(item);
}
}catch(e){}
this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
suggestion: sug,
hasSellerMore:hasSellerMore,
... ... @@ -178,6 +183,7 @@ Page({
console.log('wx.getLocation.then', res);
this.location=res
this.getCity()
this.GetRecommendSellerLists()
}).catch((e) => {
console.log('wx.getLocation.catch', e);
if ('getLocation:fail auth deny' == e.errMsg || 'getLocation:fail:auth denied' == e.errMsg) {
... ... @@ -271,5 +277,19 @@ Page({
keyword:'',
suggestion:[],
})
}
},
GetRecommendSellerLists(){
let param={}
if(this.location){
param={
lat:this.location.latitude,
lng:this.location.longitude
}
}
App.Customer.GetRecommendSellerLists(param).then(res=>{
this.setData({
rsl:res.data
})
})
},
})
\ No newline at end of file
... ...
... ... @@ -5,6 +5,7 @@
"usingComponents": {
"formids":"/components/formids/formids",
"nav":"/components/nav/nav",
"search-item":"/components/reserve/search/item"
"search-item":"/components/reserve/search/item",
"sb-tr":"/components/reserve/seller-box-transverse/seller-box"
}
}
\ No newline at end of file
... ...
<!--pages/reserve/search.wxml-->
<nav>搜索</nav>
<view class="pages">
<view class="searchAddrView">
<view class="searchAddr flex-ll">
<image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></image>
<input style="width: 100%;" placeholder="输入餐厅名或地名,快速订包间"
type="text" confirm-type="done"
focus
bindinput="getsuggest" value="{{keyword}}"/>
<image class="icon icon-del" wx:if="{{keyword.length>0}}"
catchtap="clearKeyword"
src="http://qn.colorcun.com/reserve/images/del.png"></image>
</view>
<view class="searchAddrView">
<view class="searchAddr flex-ll">
<image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></image>
<input style="width: 100%;" placeholder="输入餐厅名或地名,快速订包间"
type="text" confirm-type="done"
focus
bindinput="getsuggest" value="{{keyword}}"/>
<image class="icon icon-del" wx:if="{{keyword.length>0}}"
catchtap="clearKeyword"
src="http://qn.colorcun.com/reserve/images/del.png"></image>
</view>
</view>
<view class="pages">
<view class="res-view">
<!--绑定回填事件-->
<block wx:for="{{suggestion}}" wx:key="index"
... ... @@ -24,8 +24,39 @@
<view class="see-more bottom" wx:if="{{suggestion.length>0}}"></view>
</view>
</view>
<view class="history" wx:if="{{history.length>0 && suggestion.length<1}}">
<view class="pages">
<view class="history" wx:if="{{suggestion.length<1}}">
<view wx:if="{{keyword.length>0}}">
<view class="flex-vc empty">
<block wx:if="{{!hasFirstShow}}">
<image src="http://qn.colorcun.com/custom/lite-online/image/follow-empty.png"></image>
<view class="empty-t1">抱歉,没有找到符合的内容</view>
<view class="empty-t2">试试搜搜别的</view>
</block>
</view>
<view class="rsl-block">
<view class="line-push">为你推荐</view>
<view class="transverse-list">
<swiper
indicator-dots="{{false}}" autoplay="{{false}}" circular="{{false}}" vertical="{{false}}"
interval="2000" duration="500"
previous-margin="{{15}}px" next-margin="{{15}}px" style="height: 350rpx;"
current="{{current}}" bindchange="bindtransition" bindanimationfinish="bindtransition">
<block wx:for="{{rsl}}" wx:key="rsl.key">
<swiper-item bindtap="gotoSellerDetail" id="{{item.id}}">
<view class="seller" id="seller-{{item.id}}">
<sb-tr seller="{{item}}"
hasActivityTags="{{false}}"
hasActivityShort="{{true}}"
hasBrand="true" hasActivityTese="true"
hasSlogan="{{false}}"></sb-tr>
</view>
</swiper-item>
</block>
</swiper>
</view>
</view>
</view>
<view class="pages" wx:elif="{{history.length>0}}">
<view class="flex-lr">
<view class="history-title">最近搜索</view>
<view class="history-empty" bindtap="historyEmpty"></view>
... ...
... ... @@ -7,15 +7,14 @@
.searchAddrView{
position: fixed;
top:100rpx;
width: 110%;
height: 110rpx;
width: 100%;
height: 120rpx;
background-color: #fefefe;
z-index: 9;
margin-left: -5%;
}
.searchAddr {
position: fixed;
top:150rpx;
top:140rpx;
width: 90%;
height: 60rpx;
background-color: #F5F5F5;
... ... @@ -39,7 +38,7 @@
height: 28rpx;
}
.res-view{
margin-top: 110rpx;
margin-top: 120rpx;
}
.search-but{
... ... @@ -110,4 +109,49 @@
height: 28rpx;
background-image: url("http://qn.colorcun.com/reserve/images/empty.png");
background-size: 100% 100%;
}
.empty{margin-top: 150rpx; color: #353535}
.empty image{
width: 191px;
height: 158px;
}
.empty .empty-t1{
font-size: 28rpx;
margin-top: 60rpx;
height:40px;
line-height:40px;
}
.empty .empty-t2{
font-size: 28rpx;
margin-top: 20rpx;
height:40px;
line-height:40px;
}
.line-push{
background-image: url("http://qn.colorcun.com/reserve/images/line-push.png");
width: 328rpx;
height: 42rpx;
background-size: 100% 24rpx;
margin: 0 auto;
font-size:30rpx;
color: #C0A369;
line-height: 24rpx;
background-repeat: no-repeat;
text-align: center;
margin-bottom: 60rpx;
}
.rsl-block{
position: fixed;
bottom: 0rpx;
width: 100%;
}
.transverse-list{
background-color: #fefefe;
width: 100%;
}
.transverse-list .seller{
width: 98%;
margin: 0 auto;
}
\ No newline at end of file
... ...