|
@@ -1,11 +1,9 @@
|
|
|
// pages/orders/order-detail.ts
|
|
|
-
|
|
|
-import { api_executeOrder, api_executePayment, api_queryByParamName } from "../../api/login";
|
|
|
+import { api_executeOrder, api_executePayment, api_queryByParamName, api_userPaymentOrderUnpaid } from "../../api/login";
|
|
|
|
|
|
// 获取应用实例
|
|
|
const app = getApp<IAppOption>()
|
|
|
Page({
|
|
|
-
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
@@ -30,6 +28,7 @@ Page({
|
|
|
this.queryPayType()
|
|
|
if (options.orderInfo) {
|
|
|
const goods = JSON.parse(decodeURIComponent(options.orderInfo));
|
|
|
+ console.log(goods, 'goods')
|
|
|
this.setData({
|
|
|
goodsInfo: goods,
|
|
|
status: goods.status
|
|
@@ -39,8 +38,9 @@ Page({
|
|
|
// 获取后台配置的支付方式
|
|
|
async queryPayType() {
|
|
|
try {
|
|
|
+ // wxlite_payment_service_provider
|
|
|
const { data } = await api_queryByParamName({
|
|
|
- paramName: 'payment_service_provider'
|
|
|
+ paramName: 'wxlite_payment_service_provider'
|
|
|
});
|
|
|
if (data.code == 200) {
|
|
|
const paramValue = data.data.paramValue ? JSON.parse(data.data.paramValue) : {}
|
|
@@ -67,31 +67,42 @@ Page({
|
|
|
title: "订单提交中...",
|
|
|
});
|
|
|
try {
|
|
|
- const { salePrice, shopId, name, id } = this.data.goodsInfo
|
|
|
- const { data } = await api_executeOrder({
|
|
|
- "orderType": "WECHAT_MINI",
|
|
|
- "paymentType": this.data.paymentType,
|
|
|
- "paymentCashAmount": salePrice,
|
|
|
- "paymentCouponAmount": 0,
|
|
|
- "shopId": shopId,
|
|
|
- "opneId": app.globalData.userInfo?.liteOpenid,
|
|
|
- "goodsInfos": [{
|
|
|
- "goodsId": id,
|
|
|
- "goodsNum": 1,
|
|
|
- "goodsType": "ACTIVATION_CODE",
|
|
|
- "paymentCashAmount": salePrice,
|
|
|
- "paymentCouponAmount": 0
|
|
|
- }],
|
|
|
- "orderName": name,
|
|
|
- "orderDesc": name
|
|
|
- })
|
|
|
- console.log(data, 'data')
|
|
|
-
|
|
|
- if (data.code === 200) {
|
|
|
- const { paymentConfig, paymentType, orderNo } = data.data
|
|
|
- this.onExecutePay(paymentConfig, paymentType, orderNo)
|
|
|
+ const { salePrice, shopId, name, id, orderNo } = this.data.goodsInfo
|
|
|
+ if(orderNo) {
|
|
|
+ const {data} = await api_userPaymentOrderUnpaid({
|
|
|
+ orderNo: orderNo,
|
|
|
+ paymentType: 'WECHAT_MINI'
|
|
|
+ })
|
|
|
+ if (data.code === 200) {
|
|
|
+ const { paymentConfig, paymentType, orderNo } = data.data.paymentConfig
|
|
|
+ this.onExecutePay(paymentConfig, paymentType, orderNo)
|
|
|
+ } else {
|
|
|
+ this.onPayError()
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.onPayError()
|
|
|
+ const { data } = await api_executeOrder({
|
|
|
+ "orderType": "WECHAT_MINI",
|
|
|
+ "paymentType": this.data.paymentType,
|
|
|
+ "paymentCashAmount": salePrice,
|
|
|
+ "paymentCouponAmount": 0,
|
|
|
+ "shopId": shopId,
|
|
|
+ "opneId": app.globalData.userInfo?.liteOpenid,
|
|
|
+ "goodsInfos": [{
|
|
|
+ "goodsId": id,
|
|
|
+ "goodsNum": 1,
|
|
|
+ "goodsType": "ACTIVATION_CODE",
|
|
|
+ "paymentCashAmount": salePrice,
|
|
|
+ "paymentCouponAmount": 0
|
|
|
+ }],
|
|
|
+ "orderName": name,
|
|
|
+ "orderDesc": name
|
|
|
+ })
|
|
|
+ if (data.code === 200) {
|
|
|
+ const { paymentConfig, paymentType, orderNo } = data.data
|
|
|
+ this.onExecutePay(paymentConfig, paymentType, orderNo)
|
|
|
+ } else {
|
|
|
+ this.onPayError()
|
|
|
+ }
|
|
|
}
|
|
|
} catch {
|
|
|
wx.hideLoading()
|
|
@@ -102,7 +113,7 @@ Page({
|
|
|
success: async (wxres: any) => {
|
|
|
const res = await api_executePayment({
|
|
|
merOrderNo: paymentConfig.merOrderNo,
|
|
|
- paymentChannel: 'wx_lite',
|
|
|
+ paymentChannel: this.data.paymentChannel || 'wx_lite',
|
|
|
paymentType,
|
|
|
userId: app.globalData.userInfo?.id,
|
|
|
code: wxres.code,
|
|
@@ -134,11 +145,6 @@ Page({
|
|
|
paySign: prePayInfo.paySign,
|
|
|
signType: prePayInfo.signType ? prePayInfo.signType : 'MD5',
|
|
|
success(resInfo) {
|
|
|
- console.log('支付成功', resInfo, {
|
|
|
- orderNo,
|
|
|
- paymentConfig,
|
|
|
- paymentType
|
|
|
- })
|
|
|
wx.showToast({ title: '支付成功', icon: 'success' });
|
|
|
wx.redirectTo({
|
|
|
url: '/pages/orders/order-result?orderNo=' + orderNo
|