|
@@ -1,246 +0,0 @@ |
|
|
// pages/spellDetail/index.js |
|
|
|
|
|
var config = require("../../config/config.js"); |
|
|
|
|
|
const Http = require("../../utils/HttpBasics"); |
|
|
|
|
|
const imgurl = require("../../utils/imgurl"); |
|
|
|
|
|
const {spellStatus} = require("../../utils/spell"); |
|
|
|
|
|
Page({ |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 页面的初始数据 |
|
|
|
|
|
*/ |
|
|
|
|
|
data: { |
|
|
|
|
|
tuanzhang: imgurl.tuanzhang.url, |
|
|
|
|
|
spellBg: imgurl.spellBg.url, |
|
|
|
|
|
position: imgurl.position.url, |
|
|
|
|
|
close03: imgurl.close03.url, |
|
|
|
|
|
paramData:null, |
|
|
|
|
|
data:null, |
|
|
|
|
|
clock: "00", |
|
|
|
|
|
day: "00", |
|
|
|
|
|
hour: "00", |
|
|
|
|
|
min: "00", |
|
|
|
|
|
sec: "00", |
|
|
|
|
|
spellStatusList: spellStatus, |
|
|
|
|
|
isMyself:false, |
|
|
|
|
|
showAlert:false |
|
|
|
|
|
}, |
|
|
|
|
|
gotoAgain(){ |
|
|
|
|
|
let data = this.data.data; |
|
|
|
|
|
wx.navigateTo({ |
|
|
|
|
|
url: `/pages/spellGroup/mySpellGroup/index?couponId=${data.couponId}&couponChannelId=${data.couponChannelId}`, |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
gotoshare(){ |
|
|
|
|
|
wx.navigateTo({ |
|
|
|
|
|
url: `/pages/spellGroup/mySpellGroup/index?orderId=${this.data.paramData.orderId}&couponId=${this.data.paramData.couponId}&orderGroupId=${this.data.paramData.orderGroupId}&couponChannelId=${this.data.paramData.couponChannelId}`, |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
gotoSearch(){ |
|
|
|
|
|
wx.navigateTo({ |
|
|
|
|
|
url: `/pages/spellGroup/spellGroup`, |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
|
|
*/ |
|
|
|
|
|
onLoad: function (options) { |
|
|
|
|
|
console.log(this.data.spellStatusList, options,7777777) |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
paramData:options |
|
|
|
|
|
}) |
|
|
|
|
|
this.getDetail(options); |
|
|
|
|
|
this.checkUser(options) |
|
|
|
|
|
// 关闭来自于左上角的分享 |
|
|
|
|
|
wx.hideShareMenu() |
|
|
|
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 判断用户是否已经在团中 |
|
|
|
|
|
*/ |
|
|
|
|
|
checkUser(options) { |
|
|
|
|
|
let that = this; |
|
|
|
|
|
Http.get({ |
|
|
|
|
|
url: config.api.queryAttendStatus, |
|
|
|
|
|
data: { |
|
|
|
|
|
id: options.orderGroupId, |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
console.log(res.data,3333333333) |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
isMyself: res.data.attend |
|
|
|
|
|
}) |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 去使用 |
|
|
|
|
|
*/ |
|
|
|
|
|
gotoUse() { |
|
|
|
|
|
wx.navigateTo({ |
|
|
|
|
|
url: `/pages/couponorder/index/index` |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 拼团状态字段转换 |
|
|
|
|
|
*/ |
|
|
|
|
|
changeSatus(status){ |
|
|
|
|
|
console.log(spellStatus,8888888) |
|
|
|
|
|
return spellStatus.filter(item=>item.value==status)[0].name; |
|
|
|
|
|
}, |
|
|
|
|
|
// 时间格式化输出,如11:03 25:19 每1s都会调用一次 |
|
|
|
|
|
dateformat(micro_second) { |
|
|
|
|
|
// 总秒数 |
|
|
|
|
|
var second = Math.floor(micro_second / 1000); |
|
|
|
|
|
// 天数 |
|
|
|
|
|
var day = Math.floor(second / 3600 / 24) < 10 ? "0" + Math.floor(second / 3600 / 24) : Math.floor(second / 3600 / 24); |
|
|
|
|
|
// 小时 |
|
|
|
|
|
var hr = Math.floor(second / 3600 % 24) < 10 ? "0" + Math.floor(second / 3600 % 24) : Math.floor(second / 3600 % 24); |
|
|
|
|
|
// 分钟 |
|
|
|
|
|
var min = Math.floor(second / 60 % 60) < 10 ? "0" + Math.floor(second / 60 % 60) : Math.floor(second / 60 % 60); |
|
|
|
|
|
// 秒 |
|
|
|
|
|
var sec = Math.floor(second % 60) < 10 ? "0" + Math.floor(second % 60) : Math.floor(second % 60); |
|
|
|
|
|
|
|
|
|
|
|
// return day + "天" + hr + "小时" + min + "分钟" + sec + "秒"; |
|
|
|
|
|
return { |
|
|
|
|
|
a1: day, |
|
|
|
|
|
b1: hr, |
|
|
|
|
|
c1: min, |
|
|
|
|
|
d1: sec |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
countdown(end_time) { |
|
|
|
|
|
let that = this; |
|
|
|
|
|
var EndTime = end_time; |
|
|
|
|
|
var NowTime = new Date().getTime(); |
|
|
|
|
|
var total_micro_second = EndTime - NowTime || []; |
|
|
|
|
|
// 渲染倒计时时钟 |
|
|
|
|
|
let obj = that.dateformat(total_micro_second); |
|
|
|
|
|
if (total_micro_second > 0) { |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
clock: obj, |
|
|
|
|
|
day: obj.a1, |
|
|
|
|
|
hour: obj.b1, |
|
|
|
|
|
min: obj.c1, |
|
|
|
|
|
sec: obj.d1, |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
clock: "00", |
|
|
|
|
|
day: "00", |
|
|
|
|
|
hour: "00", |
|
|
|
|
|
min: "00", |
|
|
|
|
|
sec: "00", |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
|
total_micro_second -= 1000; |
|
|
|
|
|
that.countdown(end_time); |
|
|
|
|
|
}, 1000) |
|
|
|
|
|
}, |
|
|
|
|
|
//关闭弹框 |
|
|
|
|
|
gotoClose(){ |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
showAlert:false |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
//跳转拼团列表 |
|
|
|
|
|
gotoSpellList(){ |
|
|
|
|
|
wx.navigateTo({ |
|
|
|
|
|
url: '/pages/spellGroup/spellGroup', |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
getDetail(){ |
|
|
|
|
|
let that = this; |
|
|
|
|
|
Http.get({ |
|
|
|
|
|
url: config.api.queryOrderGroupStatus, |
|
|
|
|
|
data: { |
|
|
|
|
|
orderId: this.data.paramData.orderId, |
|
|
|
|
|
couponId: this.data.paramData.couponId, |
|
|
|
|
|
id: this.data.paramData.orderGroupId |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
console.log(res,555555555) |
|
|
|
|
|
let data=res.data; |
|
|
|
|
|
data.statustext=that.changeSatus(data.status); |
|
|
|
|
|
if(data.status!=11){ |
|
|
|
|
|
that.countdown(data.expiredDate); |
|
|
|
|
|
} |
|
|
|
|
|
data.salePrice = (data.salePrice/100).toFixed(2) |
|
|
|
|
|
for (let i = 0; i < data.remainPeople;i++){ |
|
|
|
|
|
let a={}; |
|
|
|
|
|
data.userList.push(a) |
|
|
|
|
|
} |
|
|
|
|
|
if (res.data.couponStatus!=0){ |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
showAlert: true |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
data:res.data |
|
|
|
|
|
}) |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 生命周期函数--监听页面初次渲染完成 |
|
|
|
|
|
*/ |
|
|
|
|
|
onReady: function () { |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生命周期函数--监听页面显示 |
|
|
|
|
|
*/ |
|
|
|
|
|
onShow: function () { |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生命周期函数--监听页面隐藏 |
|
|
|
|
|
*/ |
|
|
|
|
|
onHide: function () { |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 生命周期函数--监听页面卸载 |
|
|
|
|
|
*/ |
|
|
|
|
|
onUnload: function () { |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作 |
|
|
|
|
|
*/ |
|
|
|
|
|
onPullDownRefresh: function () { |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 页面上拉触底事件的处理函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
onReachBottom: function () { |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 用户点击右上角分享 |
|
|
|
|
|
*/ |
|
|
|
|
|
// paramData |
|
|
|
|
|
onShareAppMessage: function (res) { |
|
|
|
|
|
if (res.from === 'button') { |
|
|
|
|
|
console.log(res, 3333333333333333333333) |
|
|
|
|
|
// 来自页面内转发按钮 |
|
|
|
|
|
let _this = this; |
|
|
|
|
|
return { |
|
|
|
|
|
title: '拼团', |
|
|
|
|
|
path: `/pages/index/index?couponId=${_this.data.data.couponId}&orderGroupId=${_this.data.data.orderGroupId}&couponChannelId=${_this.data.paramData.couponChannelId}&orderId=${_this.data.data.orderId}`, |
|
|
|
|
|
imageUrl: _this.data.data.coverImg, |
|
|
|
|
|
success: function (res) { |
|
|
|
|
|
// 转发成功 |
|
|
|
|
|
}, |
|
|
|
|
|
fail: function (res) { |
|
|
|
|
|
// 转发失败 |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log(res, 444444444444444444) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|