afterchildbirthrecover.js
8.4 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
// pages/partneritem/afterchildbirthrecover/afterchildbirthrecover.js
const app = getApp();
var WxParse = require('../../../wxParse/wxParse.js');
Page({
/**
* 页面的初始数据
*/
data: {
//轮播图
imgUrls: [],
indicatorDots: false,
autoplay: false,
interval: 5000,
duration: 500,
currentTab: 0,
wd: '',
jd: '',
compareId: '',
detailInfo: [],
address: [],
common: '',
labelinfo: '',
number:'',
days: '',
hours: '',
minutes: '',
seconds: '',
secretary: false,
wxtary: '',
edit_img:[],
title:'',
name:'',
type:''
// disable:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
let compareId = options.compareId;
that.setData({
compareId: compareId,
name:options.name,
type:options.type
})
// 获取经纬度
wx.getLocation({
type: 'wgs84',
success: function (res) {
console.log(res)
var latitude = res.latitude
var longitude = res.longitude
that.setData({
wd: latitude, //纬度
jd: longitude //经度
})
that.getDetail(latitude, longitude);
}
})
},
// 获取服务详情
getDetail: function (latitude, longitude){
let that = this;
let url = "/api/portal/Compare/detail";
let params = {
lat: that.data.jd,
lng: that.data.wd,
compareId: that.data.compareId,
page:1
}
app.post(url, params).then((res) => {
console.log(res)
that.setData({
title: res.compare.title
})
wx.setNavigationBarTitle({
title: res.compare.title //页面切换,更换页面标题
})
let number = res.compare.surplus_time;
// 时间戳处理
var totalSecond = number;
var interval = setInterval(function () {
// 秒数
var second = totalSecond;
// 天数位
var day = Math.floor(second / 3600 / 24);
var dayStr = day.toString();
if (dayStr.length == 1) dayStr = '0' + dayStr;
// 小时位
var hr = Math.floor((second - day * 3600 * 24) / 3600);
var hrStr = hr.toString();
if (hrStr.length == 1) hrStr = '0' + hrStr;
// 分钟位
var min = Math.floor((second - day * 3600 * 24 - hr * 3600) / 60);
var minStr = min.toString();
if (minStr.length == 1) minStr = '0' + minStr;
// 秒位
var sec = second - day * 3600 * 24 - hr * 3600 - min * 60;
var secStr = sec.toString();
if (secStr.length == 1) secStr = '0' + secStr;
that.setData({
days: dayStr,
hours: hrStr,
minutes: minStr,
seconds: secStr,
});
totalSecond--;
if (totalSecond <=0) {
clearInterval(interval);
// wx.showToast({
// title: '活动已结束',
// });
// 倒计时结束
that.countDown();
that.setData({
days: '00',
hours: '00',
minutes: '00',
seconds: '00',
});
}
}.bind(this), 1000);
let comdate = res.common;
WxParse.wxParse('article', 'html', res.compare.content, that, 5)
let newaddress = res.compare.address;
for (var obj of newaddress){
let latng = obj.latng;
latng=latng.split(",");
obj.jingdu = latng[0];
obj.weidu=latng[1];
}
console.log(newaddress)
that.setData({
detailInfo: res.compare,
address: newaddress,
imgUrls: res.compare.banner.splice(0,5),
labelinfo: res.compare.tag,
common: comdate,
wxtary: res.secretary,
// edit_img: res.common.picArr
})
// console.log(that.data.edit_img)
}).catch((errMsg) => {})
},
// 倒计时结束调用
countDown: function(){
let that = this;
let url = "/api/portal/Compare/detail";
let params = {
compareId: that.data.compareId
}
app.post(url, params).then((res) => {
console.log(res)
// that.setData({
// disable:true
// })
console.log('倒计时结束');
}).catch((errMsg) => {})
},
viewImg(e) {
let that = this;
console.log(e)
let index = e.currentTarget.dataset.index;
let paridx = e.currentTarget.dataset.paridx
console.log(paridx)
let img = [];
for (var i = 0; i < that.data.common.length; i++) {
if (i == paridx) {
console.log(9090)
img = that.data.common[i].picArr;
}
}
console.log(img)
wx.previewImage({
current: img[index],
urls: img,
success: function (res) { },
fail: function (res) { },
complete: function (res) { },
})
},
//链接去地图
gotomap(e) {
let that = this;
let jingdu=e.currentTarget.dataset.jingdu;
let weidu=e.currentTarget.dataset.weidu;
let address=e.currentTarget.dataset.add;
let name=e.currentTarget.dataset.name
console.log(jingdu)
console.log(weidu)
wx.getLocation({//获取当前经纬度
type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息
success: function (res) {
wx.openLocation({//使用微信内置地图查看位置。
latitude: Number(weidu),//要去的纬度-地址
longitude: Number(jingdu),//要去的经度-地址
name: name, //打开后显示的地址名称
address: address //打开后显示的地址汉字
})
}
})
},
// 咨询客服
secreTap: function(){
let that = this;
that.setData({
secretary: true
})
},
// 关闭小秘书弹层
hideTap: function(){
let that = this;
that.setData({
secretary: false
})
},
// 一键复制
bindCopy: function () {
let that = this;
wx.setClipboardData({
data: that.data.wxtary,
success: function (res) {
console.log("复制成功")
}
})
},
// 点击切换
navbarTap: function (e) {
var that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
},
// 跳转到 确认订单
buyTap: function(e){
let compareId = e.currentTarget.dataset.compareid;
wx.navigateTo({
url: '../sureorder/sureorder?compareId=' + compareId,
})
},
//时间戳转换时间
toDate: function (number) {
let n = number * 1000;
let date = new Date(n);
let Y = date.getFullYear() + '/';
let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '/';
let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
return (Y + M + D)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
return {
title: that.data.title, // 转发后 所显示的title
// path: '/pages/home/buildtextdetail/buildtextdetail?buildid='+buildid+'&gettoken='+newtoken, // 相对的路径
path: '/pages/partneritem/afterchildbirthrecover/afterchildbirthrecover?compareId=' +this.data.compareId,//建档攻略分享1
// path:'',
success: (res) => { // 成功后要做的事情
console.log(res)
// console.log(res.shareTickets[0])
// console.log
// wx.getShareInfo({
// shareTicket: res.shareTickets[0],
// success: (res)=> {
// that.setData({
// isShow:true
// })
// console.log(that.setData.isShow)
// },
// fail: function (res) { console.log(res) },
// complete: function (res) { console.log(res) }
// })
},
fail: function (res) {
// 分享失败
console.log(res)
}
}
}
})