forked from gxwebsoft/mp-10550
新增:余额支付、微信支付、下单确认功能
This commit is contained in:
@@ -12,6 +12,7 @@ import Gap from "@/components/Gap";
|
||||
import {TenantId} from "@/config/app";
|
||||
import {payByBalance, selectPayment} from "@/api/system/payment";
|
||||
import {Payment} from "@/api/system/payment/model";
|
||||
import {API_BASE_URL} from "@/config/env";
|
||||
|
||||
const OrderConfirm = () => {
|
||||
const [goods, setGoods] = useState<ShopGoods | null>(null);
|
||||
@@ -60,9 +61,10 @@ const OrderConfirm = () => {
|
||||
const onBalancePay = async (goods: ShopGoods) => {
|
||||
Taro.showLoading({title: '支付中...'})
|
||||
payByBalance({
|
||||
payType: goods.type,
|
||||
payType: 0, // 余额支付
|
||||
payPrice: goods.price,
|
||||
totalPrice: goods.price,
|
||||
addressId: address?.id,
|
||||
userId: Taro.getStorageSync('UserId'),
|
||||
tenantId: Number(TenantId)
|
||||
}).then().finally(() => {
|
||||
@@ -73,7 +75,7 @@ const OrderConfirm = () => {
|
||||
})
|
||||
Taro.hideLoading()
|
||||
setTimeout(() => {
|
||||
// Taro.switchTab({url: '/pages/order/order'})
|
||||
Taro.switchTab({url: '/pages/order/order'})
|
||||
}, 2000)
|
||||
}).catch(() => {
|
||||
Taro.hideLoading()
|
||||
@@ -83,8 +85,8 @@ const OrderConfirm = () => {
|
||||
const onWxPay = async (goods: ShopGoods) => {
|
||||
Taro.showLoading({title: '支付中...'})
|
||||
Taro.request({
|
||||
// url: 'https://cms-api.websoft.top/api/shop/shop-order',
|
||||
url: 'http://127.0.0.1:9200/api/shop/shop-order',
|
||||
url: API_BASE_URL + '/shop/shop-order',
|
||||
// url: 'http://127.0.0.1:9200/api/shop/shop-order',
|
||||
method: 'POST',
|
||||
header: {
|
||||
'content-type': 'application/json',
|
||||
@@ -92,15 +94,26 @@ const OrderConfirm = () => {
|
||||
TenantId
|
||||
},
|
||||
data: {
|
||||
payType: 1,
|
||||
totalPrice: goods.price,
|
||||
payPrice: goods.price,
|
||||
userId: Taro.getStorageSync('UserId'),
|
||||
tenantId: TenantId,
|
||||
payType: goods.type,
|
||||
comments: goods.name,
|
||||
name: goods.name
|
||||
name: goods.name,
|
||||
addressId: address?.id,
|
||||
},
|
||||
success: function (res) {
|
||||
Taro.hideLoading()
|
||||
if(res.data.code != 0){
|
||||
Taro.showToast({
|
||||
title: res.data.message,
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
})
|
||||
return false;
|
||||
}
|
||||
// 支付结果
|
||||
const data = res.data.data
|
||||
console.log(data, 'payInfo')
|
||||
// Taro.showToast({
|
||||
@@ -131,13 +144,8 @@ const OrderConfirm = () => {
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: function (msg) {
|
||||
console.log('支付失败')
|
||||
complete: function () {
|
||||
Taro.hideLoading()
|
||||
Taro.showToast({
|
||||
title: `${msg}`,
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user