Commit fa43a1879654c0695756db54adbf43f210f78e27

Authored by vking
1 parent d0666176

search

// components/reserve/search/item.js
import App from '../../../utils/api';
Component({
/**
* 组件的属性列表
*/
properties: {
item:{
type:Object,
value:{}
},
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
detailGo(){
this.SetHistorySearch();
this.triggerEvent('click',{act:'detail',data:this.data.item})
},
reserveGo(){
this.SetHistorySearch();
this.triggerEvent('click',{act:'reserve',data:this.data.item})
},
SetHistorySearch() {
let params=this.data.item
App.Customer.SetHistorySearch(params)
},
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--components/reserve/search/item.wxml-->
<view class="item item{{item.type}} flex-ll" bindtap="detailGo">
<view class="icon"></view>
<view class="flex-lr item-info">
<view class="info">
<view class="title">{{item.title}}</view>
<view class="addr">{{item.addr}}</view>
</view>
<view class="reserve-but" wx:if="{{item.type==-1}}" catchtap="reserveGo">包间预订</view>
</view>
</view>
... ...
/* components/reserve/search/item.wxss */
@import "../../../app.wxss";
.item{
width: 100%;
box-sizing: border-box;
margin-bottom: 40rpx;
}
.item-1{
margin-bottom: 20rpx;
}
.item-1 .item-info{
width: calc(100% - 60rpx);
max-width: calc(100% - 60rpx);
box-sizing: border-box;
}
.item .title{
font-size: 28rpx;
height: 40rpx;
line-height: 40rpx;
white-space:nowrap;
overflow: hidden;
text-overflow:ellipsis;
}
.item .addr{
font-size: 24rpx;
height: 34rpx;
line-height: 34rpx;
margin-top: 4rpx;
white-space:nowrap;
overflow: hidden;
text-overflow:ellipsis;
}
.item .icon{
margin-right: 20rpx;
width: 22rpx;
height:26rpx;
background-color: #ccc;
}
.item-1 .info{
width: calc(100% - 140rpx);
max-width: calc(100% - 140rpx);
}
.item-1{
background:rgba(255,255,255,1);
box-shadow:0 0 8rpx 0 rgba(196,196,196,0.5);
border-radius:10rpx;
padding: 20rpx;
}
.item-1 .icon {
background-color: #C0A369;
width: 36rpx;
height: 36rpx;
min-width: 36rpx;
}
.reserve-but{
width:120rpx;
height:40rpx;
background:linear-gradient(360deg,rgba(131,131,131,1) 0%,rgba(76,76,76,1) 100%);
border-radius:25rpx;
font-size:24rpx;
font-weight:500;
color:rgba(240,206,161,1);
line-height:40rpx;
text-shadow:0rpx 2rpx 6rpx rgba(80,80,80,1);
text-align: center;
min-width: 120rpx;
margin-left: 20rpx;
}
\ No newline at end of file
... ...
... ... @@ -26,7 +26,7 @@
</cover-view>
<cover-view class="searchAddr flex-ll">
<cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></cover-image>
<cover-view class="title">{{hasSuggestion?suggestion.title:'搜索店铺、地点或商圈'}}</cover-view>
<cover-view class="title">{{hasSuggestion?suggestion.title:'输入餐厅名或地名,快速订包间'}}</cover-view>
</cover-view>
</cover-view>
</formids>
... ...
... ... @@ -117,7 +117,7 @@ page{
.searchAddr {
margin-left: 15rpx;
width: 380rpx;
width: 420rpx;
height: 60rpx;
background-color: #fefefe;
border-radius: 30rpx;
... ...
... ... @@ -93,19 +93,30 @@ Page({
let mapParam=this.options
this.offset=1 //page
this.size=20 //page size
//计算视窗中心
let map=JSON.parse(mapParam.map);
let lat=map.northeast.latitude-(map.northeast.latitude-map.southwest.latitude)/2;
let lng=map.northeast.longitude-(map.northeast.longitude-map.southwest.longitude)/2;
this.param={
lat:lat,
lng:lng,
lat_extend:mapParam.lat,
lng_extend:mapParam.lng,
offset:this.offset,
size:this.size,
distance:50,
};
if(mapParam.keyword){
this.param={
lat_extend:mapParam.lat,
lng_extend:mapParam.lng,
keyword:mapParam.keyword,
offset:this.offset,
size:this.size,
distance:5000,
};
}else{
//计算视窗中心
let map=JSON.parse(mapParam.map);
let lat=map.northeast.latitude-(map.northeast.latitude-map.southwest.latitude)/2;
let lng=map.northeast.longitude-(map.northeast.longitude-map.southwest.longitude)/2;
this.param={
lat:lat,
lng:lng,
lat_extend:mapParam.lat,
lng_extend:mapParam.lng,
offset:this.offset,
size:this.size,
distance:50,
};
}
if(this.data.multiIndex[0]>0){
this.param.cuisine=await DA.getCatesID(this.data.multiIndex[0]-1);
}
... ...
... ... @@ -18,6 +18,7 @@ Page({
data: {
history:[],
suggestion:[],
hasSellerMore:false,
},
/**
... ... @@ -132,8 +133,12 @@ Page({
key:map_key,
}).then(res=>{
res.data=res.data.data
var sug = [];
var sug = [],hasSellerMore=false
for (var i = 0; i < res.data.length; i++) {
if(i==2 && res.data[i].type==-1){
hasSellerMore=true
continue;
}
sug.push({ // 获取返回结果,放到sug数组中
title: res.data[i].title,
id: res.data[i].id,
... ... @@ -146,7 +151,8 @@ Page({
});
}
_this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
suggestion: sug
suggestion: sug,
hasSellerMore:hasSellerMore,
});
})
},
... ... @@ -227,5 +233,43 @@ Page({
}
},
})
}
},
gotoList(){
wx.navigateTo({
url:util.http_build_query({
lat:this.location.latitude,
lng:this.location.longitude,
keyword:this.inputVal,
multiIndex:0,
},'./indexList')
})
},
searchItemClick(e){
//console.log('searchItemClick',e)
let item=e.detail.data
if(e.detail.act=='detail'){
if(item.type==-1){
wx.navigateTo({
url:util.http_build_query({
id:item.id,
},'./detail')
})
}else{
let pages = getCurrentPages();
let p = pages[pages.length - 2];
p.setSuggestion(item)
this.setData({
backfill: item.title
});
wx.navigateBack();
}
}else{
wx.navigateTo({
url:util.http_build_query({
id:item.id,
activeTab:'reserve',
},'./detail')
})
}
},
})
\ No newline at end of file
... ...
... ... @@ -4,6 +4,7 @@
"navigationBarTitleText":"周到安排",
"usingComponents": {
"formids":"/components/formids/formids",
"nav":"/components/nav/nav"
"nav":"/components/nav/nav",
"search-item":"/components/reserve/search/item"
}
}
\ No newline at end of file
... ...
... ... @@ -4,23 +4,19 @@
<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="搜索店铺、地点或商圈"
<input style="width: 100%;" placeholder="输入餐厅名或地名,快速订包间"
type="text" confirm-type="done"
focus
bindinput="getsuggest" value="{{backfill}}"/>
<view class="search-but" bindtap="nearby_search">搜索</view>
</view>
</view>
<view class="res-view">
<!--绑定回填事件-->
<view class="res-item" wx:for="{{suggestion}}" wx:key="index"
bindtap="backfill" id="{{index}}">
<!--根据需求渲染相应数据-->
<!--渲染地址title-->
<view class="label">{{item.title}}</view>
<!--渲染详细地址-->
<view class="address">{{item.addr}}</view>
</view>
<block wx:for="{{suggestion}}" wx:key="index"
bindtap="backfill" id="{{index}}">
<search-item item="{{item}}" bindclick="searchItemClick"></search-item>
<view wx:if="{{index==1 && hasSellerMore}}" class="see-more" bindtap="gotoList"></view>
</block>
</view>
</view>
<view class="history" wx:if="{{history.length>0 && suggestion.length<1}}">
... ...
... ... @@ -90,4 +90,36 @@
color:#999999;
height: 34rpx;
line-height: 34rpx;
}
.see-more{
width: 100%;
height: 34rpx;
position: relative;
margin-bottom: 40rpx;
margin-top: 40rpx;
}
.see-more:before{
content: "";
width: 100%;
height: 2rpx;
background-color: #F5F5F5;
position: absolute;
left: 0;
top:17rpx;
}
.see-more:after{
content: "查看更多";
width:136rpx;
height:34rpx;
font-size:24rpx;
font-weight:500;
color:rgba(153,153,153,1);
line-height:34rpx;
background-color: #fefefe;
position: absolute;
display: block;
left:calc(50% - 68rpx);
top:0;
text-align: center;
}
\ No newline at end of file
... ...
... ... @@ -323,5 +323,12 @@ export default {
'App.Seller.VerificationIsAdmin':{
cachetime: 1800,
},
//搜索相关
'App.Customer.SetHistorySearch':null,
//搜索相关
'App.Customer.DelHistorySearch':null,
//搜索相关
'App.Customer.GetHistorySearch':null,
}
\ No newline at end of file
... ...