Commit f16a67d6e16dcdabe3f5dc6c15de07d8f62b529c

Authored by wangfan
1 parent 46860548

c端预定

@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 style="position:fixed;top:{{statusBarHeight}}px;left:0;height: {{titleBarHeight}}px; line-height: {{titleBarHeight}}px;"> 21 style="position:fixed;top:{{statusBarHeight}}px;left:0;height: {{titleBarHeight}}px; line-height: {{titleBarHeight}}px;">
22 <cover-view class="searchAddr flex-ll"> 22 <cover-view class="searchAddr flex-ll">
23 <cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></cover-image> 23 <cover-image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></cover-image>
24 - <cover-view class="title">{{hasSuggestion?suggestion.title:'请输入位置'}}</cover-view> 24 + <cover-view class="title">{{hasSuggestion?suggestion.title:'输入地点、餐厅、商圈'}}</cover-view>
25 </cover-view> 25 </cover-view>
26 </cover-view> 26 </cover-view>
27 </formids> 27 </formids>
@@ -7,18 +7,22 @@ var qqmapsdk = new QQMapWX({ @@ -7,18 +7,22 @@ var qqmapsdk = new QQMapWX({
7 }); 7 });
8 import util from '../../utils/util'; 8 import util from '../../utils/util';
9 const {regeneratorRuntime} = global 9 const {regeneratorRuntime} = global
  10 +const search_history_cache_key='SEARCH_HISTORY_CACHE_KEY';
10 Page({ 11 Page({
11 12
12 /** 13 /**
13 * 页面的初始数据 14 * 页面的初始数据
14 */ 15 */
15 - data: {}, 16 + data: {
  17 + history:[],
  18 + suggestion:[],
  19 + },
16 20
17 /** 21 /**
18 * 生命周期函数--监听页面加载 22 * 生命周期函数--监听页面加载
19 */ 23 */
20 onLoad: function (options) { 24 onLoad: function (options) {
21 - 25 + this.getHistory();
22 }, 26 },
23 27
24 /** 28 /**
@@ -48,7 +52,29 @@ Page({ @@ -48,7 +52,29 @@ Page({
48 onUnload: function () { 52 onUnload: function () {
49 53
50 }, 54 },
51 - 55 + getHistory(){
  56 + let ca=util.cache(search_history_cache_key);
  57 + if(ca){
  58 + this.setData({
  59 + history:ca
  60 + })
  61 + }
  62 + },
  63 + setHistory(item){
  64 + let newca=[item];
  65 + let ca=this.data.history;
  66 + let maxL=20;
  67 + for(let i=0;i<ca.length;i++){
  68 + if(ca[i].id!=item.id){
  69 + newca.push(ca[i]);
  70 + }
  71 + if(newca.length>maxL) break;
  72 + }
  73 + util.cache(search_history_cache_key,newca);
  74 + this.setData({
  75 + history:newca,
  76 + })
  77 + },
52 //在Page({})中使用下列代码 78 //在Page({})中使用下列代码
53 //数据回填方法 79 //数据回填方法
54 backfill: function (e) { 80 backfill: function (e) {
@@ -56,6 +82,7 @@ Page({ @@ -56,6 +82,7 @@ Page({
56 for (var i = 0; i < this.data.suggestion.length; i++) { 82 for (var i = 0; i < this.data.suggestion.length; i++) {
57 if (i == id) { 83 if (i == id) {
58 console.log(this.data.suggestion[i]) 84 console.log(this.data.suggestion[i])
  85 + this.setHistory(this.data.suggestion[i])
59 let pages = getCurrentPages(); 86 let pages = getCurrentPages();
60 let p = pages[pages.length - 2]; 87 let p = pages[pages.length - 2];
61 p.setSuggestion(this.data.suggestion[i]) 88 p.setSuggestion(this.data.suggestion[i])
@@ -67,12 +94,31 @@ Page({ @@ -67,12 +94,31 @@ Page({
67 } 94 }
68 } 95 }
69 }, 96 },
  97 + backHistoryFill: function (e) {
  98 + var i = util.attr(e,'index');
  99 + let item=this.data.history[i];
  100 + console.log(item)
  101 + this.setHistory(item)
  102 + this.setData({
  103 + backfill: item.title
  104 + });
  105 +
  106 + let pages = getCurrentPages();
  107 + let p = pages[pages.length - 2];
  108 + p.setSuggestion(item)
  109 + wx.navigateBack();
  110 + },
70 inputVal:'', 111 inputVal:'',
71 //触发关键词输入提示事件 112 //触发关键词输入提示事件
72 getsuggest: function (e) { 113 getsuggest: function (e) {
73 var _this = this; 114 var _this = this;
74 //调用关键词提示接口 115 //调用关键词提示接口
75 this.inputVal=e.detail.value; 116 this.inputVal=e.detail.value;
  117 + if(e.detail.value.length<1){
  118 + return this.setData({
  119 + suggestion: []
  120 + })
  121 + }
76 qqmapsdk.getSuggestion({ 122 qqmapsdk.getSuggestion({
77 //获取输入框值并设置keyword参数 123 //获取输入框值并设置keyword参数
78 keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC' 124 keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC'
@@ -96,6 +142,9 @@ Page({ @@ -96,6 +142,9 @@ Page({
96 }); 142 });
97 }, 143 },
98 fail: function (error) { 144 fail: function (error) {
  145 + _this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
  146 + suggestion: []
  147 + });
99 console.error(error); 148 console.error(error);
100 }, 149 },
101 complete: function (res) { 150 complete: function (res) {
1 <!--pages/reserve/search.wxml--> 1 <!--pages/reserve/search.wxml-->
2 -<nav>请输入位置</nav> 2 +<nav>搜索</nav>
3 <view class="pages"> 3 <view class="pages">
4 <view class="searchAddr flex-ll"> 4 <view class="searchAddr flex-ll">
5 <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></image> 5 <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/search26.png"></image>
6 - <input style="width: 100%;" placeholder="请输入位置" 6 + <input style="width: 100%;" placeholder="输入地点、餐厅、商圈"
7 type="text" confirm-type="done" 7 type="text" confirm-type="done"
8 focus 8 focus
9 bindinput="getsuggest" value="{{backfill}}"/> 9 bindinput="getsuggest" value="{{backfill}}"/>
@@ -21,3 +21,21 @@ @@ -21,3 +21,21 @@
21 </view> 21 </view>
22 </view> 22 </view>
23 </view> 23 </view>
  24 +<view class="history" wx:if="{{history && suggestion.length<1}}">
  25 + <view class="pages">
  26 + <view class="history-title">历史记录</view>
  27 + <view class="hr-one"></view>
  28 + <view class="history-list">
  29 + <view class="flex-ll item" wx:for="{{history}}" wx:key="history.key"
  30 + bindtap="backHistoryFill" data-index="{{index}}">
  31 + <view class="icon-view">
  32 + <image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/addr.png"></image>
  33 + </view>
  34 + <view class="info">
  35 + <view class="title">{{item.title}}</view>
  36 + <view class="addr">{{item.addr}}</view>
  37 + </view>
  38 + </view>
  39 + </view>
  40 + </view>
  41 +</view>
@@ -41,7 +41,47 @@ @@ -41,7 +41,47 @@
41 } 41 }
42 .search-but{ 42 .search-but{
43 min-width: 140rpx; 43 min-width: 140rpx;
44 - color:#61A5D1; 44 + color:#000000;
45 border-left: 2rpx solid #cccccc; 45 border-left: 2rpx solid #cccccc;
46 text-align: center; 46 text-align: center;
  47 + height: 32rpx;
  48 + line-height: 32rpx;
  49 +
  50 +}
  51 +.history{
  52 + margin-top: 140rpx;
  53 +}
  54 +.history .history-title{
  55 + font-size: 28rpx;
  56 + color:#999999;
  57 + height: 40rpx;
  58 + line-height: 40rpx;
  59 +}
  60 +.hr-one{
  61 + height: 2rpx;
  62 + background-color: #F5F5F5;
  63 + width: 110%;
  64 + margin: 18rpx -5% 0;
  65 +}
  66 +.history .item{
  67 + height: 120rpx;
  68 + line-height: 120rpx;
  69 +}
  70 +.history .icon{
  71 + width: 22rpx;
  72 + height: 26rpx;
  73 + min-width: 22rpx;
  74 + margin-right: 20rpx;
  75 +}
  76 +.history .title{
  77 + font-size: 28rpx;
  78 + height: 40rpx;
  79 + line-height: 40rpx;
  80 + margin-bottom: 4rpx;
  81 +}
  82 +.history .addr{
  83 + font-size: 24rpx;
  84 + color:#999999;
  85 + height: 34rpx;
  86 + line-height: 34rpx;
47 } 87 }
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 "list": [] 31 "list": []
32 }, 32 },
33 "miniprogram": { 33 "miniprogram": {
34 - "current": 6, 34 + "current": 32,
35 "list": [ 35 "list": [
36 { 36 {
37 "id": 0, 37 "id": 0,
@@ -272,11 +272,11 @@ @@ -272,11 +272,11 @@
272 "scene": "1011" 272 "scene": "1011"
273 }, 273 },
274 { 274 {
275 - "id": -1,  
276 - "name": "pages/reserve/index",  
277 - "pathName": "pages/reserve/index", 275 + "id": 32,
  276 + "name": "pages/reserve/search 在线预定",
  277 + "pathName": "pages/reserve/search",
278 "query": "", 278 "query": "",
279 - "scene": "1001" 279 + "scene": 1001
280 }, 280 },
281 { 281 {
282 "id": -1, 282 "id": -1,