seller-card.js
3.08 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
// components/seller-card/seller-card.js
import util from '../../utils/util';
import RS from '../../utils/reserveStatus'
Component({
options: {
multipleSlots: true // 在组件定义时的选项中启用多slot支持
},
/**
* 组件的属性列表
*/
properties: {
seller: Object,
detail: {
type: Object,
value: {},
observer: function () {
//console.log('observer', arguments);
this.init();
}
},
hasMaster: { //预订人+手机
type: Boolean,
value: false
},
hasListShare: { //首页列表的预订人+分享
type: Boolean,
value: false
},
hasShowStatus: { //右上角显示状态
type: Boolean,
value: false
},
hasAddress: { //显示地址,默认显示
type: Boolean,
value: true
},
hasOnlineReserve:{ //是否为在线预订卡片
type: Boolean,
value: false
},
},
/**
* 组件的初始数据
*/
data: {
rdateStr: "",
tableSubInfo: "",
masterMan: "",
},
attached() {
},
detached() {
},
/**
* 组件的方法列表
*/
methods: {
init() {
if (this.data.detail && this.data.detail.ddate) {
let masterMan = (this.data.detail.rname || '');
if (this.data.detail.phone) {
masterMan += ' (' +
this.data.detail.phone
.replace(/([\d]{2}).*([\d]{4})/, function ($0, $1, $2) {
return $1 + '*' + $2
})
+ ')';
}
let tableSubInfo = ''
let tableFirst = '';
if (this.data.detail.tableFirst) {
tableSubInfo = (this.data.detail.tableFirst || '') + ' ' + (this.data.detail.tableSubInfo || '');
tableFirst = this.data.detail.tableFirst
} else if(this.data.detail.tables && this.data.detail.tables.length>0) {
tableFirst = this.data.detail.tables[0].name
tableSubInfo = this.data.detail.tables[0].name;
if (this.data.detail.tables.length > 1) {
tableSubInfo += ' 等' + (this.data.detail.tables.length) + '个'
+ (this.data.detail.tables[0].tid == 2 ? '包间' : '');
tableFirst += '等';
}
}
let obj = {
rdateStr: util.unixtoTime(this.data.detail.ddate, 'MM月DD日 HH:II'),
tableSubInfo: tableSubInfo,
tableFirst: tableFirst,
masterMan: masterMan,
}
if (this.data.hasShowStatus) {
obj.showStatusStr = RS.reserve(this.data.detail).getStatusStr;
}
this.setData(obj)
}
},
lookLocation: function () {
//console.log(this.data.seller.lat,this.data.seller.long,this.data.detail.map_address)
wx.openLocation({
latitude: Number(this.data.seller.lat),
longitude: Number(this.data.seller.long),
scale: 17,
address: this.data.seller.map_address,
success: function (res) {
console.log(res)
}
})
},
tapEvent(){
this.triggerEvent('event',{
act:'gotoDetail',
detail:this.data.detail,
})
},
}
})