|
|
|
// components/seller-card/seller-card.js
|
|
|
|
import util from '../../utils/util';
|
|
|
|
|
|
|
|
Component({
|
|
|
|
options: {
|
|
|
|
multipleSlots: true // 在组件定义时的选项中启用多slot支持
|
|
|
|
},
|
|
|
|
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
|
|
|
|
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:"",
|
|
|
|
rdateStr: "",
|
|
|
|
tableSubInfo: "",
|
|
|
|
masterMan: "",
|
|
|
|
},
|
|
|
|
attached(){
|
|
|
|
attached() {
|
|
|
|
|
|
|
|
},
|
|
|
|
detached(){
|
|
|
|
},
|
|
|
|
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{
|
|
|
|
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){
|
|
|
|
let ns=new Date()/1000
|
|
|
|
obj.showStatusStr='已预订'
|
|
|
|
if(this.data.detail.status==4){
|
|
|
|
obj.showStatusStr='已取消'
|
|
|
|
}else if(this.data.detail.status>=2 || ns>this.data.detail.ddate){
|
|
|
|
obj.showStatusStr='已完成'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.setData(obj)
|
|
|
|
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 {
|
|
|
|
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) {
|
|
|
|
let ns = new Date() / 1000
|
|
|
|
obj.showStatusStr = '已预订'
|
|
|
|
if (this.data.detail.status == 4) {
|
|
|
|
obj.showStatusStr = '已取消'
|
|
|
|
} else if (this.data.detail.status >= 2 || ns > this.data.detail.ddate) {
|
|
|
|
obj.showStatusStr = '已完成'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}) |
...
|
...
|
|