Commit f16a67d6e16dcdabe3f5dc6c15de07d8f62b529c

Authored by wangfan
1 parent 46860548

c端预定

... ... @@ -21,7 +21,7 @@
style="position:fixed;top:{{statusBarHeight}}px;left:0;height: {{titleBarHeight}}px; line-height: {{titleBarHeight}}px;">
<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>
... ...
... ... @@ -7,18 +7,22 @@ var qqmapsdk = new QQMapWX({
});
import util from '../../utils/util';
const {regeneratorRuntime} = global
const search_history_cache_key='SEARCH_HISTORY_CACHE_KEY';
Page({
/**
* 页面的初始数据
*/
data: {},
data: {
history:[],
suggestion:[],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getHistory();
},
/**
... ... @@ -48,7 +52,29 @@ Page({
onUnload: function () {
},
getHistory(){
let ca=util.cache(search_history_cache_key);
if(ca){
this.setData({
history:ca
})
}
},
setHistory(item){
let newca=[item];
let ca=this.data.history;
let maxL=20;
for(let i=0;i<ca.length;i++){
if(ca[i].id!=item.id){
newca.push(ca[i]);
}
if(newca.length>maxL) break;
}
util.cache(search_history_cache_key,newca);
this.setData({
history:newca,
})
},
//在Page({})中使用下列代码
//数据回填方法
backfill: function (e) {
... ... @@ -56,6 +82,7 @@ Page({
for (var i = 0; i < this.data.suggestion.length; i++) {
if (i == id) {
console.log(this.data.suggestion[i])
this.setHistory(this.data.suggestion[i])
let pages = getCurrentPages();
let p = pages[pages.length - 2];
p.setSuggestion(this.data.suggestion[i])
... ... @@ -67,12 +94,31 @@ Page({
}
}
},
backHistoryFill: function (e) {
var i = util.attr(e,'index');
let item=this.data.history[i];
console.log(item)
this.setHistory(item)
this.setData({
backfill: item.title
});
let pages = getCurrentPages();
let p = pages[pages.length - 2];
p.setSuggestion(item)
wx.navigateBack();
},
inputVal:'',
//触发关键词输入提示事件
getsuggest: function (e) {
var _this = this;
//调用关键词提示接口
this.inputVal=e.detail.value;
if(e.detail.value.length<1){
return this.setData({
suggestion: []
})
}
qqmapsdk.getSuggestion({
//获取输入框值并设置keyword参数
keyword: e.detail.value, //用户输入的关键词,可设置固定值,如keyword:'KFC'
... ... @@ -96,6 +142,9 @@ Page({
});
},
fail: function (error) {
_this.setData({ //设置suggestion属性,将关键词搜索结果以列表形式展示
suggestion: []
});
console.error(error);
},
complete: function (res) {
... ...
<!--pages/reserve/search.wxml-->
<nav>请输入位置</nav>
<nav>搜索</nav>
<view class="pages">
<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}}"/>
... ... @@ -21,3 +21,21 @@
</view>
</view>
</view>
<view class="history" wx:if="{{history && suggestion.length<1}}">
<view class="pages">
<view class="history-title">历史记录</view>
<view class="hr-one"></view>
<view class="history-list">
<view class="flex-ll item" wx:for="{{history}}" wx:key="history.key"
bindtap="backHistoryFill" data-index="{{index}}">
<view class="icon-view">
<image class="icon" src="http://qn.colorcun.com/custom/lite-online/image/addr.png"></image>
</view>
<view class="info">
<view class="title">{{item.title}}</view>
<view class="addr">{{item.addr}}</view>
</view>
</view>
</view>
</view>
</view>
... ...
... ... @@ -41,7 +41,47 @@
}
.search-but{
min-width: 140rpx;
color:#61A5D1;
color:#000000;
border-left: 2rpx solid #cccccc;
text-align: center;
height: 32rpx;
line-height: 32rpx;
}
.history{
margin-top: 140rpx;
}
.history .history-title{
font-size: 28rpx;
color:#999999;
height: 40rpx;
line-height: 40rpx;
}
.hr-one{
height: 2rpx;
background-color: #F5F5F5;
width: 110%;
margin: 18rpx -5% 0;
}
.history .item{
height: 120rpx;
line-height: 120rpx;
}
.history .icon{
width: 22rpx;
height: 26rpx;
min-width: 22rpx;
margin-right: 20rpx;
}
.history .title{
font-size: 28rpx;
height: 40rpx;
line-height: 40rpx;
margin-bottom: 4rpx;
}
.history .addr{
font-size: 24rpx;
color:#999999;
height: 34rpx;
line-height: 34rpx;
}
\ No newline at end of file
... ...
... ... @@ -31,7 +31,7 @@
"list": []
},
"miniprogram": {
"current": 6,
"current": 32,
"list": [
{
"id": 0,
... ... @@ -272,11 +272,11 @@
"scene": "1011"
},
{
"id": -1,
"name": "pages/reserve/index",
"pathName": "pages/reserve/index",
"id": 32,
"name": "pages/reserve/search 在线预定",
"pathName": "pages/reserve/search",
"query": "",
"scene": "1001"
"scene": 1001
},
{
"id": -1,
... ...