Commit 03b7a48bc2f3ffdd7da437b5550c463a2c42c8b7

Authored by vking
1 parent 39efd02f

search

... ... @@ -104,6 +104,9 @@ Page({
if(data.fun=='setSuggestion'){
this.setSuggestion(data.suggestion);
}
if(data.fun=='moveToLocation'){
this.moveToLocation();
}
}
)
PubSub.on(
... ... @@ -886,7 +889,7 @@ Page({
tags:this.param.tags,
centre_pos:this.param.centre_pos,
hasSuggestion:this.data.hasSuggestion?1:'',
keywordTip:this.data.hasSuggestion?this.data.suggestion.title:'',
keyword:this.data.hasSuggestion?this.data.suggestion.title:'',
},'./indexList'),
success: res=> {
// 通过eventChannel向被打开页面传送数据
... ...
... ... @@ -27,6 +27,7 @@
<view class="searchAddr flex-ll">
<image class="icon" src="http://nosqn.colorcun.com/custom/lite-online/image/search26.png"></image>
<view class="title">{{hasSuggestion?suggestion.title:'搜索餐厅/位置'}}</view>
<view class="clean" catchtap="moveToLocation" wx:if="{{hasSuggestion}}"></view>
</view>
<view class="searchList flex-tb" catchtap="listShow">
<image class="icon" src="http://nosqn.colorcun.com/mapmenu/maplist.png"></image>
... ...
... ... @@ -379,4 +379,21 @@ page{
width: 100%;
padding-top: 20rpx;
height: 426rpx;
}
.searchAddr .clean{
position: relative;
width: 100rpx;
height: 60rpx;
min-width: 100rpx;
}
.searchAddr .clean:after{
background-image: url("http://nosqn.colorcun.com/clean.png");
background-size: 100% 100%;
display: block;
content: "";
width:28rpx;
height:28rpx;
position: absolute;
top:16rpx;
left:32rpx;
}
\ No newline at end of file
... ...
... ... @@ -32,11 +32,20 @@ Page({
eventChannel:null,
onLoad: async function (options) {
//lat=34.21719&lng=108.89155&map={"errMsg":"getMapRegion:ok","southwest":{"longitude":108.87545674591064,"latitude":34.204520114013846},"northeast":{"longitude":108.90764325408935,"latitude":34.229857981005225},"scale":15}&multiIndex=1&tags=1,2
//lat=39.65273&lng=118.15813&map={"errMsg":"getMapRegion:ok","southwest":{"longitude":118.11012337295534,"latitude":39.61934377763755},"northeast":{"longitude":118.1262166270447,"latitude":39.63137569933196},"scale":15}&multiIndex=0&centre_pos=39.625360,118.118170&hasSuggestion=1&keywordTip=唐山站
this.options=options;
if(options.hasSuggestion){
let pos=options.centre_pos.split(',')
this.suggestion={
latitude:pos[0],
longitude:pos[1],
title:options.keyword,
}
this.setData({
hasSuggestion:true
hasSuggestion:true,
suggestion:this.suggestion
})
delete this.options.keyword
}
let tags=[
{id:1,name:'环境好'},
... ... @@ -106,7 +115,9 @@ Page({
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
PubSub.off('searchParamList')
if(this.hasOneListPage()){
PubSub.off('searchParamList')
}
},
/**
... ... @@ -122,20 +133,28 @@ Page({
onReachBottom: function () {
this.getListMore()
},
hasOneListPage(){//判断是否只有一个列表页面
let pages = getCurrentPages();
let pc=0
pages.forEach(p=>{
if(p.route=='pages/reserve/indexList'){
pc++;
}
})
if(pc==1){//只有一个列表页
return true
}
return false
},
hasGetSellerEnd:false,
hasCleanSuggestion:false,
async getList(){
let mapParam=this.options
this.offset=1 //page
this.size=20 //page size
if(mapParam.keywordTip){
this.setData({
keyword:mapParam.keywordTip,
})
}else{
this.setData({
keyword:mapParam.keyword||'',
})
}
this.setData({
keyword:mapParam.keyword||'',
})
if(mapParam.keyword){
this.param={
... ... @@ -161,7 +180,11 @@ Page({
this.setData({
keyword:this.suggestion.title,
})
}else{
}else if(this.hasCleanSuggestion){//清理地标使用人的位置
lat=this.location.latitude
lng=this.location.longitude
}
if(!lat || !lng){//不完整时,使用地图中心点
let map=JSON.parse(mapParam.map);
lat=map.northeast.latitude-(map.northeast.latitude-map.southwest.latitude)/2;
lng=map.northeast.longitude-(map.northeast.longitude-map.southwest.longitude)/2;
... ... @@ -175,7 +198,7 @@ Page({
size:this.size,
distance:50,
};
if(this.suggestion){
if(this.suggestion || this.hasCleanSuggestion){
this.param.centre_pos=`${lat},${lng}`
}else{
if(mapParam.centre_pos){
... ... @@ -260,13 +283,15 @@ Page({
value:[e.detail]
}
})
PubSub.emit(
'searchParam',
{
fun:'caixiActive',
e:e,
}
)
if(this.hasOneListPage()){
PubSub.emit(
'searchParam',
{
fun:'caixiActive',
e:e,
}
)
}
},
bindMultiPickerChange(e){
console.log(e);
... ... @@ -292,13 +317,15 @@ Page({
this.setData({
tags:tags,
})
PubSub.emit(
'searchParam',
{
fun:'tagsChange',
e:e,
}
)
if(this.hasOneListPage()) {
PubSub.emit(
'searchParam',
{
fun: 'tagsChange',
e: e,
}
)
}
setTimeout(()=>{this.getList();},0)
},
gotoDetail(e){
... ... @@ -404,4 +431,15 @@ Page({
})
this.getList()
},
moveToLocation(){
this.suggestion=null
this.hasCleanSuggestion=true,
this.setData({
suggestion:null,
hasSuggestion:false,
keyword:'',
})
PubSub.emit('searchParam', {fun:'moveToLocation'})
setTimeout(()=>{this.getList()},0)
},
})
\ No newline at end of file
... ...
... ... @@ -17,6 +17,7 @@
<input style="width: 100%;" placeholder="{{search_placeholder}}"
type="text" disabled placeholder-class="placeholder"
value="{{keyword}}"/>
<view class="clean" catchtap="moveToLocation" wx:if="{{keyword && hasSuggestion}}"></view>
</view>
</view>
<view class="transverse-search flex-ll {{hasDisabled?'disabled':''}}">
... ...
... ... @@ -197,4 +197,21 @@
width:22rpx;
height: 22rpx;
margin: 0 10rpx 0 40rpx;
}
.searchAddr .clean{
position: relative;
width: 100rpx;
height: 60rpx;
min-width: 100rpx;
}
.searchAddr .clean:after{
background-image: url("http://nosqn.colorcun.com/clean.png");
background-size: 100% 100%;
display: block;
content: "";
width:28rpx;
height:28rpx;
position: absolute;
top:16rpx;
left:32rpx;
}
\ No newline at end of file
... ...