seller-card.js
2.72 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
// components/seller-card/seller-card.js
import util from '../../utils/util';
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
}
},
/**
* 组件的初始数据
*/
data: {
rdateStr:"",
tableSubInfo:"",
masterMan:"",
},
attached(){
},
detached(){
},
/**
* 组件的方法列表
*/
methods: {
init(){
if(this.data.detail && this.data.detail.rdate){
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=''
if(this.data.detail.tableFirst){
tableSubInfo=(this.data.detail.tableFirst||'')+' '+(this.data.detail.tableSubInfo||'');
}else{
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?'包间':'');
}
}
let obj={
rdateStr:util.unixtoTime(this.data.detail.rdate,'MM月DD日 HH:II'),
tableSubInfo:tableSubInfo,
masterMan:masterMan,
}
if(this.data.hasShowStatus){
let ns=new Date()/1000
obj.showStatusStr=ns>this.data.detail.rdate?'已结束':'已预定';
}
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)
}
})
},
}
})