card.js
3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// components/2.0/reserve/card.js
import util from '../../../utils/util';
import App from '../../../utils/api';
import RS from '../../../utils/reserveStatus'
Component({
/**
* 组件的属性列表
*/
properties: {
detail:Object,
tabType:Number
},
/**
* 组件的初始数据
*/
data: {
},
attached(){
//this.init()
},
observers: {
'detail': function() {
this.init()
},
},
/**
* 组件的方法列表
*/
methods: {
init(){
let detail=RS.reserve(this.data.detail)
console.log('detail.init',detail)
let tableSubInfo = ''
let tableFirst = '';
if (detail.tableFirst) {
tableSubInfo = (detail.tableFirst || '') + ' ' + (detail.tableSubInfo || '');
tableFirst = detail.tableFirst
} else if(detail.tables && detail.tables.length>0) {
tableFirst = detail.tables[0].name
tableSubInfo = detail.tables[0].name;
if (detail.tables.length > 1) {
tableSubInfo += ' 等' + (detail.tables.length) + '个'
+ (detail.tables[0].tid == 2 ? '包间' : '');
tableFirst += '等';
}
}
detail.tableFirst=tableFirst
detail.tableSubInfo=tableSubInfo
this.setData({
reserve:detail,
})
console.log('666666',detail);
if(this.data.tabType==6){
this.remark('auto');
}
},
openlocation(){
console.log('6666666')
wx.openLocation({
latitude:Number(this.data.reserve.seller.lat),
longitude:Number(this.data.reserve.seller.long),
scale: 18
})
},
remark(action='click'){
App.Customer.CheckIsComment({rid:this.data.reserve.id}).then(res => {
console.log('66666fffffff',res)
this.setData({
hasComment:res.data!=1,//已评论
})
if(action.type=="tap"){
if(res.data==0){
wx.navigateTo({
url:'/pages/pinglun/create?sid='+this.data.reserve.seller.id+'&oid='+this.data.reserve.id+'&sellername='+this.data.reserve.seller.sellername
})
}else{
wx.showToast({
title:'该订单已评论',
icon:'none'
})
}
}
})
},
cookbook() {
if (this.data.reserve.order && this.data.reserve.order.cookbooklist.length > 0) {
wx.navigateTo({
url: util.http_build_query({
rid: this.data.reserve.id,
oid: this.data.reserve.order.id,
identity: 1
}, '/pack-cookbook/pages/success')
});
} else {
App.Advance.CreateOrder({
rid: this.data.reserve.id,
openid: getApp().openid,
}).then(res => {
if (res.ret != 200) {
return util.toast(res.msg, 'none')
}
wx.navigateTo({
url: util.http_build_query({
rid: this.data.reserve.id,
oid: res.data.id,
identity: 1,
sid: res.data.sellerid
}, '/pack-cookbook/pages/index')
});
})
}
},
checkout(){
if(this.data.reserve.status==0){
this.selectComponent('#showModal').options({
header: '您点早啦!',
body: '商家分配包间后,您可以通过在线买单支付,无需到前台结账排队等发票。'
}).show();
}else{
wx.navigateTo({
url:util.http_build_query({
rid:this.data.reserve.id,
sid:this.data.reserve.seller.id
},'/pack-checkout/pages/index')
})
}
},
}
})