Commit fa43a1879654c0695756db54adbf43f210f78e27

Authored by vking
1 parent d0666176

search

  1 +// components/reserve/search/item.js
  2 +import App from '../../../utils/api';
  3 +Component({
  4 + /**
  5 + * 组件的属性列表
  6 + */
  7 + properties: {
  8 + item:{
  9 + type:Object,
  10 + value:{}
  11 + },
  12 + },
  13 +
  14 + /**
  15 + * 组件的初始数据
  16 + */
  17 + data: {
  18 +
  19 + },
  20 +
  21 + /**
  22 + * 组件的方法列表
  23 + */
  24 + methods: {
  25 + detailGo(){
  26 + this.SetHistorySearch();
  27 + this.triggerEvent('click',{act:'detail',data:this.data.item})
  28 + },
  29 + reserveGo(){
  30 + this.SetHistorySearch();
  31 + this.triggerEvent('click',{act:'reserve',data:this.data.item})
  32 + },
  33 + SetHistorySearch() {
  34 + let params=this.data.item
  35 + App.Customer.SetHistorySearch(params)
  36 + },
  37 + }
  38 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +<!--components/reserve/search/item.wxml-->
  2 +<view class="item item{{item.type}} flex-ll" bindtap="detailGo">
  3 + <view class="icon"></view>
  4 + <view class="flex-lr item-info">
  5 + <view class="info">
  6 + <view class="title">{{item.title}}</view>
  7 + <view class="addr">{{item.addr}}</view>
  8 + </view>
  9 + <view class="reserve-but" wx:if="{{item.type==-1}}" catchtap="reserveGo">包间预订</view>
  10 + </view>
  11 +</view>
  1 +/* components/reserve/search/item.wxss */
  2 +@import "../../../app.wxss";
  3 +.item{
  4 + width: 100%;
  5 + box-sizing: border-box;
  6 + margin-bottom: 40rpx;
  7 +}
  8 +.item-1{
  9 + margin-bottom: 20rpx;
  10 +}
  11 +.item-1 .item-info{
  12 + width: calc(100% - 60rpx);
  13 + max-width: calc(100% - 60rpx);
  14 + box-sizing: border-box;
  15 +}
  16 +.item .title{
  17 + font-size: 28rpx;
  18 + height: 40rpx;
  19 + line-height: 40rpx;
  20 + white-space:nowrap;
  21 + overflow: hidden;
  22 + text-overflow:ellipsis;
  23 +
  24 +}
  25 +.item .addr{
  26 + font-size: 24rpx;
  27 + height: 34rpx;
  28 + line-height: 34rpx;
  29 + margin-top: 4rpx;
  30 + white-space:nowrap;
  31 + overflow: hidden;
  32 + text-overflow:ellipsis;
  33 +}
  34 +.item .icon{
  35 + margin-right: 20rpx;
  36 + width: 22rpx;
  37 + height:26rpx;
  38 + background-color: #ccc;
  39 +}
  40 +.item-1 .info{
  41 + width: calc(100% - 140rpx);
  42 + max-width: calc(100% - 140rpx);
  43 +}
  44 +.item-1{
  45 + background:rgba(255,255,255,1);
  46 + box-shadow:0 0 8rpx 0 rgba(196,196,196,0.5);
  47 + border-radius:10rpx;
  48 + padding: 20rpx;
  49 +}
  50 +.item-1 .icon {
  51 + background-color: #C0A369;
  52 + width: 36rpx;
  53 + height: 36rpx;
  54 + min-width: 36rpx;
  55 +}
  56 +.reserve-but{
  57 + width:120rpx;
  58 + height:40rpx;
  59 + background:linear-gradient(360deg,rgba(131,131,131,1) 0%,rgba(76,76,76,1) 100%);
  60 + border-radius:25rpx;
  61 + font-size:24rpx;
  62 + font-weight:500;
  63 + color:rgba(240,206,161,1);
  64 + line-height:40rpx;
  65 + text-shadow:0rpx 2rpx 6rpx rgba(80,80,80,1);
  66 + text-align: center;
  67 + min-width: 120rpx;
  68 + margin-left: 20rpx;
  69 +}
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 </cover-view> 26 </cover-view>
27 <cover-view class="searchAddr flex-ll"> 27 <cover-view class="searchAddr flex-ll">
28 <cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></cover-image> 28 <cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></cover-image>
29 - <cover-view class="title">{{hasSuggestion?suggestion.title:'搜索店铺、地点或商圈'}}</cover-view> 29 + <cover-view class="title">{{hasSuggestion?suggestion.title:'输入餐厅名或地名,快速订包间'}}</cover-view>
30 </cover-view> 30 </cover-view>
31 </cover-view> 31 </cover-view>
32 </formids> 32 </formids>
@@ -117,7 +117,7 @@ page{ @@ -117,7 +117,7 @@ page{
117 117
118 .searchAddr { 118 .searchAddr {
119 margin-left: 15rpx; 119 margin-left: 15rpx;
120 - width: 380rpx; 120 + width: 420rpx;
121 height: 60rpx; 121 height: 60rpx;
122 background-color: #fefefe; 122 background-color: #fefefe;
123 border-radius: 30rpx; 123 border-radius: 30rpx;
@@ -93,19 +93,30 @@ Page({ @@ -93,19 +93,30 @@ Page({
93 let mapParam=this.options 93 let mapParam=this.options
94 this.offset=1 //page 94 this.offset=1 //page
95 this.size=20 //page size 95 this.size=20 //page size
96 - //计算视窗中心  
97 - let map=JSON.parse(mapParam.map);  
98 - let lat=map.northeast.latitude-(map.northeast.latitude-map.southwest.latitude)/2;  
99 - let lng=map.northeast.longitude-(map.northeast.longitude-map.southwest.longitude)/2;  
100 - this.param={  
101 - lat:lat,  
102 - lng:lng,  
103 - lat_extend:mapParam.lat,  
104 - lng_extend:mapParam.lng,  
105 - offset:this.offset,  
106 - size:this.size,  
107 - distance:50,  
108 - }; 96 + if(mapParam.keyword){
  97 + this.param={
  98 + lat_extend:mapParam.lat,
  99 + lng_extend:mapParam.lng,
  100 + keyword:mapParam.keyword,
  101 + offset:this.offset,
  102 + size:this.size,
  103 + distance:5000,
  104 + };
  105 + }else{
  106 + //计算视窗中心
  107 + let map=JSON.parse(mapParam.map);
  108 + let lat=map.northeast.latitude-(map.northeast.latitude-map.southwest.latitude)/2;
  109 + let lng=map.northeast.longitude-(map.northeast.longitude-map.southwest.longitude)/2;
  110 + this.param={
  111 + lat:lat,
  112 + lng:lng,
  113 + lat_extend:mapParam.lat,
  114 + lng_extend:mapParam.lng,
  115 + offset:this.offset,
  116 + size:this.size,
  117 + distance:50,
  118 + };
  119 + }
109 if(this.data.multiIndex[0]>0){ 120 if(this.data.multiIndex[0]>0){
110 this.param.cuisine=await DA.getCatesID(this.data.multiIndex[0]-1); 121 this.param.cuisine=await DA.getCatesID(this.data.multiIndex[0]-1);
111 } 122 }
@@ -18,6 +18,7 @@ Page({ @@ -18,6 +18,7 @@ Page({
18 data: { 18 data: {
19 history:[], 19 history:[],
20 suggestion:[], 20 suggestion:[],
  21 + hasSellerMore:false,
21 }, 22 },
22 23
23 /** 24 /**
@@ -132,8 +133,12 @@ Page({ @@ -132,8 +133,12 @@ Page({
132 key:map_key, 133 key:map_key,
133 }).then(res=>{ 134 }).then(res=>{
134 res.data=res.data.data 135 res.data=res.data.data
135 - var sug = []; 136 + var sug = [],hasSellerMore=false
136 for (var i = 0; i < res.data.length; i++) { 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 + }
137 sug.push({ // 获取返回结果,放到sug数组中 142 sug.push({ // 获取返回结果,放到sug数组中
138 title: res.data[i].title, 143 title: res.data[i].title,
139 id: res.data[i].id, 144 id: res.data[i].id,
@@ -146,7 +151,8 @@ Page({ @@ -146,7 +151,8 @@ Page({
146 }); 151 });
147 } 152 }
148 _this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示 153 _this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
149 - suggestion: sug 154 + suggestion: sug,
  155 + hasSellerMore:hasSellerMore,
150 }); 156 });
151 }) 157 })
152 }, 158 },
@@ -227,5 +233,43 @@ Page({ @@ -227,5 +233,43 @@ Page({
227 } 233 }
228 }, 234 },
229 }) 235 })
230 - } 236 + },
  237 + gotoList(){
  238 + wx.navigateTo({
  239 + url:util.http_build_query({
  240 + lat:this.location.latitude,
  241 + lng:this.location.longitude,
  242 + keyword:this.inputVal,
  243 + multiIndex:0,
  244 + },'./indexList')
  245 + })
  246 + },
  247 + searchItemClick(e){
  248 + //console.log('searchItemClick',e)
  249 + let item=e.detail.data
  250 + if(e.detail.act=='detail'){
  251 + if(item.type==-1){
  252 + wx.navigateTo({
  253 + url:util.http_build_query({
  254 + id:item.id,
  255 + },'./detail')
  256 + })
  257 + }else{
  258 + let pages = getCurrentPages();
  259 + let p = pages[pages.length - 2];
  260 + p.setSuggestion(item)
  261 + this.setData({
  262 + backfill: item.title
  263 + });
  264 + wx.navigateBack();
  265 + }
  266 + }else{
  267 + wx.navigateTo({
  268 + url:util.http_build_query({
  269 + id:item.id,
  270 + activeTab:'reserve',
  271 + },'./detail')
  272 + })
  273 + }
  274 + },
231 }) 275 })
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 "navigationBarTitleText":"周到安排", 4 "navigationBarTitleText":"周到安排",
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 } 9 }
9 } 10 }
@@ -4,23 +4,19 @@ @@ -4,23 +4,19 @@
4 <view class="searchAddrView"> 4 <view class="searchAddrView">
5 <view class="searchAddr flex-ll"> 5 <view class="searchAddr flex-ll">
6 <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></image> 6 <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></image>
7 - <input style="width: 100%;" placeholder="搜索店铺、地点或商圈" 7 + <input style="width: 100%;" placeholder="输入餐厅名或地名,快速订包间"
8 type="text" confirm-type="done" 8 type="text" confirm-type="done"
9 focus 9 focus
10 bindinput="getsuggest" value="{{backfill}}"/> 10 bindinput="getsuggest" value="{{backfill}}"/>
11 - <view class="search-but" bindtap="nearby_search">搜索</view>  
12 </view> 11 </view>
13 </view> 12 </view>
14 <view class="res-view"> 13 <view class="res-view">
15 <!--绑定回填事件--> 14 <!--绑定回填事件-->
16 - <view class="res-item" wx:for="{{suggestion}}" wx:key="index"  
17 - bindtap="backfill" id="{{index}}">  
18 - <!--根据需求渲染相应数据-->  
19 - <!--渲染地址title-->  
20 - <view class="label">{{item.title}}</view>  
21 - <!--渲染详细地址-->  
22 - <view class="address">{{item.addr}}</view>  
23 - </view> 15 + <block wx:for="{{suggestion}}" wx:key="index"
  16 + bindtap="backfill" id="{{index}}">
  17 + <search-item item="{{item}}" bindclick="searchItemClick"></search-item>
  18 + <view wx:if="{{index==1 && hasSellerMore}}" class="see-more" bindtap="gotoList"></view>
  19 + </block>
24 </view> 20 </view>
25 </view> 21 </view>
26 <view class="history" wx:if="{{history.length>0 && suggestion.length<1}}"> 22 <view class="history" wx:if="{{history.length>0 && suggestion.length<1}}">
@@ -90,4 +90,36 @@ @@ -90,4 +90,36 @@
90 color:#999999; 90 color:#999999;
91 height: 34rpx; 91 height: 34rpx;
92 line-height: 34rpx; 92 line-height: 34rpx;
  93 +}
  94 +
  95 +.see-more{
  96 + width: 100%;
  97 + height: 34rpx;
  98 + position: relative;
  99 + margin-bottom: 40rpx;
  100 + margin-top: 40rpx;
  101 +}
  102 +.see-more:before{
  103 + content: "";
  104 + width: 100%;
  105 + height: 2rpx;
  106 + background-color: #F5F5F5;
  107 + position: absolute;
  108 + left: 0;
  109 + top:17rpx;
  110 +}
  111 +.see-more:after{
  112 + content: "查看更多";
  113 + width:136rpx;
  114 + height:34rpx;
  115 + font-size:24rpx;
  116 + font-weight:500;
  117 + color:rgba(153,153,153,1);
  118 + line-height:34rpx;
  119 + background-color: #fefefe;
  120 + position: absolute;
  121 + display: block;
  122 + left:calc(50% - 68rpx);
  123 + top:0;
  124 + text-align: center;
93 } 125 }
@@ -323,5 +323,12 @@ export default { @@ -323,5 +323,12 @@ export default {
323 'App.Seller.VerificationIsAdmin':{ 323 'App.Seller.VerificationIsAdmin':{
324 cachetime: 1800, 324 cachetime: 1800,
325 }, 325 },
  326 +
  327 + //搜索相关
  328 + 'App.Customer.SetHistorySearch':null,
  329 + //搜索相关
  330 + 'App.Customer.DelHistorySearch':null,
  331 + //搜索相关
  332 + 'App.Customer.GetHistorySearch':null,
326 333
327 } 334 }