detail_owner.js
3.97 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// pages/customer/detail_owner.js
import util from '../../utils/util';
import App from '../../utils/api';
const {regeneratorRuntime} = global
import TP from '../../utils/tpls';
Page({
/**
* 页面的初始数据
*/
data: {
detail:null,
},
id:null,
tpls:TP.tpls(),
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.id=options.id;
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
App.Reserve.Detail({
openid: getApp().openid,
rid: this.id
}).then(res => {
this.setData({
detail:this.formatDatail(res.data)
})
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (e) {
console.log('onShareAppMessage',arguments)
return this.shareSetting(e);
},
formatDatail(detail){
detail.rdateStr=util.unixtoTime(detail.ddate,'MM月DD日 WW HH:II');
detail.tableFirst=detail.tables[0].name;
if(detail.tables.length>1){
detail.tableSubInfo='等'+(detail.tables.length)+'个'
+(detail.tables[0].tid==2?'包间':'');
}
// if(!detail.cusman){
// detail.cusman='vking';
// detail.cusman_phone='15877556369';
// detail.cusman_account='wx:vking';
// }
let ns=new Date()/1000
detail.hasCancel=detail.status==4
detail.hasOvered=false
if(!detail.hasCancel){
detail.hasOvered=ns>detail.ddate || detail.status>=2
}
return detail;
},
showManager(){
this.selectComponent('#manager').show();
},
lookLocation:function(){
wx.openLocation({
latitude:Number(this.data.detail.seller.lat),
longitude:Number(this.data.detail.seller.long),
scale:17,
address:this.data.detail.seller.map_address,
success:function (res) {
console.log(res)
}
})
},
userinfo(e){
console.log('userinfo',e)
util.toast('授权成功,可以继续转发','none');
// wx.navigateTo({
// url:'invite?id='+this.id,
// });
},
shareSetting(e){
console.log('shareSetting',e.target.dataset);
let hasInvitation=e.target.dataset.act=='invitation';
if (this.topicVal && this.data.detail.openid == getApp().openid) {
App.Reserve.SetTopicFromShare({
rid: this.id,
topic: this.topicVal
})
}
let nickname = "";
try {
nickname = util.cache('userInfo').nickName;
} catch (e) {
}
let obj={
//title: (nickname || '') + '给你发了一个邀请,点击查看',
title: this.tpls[0].shareTitle,
path: '/pages/customer/index?id=' + this.id + '&fromid=' + getApp().openid + '&invite_name=' + nickname+'&hasInvitation=1&tplid=1',
imageUrl: this.tpls[0].shareImage,
}
if(hasInvitation){
//obj.title=(nickname || '') + '给你发了一个邀请函,点击查看';
obj.path=obj.path+'&hasInvitation=1';
}
return obj;
},
cookbook(){
if(this.data.detail.order && this.data.detail.order.cookbooklist.length>0){
wx.navigateTo({
url:util.http_build_query({rid:this.id,oid:this.data.detail.order.id,identity:1},'/pack-cookbook/pages/success')
});
}else{
App.Advance.CreateOrder({
rid:this.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.id,oid:res.data.id,identity:1,sid:res.data.sellerid},'/pack-cookbook/pages/index')
});
})
}
},
wineGo(){
util.toast('本区域暂无配送人员','none');
},
})