Commit 1fd35486d5fe430a878652c70192c4e0c0e24ebb

Authored by wangfan
1 parent 348c856d

c端预定

@@ -370,6 +370,7 @@ Page({ @@ -370,6 +370,7 @@ Page({
370 }, 370 },
371 setSuggestion(suggestion){ 371 setSuggestion(suggestion){
372 let map=this.data.map; 372 let map=this.data.map;
  373 + //let pos=DA.gcj02towgs84(suggestion.longitude,suggestion.latitude)
373 map.latitude=suggestion.latitude 374 map.latitude=suggestion.latitude
374 map.longitude=suggestion.longitude 375 map.longitude=suggestion.longitude
375 this.setData({ 376 this.setData({
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 enable-rotate 14 enable-rotate
15 show-compass 15 show-compass
16 style="width: 100%; height: {{map.height}}px;"></map> 16 style="width: 100%; height: {{map.height}}px;"></map>
17 - <formids url="/pages/reserve/search"> 17 + <formids url="/pages/reserve/search" style="position: fixed;">
18 <cover-view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;"> 18 <cover-view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;">
19 <cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></cover-image> 19 <cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></cover-image>
20 <cover-view class="title">{{hasSuggestion?suggestion.title:'请输入位置'}}</cover-view> 20 <cover-view class="title">{{hasSuggestion?suggestion.title:'请输入位置'}}</cover-view>
@@ -9,99 +9,134 @@ import util from '../../utils/util'; @@ -9,99 +9,134 @@ import util from '../../utils/util';
9 const {regeneratorRuntime} = global 9 const {regeneratorRuntime} = global
10 Page({ 10 Page({
11 11
12 - /**  
13 - * 页面的初始数据  
14 - */  
15 - data: { 12 + /**
  13 + * 页面的初始数据
  14 + */
  15 + data: {},
16 16
17 - }, 17 + /**
  18 + * 生命周期函数--监听页面加载
  19 + */
  20 + onLoad: function (options) {
18 21
19 - /**  
20 - * 生命周期函数--监听页面加载  
21 - */  
22 - onLoad: function (options) { 22 + },
23 23
24 - }, 24 + /**
  25 + * 生命周期函数--监听页面初次渲染完成
  26 + */
  27 + onReady: function () {
25 28
26 - /**  
27 - * 生命周期函数--监听页面初次渲染完成  
28 - */  
29 - onReady: function () { 29 + },
30 30
31 - }, 31 + /**
  32 + * 生命周期函数--监听页面显示
  33 + */
  34 + onShow: function () {
32 35
33 - /**  
34 - * 生命周期函数--监听页面显示  
35 - */  
36 - onShow: function () { 36 + },
37 37
38 - }, 38 + /**
  39 + * 生命周期函数--监听页面隐藏
  40 + */
  41 + onHide: function () {
39 42
40 - /**  
41 - * 生命周期函数--监听页面隐藏  
42 - */  
43 - onHide: function () { 43 + },
44 44
45 - }, 45 + /**
  46 + * 生命周期函数--监听页面卸载
  47 + */
  48 + onUnload: function () {
46 49
47 - /**  
48 - * 生命周期函数--监听页面卸载  
49 - */  
50 - onUnload: function () { 50 + },
51 51
52 - },  
53 -  
54 - //在Page({})中使用下列代码  
55 - //数据回填方法  
56 - backfill: function (e) {  
57 - var id = e.currentTarget.id;  
58 - for (var i = 0; i < this.data.suggestion.length;i++){  
59 - if(i == id){  
60 - console.log(this.data.suggestion[i])  
61 - let pages=getCurrentPages();  
62 - let p=pages[pages.length-2];  
63 - p.setSuggestion(this.data.suggestion[i])  
64 - //util.cache('suggestion',this.data.suggestion[i]);  
65 - this.setData({  
66 - backfill: this.data.suggestion[i].title  
67 - });  
68 - wx.navigateBack();  
69 - } 52 + //在Page({})中使用下列代码
  53 + //数据回填方法
  54 + backfill: function (e) {
  55 + var id = e.currentTarget.id;
  56 + for (var i = 0; i < this.data.suggestion.length; i++) {
  57 + if (i == id) {
  58 + console.log(this.data.suggestion[i])
  59 + let pages = getCurrentPages();
  60 + let p = pages[pages.length - 2];
  61 + p.setSuggestion(this.data.suggestion[i])
  62 + //util.cache('suggestion',this.data.suggestion[i]);
  63 + this.setData({
  64 + backfill: this.data.suggestion[i].title
  65 + });
  66 + wx.navigateBack();
70 } 67 }
71 - },  
72 -  
73 - //触发关键词输入提示事件  
74 - getsuggest: function(e) {  
75 - var _this = this;  
76 - //调用关键词提示接口  
77 - qqmapsdk.getSuggestion({  
78 - //获取输入框值并设置keyword参数  
79 - keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC'  
80 - //region:'北京', //设置城市名,限制关键词所示的地域范围,非必填参数  
81 - success: function(res) {//搜索成功后的回调  
82 - console.log(res);  
83 - var sug = [];  
84 - for (var i = 0; i < res.data.length; i++) {  
85 - sug.push({ // 获取返回结果,放到sug数组中  
86 - title: res.data[i].title,  
87 - id: res.data[i].id,  
88 - addr: res.data[i].address,  
89 - city: res.data[i].city,  
90 - district: res.data[i].district,  
91 - latitude: res.data[i].location.lat,  
92 - longitude: res.data[i].location.lng  
93 - });  
94 - }  
95 - _this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示  
96 - suggestion: sug 68 + }
  69 + },
  70 + inputVal:'',
  71 + //触发关键词输入提示事件
  72 + getsuggest: function (e) {
  73 + var _this = this;
  74 + //调用关键词提示接口
  75 + this.inputVal=e.detail.value;
  76 + qqmapsdk.getSuggestion({
  77 + //获取输入框值并设置keyword参数
  78 + keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC'
  79 + //region:'北京', //设置城市名,限制关键词所示的地域范围,非必填参数
  80 + success: function (res) {//搜索成功后的回调
  81 + console.log(res);
  82 + var sug = [];
  83 + for (var i = 0; i < res.data.length; i++) {
  84 + sug.push({ // 获取返回结果,放到sug数组中
  85 + title: res.data[i].title,
  86 + id: res.data[i].id,
  87 + addr: res.data[i].address,
  88 + city: res.data[i].city,
  89 + district: res.data[i].district,
  90 + latitude: res.data[i].location.lat,
  91 + longitude: res.data[i].location.lng
97 }); 92 });
98 - },  
99 - fail: function(error) {  
100 - console.error(error);  
101 - },  
102 - complete: function(res) {  
103 - console.log(res);  
104 } 93 }
105 - }); 94 + _this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
  95 + suggestion: sug
  96 + });
  97 + },
  98 + fail: function (error) {
  99 + console.error(error);
  100 + },
  101 + complete: function (res) {
  102 + console.log('getsuggest',res);
  103 + }
  104 + });
  105 + },
  106 + nearby_search: function () {
  107 + var _this = this;
  108 + // 调用接口
  109 + let location='';
  110 + if(this.data.suggestion.length>0){
  111 + location=this.data.suggestion[0]
106 } 112 }
  113 + qqmapsdk.search({
  114 + keyword: this.inputVal, //搜索关键词
  115 + page_size:50,
  116 + location:location,
  117 + success: function (res) { //搜索成功后的回调
  118 + var mks = []
  119 + for (var i = 0; i < res.data.length; i++) {
  120 + mks.push({ // 获取返回结果,放到mks数组中
  121 + title: res.data[i].title,
  122 + id: res.data[i].id,
  123 + addr: res.data[i].address,
  124 + city: res.data[i].city,
  125 + district: res.data[i].district,
  126 + latitude: res.data[i].location.lat,
  127 + longitude: res.data[i].location.lng,
  128 + })
  129 + }
  130 + _this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
  131 + suggestion:mks,
  132 + });
  133 + },
  134 + fail: function (res) {
  135 + console.log(res);
  136 + },
  137 + complete: function (res) {
  138 + console.log('nearby_search',res);
  139 + }
  140 + });
  141 + },
107 }) 142 })
@@ -3,7 +3,11 @@ @@ -3,7 +3,11 @@
3 <view class="pages"> 3 <view class="pages">
4 <view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;"> 4 <view class="searchAddr flex-ll" style="top: {{searchAddrTop}}rpx;">
5 <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></image> 5 <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search.png"></image>
6 - <input style="width: 100%;" placeholder="请输入位置" bindinput="getsuggest" value="{{backfill}}"/> 6 + <input style="width: 100%;" placeholder="请输入位置"
  7 + type="text" confirm-type="done"
  8 + focus
  9 + bindinput="getsuggest" value="{{backfill}}"/>
  10 + <view class="search-but" bindtap="nearby_search">搜索</view>
7 </view> 11 </view>
8 <view class="res-view"> 12 <view class="res-view">
9 <!--绑定回填事件--> 13 <!--绑定回填事件-->
@@ -18,7 +18,8 @@ @@ -18,7 +18,8 @@
18 border: 2rpx solid #cccccc; 18 border: 2rpx solid #cccccc;
19 } 19 }
20 .searchAddr .icon{ 20 .searchAddr .icon{
21 - width: 42rpx; 21 + min-width: 42rpx;
  22 + width:42rpx;
22 height: 40rpx; 23 height: 40rpx;
23 margin: 0 20rpx; 24 margin: 0 20rpx;
24 } 25 }
@@ -36,4 +37,10 @@ @@ -36,4 +37,10 @@
36 .res-item .address{ 37 .res-item .address{
37 font-size: 24rpx; 38 font-size: 24rpx;
38 color:#4C4E4F; 39 color:#4C4E4F;
  40 +}
  41 +.search-but{
  42 + min-width: 140rpx;
  43 + color:#61A5D1;
  44 + border-left: 2rpx solid #cccccc;
  45 + text-align: center;
39 } 46 }