...
|
...
|
@@ -8,21 +8,23 @@ Page({ |
|
|
success: false,
|
|
|
fail: false,
|
|
|
name: '',
|
|
|
choudanNum:0,
|
|
|
choudanNum: 0,
|
|
|
addressId: 0,
|
|
|
tel: '',
|
|
|
area: '',
|
|
|
address: '',
|
|
|
cover_type: false,
|
|
|
total:'',
|
|
|
|
|
|
info:{
|
|
|
address:{
|
|
|
address:'',
|
|
|
area:'',
|
|
|
id:'',
|
|
|
tel:'',
|
|
|
name:''
|
|
|
total: '',
|
|
|
payMent: '',
|
|
|
orderPayMent: '',
|
|
|
|
|
|
info: {
|
|
|
address: {
|
|
|
address: '',
|
|
|
area: '',
|
|
|
id: '',
|
|
|
tel: '',
|
|
|
name: ''
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
@@ -36,16 +38,16 @@ Page({ |
|
|
let index = e.currentTarget.dataset.index
|
|
|
let id = e.currentTarget.dataset.id
|
|
|
let check = e.currentTarget.dataset.check
|
|
|
let coudan = this.data.coudan||[]
|
|
|
let coudan_arr = this.data.coudan_arr||[]
|
|
|
let coudan = this.data.coudan || []
|
|
|
let coudan_arr = this.data.coudan_arr || []
|
|
|
let price = e.currentTarget.dataset.price;
|
|
|
let price2 = e.currentTarget.dataset.price2;
|
|
|
|
|
|
if (type == 1) {
|
|
|
if(this.data.info.choudan*100<(price*100)){
|
|
|
if (this.data.info.choudan * 100 < (price * 100)) {
|
|
|
wx.showToast({
|
|
|
title: '当前剩余积分不足,请重新挑选',
|
|
|
icon:'none'
|
|
|
icon: 'none'
|
|
|
})
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -58,7 +60,7 @@ Page({ |
|
|
}
|
|
|
}
|
|
|
|
|
|
if (num<1) {
|
|
|
if (num < 1) {
|
|
|
coudan.forEach((item, index) => {
|
|
|
if (item.id == id) {
|
|
|
coudan.splice(index, 1)
|
...
|
...
|
@@ -66,7 +68,7 @@ Page({ |
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
if(type==1&&num==1){
|
|
|
if (type == 1 && num == 1) {
|
|
|
//选中
|
|
|
coudan.push({
|
|
|
id: id,
|
...
|
...
|
@@ -76,9 +78,9 @@ Page({ |
|
|
id: id,
|
|
|
num: num,
|
|
|
price: Number(price),
|
|
|
price2:Number(price2)
|
|
|
price2: Number(price2)
|
|
|
})
|
|
|
}else{
|
|
|
} else {
|
|
|
coudan.forEach((item, index) => {
|
|
|
if (item.id == id) {
|
|
|
item.num = num
|
...
|
...
|
@@ -104,19 +106,19 @@ Page({ |
|
|
for (let obj of coudan_arr) {
|
|
|
console.log(obj)
|
|
|
console.log(obj.price2)
|
|
|
if (obj.price2!= null) {
|
|
|
if (obj.price2 != null) {
|
|
|
console.log(111)
|
|
|
choudan_money = (obj.price2 * 100 * obj.num) / 100 + choudan_money
|
|
|
} else {
|
|
|
console.log(222)
|
|
|
choudan_money = (obj.price * 100 * obj.num) / 100 + choudan_money
|
|
|
}
|
|
|
num = num+obj.num
|
|
|
num = num + obj.num
|
|
|
}
|
|
|
|
|
|
this.setData({
|
|
|
choudan_money: choudan_money*100,
|
|
|
choudanNum:num,
|
|
|
choudan_money: choudan_money * 100,
|
|
|
choudanNum: num,
|
|
|
'info.choudan': this.data.info.syjf - choudan_money
|
|
|
// choudan_money: Math.floor(choudan_money* 100) / 100
|
|
|
})
|
...
|
...
|
@@ -183,7 +185,7 @@ Page({ |
|
|
id: id,
|
|
|
num: num,
|
|
|
price: Number(price),
|
|
|
price2:Number(price2)
|
|
|
price2: Number(price2)
|
|
|
})
|
|
|
}
|
|
|
that.setData({
|
...
|
...
|
@@ -204,7 +206,11 @@ Page({ |
|
|
app.post(url, params).then((res) => {
|
|
|
console.log('99999', res, Number(res.msg.total))
|
|
|
res.msg.syjf = res.msg.choudan - res.msg.yunfei
|
|
|
res.msg.choudan = res.msg.choudan - res.msg.yunfei
|
|
|
let a = (res.msg.choudan - res.msg.yunfei).toFixed(2)
|
|
|
if (a < 0) {
|
|
|
a = 0
|
|
|
}
|
|
|
res.msg.choudan = a
|
|
|
res.msg.total = Number(res.msg.total * 100)
|
|
|
res.msg.yunfei = Number(res.msg.yunfei * 100)
|
|
|
|
...
|
...
|
@@ -213,10 +219,8 @@ Page({ |
|
|
|
|
|
that.setData({
|
|
|
info: res.msg,
|
|
|
total:total
|
|
|
|
|
|
total: total
|
|
|
})
|
|
|
|
|
|
console.log('9988756', that.data.info)
|
|
|
|
|
|
})
|
...
|
...
|
@@ -233,12 +237,46 @@ Page({ |
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
that.setData({
|
|
|
"info.yunfei": Number(res.msg.yunfei)*100
|
|
|
"info.yunfei": Number(res.msg.yunfei) * 100
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
// 支付失败弹窗关闭
|
|
|
payFail() {
|
|
|
this.setData({
|
|
|
fail: false
|
|
|
})
|
|
|
},
|
|
|
// 混合支付
|
|
|
mixedPay() {
|
|
|
let that = this
|
|
|
let url = app.interface.orderMixed
|
|
|
let params = {
|
|
|
order_odd: that.data.orderPayMent,
|
|
|
money: that.data.payMent
|
|
|
}
|
|
|
app.post(url, params).then((res) => {
|
|
|
wx.requestPayment({
|
|
|
timeStamp: res.data.timestamp,
|
|
|
nonceStr: res.data.nonceStr,
|
|
|
package: res.data.package,
|
|
|
signType: 'MD5',
|
|
|
paySign: res.data.paySign,
|
|
|
success(res) {
|
|
|
console.log(res,'支付成功')
|
|
|
that.setData({
|
|
|
fail: false
|
|
|
})
|
|
|
wx.showToast({
|
|
|
title: '支付成功',
|
|
|
})
|
|
|
},
|
|
|
fail(res) {
|
|
|
console.log(res,'支付失败')
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
|
|
|
|
|
|
//点击支付
|
|
|
submit() {
|
|
|
let that = this
|
...
|
...
|
@@ -272,12 +310,16 @@ Page({ |
|
|
that.setData({
|
|
|
cover_type: false
|
|
|
})
|
|
|
that.setData({
|
|
|
orderPayMent: res.msg
|
|
|
})
|
|
|
that.order_pay(res.msg)
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//订单支付
|
|
|
order_pay(order_odd) {
|
|
|
let that = this
|
|
|
let url = app.interface.order_pay
|
|
|
let params = {
|
|
|
order_odd: order_odd
|
...
|
...
|
@@ -298,13 +340,18 @@ Page({ |
|
|
this.setData({
|
|
|
fail: true
|
|
|
})
|
|
|
let payMents = (that.data.info.total + that.data.info.yunfei) / 100 - that.data.order.syjf
|
|
|
that.setData({
|
|
|
payMent: payMents.toFixed(2)
|
|
|
})
|
|
|
console.log(payMents, 'payMent')
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function(options) {
|
|
|
onLoad: function (options) {
|
|
|
console.log(options)
|
|
|
this.setData({
|
|
|
type: options.type,
|
...
|
...
|
@@ -317,21 +364,21 @@ Page({ |
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
|
onReady: function() {
|
|
|
onReady: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function() {
|
|
|
onShow: function () {
|
|
|
|
|
|
let pages = getCurrentPages();
|
|
|
|
|
|
let currPage = pages[pages.length - 1]
|
|
|
console.log('887766554',currPage.data.id)
|
|
|
console.log('887766554', currPage.data.id)
|
|
|
if (currPage.data.id) {
|
|
|
console.log('4778785',this.data.info)
|
|
|
console.log('4778785', this.data.info)
|
|
|
|
|
|
this.setData({
|
|
|
"info.address.address": currPage.data.address,
|
...
|
...
|
@@ -356,35 +403,35 @@ Page({ |
|
|
/**
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
*/
|
|
|
onHide: function() {
|
|
|
onHide: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
*/
|
|
|
onUnload: function() {
|
|
|
onUnload: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh: function() {
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom: function() {
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 用户点击右上角分享
|
|
|
*/
|
|
|
onShareAppMessage: function() {
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|