...
This commit is contained in:
@@ -104,7 +104,7 @@
|
||||
:merchant_name='payParams.merchant_name'
|
||||
:notify_url='payParams.notify_url'
|
||||
:sign='payParams.sign'>
|
||||
<text class='confirm-order' @click.stop='payment'>确认订单</text>
|
||||
<button class='confirm-order' @click='payment'>确认订单</button>
|
||||
</sqb-pay>
|
||||
</view>
|
||||
</view>
|
||||
@@ -117,10 +117,11 @@
|
||||
import { assetsUrl } from '@/utils/assets';
|
||||
import PaymentDialog from '@/components/payment-dialog.vue';
|
||||
import CouponDialog from '@/pages/mall/subs/components/coupon-dialog.vue';
|
||||
import { goPath } from '@/utils';
|
||||
import { orderCreate } from '@/api/goods';
|
||||
import { goPath, parseParameter, sortASCII } from '@/utils';
|
||||
import { hexMD5 } from '@/utils/common/md5';
|
||||
import { orderCreate } from '@/api/order';
|
||||
import { CouponBean } from '@/api/user/types';
|
||||
import { OrderBean } from '@/api/goods/types';
|
||||
import { OrderBean } from '@/api/order/types';
|
||||
import { useUserStore } from '@/store';
|
||||
|
||||
const userStore = useUserStore();
|
||||
@@ -149,8 +150,21 @@ const orderBean = ref<OrderBean>();
|
||||
|
||||
onLoad((e) => {
|
||||
orderBean.value = JSON.parse(decodeURIComponent(e?.orderBean));
|
||||
console.log(orderBean.value);
|
||||
});
|
||||
|
||||
const buildSignParams = computed(() => {
|
||||
return sortASCII({
|
||||
client_sn: orderBean.value?.id || '',
|
||||
return_url: '/pages/payResult/index',
|
||||
total_amount: ((orderBean.value?.totalPrice || 0) * 100).toString(),
|
||||
terminal_sn: terminalInfo.value.terminalSn,
|
||||
subject: orderBean?.value?.orderGoods[0].name,
|
||||
subject_img: orderBean?.value?.orderGoods[0].images || '',
|
||||
merchant_name: terminalInfo.value.companyName,
|
||||
notify_url: 'https://www.baidu.com'
|
||||
}, true);
|
||||
});
|
||||
|
||||
const changePayment = () => {
|
||||
paymentDialogRef.value.show();
|
||||
};
|
||||
@@ -164,7 +178,15 @@ const confirmCoupon = (item: CouponBean) => {
|
||||
};
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
|
||||
console.log('----------->>>>>navigateTo ', e);
|
||||
uni.redirectTo({
|
||||
url: e.detail.url,
|
||||
fail(e) {
|
||||
uni.showToast({
|
||||
title: '支付失败'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const payment = async () => {
|
||||
@@ -180,7 +202,7 @@ const payment = async () => {
|
||||
'remark': orderBean.value?.remark,
|
||||
'orderGoods': orderBean?.value?.orderGoods?.map(item => (
|
||||
{
|
||||
'goodsId': item.goodsId,
|
||||
'goodsId': item.id,
|
||||
'goodsCode': item.code,
|
||||
'goodsNum': item.checkedStock.count,
|
||||
'stockId': item.checkedStock.stockId,
|
||||
@@ -196,6 +218,16 @@ const payment = async () => {
|
||||
};
|
||||
|
||||
const result = await orderCreate(params);
|
||||
orderBean.value!.id = result.id;
|
||||
|
||||
let signParams = buildSignParams.value;
|
||||
const signStr = parseParameter(signParams) + '&key=' + terminalInfo.value.terminalKey;
|
||||
const sign = hexMD5(signStr).toUpperCase();
|
||||
payParams.value = {
|
||||
...signParams,
|
||||
sign: sign
|
||||
};
|
||||
|
||||
uni.hideLoading();
|
||||
};
|
||||
</script>
|
||||
@@ -433,7 +465,7 @@ const payment = async () => {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 30rpx 30rpx 78rpx 30rpx;
|
||||
padding: 20rpx 30rpx 78rpx 30rpx;
|
||||
|
||||
text:nth-of-type(1) {
|
||||
font-weight: 400;
|
||||
@@ -450,12 +482,17 @@ const payment = async () => {
|
||||
}
|
||||
|
||||
sqb-pay .confirm-order {
|
||||
padding: 17rpx 45rpx;
|
||||
border-radius: 43rpx;
|
||||
border: 1rpx solid #F32B2B;
|
||||
display: flex;
|
||||
padding: 0 45rpx;
|
||||
height: 80rpx;
|
||||
border: 2rpx solid #F32B2B;
|
||||
font-weight: bold;
|
||||
font-size: 30rpx;
|
||||
color: #F32B2B;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #FFFFFF;
|
||||
border-radius: 40rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user