|
@@ -17,9 +17,9 @@ Page({ |
|
|
min: null, |
|
|
min: null, |
|
|
sec: null, |
|
|
sec: null, |
|
|
showPage: false, |
|
|
showPage: false, |
|
|
discountStatus:null, |
|
|
|
|
|
disabled:false, |
|
|
|
|
|
display:"block!important", |
|
|
|
|
|
|
|
|
discountStatus: null, |
|
|
|
|
|
disabled: false, |
|
|
|
|
|
display: "block!important", |
|
|
showButton: false |
|
|
showButton: false |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@@ -44,13 +44,13 @@ Page({ |
|
|
} |
|
|
} |
|
|
this.getUserInfo() |
|
|
this.getUserInfo() |
|
|
}, |
|
|
}, |
|
|
getUserInfo: function () { |
|
|
|
|
|
|
|
|
getUserInfo: function() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
// 获取用户信息 |
|
|
// 获取用户信息 |
|
|
Http.get({ |
|
|
Http.get({ |
|
|
url: config.api.getScore, |
|
|
|
|
|
data: {} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
url: config.api.getScore, |
|
|
|
|
|
data: {} |
|
|
|
|
|
}) |
|
|
.then(res => { |
|
|
.then(res => { |
|
|
console.log(res) |
|
|
console.log(res) |
|
|
that.setData({ |
|
|
that.setData({ |
|
@@ -59,19 +59,19 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
onShow: function () { |
|
|
|
|
|
|
|
|
onShow: function() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
console.log("--------------------------------onShow-------------------------------") |
|
|
console.log("--------------------------------onShow-------------------------------") |
|
|
var todayDate = new Date().getTime(); |
|
|
var todayDate = new Date().getTime(); |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
todayDate: todayDate, |
|
|
todayDate: todayDate, |
|
|
showButton:false |
|
|
|
|
|
|
|
|
showButton: false |
|
|
}) |
|
|
}) |
|
|
if(that.data.pressEndDate){ |
|
|
|
|
|
|
|
|
if (that.data.pressEndDate) { |
|
|
that.countdown(that.data.pressEndDate) |
|
|
that.countdown(that.data.pressEndDate) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
goback:function(){ |
|
|
|
|
|
|
|
|
goback: function() { |
|
|
wx.switchTab({ |
|
|
wx.switchTab({ |
|
|
url: '/pages/main/index', |
|
|
url: '/pages/main/index', |
|
|
}) |
|
|
}) |
|
@@ -138,7 +138,7 @@ Page({ |
|
|
.then(res => { |
|
|
.then(res => { |
|
|
console.log(res); |
|
|
console.log(res); |
|
|
// id 是订单号 |
|
|
// id 是订单号 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
that.pressOrderDetail(orderId); |
|
|
that.pressOrderDetail(orderId); |
|
|
}) |
|
|
}) |
|
|
.catch(err => { |
|
|
.catch(err => { |
|
@@ -167,7 +167,7 @@ Page({ |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
pressEndDate: res.data.pressEndDate |
|
|
pressEndDate: res.data.pressEndDate |
|
|
}) |
|
|
}) |
|
|
res.data.orderPressList.map(file=>{ |
|
|
|
|
|
|
|
|
res.data.orderPressList.map(file => { |
|
|
compare(file.first); |
|
|
compare(file.first); |
|
|
}) |
|
|
}) |
|
|
console.log(res.data.orderPressList.sort(compare('first'))) |
|
|
console.log(res.data.orderPressList.sort(compare('first'))) |
|
@@ -216,10 +216,10 @@ Page({ |
|
|
} |
|
|
} |
|
|
total_micro_second -= 1000; |
|
|
total_micro_second -= 1000; |
|
|
}, |
|
|
}, |
|
|
countdown: function (end_time) { |
|
|
|
|
|
|
|
|
countdown: function(end_time) { |
|
|
let that = this; |
|
|
let that = this; |
|
|
that.setIntervalTime(end_time); |
|
|
that.setIntervalTime(end_time); |
|
|
that.data.setInterval = setInterval(function () { |
|
|
|
|
|
|
|
|
that.data.setInterval = setInterval(function() { |
|
|
that.setIntervalTime(end_time); |
|
|
that.setIntervalTime(end_time); |
|
|
}, 1000) |
|
|
}, 1000) |
|
|
}, |
|
|
}, |
|
@@ -292,13 +292,224 @@ Page({ |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
/** |
|
|
|
|
|
* 按原价付款 |
|
|
|
|
|
*/ |
|
|
|
|
|
orderFunc1(e) { |
|
|
|
|
|
var that = this; |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
showButton: true |
|
|
|
|
|
}) |
|
|
|
|
|
Http.get({ |
|
|
|
|
|
url: config.api.checkPhoneStatus, |
|
|
|
|
|
data: {} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
showButton: false |
|
|
|
|
|
}) |
|
|
|
|
|
/** |
|
|
|
|
|
* orderSave 下单 |
|
|
|
|
|
*/ |
|
|
|
|
|
var data = { |
|
|
|
|
|
couponChannelId:e.currentTarget.dataset.couponchannelid, |
|
|
|
|
|
couponId:e.currentTarget.dataset.couponid |
|
|
|
|
|
} |
|
|
|
|
|
return Http.post({ |
|
|
|
|
|
url: config.api.orderSave, |
|
|
|
|
|
data: data |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
showButton: true |
|
|
|
|
|
}) |
|
|
|
|
|
if (err.code == 2011) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "商户信息没找到", |
|
|
|
|
|
image: './../../../assets/images/fail.png', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 2013) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "商户信息禁用", |
|
|
|
|
|
image: './../../../assets/images/fail.png', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 3000) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "库存不足", |
|
|
|
|
|
image: './../../../assets/images/fail.png', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 3001) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "超过限购条件", |
|
|
|
|
|
image: './../../../assets/images/fail.png', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 3002) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "订单失败", |
|
|
|
|
|
image: './../../../assets/images/fail.png', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 3003) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "订单不存在", |
|
|
|
|
|
image: './../../../assets/images/fail.png', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 3004) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "订单不存在", |
|
|
|
|
|
image: './../../../assets/images/fail.png', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 4003) { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: "卡券已作废", |
|
|
|
|
|
image: './../../../assets/images/fail.png', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 11005) { |
|
|
|
|
|
/** |
|
|
|
|
|
* 将值传到用户手机号授权的页面 |
|
|
|
|
|
* |
|
|
|
|
|
*/ |
|
|
|
|
|
wx.redirectTo({ |
|
|
|
|
|
url: "/pages/getphoneInfo/index?couponChannelId=" + |
|
|
|
|
|
that.data.couponChannelId + |
|
|
|
|
|
"&couponId=" + |
|
|
|
|
|
that.data.couponId |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 11006) { |
|
|
|
|
|
// 用户手机已加密 |
|
|
|
|
|
wx.redirectTo({ |
|
|
|
|
|
url: "/pages/phoneinput/phoneinput?couponChannelId=" + |
|
|
|
|
|
that.data.couponChannelId + |
|
|
|
|
|
"&couponId=" + |
|
|
|
|
|
that.data.couponId |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: err.message, |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res => { |
|
|
|
|
|
console.log(res); |
|
|
|
|
|
debugger |
|
|
|
|
|
if (typeof(res) != "undefined") { |
|
|
|
|
|
let orderId = "" + res.data.id; |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
orderId: orderId |
|
|
|
|
|
}); |
|
|
|
|
|
if (e.currentTarget.dataset.saleprice / 100 > 0 || e.currentTarget.dataset.price / 100 > 0) { |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付订单创建 |
|
|
|
|
|
*/ |
|
|
|
|
|
Http.post({ |
|
|
|
|
|
url: config.api.payOrderCreate, |
|
|
|
|
|
data: { |
|
|
|
|
|
orderId: orderId |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
var payOrderId = "" + res.data.payOrderId; |
|
|
|
|
|
wx.hideLoading(); |
|
|
|
|
|
wx.requestPayment({ |
|
|
|
|
|
timeStamp: res.data.timeStamp, |
|
|
|
|
|
nonceStr: res.data.nonceStr, |
|
|
|
|
|
package: res.data.package, |
|
|
|
|
|
signType: (res.data.signType) ? res.data.signType : "MD5", |
|
|
|
|
|
paySign: res.data.paySign, |
|
|
|
|
|
success: res => { |
|
|
|
|
|
wx.showLoading({ |
|
|
|
|
|
title: '订单正在处理中...', |
|
|
|
|
|
}) |
|
|
|
|
|
setTimeout(function() { |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
}, 5000) |
|
|
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', '', that); |
|
|
|
|
|
if (res.errMsg == "requestPayment:ok") { |
|
|
|
|
|
setTimeout(function() { |
|
|
|
|
|
wx.hideLoading(); |
|
|
|
|
|
}, 2000); |
|
|
|
|
|
/** |
|
|
|
|
|
* 用户支付成功以后跳转到券包列表 |
|
|
|
|
|
*/ |
|
|
|
|
|
if (that.data.cardType == 100) { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum2', |
|
|
|
|
|
data: "couponNum2" |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum', |
|
|
|
|
|
data: "couponNum" |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
fail: res => { |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付失败,需要更新订单的状态 |
|
|
|
|
|
*/ |
|
|
|
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 2, '', 'fail', that); |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
showbutton: false |
|
|
|
|
|
}) |
|
|
|
|
|
return; |
|
|
|
|
|
}, |
|
|
|
|
|
complete: res => {} |
|
|
|
|
|
}); |
|
|
|
|
|
/// End payment -------- |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.log(err); |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: err.message, |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
// 免费券 |
|
|
|
|
|
that.payOrderUpdate(orderId, "0", 1, '', 'free', that); |
|
|
|
|
|
if (that.data.cardType == 100) { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum2', |
|
|
|
|
|
data: "couponNum2" |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
wx.setStorage({ |
|
|
|
|
|
key: 'couponNum', |
|
|
|
|
|
data: "couponNum" |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 发起支付 |
|
|
* 发起支付 |
|
|
*/ |
|
|
*/ |
|
|
orderFunc(e) { |
|
|
orderFunc(e) { |
|
|
var that = this; |
|
|
var that = this; |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
showButton:true |
|
|
|
|
|
|
|
|
showButton: true |
|
|
}) |
|
|
}) |
|
|
Http.get({ |
|
|
Http.get({ |
|
|
url: config.api.checkPhoneStatus, |
|
|
url: config.api.checkPhoneStatus, |
|
@@ -385,7 +596,7 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
// 免费券 |
|
|
// 免费券 |
|
|
that.payOrderUpdate(orderId, "0", 1, '', 'free',that); |
|
|
|
|
|
|
|
|
that.payOrderUpdate(orderId, "0", 1, '', 'free', that); |
|
|
if (that.data.cardType == 100) { |
|
|
if (that.data.cardType == 100) { |
|
|
wx.setStorage({ |
|
|
wx.setStorage({ |
|
|
key: 'couponNum2', |
|
|
key: 'couponNum2', |
|
@@ -489,11 +700,11 @@ Page({ |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
onUnload: function () { |
|
|
|
|
|
|
|
|
onUnload: function() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
clearInterval(that.data.setInterval) |
|
|
clearInterval(that.data.setInterval) |
|
|
}, |
|
|
}, |
|
|
onHide: function () { |
|
|
|
|
|
|
|
|
onHide: function() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
clearInterval(that.data.setInterval) |
|
|
clearInterval(that.data.setInterval) |
|
|
}, |
|
|
}, |
|
@@ -511,8 +722,8 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 刷新 |
|
|
* 刷新 |
|
|
*/ |
|
|
|
|
|
onPullDownRefresh: function (e) { |
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
onPullDownRefresh: function(e) { |
|
|
let that = this; |
|
|
let that = this; |
|
|
if (that.data.orderId || that.data.orderId && that.data.from == 'discount') { |
|
|
if (that.data.orderId || that.data.orderId && that.data.from == 'discount') { |
|
|
if (that.data.from) { |
|
|
if (that.data.from) { |
|
@@ -572,17 +783,18 @@ function diffTime(startDate) { |
|
|
if (days > 0) { |
|
|
if (days > 0) { |
|
|
returnStr = days + "天" + returnStr; |
|
|
returnStr = days + "天" + returnStr; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (returnStr.indexOf('-1')==-1){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (returnStr.indexOf('-1') == -1) { |
|
|
return returnStr; |
|
|
return returnStr; |
|
|
}else{ |
|
|
|
|
|
|
|
|
} else { |
|
|
return '1秒' |
|
|
return '1秒' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function compare(property) { |
|
|
function compare(property) { |
|
|
return function (a, b) { |
|
|
|
|
|
|
|
|
return function(a, b) { |
|
|
var value1 = a[property]; |
|
|
var value1 = a[property]; |
|
|
var value2 = b[property]; |
|
|
var value2 = b[property]; |
|
|
return value2 - value1; |
|
|
return value2 - value1; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |