Commit 1fd35486d5fe430a878652c70192c4e0c0e24ebb

Authored by wangfan
1 parent 348c856d

c端预定

... ... @@ -370,6 +370,7 @@ Page({
},
setSuggestion(suggestion){
let map=this.data.map;
//let pos=DA.gcj02towgs84(suggestion.longitude,suggestion.latitude)
map.latitude=suggestion.latitude
map.longitude=suggestion.longitude
this.setData({
... ...
... ... @@ -14,7 +14,7 @@
enable-rotate
show-compass
style="width: 100%; height: {{map.height}}px;"></map>
<formids url="/pages/reserve/search">
<formids url="/pages/reserve/search" style="position: fixed;">
<cover-view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;">
<cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></cover-image>
<cover-view class="title">{{hasSuggestion?suggestion.title:'请输入位置'}}</cover-view>
... ...
... ... @@ -9,99 +9,134 @@ import util from '../../utils/util';
const {regeneratorRuntime} = global
Page({
/**
* 页面的初始数据
*/
data: {
/**
* 页面的初始数据
*/
data: {},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
},
//在Page({})中使用下列代码
//数据回填方法
backfill: function (e) {
var id = e.currentTarget.id;
for (var i = 0; i < this.data.suggestion.length;i++){
if(i == id){
console.log(this.data.suggestion[i])
let pages=getCurrentPages();
let p=pages[pages.length-2];
p.setSuggestion(this.data.suggestion[i])
//util.cache('suggestion',this.data.suggestion[i]);
this.setData({
backfill: this.data.suggestion[i].title
});
wx.navigateBack();
}
//在Page({})中使用下列代码
//数据回填方法
backfill: function (e) {
var id = e.currentTarget.id;
for (var i = 0; i < this.data.suggestion.length; i++) {
if (i == id) {
console.log(this.data.suggestion[i])
let pages = getCurrentPages();
let p = pages[pages.length - 2];
p.setSuggestion(this.data.suggestion[i])
//util.cache('suggestion',this.data.suggestion[i]);
this.setData({
backfill: this.data.suggestion[i].title
});
wx.navigateBack();
}
},
//触发关键词输入提示事件
getsuggest: function(e) {
var _this = this;
//调用关键词提示接口
qqmapsdk.getSuggestion({
//获取输入框值并设置keyword参数
keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC'
//region:'北京', //设置城市名,限制关键词所示的地域范围,非必填参数
success: function(res) {//搜索成功后的回调
console.log(res);
var sug = [];
for (var i = 0; i < res.data.length; i++) {
sug.push({ // 获取返回结果,放到sug数组中
title: res.data[i].title,
id: res.data[i].id,
addr: res.data[i].address,
city: res.data[i].city,
district: res.data[i].district,
latitude: res.data[i].location.lat,
longitude: res.data[i].location.lng
});
}
_this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
suggestion: sug
}
},
inputVal:'',
//触发关键词输入提示事件
getsuggest: function (e) {
var _this = this;
//调用关键词提示接口
this.inputVal=e.detail.value;
qqmapsdk.getSuggestion({
//获取输入框值并设置keyword参数
keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC'
//region:'北京', //设置城市名,限制关键词所示的地域范围,非必填参数
success: function (res) {//搜索成功后的回调
console.log(res);
var sug = [];
for (var i = 0; i < res.data.length; i++) {
sug.push({ // 获取返回结果,放到sug数组中
title: res.data[i].title,
id: res.data[i].id,
addr: res.data[i].address,
city: res.data[i].city,
district: res.data[i].district,
latitude: res.data[i].location.lat,
longitude: res.data[i].location.lng
});
},
fail: function(error) {
console.error(error);
},
complete: function(res) {
console.log(res);
}
});
_this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
suggestion: sug
});
},
fail: function (error) {
console.error(error);
},
complete: function (res) {
console.log('getsuggest',res);
}
});
},
nearby_search: function () {
var _this = this;
// 调用接口
let location='';
if(this.data.suggestion.length>0){
location=this.data.suggestion[0]
}
qqmapsdk.search({
keyword: this.inputVal, //搜索关键词
page_size:50,
location:location,
success: function (res) { //搜索成功后的回调
var mks = []
for (var i = 0; i < res.data.length; i++) {
mks.push({ // 获取返回结果,放到mks数组中
title: res.data[i].title,
id: res.data[i].id,
addr: res.data[i].address,
city: res.data[i].city,
district: res.data[i].district,
latitude: res.data[i].location.lat,
longitude: res.data[i].location.lng,
})
}
_this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
suggestion:mks,
});
},
fail: function (res) {
console.log(res);
},
complete: function (res) {
console.log('nearby_search',res);
}
});
},
})
\ No newline at end of file
... ...
... ... @@ -3,7 +3,11 @@
<view class="pages">
<view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;">
<image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></image>
<input style="width: 100%;" placeholder="请输入位置" bindinput="getsuggest" value="{{backfill}}"/>
<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 class="res-view">
<!--绑定回填事件-->
... ...
... ... @@ -18,7 +18,8 @@
border: 2rpx solid #cccccc;
}
.searchAddr .icon{
width: 42rpx;
min-width: 42rpx;
width:42rpx;
height: 40rpx;
margin: 0 20rpx;
}
... ... @@ -36,4 +37,10 @@
.res-item .address{
font-size: 24rpx;
color:#4C4E4F;
}
.search-but{
min-width: 140rpx;
color:#61A5D1;
border-left: 2rpx solid #cccccc;
text-align: center;
}
\ No newline at end of file
... ...