|
@@ -187,7 +187,7 @@ export default {
|
|
|
addressList: [],
|
|
addressList: [],
|
|
|
dBalance: 0.00,
|
|
dBalance: 0.00,
|
|
|
wxconfig: {},
|
|
wxconfig: {},
|
|
|
- orderNo:null,
|
|
|
|
|
|
|
+ orderNo: null,
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -202,21 +202,17 @@ export default {
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
|
- console.log(this.selectedAddressId, '666661111111')
|
|
|
|
|
- if (!this.selectedAddressId) {
|
|
|
|
|
- this.defaultAddress = null
|
|
|
|
|
- } else if (!this.defaultAddress) {
|
|
|
|
|
- this.getAddrListFun(this.selectedAddressId)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.getAddrListFun()
|
|
|
|
|
+
|
|
|
//选择地址后传回的地址id
|
|
//选择地址后传回的地址id
|
|
|
- if (this.selectedAddressId && this.defaultAddress) {
|
|
|
|
|
- if (this.selectedAddressId !== this.defaultAddress.id) {
|
|
|
|
|
- this.defaultAddress = this.addressList.find(item => {
|
|
|
|
|
- if (item.id == this.selectedAddressId)
|
|
|
|
|
- return item
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (this.selectedAddressId && this.defaultAddress) {
|
|
|
|
|
+ // if (this.selectedAddressId !== this.defaultAddress.id) {
|
|
|
|
|
+ // this.defaultAddress = this.addressList.find(item => {
|
|
|
|
|
+ // if (item.id == this.selectedAddressId)
|
|
|
|
|
+ // return item
|
|
|
|
|
+ // });
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
},
|
|
},
|
|
|
onPageScroll(e) {
|
|
onPageScroll(e) {
|
|
|
//console.log("滚动距离为:" + e.scrollTop);
|
|
//console.log("滚动距离为:" + e.scrollTop);
|
|
@@ -237,7 +233,7 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
//查询默认地址
|
|
//查询默认地址
|
|
|
- getAddrListFun(selectedAddressId) {
|
|
|
|
|
|
|
+ getAddrListFun() {
|
|
|
let params = {
|
|
let params = {
|
|
|
current: 1,
|
|
current: 1,
|
|
|
size: 100,
|
|
size: 100,
|
|
@@ -245,21 +241,40 @@ export default {
|
|
|
}
|
|
}
|
|
|
getAddrList(params).then(res => {
|
|
getAddrList(params).then(res => {
|
|
|
if (res.data.code === 200) {
|
|
if (res.data.code === 200) {
|
|
|
- this.addressList = res.data.data
|
|
|
|
|
- if (selectedAddressId) {
|
|
|
|
|
- this.defaultAddress = res.data.data.find(item => {
|
|
|
|
|
- if (item.id == selectedAddressId)
|
|
|
|
|
- return item
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ if (!res.data.data.length) {
|
|
|
|
|
+ this.defaultAddress = null
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (!this.defaultAddress) {
|
|
|
|
|
- this.defaultAddress = res.data.data.find(item => {
|
|
|
|
|
- if (item.type == 1)
|
|
|
|
|
- return item
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (this.selectedAddressId) {
|
|
|
|
|
+ let flag = res.data.data.some(item => {
|
|
|
|
|
+ return item.id == this.selectedAddressId
|
|
|
});
|
|
});
|
|
|
|
|
+ if (flag) {
|
|
|
|
|
+ let defaultAddress = res.data.data.find(item => {
|
|
|
|
|
+ if (item.id == this.selectedAddressId)
|
|
|
|
|
+ return item
|
|
|
|
|
+ });
|
|
|
|
|
+ this.$set(this, 'defaultAddress', defaultAddress);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.defaultAddress = res.data.data[0]
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log(this.selectedAddressId, 'this.selectedAddressId99999999999')
|
|
|
|
|
+ console.log(this.defaultAddress, 'this.defaultAddress9999999999')
|
|
|
|
|
+ return
|
|
|
|
|
+ } else if (!this.selectedAddressId || !this.defaultAddress) {
|
|
|
|
|
+ let flag = res.data.data.some(item => {
|
|
|
|
|
+ return item.type == 1
|
|
|
|
|
+ });
|
|
|
|
|
+ if (flag) {
|
|
|
|
|
+ this.defaultAddress = res.data.data.find(item => {
|
|
|
|
|
+ if (item.type == 1)
|
|
|
|
|
+ return item
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.defaultAddress = res.data.data[0]
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
@@ -304,7 +319,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (this.selectedObj) {
|
|
if (this.selectedObj) {
|
|
|
- if (this.selectPayMeth == null) {
|
|
|
|
|
|
|
+ if (this.selectPayMeth == null && (params.paymentType == 2 || params.paymentType == 3)) {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '请选择支付方式',
|
|
title: '请选择支付方式',
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
@@ -324,15 +339,16 @@ export default {
|
|
|
params.skuId = this.selectedObj.skuId; //选中的SKU ID
|
|
params.skuId = this.selectedObj.skuId; //选中的SKU ID
|
|
|
params.specNameValueLis = this.selectedObj.specNameValueList; // SKU列表(规格组合明细)
|
|
params.specNameValueLis = this.selectedObj.specNameValueList; // SKU列表(规格组合明细)
|
|
|
params.quantity = 1; //购买数量
|
|
params.quantity = 1; //购买数量
|
|
|
- params.payType = Number(this.selectPayMeth);//支付方式:1微信支付 2账户余额
|
|
|
|
|
|
|
+ params.payType = this.params.paymentType == 1 ? null : Number(this.selectPayMeth);//支付方式:1微信支付 2账户余额
|
|
|
params.freightAmount = this.params.freight; //运费
|
|
params.freightAmount = this.params.freight; //运费
|
|
|
params.totalAmount = (this.selectedObj.priceMoney + (this.params.freight > 0 ? this.params.freight : 0));// 支付金额+运费=总金额
|
|
params.totalAmount = (this.selectedObj.priceMoney + (this.params.freight > 0 ? this.params.freight : 0));// 支付金额+运费=总金额
|
|
|
params.payAmount = this.selectedObj.priceMoney;// 支付金额
|
|
params.payAmount = this.selectedObj.priceMoney;// 支付金额
|
|
|
params.pointsUsed = this.selectedObj.pricePoint;// 使用的积分
|
|
params.pointsUsed = this.selectedObj.pricePoint;// 使用的积分
|
|
|
params.buyerRemark = this.orderRemarks;//买家备注信息
|
|
params.buyerRemark = this.orderRemarks;//买家备注信息
|
|
|
- console.log(params, 'params')
|
|
|
|
|
- console.log(this.params, 'this.params')
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if (params.paymentType == 1) {//只有积分兑换
|
|
|
|
|
+ this.productOrderCreateFun(params)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
if (this.selectPayMeth == 1) {
|
|
if (this.selectPayMeth == 1) {
|
|
|
//微信支付
|
|
//微信支付
|
|
|
this.weixinPay(params)
|
|
this.weixinPay(params)
|
|
@@ -341,6 +357,7 @@ export default {
|
|
|
this.nowYuyue(params)
|
|
this.nowYuyue(params)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
} else {
|
|
} else {
|
|
|
this.selectProductShowPopup = true
|
|
this.selectProductShowPopup = true
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
@@ -350,93 +367,74 @@ export default {
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
//微信支付
|
|
//微信支付
|
|
|
- weixinPay(params) {
|
|
|
|
|
- productOrderCreate(params).then(res => {
|
|
|
|
|
- if (res.data.code == 200) {
|
|
|
|
|
- this.orderNo = res.data.data
|
|
|
|
|
- productOrderPay({
|
|
|
|
|
- orderNo: res.data.data, //订单编号
|
|
|
|
|
- payType: params.payType, //支付方式:1微信支付 2:余额支付
|
|
|
|
|
- totalPrice: params.totalAmount //订单总金额,单位:元
|
|
|
|
|
- }).then(res => {
|
|
|
|
|
- if (res.data.code == 200) {
|
|
|
|
|
- let payConfig = JSON.parse(res.data.data)
|
|
|
|
|
- console.log(payConfig, 'this.payConfig9999999')
|
|
|
|
|
- getSignature(h5Url).then(res => {
|
|
|
|
|
- this.wxconfig = res.data
|
|
|
|
|
- console.log(this.wxconfig, 'this.wxconfig66666')
|
|
|
|
|
- wx.config({
|
|
|
|
|
- beta: true,
|
|
|
|
|
- debug: false,
|
|
|
|
|
- appId: this.wxconfig.appId, // 公众号ID
|
|
|
|
|
- // appId: uni.getAppBaseInfo().host.appId, // 公众号ID
|
|
|
|
|
- timestamp: this.wxconfig.timestamp, // 时间戳,自1970年以来的秒数
|
|
|
|
|
- nonceStr: this.wxconfig.nonceStr, // 随机串
|
|
|
|
|
- signature: this.wxconfig.signature, // 微信签名方式
|
|
|
|
|
- jsApiList: ['getBrandWCPayRequest']
|
|
|
|
|
- });
|
|
|
|
|
- var vm = this
|
|
|
|
|
- wx.invoke('getBrandWCPayRequest',
|
|
|
|
|
- // 下面参数内容都是后台返回的
|
|
|
|
|
- {
|
|
|
|
|
- 'appId': payConfig.appId, // 公众号名称,由商户传入
|
|
|
|
|
- 'timeStamp': payConfig.timeStamp, // 时间戳
|
|
|
|
|
- 'nonceStr': payConfig.nonceStr, // 随机串
|
|
|
|
|
- 'package': payConfig.package, // 预支付id
|
|
|
|
|
- 'signType': payConfig.signType, // 微信签名方式
|
|
|
|
|
- 'paySign': payConfig.paySign, // 微信签名
|
|
|
|
|
- },
|
|
|
|
|
- function (res) {
|
|
|
|
|
- console.log(res, '---------------付款')
|
|
|
|
|
- // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
|
|
-
|
|
|
|
|
- // JSON.stringify(res);
|
|
|
|
|
- if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
|
|
- this.redeemNowBtnDisable = false
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/points/productDetails/paymentSuccessful?orderNo=' + this.orderNo
|
|
|
|
|
- });
|
|
|
|
|
- } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
|
|
|
|
|
- this.redeemNowBtnDisable = false
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: '已取消支付',
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/points/productDetails/pendingPayment?orderNo=' + this.orderNo
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- this.redeemNowBtnDisable = false
|
|
|
|
|
- alert('付款失败');
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- }).catch(err => {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: err,
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- this.redeemNowBtnDisable = false
|
|
|
|
|
|
|
+ async weixinPay(params) {
|
|
|
|
|
+ let data = await this.productOrderCreateFun(params)
|
|
|
|
|
+ if (!data) return
|
|
|
|
|
+ let payConfig = JSON.parse(data.data)
|
|
|
|
|
+ getSignature(h5Url).then(res => {
|
|
|
|
|
+ this.wxconfig = res.data
|
|
|
|
|
+ console.log(this.wxconfig, 'this.wxconfig66666')
|
|
|
|
|
+ wx.config({
|
|
|
|
|
+ beta: true,
|
|
|
|
|
+ debug: false,
|
|
|
|
|
+ appId: this.wxconfig.appId, // 公众号ID
|
|
|
|
|
+ // appId: uni.getAppBaseInfo().host.appId, // 公众号ID
|
|
|
|
|
+ timestamp: this.wxconfig.timestamp, // 时间戳,自1970年以来的秒数
|
|
|
|
|
+ nonceStr: this.wxconfig.nonceStr, // 随机串
|
|
|
|
|
+ signature: this.wxconfig.signature, // 微信签名方式
|
|
|
|
|
+ jsApiList: ['getBrandWCPayRequest']
|
|
|
|
|
+ });
|
|
|
|
|
+ var vm = this
|
|
|
|
|
+ wx.invoke('getBrandWCPayRequest',
|
|
|
|
|
+ // 下面参数内容都是后台返回的
|
|
|
|
|
+ {
|
|
|
|
|
+ 'appId': payConfig.appId, // 公众号名称,由商户传入
|
|
|
|
|
+ 'timeStamp': payConfig.timeStamp, // 时间戳
|
|
|
|
|
+ 'nonceStr': payConfig.nonceStr, // 随机串
|
|
|
|
|
+ 'package': payConfig.package, // 预支付id
|
|
|
|
|
+ 'signType': payConfig.signType, // 微信签名方式
|
|
|
|
|
+ 'paySign': payConfig.paySign, // 微信签名
|
|
|
|
|
+ },
|
|
|
|
|
+ function (res) {
|
|
|
|
|
+ console.log(res, '---------------付款')
|
|
|
|
|
+ vm.redeemNowBtnDisable = false
|
|
|
|
|
+ // 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
|
|
|
|
|
+
|
|
|
|
|
+ // JSON.stringify(res);
|
|
|
|
|
+ if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/points/productDetails/paymentSuccessful?orderNo=' + vm.orderNo
|
|
|
|
|
+ });
|
|
|
|
|
+ } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '已取消支付',
|
|
|
|
|
+ icon: 'none'
|
|
|
})
|
|
})
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/points/productDetails/pendingPayment?orderNo=' + vm.orderNo
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ vm.redeemNowBtnDisable = false
|
|
|
|
|
+ alert('付款失败');
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ this.redeemNowBtnDisable = false
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: err,
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- }).catch(err => {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: err,
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- this.redeemNowBtnDisable = false
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
//账号余额支付
|
|
//账号余额支付
|
|
|
- nowYuyue(params) {
|
|
|
|
|
|
|
+ async nowYuyue(params) {
|
|
|
if (parseInt(this.dBalance) < parseInt(this.selectedObj.priceMoney)) {
|
|
if (parseInt(this.dBalance) < parseInt(this.selectedObj.priceMoney)) {
|
|
|
|
|
+ this.redeemNowBtnDisable = false
|
|
|
uni.showModal({
|
|
uni.showModal({
|
|
|
title: '账户余额不足',
|
|
title: '账户余额不足',
|
|
|
content: '请充值',
|
|
content: '请充值',
|
|
@@ -449,45 +447,47 @@ export default {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
- productOrderCreate(params).then(res => {
|
|
|
|
|
- if (res.data.code == 200) {
|
|
|
|
|
- productOrderPay({
|
|
|
|
|
- orderNo: res.data.data, //订单编号
|
|
|
|
|
- payType: params.payType, //支付方式:1微信支付 2:余额支付
|
|
|
|
|
- totalPrice: params.totalAmount //订单总金额,单位:元
|
|
|
|
|
- }).then(res => {
|
|
|
|
|
- if (res.data.code == 200) {
|
|
|
|
|
- this.redeemNowBtnDisable = false
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/points/productDetails/paymentSuccessful'
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- this.redeemNowBtnDisable = false
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- icon: 'error',
|
|
|
|
|
- title: res.data.msg,
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }).catch(err => {
|
|
|
|
|
- this.redeemNowBtnDisable = false
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: err,
|
|
|
|
|
- icon: 'none'
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ let data = await this.productOrderCreateFun(params)
|
|
|
|
|
+ if (!data) return
|
|
|
|
|
+ this.redeemNowBtnDisable = false
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/points/productDetails/paymentSuccessful'
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- }).catch(err => {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ //支付api
|
|
|
|
|
+ async productOrderCreateFun(params) {
|
|
|
|
|
+ let res = await productOrderCreate(params)
|
|
|
|
|
+ if (res.data.code == 200) {
|
|
|
|
|
+ this.orderNo = res.data.data
|
|
|
|
|
+ let res1 = await productOrderPay({
|
|
|
|
|
+ orderNo: res.data.data, //订单编号
|
|
|
|
|
+ payType: params.payType, //支付方式:1微信支付 2:余额支付
|
|
|
|
|
+ totalPrice: params.totalAmount //订单总金额,单位:元
|
|
|
|
|
+ })
|
|
|
|
|
+ if (res1.data.code == 200) {
|
|
|
|
|
+ return res1.data
|
|
|
|
|
+ } else {
|
|
|
this.redeemNowBtnDisable = false
|
|
this.redeemNowBtnDisable = false
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
- title: err,
|
|
|
|
|
|
|
+ title: res.data.msg,
|
|
|
icon: 'none'
|
|
icon: 'none'
|
|
|
})
|
|
})
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.redeemNowBtnDisable = false
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: res.data.msg,
|
|
|
|
|
+ icon: 'none'
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
//打开选择商品页
|
|
//打开选择商品页
|
|
|
selectProductShowFun() {
|
|
selectProductShowFun() {
|
|
|
this.selectProductShowPopup = true
|
|
this.selectProductShowPopup = true
|