Commit fa4c00dd3bbc287e6e8c0bdd28c852038fde73ba

Authored by wangfan
2 parents 18a9fe28 0bd9aafe

Merge remote-tracking branch 'remotes/origin/master-moretable'

1 -<!--components/reserve/caixi.wxml-->  
2 -<cover-view class="mask" catchtap="hide" hidden="{{hidden}}">  
3 - <cover-view class="caixi" catchtap="">  
4 - <cover-view class="caixi-title flex-lr" catchtap="hide">  
5 - <cover-view class="close"></cover-view>  
6 - <cover-view class="title Semibold">选择菜系</cover-view>  
7 - <cover-view class="close">  
8 - <cover-image src="http://qn.colorcun.com/reserve/images/%E5%85%B3%20%20%E9%97%AD.png"></cover-image>  
9 - </cover-view>  
10 - </cover-view>  
11 - <cover-view class="caixi-view flex-auto-ll">  
12 - <cover-view class="item {{index==multiIndex[0]?'active':''}}"  
13 - bindtap="active" data-index="{{index}}"  
14 - wx:for="{{multiArray[0]}}" wx:key="multiArray.key">  
15 - {{item}}  
16 - <cover-image class="number" wx:if="{{index>=1 && index<4}}" src="http://qn.colorcun.com/reserve/images/cx{{index}}.png"></cover-image>  
17 - </cover-view>  
18 - </cover-view>  
19 - </cover-view>  
20 -</cover-view>  
@@ -2,7 +2,11 @@ var util = require('../../../../utils/util') @@ -2,7 +2,11 @@ var util = require('../../../../utils/util')
2 var uri = require('../../../../utils/uri'); 2 var uri = require('../../../../utils/uri');
3 Component({ 3 Component({
4 properties: { 4 properties: {
5 - list: Array 5 + list: Array,
  6 + checkedTids:{
  7 + type:String,
  8 + value:"",
  9 + },
6 }, 10 },
7 data: {}, 11 data: {},
8 methods: { 12 methods: {
@@ -12,8 +16,11 @@ Component({ @@ -12,8 +16,11 @@ Component({
12 var list = this.data.list; 16 var list = this.data.list;
13 var pages = getCurrentPages(); 17 var pages = getCurrentPages();
14 var addnewPage=pages[pages.length - 2]; 18 var addnewPage=pages[pages.length - 2];
  19 + let checkedTids=this.data.checkedTids.split(',');
15 list.forEach(function (v, i) { 20 list.forEach(function (v, i) {
16 if (v.id == tebleid) { 21 if (v.id == tebleid) {
  22 + console.log('click.board',v);
  23 + if(v.status_str && checkedTids._indexOf(v.id)<0) return util.toast('不能预订该桌位','none');
17 if (v.isselect == true) { 24 if (v.isselect == true) {
18 var thisindex = tables.indexOf(tebleid); 25 var thisindex = tables.indexOf(tebleid);
19 tables.splice(thisindex, 1) 26 tables.splice(thisindex, 1)
@@ -123,7 +123,7 @@ @@ -123,7 +123,7 @@
123 <view class="page" style="margin-top: 0"> 123 <view class="page" style="margin-top: 0">
124 <view class="title flex-lr"> 124 <view class="title flex-lr">
125 <view>可订桌位<text wx:if="{{tables.length>0}}"> ({{tablesLength}})</text></view> 125 <view>可订桌位<text wx:if="{{tables.length>0}}"> ({{tablesLength}})</text></view>
126 - <view class="flex-rr advice-more" bindtap="selectdesk" wx:if="{{tablesLength>1}}"> 126 + <view class="flex-rr advice-more" bindtap="selectdesk">
127 <view style="padding-right:20rpx;" class="gray-deep-font font26r">更多</view> 127 <view style="padding-right:20rpx;" class="gray-deep-font font26r">更多</view>
128 <image src="http://qn.colorcun.com/custom/lite-yd/image/click.png" class="icon12-22"></image> 128 <image src="http://qn.colorcun.com/custom/lite-yd/image/click.png" class="icon12-22"></image>
129 </view> 129 </view>
@@ -3,77 +3,81 @@ import comm from '../../../utils/bookCommon'; @@ -3,77 +3,81 @@ import comm from '../../../utils/bookCommon';
3 import App from '../../../utils/api'; 3 import App from '../../../utils/api';
4 const {regeneratorRuntime} = global 4 const {regeneratorRuntime} = global
5 Page({ 5 Page({
6 - data:{  
7 - menu_active_id:''  
8 - },  
9 - checked_tids:[],  
10 - desks:[],  
11 - onLoad:function(opt){  
12 - console.log('onLoad',opt)  
13 - util.setBarTitle('选择桌位');  
14 - var radio=750/util.getsystem().windowWidth;  
15 - var contentHeight=util.getsystem().windowHeight-Math.ceil(350/radio);  
16 - if(opt.tid==0){  
17 - delete opt.tid  
18 - }  
19 - if(opt.checked_tids){  
20 - this.checked_tids=opt.checked_tids.split(',')  
21 - util.cache('tableid',this.checked_tids)  
22 - }  
23 - this.setData({  
24 - sellerid:util.cache('sellerid'),  
25 - opt:opt,  
26 - hasCheckedTable:this.checked_tids.length>0  
27 - })  
28 - this.getdesklist();  
29 - },  
30 - onShow:function(){  
31 - this.setData({  
32 - height:getApp().system.windowHeight-55  
33 - })  
34 - },  
35 - changedesk:function(e){  
36 - let tableid=util.cache('tableid');  
37 - this.checked_tids= tableid && tableid.length>0?tableid:[];  
38 - this.setData({  
39 - hasCheckedTable:this.checked_tids.length>0  
40 - })  
41 - },  
42 - back:function(){  
43 - this.setData({  
44 - buttonClick:true  
45 - })  
46 - //wx.removeStorage({key:'tableid'})  
47 - wx.navigateBack();  
48 - },  
49 - getdesklist:function(){  
50 - var formdata=this.data.opt;  
51 - formdata.sid=this.data.sellerid;  
52 - var that=this;  
53 - App.Reserve.GetTableList(formdata).then(function (json) {  
54 - if(json.ret==200){  
55 - console.log('this.checked_tids',that.checked_tids);  
56 - that.desks=json.data  
57 - that.formatDesklist(true)  
58 - }  
59 - })  
60 - },  
61 - formatDesklist(hasFirst=true){  
62 - let desks=this.desks;  
63 - if(desks.length>0){  
64 - desks.forEach((v,i)=>{  
65 - v.list.forEach((r,n)=>{  
66 - r.isselect=false  
67 - if(this.checked_tids._indexOf(r.id)>-1){  
68 - r.isselect=true; 6 + data: {
  7 + menu_active_id: ''
  8 + },
  9 + checked_tids: [],
  10 + desks: [],
  11 + sellerid:'',
  12 + options:null,
  13 + onLoad: function (opt) {
  14 + console.log('onLoad', opt)
  15 + this.options=opt;
  16 + var radio = 750 / util.getsystem().windowWidth;
  17 + var contentHeight = util.getsystem().windowHeight - Math.ceil(350 / radio);
  18 + if (opt.tid == 0) {
  19 + delete opt.tid
  20 + }
  21 + if (opt.checked_tids) {
  22 + this.checked_tids = opt.checked_tids.split(',')
  23 + util.cache('tableid', this.checked_tids)
  24 + }
  25 + this.sellerid=util.cache('sellerid');
  26 + this.setData({
  27 + sellerid: this.sellerid,
  28 + opt: opt,
  29 + hasCheckedTable: this.checked_tids.length > 0
  30 + })
  31 + //this.getdesklist();
  32 + this.getDeskList();
  33 + },
  34 + onShow: function () {
  35 + this.setData({
  36 + height: getApp().system.windowHeight - 55
  37 + })
  38 + },
  39 + changedesk: function (e) {
  40 + let tableid = util.cache('tableid');
  41 + this.checked_tids = tableid && tableid.length > 0 ? tableid : [];
  42 + this.setData({
  43 + hasCheckedTable: this.checked_tids.length > 0
  44 + })
  45 + },
  46 + back: function () {
  47 + this.setData({
  48 + buttonClick: true
  49 + })
  50 + //wx.removeStorage({key:'tableid'})
  51 + wx.navigateBack();
  52 + },
  53 + getdesklist: function () {
  54 + var formdata = this.data.opt;
  55 + formdata.sid = this.data.sellerid;
  56 + var that = this;
  57 + App.Reserve.GetTableList(formdata).then(function (json) {
  58 + if (json.ret == 200) {
  59 + console.log('this.checked_tids', that.checked_tids);
  60 + that.desks = json.data
  61 + that.formatDesklist(true)
  62 + }
  63 + })
  64 + },
  65 + formatDesklist(hasFirst = true){
  66 + let desks = this.desks;
  67 + if (desks.length > 0) {
  68 + desks.forEach((v, i) => {
  69 + v.list.forEach((r, n) => {
  70 + r.isselect = false
  71 + if (this.checked_tids._indexOf(r.id) > -1) {
  72 + r.isselect = true;
69 } 73 }
70 }) 74 })
71 }) 75 })
72 - let param={  
73 - desklist:desks, 76 + let param = {
  77 + desklist: desks,
74 } 78 }
75 - if(hasFirst){  
76 - param.menu_active_id=desks[0].name 79 + if (hasFirst) {
  80 + param.menu_active_id = desks[0].name
77 } 81 }
78 this.setData(param) 82 this.setData(param)
79 } 83 }
@@ -83,7 +87,85 @@ Page({ @@ -83,7 +87,85 @@ Page({
83 87
84 this.formatDesklist(false) 88 this.formatDesklist(false)
85 this.setData({ 89 this.setData({
86 - menu_active_id:util.attr(e,'id') 90 + menu_active_id: util.attr(e, 'id')
  91 + })
  92 + },
  93 + getDeskList(){
  94 + App.Tables.GetTableListsBySellerId({
  95 + sellerid:this.sellerid
  96 + }).then((res)=>{
  97 + this.desks=res.data[0];
  98 + this.getbooklist();
  99 + })
  100 + },
  101 + async getbooklist(){
  102 + let obj={};
  103 +
  104 + let formdata={};
  105 + formdata.sid=this.sellerid;
  106 + formdata.x=1;
  107 + formdata.y=200;
  108 + formdata.rdate=this.options.rdate;
  109 + formdata.status='1,2';
  110 + let tids={};
  111 + let reserves=await App.Reserve.GetReserveList(formdata);
  112 + if(reserves.data.length>0){
  113 + reserves.data.forEach(r=>{
  114 + let ts=r.tid.split(',');
  115 + ts.forEach(tid=>{
  116 + let rname='';
  117 + if(r.sex==3){
  118 + rname=r.rname.substr(0,10)
  119 + }else{
  120 + rname=r.rname.substr(0,1)+(r.sex==1?'先生':'女士')
  121 + }
  122 + tids[tid]={
  123 + rdate:r.rdate,
  124 + id:r.id,
  125 + status:r.status,
  126 + rname:rname,
  127 + }
  128 + })
  129 + })
  130 + }
  131 + console.log('tids',tids);
  132 + let regions=[];
  133 + this.desks.forEach(region=>{
  134 + if(region.list.length>0){
  135 + let list_num=0;
  136 + region.list.forEach(tb=>{
  137 + tb.status_str='';
  138 + tb.status_classname='enabled'
  139 + tb.reserve_name=''
  140 + tb.reserve_id=''
  141 + if(tb.status!=0 && tb.status!=""){
  142 + tb.status_str='用餐中';
  143 + tb.status_classname='highlight';
  144 + tb.reserve_name=tb.spell==1?'拼桌':'堂食';
  145 + }else if(tids[tb.id]){
  146 + console.log('tids',region.name,tb.name);
  147 + tb.status_str=tids[tb.id].status==2?'用餐中':'已预订';
  148 + tb.status_classname='highlight';
  149 + tb.reserve_id=tids[tb.id].id;
  150 + tb.reserve_name=tids[tb.id].rname;
  151 + }
  152 + if(tb.enable!=1){
  153 + if(tb.status_str){
  154 + tb.status_classname='disabled-highlight';
  155 + }else{
  156 + tb.status_str='已停用';
  157 + tb.status_classname='disabled';
  158 + }
  159 + }
  160 + if(!tb.status_str){
  161 + list_num++;
  162 + }
  163 + region.list_num=list_num;
  164 + })
  165 + regions.push(region);
  166 + }
87 }) 167 })
  168 + this.desks=regions
  169 + this.formatDesklist(true);
88 }, 170 },
89 }) 171 })
@@ -11,7 +11,9 @@ @@ -11,7 +11,9 @@
11 </view> 11 </view>
12 <view style="height: {{height-80}}px;overflow-y: auto;padding-bottom: 160rpx;overflow-x: hidden;width: 100%;"> 12 <view style="height: {{height-80}}px;overflow-y: auto;padding-bottom: 160rpx;overflow-x: hidden;width: 100%;">
13 <block wx:for="{{desklist}}" wx:key="desklist.key"> 13 <block wx:for="{{desklist}}" wx:key="desklist.key">
14 - <orderDesk list="{{item.list}}" bind:changedesk="changedesk" wx:if="{{item.name==menu_active_id}}"></orderDesk> 14 + <orderDesk list="{{item.list}}" checkedTids="{{opt.checked_tids}}"
  15 + bind:changedesk="changedesk"
  16 + wx:if="{{item.name==menu_active_id}}"></orderDesk>
15 </block> 17 </block>
16 18
17 </view> 19 </view>
@@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
44 "list": [] 44 "list": []
45 }, 45 },
46 "miniprogram": { 46 "miniprogram": {
47 - "current": 52, 47 + "current": 53,
48 "list": [ 48 "list": [
49 { 49 {
50 "id": 0, 50 "id": 0,
@@ -440,6 +440,13 @@ @@ -440,6 +440,13 @@
440 "pathName": "pages/reserve/indexList", 440 "pathName": "pages/reserve/indexList",
441 "query": "lat=34.21719&lng=108.89155&map={\"errMsg\":\"getMapRegion:ok\",\"southwest\":{\"longitude\":108.87545674591064,\"latitude\":34.204520114013846},\"northeast\":{\"longitude\":108.90764325408935,\"latitude\":34.229857981005225},\"scale\":15}&multiIndex=1&tags=1,2", 441 "query": "lat=34.21719&lng=108.89155&map={\"errMsg\":\"getMapRegion:ok\",\"southwest\":{\"longitude\":108.87545674591064,\"latitude\":34.204520114013846},\"northeast\":{\"longitude\":108.90764325408935,\"latitude\":34.229857981005225},\"scale\":15}&multiIndex=1&tags=1,2",
442 "scene": null 442 "scene": null
  443 + },
  444 + {
  445 + "id": 53,
  446 + "name": "选择更多桌位",
  447 + "pathName": "pack-book/pages/book/b_desk",
  448 + "query": "rdate=1559617200-1559631600&tid=0&pnum=6&checked_tids=760,761&rid=",
  449 + "scene": null
443 } 450 }
444 ] 451 ]
445 } 452 }