detail.js
4.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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// pages/reserve/detail.js
import util from '../../utils/util';
import App from '../../utils/api';
const {regeneratorRuntime} = global
import PubSub from '../../utils/PubSub'
Page({
/**
* 页面的初始数据
*/
data: {
seller:{},
IsCollectionSeller:false,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log('onLoad', options)
this.options=options
App.Customer.IsCollectionSeller({
sid:options.id,
openid:getApp().openid
}).then(res=>{
this.setData({
IsCollectionSeller:res.data,
})
})
},
GetSellerDetail(){
let options=this.options
App.Customer.GetSellerDetail({
sid:options.id,
lat:this.location.latitude,
lng:this.location.longitude,
}).then(res=>{
if(res.ret==200){
let seller=res.data
let seller_tel=[]
if(seller.seller_tel){
seller_tel=seller.seller_tel.split(',')
}else{
seller_tel=[seller.phone];
}
seller.seller_tel=seller_tel
seller.distance=parseInt(seller.distance);
if(seller.distance>1000){
seller.distanceStr=(seller.distance/1000).toFixed(2)+'公里'
}else{
seller.distanceStr=seller.distance+'米';
}
if(seller.envi_image.length<1){
seller.envi_image=['http://qn.colorcun.com/custom/lite-online/image/def-banner.png']
}
this.setData({
seller:seller,
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.selectComponent('#getpos').getPos();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
reserve(){
let seller_tel=this.data.seller.seller_tel
if(seller_tel.length<1) return util.toast('商家电话错误','none')
if(seller_tel.length==1){//只有一个电话
let phone=seller_tel[0].replace(/[^\d]/,'')
wx.makePhoneCall({
phoneNumber:phone
})
}else{
this.selectComponent('#as').show();
}
},
reservePhone(e){
if(e.detail.value){
let phone=e.detail.value.replace(/[^\d]/,'')
wx.makePhoneCall({
phoneNumber:phone
})
}
},
follow(){
let param={
sid:this.options.id,
openid:getApp().openid,
}
if(this.data.IsCollectionSeller){//已收藏
param.cancel=1
}
let hasFollow=!this.data.IsCollectionSeller
this.setData({
IsCollectionSeller:hasFollow
})
App.Customer.SetCollectionRel(param);
PubSub.emit(
'follow',
{
sid:this.options.id,
hasFollow:hasFollow,
}
)
},
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)
}
})
},
onpos(e){
console.log(e);
this.location=e.detail
this.GetSellerDetail();
},
reviweBanner(){
wx.previewImage({
current:this.data.seller.envi_image[this.data.current],
urls:this.data.seller.envi_image
})
},
reviweRoomImage(e){
wx.previewImage({
current:util.attr(e,'current'),
urls:this.data.seller.room_image
})
},
reviweDishesImage(e){
let urls=[];
this.data.seller.dishes.forEach(d=>{
if(d.image){
urls.push(d.image)
}
})
wx.previewImage({
current:util.attr(e,'current'),
urls:urls
})
},
})