Commit 312db3195e5f4964055b18d47765c4187d2fed86

Authored by vking
1 parent 547aa611

search

@@ -3,7 +3,7 @@ var myBehavior = require('hv_behavior') @@ -3,7 +3,7 @@ var myBehavior = require('hv_behavior')
3 const items=(function(){ 3 const items=(function(){
4 let today=parseInt(new Date()/1000); 4 let today=parseInt(new Date()/1000);
5 let ds=[] 5 let ds=[]
6 - for(let i=0;i<=15;i++){ 6 + for(let i=0;i<15;i++){
7 ds.push(today+86400*i) 7 ds.push(today+86400*i)
8 } 8 }
9 return ds 9 return ds
1 <!--components/reserve/search/how/hv/date.wxml--> 1 <!--components/reserve/search/how/hv/date.wxml-->
2 <wxs src="../../../../utils/util.wxs" module="util" /> 2 <wxs src="../../../../utils/util.wxs" module="util" />
3 -<swiper previous-margin="20rpx" next-margin="20rpx" 3 +<swiper previous-margin="35rpx" next-margin="45rpx"
4 class="tabs" 4 class="tabs"
5 display-multiple-items="5"> 5 display-multiple-items="5">
6 <swiper-item wx:for="{{items}}" wx:key="items"> 6 <swiper-item wx:for="{{items}}" wx:key="items">
1 -// components/reserve/search/how/dur.js 1 +// components/reserve/search/how/hv/pnum.js
  2 +var myBehavior = require('hv_behavior')
  3 +const items=[
  4 + {id:1,label:'早餐'},
  5 + {id:2,label:'午餐'},
  6 + {id:3,label:'晚餐'},
  7 + {},
  8 + {},
  9 +]
2 Component({ 10 Component({
3 - /**  
4 - * 组件的属性列表  
5 - */  
6 - properties: {  
7 - 11 + behaviors: [myBehavior],
  12 + data:{
  13 + items:items,
8 }, 14 },
9 -  
10 - /**  
11 - * 组件的初始数据  
12 - */  
13 - data: {  
14 - 15 + lifetimes: {
  16 + attached: function () {
  17 + // 在组件实例进入页面节点树时执行
  18 + console.log(this.data.pi)
  19 + this.setData({
  20 + spi:this.data.pi,
  21 + })
  22 + },
  23 + detached: function () {
  24 + // 在组件实例被从页面节点树移除时执行
  25 + },
15 }, 26 },
16 27
17 /** 28 /**
1 <!--components/reserve/search/how/dur.wxml--> 1 <!--components/reserve/search/how/dur.wxml-->
2 -<view class="tabs flex-ll">  
3 - <view class="item" data-id="1">  
4 - 早餐  
5 - </view>  
6 - <view class="item" data-id="2">  
7 - 午餐  
8 - </view>  
9 - <view class="item" data-id="3">  
10 - 晚餐  
11 - </view>  
12 -</view> 2 +<swiper previous-margin="35rpx" next-margin="45rpx"
  3 + class="tabs"
  4 + display-multiple-items="5">
  5 + <swiper-item wx:for="{{items}}" wx:key="items">
  6 + <view class="item {{spi==index?'active':''}} flex-vc"
  7 + bindtap="{{index>2?'':'checked'}}"
  8 + data-index="{{index}}"
  9 + data-val="{{item.id}}"
  10 + data-type="dur">
  11 + <view class="name">{{item.label}}</view>
  12 + </view>
  13 + </swiper-item>
  14 +</swiper>
1 // components/reserve/search/how/index.js 1 // components/reserve/search/how/index.js
  2 +import util from '../../../../utils/util'
2 Component({ 3 Component({
3 /** 4 /**
4 * 组件的属性列表 5 * 组件的属性列表
5 */ 6 */
6 properties: { 7 properties: {
7 - 8 + hasPage:{
  9 + type:Boolean,
  10 + value:false,
  11 + },
  12 + date_pi:{
  13 + type:Number,
  14 + value:0,
  15 + },
  16 + pnum_pi:{
  17 + type:Number,
  18 + value:0,
  19 + },
  20 + dur_pi:{
  21 + type:Number,
  22 + value:-1,
  23 + }
8 }, 24 },
9 25
10 /** 26 /**
@@ -13,16 +29,30 @@ Component({ @@ -13,16 +29,30 @@ Component({
13 data: { 29 data: {
14 30
15 }, 31 },
16 - 32 + attached(){
  33 + this.params={}
  34 + },
17 /** 35 /**
18 * 组件的方法列表 36 * 组件的方法列表
19 */ 37 */
20 methods: { 38 methods: {
21 - pnumEvent(e){  
22 - console.log(e) 39 + paramEvent(e){
  40 + console.log('paramEvent',e.detail)
  41 + this.params[e.detail.type]=e.detail
23 }, 42 },
24 - dateEvent(e){  
25 - console.log(e) 43 + submit(){
  44 + console.log(this.params)
  45 + let paramObj={
  46 + when_date:util.unixtoTime(this.params['date'].val,'YYYY-MM-DD'),
  47 + several:this.params['pnum'].val,
  48 + }
  49 + if(this.params['dur'].val>=0){
  50 + paramObj.daily=this.params['dur'].val
  51 + }
  52 + this.triggerEvent('event',{
  53 + params:this.params,
  54 + paramObj:paramObj,
  55 + })
26 }, 56 },
27 } 57 }
28 }) 58 })
1 <!--components/reserve/search/how/index.wxml--> 1 <!--components/reserve/search/how/index.wxml-->
2 -<view class="mask"></view>  
3 -<view class="pages {{hasPage?'':'window'}}">  
4 - <view>  
5 - <view>您好,几位,什么时候</view>  
6 - <view class="close">X</view> 2 +<view class="mask" wx:if="{{!hasPage}}"></view>
  3 +<view class="{{hasPage?'pages':'pages-window'}}">
  4 + <view class="title flex-lr">
  5 + <view class="title-name">您好,几位,什么时候</view>
  6 + <view class="close"></view>
7 </view> 7 </view>
8 <view> 8 <view>
9 - <pnum bindevent="pnumEvent"></pnum> 9 + <pnum bindevent="paramEvent" pi="{{pnum_pi}}"></pnum>
10 <view style="margin: 60rpx 0"> 10 <view style="margin: 60rpx 0">
11 - <date bindevent="dateEvent"></date> 11 + <date bindevent="paramEvent" pi="{{pnum_pi}}"></date>
12 </view> 12 </view>
13 - <dur></dur> 13 + <dur bindevent="paramEvent" pi="{{dur_pi}}"></dur>
14 </view> 14 </view>
15 - <view class="button" bindtap></view>  
16 </view> 15 </view>
  16 +<view class="submit" bindtap="submit">查找餐厅</view>
17 17
1 -/* components/reserve/search/how/index.wxss */  
  1 +/* components/reserve/search/how/index.wxss */
  2 +@import "../../../../app.wxss";
  3 +.pages{
  4 + padding: 20rpx 0;
  5 +}
  6 +.pages-window{
  7 + padding: 58rpx 0;
  8 + border-radius:20rpx 20rpx 0 0;
  9 +}
  10 +.pages .close{
  11 + display: none;
  12 +}
  13 +.title{
  14 + height:48rpx;
  15 + font-size:34rpx;
  16 + font-weight:600;
  17 + color:rgba(53,53,53,1);
  18 + line-height:48rpx;
  19 + padding: 0 40rpx;
  20 + width: calc(100% - 80rpx);
  21 + margin-bottom: 60rpx;
  22 +}
  23 +.close{
  24 + background-image: url("http://qn.colorcun.com/reserve/images/close.png");
  25 + background-size: 100% 100%;
  26 + width: 32rpx;
  27 + height: 32rpx;
  28 +}
  29 +.submit{
  30 + height:80rpx;
  31 + background:rgba(192,163,105,1);
  32 + border-radius:10rpx;
  33 + font-size:32rpx;
  34 + font-weight:500;
  35 + color:rgba(255,255,255,1);
  36 + line-height:80rpx;
  37 + text-align: center;
  38 + margin: 0 40rpx;
  39 + width: calc(100% - 80rpx);
  40 + position: fixed;
  41 + bottom: 80rpx;
  42 +}
1 <!--components/reserve/search/how/hv/pnum.wxml--> 1 <!--components/reserve/search/how/hv/pnum.wxml-->
2 -<swiper previous-margin="20rpx" next-margin="20rpx" 2 +<swiper previous-margin="35rpx" next-margin="45rpx"
3 class="tabs" 3 class="tabs"
4 display-multiple-items="5"> 4 display-multiple-items="5">
5 <swiper-item wx:for="{{items}}" wx:key="items"> 5 <swiper-item wx:for="{{items}}" wx:key="items">
@@ -199,7 +199,7 @@ @@ -199,7 +199,7 @@
199 </view> 199 </view>
200 <view class="reserve reserve-click flex-vc"> 200 <view class="reserve reserve-click flex-vc">
201 <formids class="flex-vc" bindclick="reserveEvent" id="reserve-button"> 201 <formids class="flex-vc" bindclick="reserveEvent" id="reserve-button">
202 - <view class="text">{{hasOnlineReserve?'包间预订':'联系餐厅'}}</view> 202 + <view class="text">{{hasOnlineReserve?'订包间':'联系餐厅'}}</view>
203 </formids> 203 </formids>
204 </view> 204 </view>
205 205
@@ -58,6 +58,6 @@ Page({ @@ -58,6 +58,6 @@ Page({
58 }, 58 },
59 59
60 howEvent(e){ 60 howEvent(e){
61 - console.log(e) 61 + console.log('howEvent',e)
62 }, 62 },
63 }) 63 })