|
@@ -3,7 +3,8 @@ const navigationBarHeight = (getApp().statusBarHeight + 50) + 'px' |
|
|
var config = require("../../../config/config.js"); |
|
|
var config = require("../../../config/config.js"); |
|
|
const Http = require("../../../utils/HttpBasics"); |
|
|
const Http = require("../../../utils/HttpBasics"); |
|
|
const imgurl = require("../../../utils/imgurl"); |
|
|
const imgurl = require("../../../utils/imgurl"); |
|
|
const utils = require("../../../utils/util.js") |
|
|
|
|
|
|
|
|
const utils = require("../../../utils/util.js"); |
|
|
|
|
|
let app = getApp(); |
|
|
Page({ |
|
|
Page({ |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -22,7 +23,6 @@ Page({ |
|
|
quesGouUrl: imgurl.ques_gou.url, |
|
|
quesGouUrl: imgurl.ques_gou.url, |
|
|
headbgUrl: imgurl.headbg.url, |
|
|
headbgUrl: imgurl.headbg.url, |
|
|
quesBgUrl: imgurl.ques_bg.url, |
|
|
quesBgUrl: imgurl.ques_bg.url, |
|
|
|
|
|
|
|
|
couponChannelId: '', |
|
|
couponChannelId: '', |
|
|
couponId: '', |
|
|
couponId: '', |
|
|
data: null, |
|
|
data: null, |
|
@@ -63,8 +63,6 @@ Page({ |
|
|
if (options && options.couponId) { |
|
|
if (options && options.couponId) { |
|
|
this.getOneSpell(options.couponId) |
|
|
this.getOneSpell(options.couponId) |
|
|
} |
|
|
} |
|
|
console.log(this.data.couponId) |
|
|
|
|
|
this.getUserInfo(); |
|
|
|
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 显示分享海报 |
|
|
* 显示分享海报 |
|
@@ -91,21 +89,6 @@ Page({ |
|
|
isshowposter: false, |
|
|
isshowposter: false, |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
getUserInfo: function() { |
|
|
|
|
|
let that = this; |
|
|
|
|
|
// 获取用户信息 |
|
|
|
|
|
Http.get({ |
|
|
|
|
|
url: config.api.getScore, |
|
|
|
|
|
data: {} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
console.log(res) |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
nickName: res.data.nickName, |
|
|
|
|
|
avatarUrl: res.data.avatarUrl |
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
gotoIndex: function() { |
|
|
gotoIndex: function() { |
|
|
wx.switchTab({ |
|
|
wx.switchTab({ |
|
|
url: '/pages/main/index', |
|
|
url: '/pages/main/index', |
|
@@ -499,6 +482,7 @@ Page({ |
|
|
* 发起支付 |
|
|
* 发起支付 |
|
|
*/ |
|
|
*/ |
|
|
orderFunc() { |
|
|
orderFunc() { |
|
|
|
|
|
let that = this; |
|
|
let orderGroupId = this.data.orderGroupId; |
|
|
let orderGroupId = this.data.orderGroupId; |
|
|
let data = { |
|
|
let data = { |
|
|
couponChannelId: this.data.data.id, |
|
|
couponChannelId: this.data.data.id, |
|
@@ -508,7 +492,6 @@ Page({ |
|
|
/** |
|
|
/** |
|
|
* 拼团订单 |
|
|
* 拼团订单 |
|
|
*/ |
|
|
*/ |
|
|
let that = this; |
|
|
|
|
|
if (this.data.orderGroupId == 0) { |
|
|
if (this.data.orderGroupId == 0) { |
|
|
data.orderGroupId = this.data.orderGroupId, |
|
|
data.orderGroupId = this.data.orderGroupId, |
|
|
that.setData({ |
|
|
that.setData({ |
|
@@ -519,125 +502,132 @@ Page({ |
|
|
isFromSpell: false |
|
|
isFromSpell: false |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Http.get({ |
|
|
Http.get({ |
|
|
|
|
|
url: config.api.checkUserStatus, |
|
|
|
|
|
data: { |
|
|
|
|
|
token: app.globalData.token |
|
|
|
|
|
} |
|
|
|
|
|
}).then(res=>{ |
|
|
|
|
|
Http.get({ |
|
|
url: config.api.checkPhoneStatus, |
|
|
url: config.api.checkPhoneStatus, |
|
|
data: {} |
|
|
data: {} |
|
|
}) |
|
|
}) |
|
|
.then(res => { |
|
|
|
|
|
/** |
|
|
|
|
|
* orderSave 下单 |
|
|
|
|
|
*/ |
|
|
|
|
|
return Http.post({ |
|
|
|
|
|
url: config.api.orderSave, |
|
|
|
|
|
data: data |
|
|
|
|
|
}); |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.log(err); |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
showbutton: false, |
|
|
|
|
|
showbutton1: false, |
|
|
|
|
|
canSpell: true, |
|
|
|
|
|
canBuyIf: 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 == 3012) { |
|
|
|
|
|
// wx.showToast({ |
|
|
|
|
|
// title: err.message, |
|
|
|
|
|
// icon: "none" |
|
|
|
|
|
// }) |
|
|
|
|
|
that.getUnPaidOrder(that.data.data.couponId); |
|
|
|
|
|
} else if (err.code == 11005) { |
|
|
|
|
|
|
|
|
.then(res => { |
|
|
/** |
|
|
/** |
|
|
* 将值传到用户手机号授权的页面 |
|
|
|
|
|
* |
|
|
|
|
|
|
|
|
* orderSave 下单 |
|
|
*/ |
|
|
*/ |
|
|
wx.redirectTo({ |
|
|
|
|
|
url: `/pages/getphoneInfo/index?path=spell&couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}` |
|
|
|
|
|
|
|
|
return Http.post({ |
|
|
|
|
|
url: config.api.orderSave, |
|
|
|
|
|
data: data |
|
|
}); |
|
|
}); |
|
|
} else if (err.code == 11006) { |
|
|
|
|
|
// 用户手机已加密 |
|
|
|
|
|
wx.redirectTo({ |
|
|
|
|
|
url: `/pages/phoneinput/phoneinput?path=spell&couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}` |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: err.message, |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
console.log(res) |
|
|
|
|
|
if (typeof(res) != "undefined") { |
|
|
|
|
|
let orderId = "" + res.data.id; |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.log(err); |
|
|
that.setData({ |
|
|
that.setData({ |
|
|
orderId: orderId, |
|
|
|
|
|
canSpell: false, |
|
|
|
|
|
|
|
|
showbutton: false, |
|
|
|
|
|
showbutton1: false, |
|
|
|
|
|
canSpell: true, |
|
|
canBuyIf: true |
|
|
canBuyIf: true |
|
|
}); |
|
|
|
|
|
// 支付金额不为0 |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付订单创建 |
|
|
|
|
|
*/ |
|
|
|
|
|
Http.post({ |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
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 == 3012) { |
|
|
|
|
|
// wx.showToast({ |
|
|
|
|
|
// title: err.message, |
|
|
|
|
|
// icon: "none" |
|
|
|
|
|
// }) |
|
|
|
|
|
that.getUnPaidOrder(that.data.data.couponId); |
|
|
|
|
|
} else if (err.code == 11005) { |
|
|
|
|
|
/** |
|
|
|
|
|
* 将值传到用户手机号授权的页面 |
|
|
|
|
|
* |
|
|
|
|
|
*/ |
|
|
|
|
|
wx.redirectTo({ |
|
|
|
|
|
url: `/pages/getphoneInfo/index?path=spell&couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}` |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (err.code == 11006) { |
|
|
|
|
|
// 用户手机已加密 |
|
|
|
|
|
wx.redirectTo({ |
|
|
|
|
|
url: `/pages/phoneinput/phoneinput?path=spell&couponChannelId=${that.data.couponChannelId}&couponId=${that.data.data.couponId}` |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: err.message, |
|
|
|
|
|
icon: 'none', |
|
|
|
|
|
duration: 2000, |
|
|
|
|
|
mask: false |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
.then(res => { |
|
|
|
|
|
console.log(res) |
|
|
|
|
|
if (typeof (res) != "undefined") { |
|
|
|
|
|
let orderId = "" + res.data.id; |
|
|
|
|
|
that.setData({ |
|
|
|
|
|
orderId: orderId, |
|
|
|
|
|
canSpell: false, |
|
|
|
|
|
canBuyIf: true |
|
|
|
|
|
}); |
|
|
|
|
|
// 支付金额不为0 |
|
|
|
|
|
/** |
|
|
|
|
|
* 支付订单创建 |
|
|
|
|
|
*/ |
|
|
|
|
|
Http.post({ |
|
|
url: config.api.payOrderCreate, |
|
|
url: config.api.payOrderCreate, |
|
|
data: { |
|
|
data: { |
|
|
orderId: orderId |
|
|
orderId: orderId |
|
@@ -659,12 +649,12 @@ Page({ |
|
|
wx.showLoading({ |
|
|
wx.showLoading({ |
|
|
title: '订单正在处理中...', |
|
|
title: '订单正在处理中...', |
|
|
}) |
|
|
}) |
|
|
setTimeout(function() { |
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
}, 5000) |
|
|
}, 5000) |
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', that, orderGroupId); |
|
|
that.payOrderUpdate(that.data.orderId, payOrderId, 1, '', that, orderGroupId); |
|
|
if (res.errMsg == "requestPayment:ok") { |
|
|
if (res.errMsg == "requestPayment:ok") { |
|
|
setTimeout(function() { |
|
|
|
|
|
|
|
|
setTimeout(function () { |
|
|
wx.hideLoading(); |
|
|
wx.hideLoading(); |
|
|
}, 2000); |
|
|
}, 2000); |
|
|
} |
|
|
} |
|
@@ -681,7 +671,7 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
return; |
|
|
return; |
|
|
}, |
|
|
}, |
|
|
complete: res => {} |
|
|
|
|
|
|
|
|
complete: res => { } |
|
|
}); |
|
|
}); |
|
|
/// End payment -------- |
|
|
/// End payment -------- |
|
|
}) |
|
|
}) |
|
@@ -697,9 +687,25 @@ Page({ |
|
|
mask: false |
|
|
mask: false |
|
|
}); |
|
|
}); |
|
|
}) |
|
|
}) |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
.catch(err => { |
|
|
|
|
|
console.log(err) |
|
|
|
|
|
if(err.code == 11004){ |
|
|
|
|
|
wx.redirectTo({ |
|
|
|
|
|
url: `/pages/getuserinfo/index?fromflag=spellcoupondetail&couponChannelIdflag=${that.data.couponChannelId}`, |
|
|
|
|
|
}) |
|
|
|
|
|
}else{ |
|
|
|
|
|
wx.showToast({ |
|
|
|
|
|
title: err.message, |
|
|
|
|
|
icon:"none", |
|
|
|
|
|
duration:2500 |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
* 生命周期函数--监听页面显示 |
|
|
* 生命周期函数--监听页面显示 |
|
|