|
1
|
// pages/customer/detail_owner.js
|
1
|
// pages/customer/detail_owner.js
|
|
2
|
import util from '../../utils/util';
|
2
|
import util from '../../utils/util';
|
|
3
|
import App from '../../utils/api';
|
3
|
import App from '../../utils/api';
|
|
|
|
4
|
+
|
|
4
|
const {regeneratorRuntime} = global
|
5
|
const {regeneratorRuntime} = global
|
|
5
|
import TP from '../../utils/tpls';
|
6
|
import TP from '../../utils/tpls';
|
|
|
|
7
|
+
|
|
6
|
Page({
|
8
|
Page({
|
|
7
|
|
9
|
|
|
8
|
/**
|
10
|
/**
|
|
9
|
* 页面的初始数据
|
11
|
* 页面的初始数据
|
|
10
|
*/
|
12
|
*/
|
|
11
|
data: {
|
13
|
data: {
|
|
12
|
- detail:null,
|
14
|
+ detail: null,
|
|
|
|
15
|
+ hasOnlineReserve: false,
|
|
13
|
},
|
16
|
},
|
|
14
|
- id:null,
|
|
|
|
15
|
- tpls:TP.tpls(),
|
17
|
+ id: null,
|
|
|
|
18
|
+ tpls: TP.tpls(),
|
|
16
|
/**
|
19
|
/**
|
|
17
|
* 生命周期函数--监听页面加载
|
20
|
* 生命周期函数--监听页面加载
|
|
18
|
*/
|
21
|
*/
|
|
19
|
onLoad: function (options) {
|
22
|
onLoad: function (options) {
|
|
20
|
- this.id=options.id;
|
23
|
+ this.id = options.id;
|
|
21
|
},
|
24
|
},
|
|
22
|
|
25
|
|
|
23
|
/**
|
26
|
/**
|
|
@@ -31,81 +34,83 @@ Page({ |
|
@@ -31,81 +34,83 @@ Page({ |
|
31
|
* 生命周期函数--监听页面显示
|
34
|
* 生命周期函数--监听页面显示
|
|
32
|
*/
|
35
|
*/
|
|
33
|
onShow: function () {
|
36
|
onShow: function () {
|
|
34
|
- App.Reserve.Detail({
|
|
|
|
35
|
- openid: getApp().openid,
|
|
|
|
36
|
- rid: this.id
|
|
|
|
37
|
- }).then(res => {
|
|
|
|
38
|
- this.setData({
|
|
|
|
39
|
- detail:this.formatDatail(res.data)
|
|
|
|
40
|
- })
|
37
|
+ App.Reserve.Detail({
|
|
|
|
38
|
+ openid: getApp().openid,
|
|
|
|
39
|
+ rid: this.id
|
|
|
|
40
|
+ }).then(res => {
|
|
|
|
41
|
+ this.setData({
|
|
|
|
42
|
+ detail: this.formatDatail(res.data),
|
|
|
|
43
|
+ hasOnlineReserve:res.data.type==0,
|
|
41
|
})
|
44
|
})
|
|
|
|
45
|
+ })
|
|
42
|
},
|
46
|
},
|
|
43
|
|
47
|
|
|
44
|
/**
|
48
|
/**
|
|
45
|
* 生命周期函数--监听页面隐藏
|
49
|
* 生命周期函数--监听页面隐藏
|
|
46
|
*/
|
50
|
*/
|
|
47
|
onHide: function () {
|
51
|
onHide: function () {
|
|
48
|
-
|
52
|
+
|
|
49
|
},
|
53
|
},
|
|
50
|
|
54
|
|
|
51
|
/**
|
55
|
/**
|
|
52
|
* 生命周期函数--监听页面卸载
|
56
|
* 生命周期函数--监听页面卸载
|
|
53
|
*/
|
57
|
*/
|
|
54
|
onUnload: function () {
|
58
|
onUnload: function () {
|
|
55
|
-
|
59
|
+
|
|
56
|
},
|
60
|
},
|
|
57
|
|
61
|
|
|
58
|
/**
|
62
|
/**
|
|
59
|
* 用户点击右上角分享
|
63
|
* 用户点击右上角分享
|
|
60
|
*/
|
64
|
*/
|
|
61
|
onShareAppMessage: function (e) {
|
65
|
onShareAppMessage: function (e) {
|
|
62
|
- console.log('onShareAppMessage',arguments)
|
66
|
+ console.log('onShareAppMessage', arguments)
|
|
63
|
return this.shareSetting(e);
|
67
|
return this.shareSetting(e);
|
|
64
|
},
|
68
|
},
|
|
65
|
- formatDatail(detail){
|
|
|
|
66
|
- detail.rdateStr=util.unixtoTime(detail.ddate,'MM月DD日 WW HH:II');
|
|
|
|
67
|
- detail.tableFirst=detail.tables[0].name;
|
|
|
|
68
|
- if(detail.tables.length>1){
|
|
|
|
69
|
- detail.tableSubInfo='等'+(detail.tables.length)+'个'
|
|
|
|
70
|
- +(detail.tables[0].tid==2?'包间':'');
|
|
|
|
71
|
- }
|
|
|
|
72
|
- // if(!detail.cusman){
|
|
|
|
73
|
- // detail.cusman='vking';
|
|
|
|
74
|
- // detail.cusman_phone='15877556369';
|
|
|
|
75
|
- // detail.cusman_account='wx:vking';
|
|
|
|
76
|
- // }
|
|
|
|
77
|
- let ns=new Date()/1000
|
|
|
|
78
|
- detail.hasCancel=detail.status==4
|
|
|
|
79
|
- detail.hasOvered=false
|
|
|
|
80
|
- if(!detail.hasCancel){
|
|
|
|
81
|
- detail.hasOvered=ns>detail.ddate || detail.status>=2
|
69
|
+ formatDatail(detail) {
|
|
|
|
70
|
+ detail.rdateStr = util.unixtoTime(detail.ddate, 'MM月DD日 WW HH:II');
|
|
|
|
71
|
+ detail.tableFirst = detail.tables[0].name;
|
|
|
|
72
|
+ if (detail.tables.length > 1) {
|
|
|
|
73
|
+ detail.tableSubInfo = '等' + (detail.tables.length) + '个'
|
|
|
|
74
|
+ + (detail.tables[0].tid == 2 ? '包间' : '');
|
|
82
|
}
|
75
|
}
|
|
83
|
- return detail;
|
|
|
|
84
|
- },
|
|
|
|
85
|
- showManager(){
|
|
|
|
86
|
- this.selectComponent('#manager').show();
|
|
|
|
87
|
- },
|
|
|
|
88
|
- lookLocation:function(){
|
|
|
|
89
|
- wx.openLocation({
|
|
|
|
90
|
- latitude:Number(this.data.detail.seller.lat),
|
|
|
|
91
|
- longitude:Number(this.data.detail.seller.long),
|
|
|
|
92
|
- scale:17,
|
|
|
|
93
|
- address:this.data.detail.seller.map_address,
|
|
|
|
94
|
- success:function (res) {
|
|
|
|
95
|
- console.log(res)
|
|
|
|
96
|
- }
|
|
|
|
97
|
- })
|
|
|
|
98
|
- },
|
|
|
|
99
|
- userinfo(e){
|
|
|
|
100
|
- console.log('userinfo',e)
|
|
|
|
101
|
- util.toast('授权成功,可以继续转发','none');
|
|
|
|
102
|
- // wx.navigateTo({
|
|
|
|
103
|
- // url:'invite?id='+this.id,
|
|
|
|
104
|
- // });
|
|
|
|
105
|
- },
|
|
|
|
106
|
- shareSetting(e){
|
|
|
|
107
|
- console.log('shareSetting',e.target.dataset);
|
|
|
|
108
|
- let hasInvitation=e.target.dataset.act=='invitation';
|
76
|
+ // if(!detail.cusman){
|
|
|
|
77
|
+ // detail.cusman='vking';
|
|
|
|
78
|
+ // detail.cusman_phone='15877556369';
|
|
|
|
79
|
+ // detail.cusman_account='wx:vking';
|
|
|
|
80
|
+ // }
|
|
|
|
81
|
+ let ns = new Date() / 1000
|
|
|
|
82
|
+ detail.hasCancel = detail.status == 4
|
|
|
|
83
|
+ detail.hasOvered = false
|
|
|
|
84
|
+ if (!detail.hasCancel) {
|
|
|
|
85
|
+ detail.hasOvered = ns > detail.ddate || detail.status >= 2
|
|
|
|
86
|
+ }
|
|
|
|
87
|
+ detail.seller.seller_tel=detail.seller.seller_tel.split(',');
|
|
|
|
88
|
+ return detail;
|
|
|
|
89
|
+ },
|
|
|
|
90
|
+ showManager() {
|
|
|
|
91
|
+ this.selectComponent('#manager').show();
|
|
|
|
92
|
+ },
|
|
|
|
93
|
+ lookLocation: function () {
|
|
|
|
94
|
+ wx.openLocation({
|
|
|
|
95
|
+ latitude: Number(this.data.detail.seller.lat),
|
|
|
|
96
|
+ longitude: Number(this.data.detail.seller.long),
|
|
|
|
97
|
+ scale: 17,
|
|
|
|
98
|
+ address: this.data.detail.seller.map_address,
|
|
|
|
99
|
+ success: function (res) {
|
|
|
|
100
|
+ console.log(res)
|
|
|
|
101
|
+ }
|
|
|
|
102
|
+ })
|
|
|
|
103
|
+ },
|
|
|
|
104
|
+ userinfo(e) {
|
|
|
|
105
|
+ console.log('userinfo', e)
|
|
|
|
106
|
+ util.toast('授权成功,可以继续转发', 'none');
|
|
|
|
107
|
+ // wx.navigateTo({
|
|
|
|
108
|
+ // url:'invite?id='+this.id,
|
|
|
|
109
|
+ // });
|
|
|
|
110
|
+ },
|
|
|
|
111
|
+ shareSetting(e) {
|
|
|
|
112
|
+ console.log('shareSetting', e.target.dataset);
|
|
|
|
113
|
+ let hasInvitation = e.target.dataset.act == 'invitation';
|
|
109
|
if (this.topicVal && this.data.detail.openid == getApp().openid) {
|
114
|
if (this.topicVal && this.data.detail.openid == getApp().openid) {
|
|
110
|
App.Reserve.SetTopicFromShare({
|
115
|
App.Reserve.SetTopicFromShare({
|
|
111
|
rid: this.id,
|
116
|
rid: this.id,
|
|
@@ -117,39 +122,68 @@ Page({ |
|
@@ -117,39 +122,68 @@ Page({ |
|
117
|
nickname = util.cache('userInfo').nickName;
|
122
|
nickname = util.cache('userInfo').nickName;
|
|
118
|
} catch (e) {
|
123
|
} catch (e) {
|
|
119
|
}
|
124
|
}
|
|
120
|
- let obj={
|
125
|
+ let obj = {
|
|
121
|
//title: (nickname || '') + '给你发了一个邀请,点击查看',
|
126
|
//title: (nickname || '') + '给你发了一个邀请,点击查看',
|
|
122
|
title: this.tpls[0].shareTitle,
|
127
|
title: this.tpls[0].shareTitle,
|
|
123
|
- path: '/pages/customer/index?id=' + this.id + '&fromid=' + getApp().openid + '&invite_name=' + nickname+'&hasInvitation=1&tplid=1',
|
128
|
+ path: '/pages/customer/index?id=' + this.id + '&fromid=' + getApp().openid + '&invite_name=' + nickname + '&hasInvitation=1&tplid=1',
|
|
124
|
imageUrl: this.tpls[0].shareImage,
|
129
|
imageUrl: this.tpls[0].shareImage,
|
|
125
|
}
|
130
|
}
|
|
126
|
- if(hasInvitation){
|
131
|
+ if (hasInvitation) {
|
|
127
|
//obj.title=(nickname || '') + '给你发了一个邀请函,点击查看';
|
132
|
//obj.title=(nickname || '') + '给你发了一个邀请函,点击查看';
|
|
128
|
- obj.path=obj.path+'&hasInvitation=1';
|
133
|
+ obj.path = obj.path + '&hasInvitation=1';
|
|
129
|
}
|
134
|
}
|
|
130
|
return obj;
|
135
|
return obj;
|
|
131
|
},
|
136
|
},
|
|
132
|
- cookbook(){
|
|
|
|
133
|
- if(this.data.detail.order && this.data.detail.order.cookbooklist.length>0){
|
137
|
+ cookbook() {
|
|
|
|
138
|
+ if (this.data.detail.order && this.data.detail.order.cookbooklist.length > 0) {
|
|
134
|
wx.navigateTo({
|
139
|
wx.navigateTo({
|
|
135
|
- url:util.http_build_query({rid:this.id,oid:this.data.detail.order.id,identity:1},'/pack-cookbook/pages/success')
|
140
|
+ url: util.http_build_query({
|
|
|
|
141
|
+ rid: this.id,
|
|
|
|
142
|
+ oid: this.data.detail.order.id,
|
|
|
|
143
|
+ identity: 1
|
|
|
|
144
|
+ }, '/pack-cookbook/pages/success')
|
|
136
|
});
|
145
|
});
|
|
137
|
- }else{
|
146
|
+ } else {
|
|
138
|
App.Advance.CreateOrder({
|
147
|
App.Advance.CreateOrder({
|
|
139
|
- rid:this.id,
|
|
|
|
140
|
- openid:getApp().openid,
|
|
|
|
141
|
- }).then(res=>{
|
|
|
|
142
|
- if(res.ret!=200){
|
|
|
|
143
|
- return util.toast(res.msg,'none')
|
148
|
+ rid: this.id,
|
|
|
|
149
|
+ openid: getApp().openid,
|
|
|
|
150
|
+ }).then(res => {
|
|
|
|
151
|
+ if (res.ret != 200) {
|
|
|
|
152
|
+ return util.toast(res.msg, 'none')
|
|
144
|
}
|
153
|
}
|
|
145
|
wx.navigateTo({
|
154
|
wx.navigateTo({
|
|
146
|
- url:util.http_build_query({rid:this.id,oid:res.data.id,identity:1,sid:res.data.sellerid},'/pack-cookbook/pages/index')
|
155
|
+ url: util.http_build_query({
|
|
|
|
156
|
+ rid: this.id,
|
|
|
|
157
|
+ oid: res.data.id,
|
|
|
|
158
|
+ identity: 1,
|
|
|
|
159
|
+ sid: res.data.sellerid
|
|
|
|
160
|
+ }, '/pack-cookbook/pages/index')
|
|
147
|
});
|
161
|
});
|
|
148
|
})
|
162
|
})
|
|
149
|
}
|
163
|
}
|
|
150
|
|
164
|
|
|
151
|
},
|
165
|
},
|
|
152
|
- wineGo(){
|
|
|
|
153
|
- util.toast('本区域暂无配送人员','none');
|
166
|
+ wineGo() {
|
|
|
|
167
|
+ util.toast('本区域暂无配送人员', 'none');
|
|
|
|
168
|
+ },
|
|
|
|
169
|
+ callSeller(){
|
|
|
|
170
|
+ let seller_tel=this.data.detail.seller.seller_tel
|
|
|
|
171
|
+ if(seller_tel.length<1) return util.toast('商家电话错误','none')
|
|
|
|
172
|
+ if(seller_tel.length==1){//只有一个电话
|
|
|
|
173
|
+ let phone=seller_tel[0].replace(/[^\d]/,'')
|
|
|
|
174
|
+ wx.makePhoneCall({
|
|
|
|
175
|
+ phoneNumber:phone
|
|
|
|
176
|
+ })
|
|
|
|
177
|
+ }else{
|
|
|
|
178
|
+ this.selectComponent('#as').show();
|
|
|
|
179
|
+ }
|
|
|
|
180
|
+ },
|
|
|
|
181
|
+ callSellerPhone(e){
|
|
|
|
182
|
+ if(e.detail.value){
|
|
|
|
183
|
+ let phone=e.detail.value.replace(/[^\d]/,'')
|
|
|
|
184
|
+ wx.makePhoneCall({
|
|
|
|
185
|
+ phoneNumber:phone
|
|
|
|
186
|
+ })
|
|
|
|
187
|
+ }
|
|
154
|
},
|
188
|
},
|
|
155
|
}) |
189
|
}) |