save1
This commit is contained in:
parent
a496b528c3
commit
4f22196d68
@ -5,7 +5,7 @@
|
|||||||
const BASE_URL = import.meta.env.VITE_API_URL || 'http://127.0.0.1:3001';
|
const BASE_URL = import.meta.env.VITE_API_URL || 'http://127.0.0.1:3001';
|
||||||
|
|
||||||
// 默认超时时间 15 秒
|
// 默认超时时间 15 秒
|
||||||
const DEFAULT_TIMEOUT = 15000;
|
const DEFAULT_TIMEOUT = 30000;
|
||||||
|
|
||||||
// 错误码定义
|
// 错误码定义
|
||||||
const ERR_CODE = {
|
const ERR_CODE = {
|
||||||
|
|||||||
@ -5,8 +5,10 @@ export function isLogin() {
|
|||||||
export function formatGMT(t, format) {
|
export function formatGMT(t, format) {
|
||||||
// 传入的格式 "2026-04-01T14:06:56.5879258"
|
// 传入的格式 "2026-04-01T14:06:56.5879258"
|
||||||
if (!t)
|
if (!t)
|
||||||
return
|
return ''
|
||||||
const index = t.indexOf('T');
|
const index = t.indexOf('T');
|
||||||
|
if (index === -1)
|
||||||
|
return t
|
||||||
const date = t.substring(0, index).split('-')
|
const date = t.substring(0, index).split('-')
|
||||||
const time = t.substring(index + 1).split(':')
|
const time = t.substring(index + 1).split(':')
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ export function formatGMT(t, format) {
|
|||||||
const sctime = time[2].split('.')
|
const sctime = time[2].split('.')
|
||||||
|
|
||||||
const second = sctime[0].padStart(2, '0')
|
const second = sctime[0].padStart(2, '0')
|
||||||
const millisecond = sctime[1].substring(0, 2).padStart(2, '0')
|
const millisecond = sctime[1] ? sctime[1].substring(0, 2).padStart(2, '0') : '00'
|
||||||
return format
|
return format
|
||||||
.replace('yyyy', year)
|
.replace('yyyy', year)
|
||||||
.replace('MM', month)
|
.replace('MM', month)
|
||||||
|
|||||||
@ -81,7 +81,7 @@ const routes = [
|
|||||||
name: 'CV',
|
name: 'CV',
|
||||||
component: () => import('./views/User/Wallet/CV.vue'),
|
component: () => import('./views/User/Wallet/CV.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '会员卡额度',
|
title: '会员卡',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -106,7 +106,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
back() {
|
back() {
|
||||||
this.$router.push('/Tradelist');
|
this.$router.push('/TradeList');
|
||||||
},
|
},
|
||||||
async loadData() {
|
async loadData() {
|
||||||
try {
|
try {
|
||||||
@ -135,28 +135,67 @@ export default {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await this.$post(`/v1/client/FOrdersClient/${this.ordernum}/pay`, {
|
const res = await this.$post(`/v1/client/FOrdersClient/${this.ordernum}/pay`, {
|
||||||
Paychannel: paychannel,
|
paychannel: paychannel,
|
||||||
Openid: method === 'wechat' ? openid : ''
|
openid: method === 'wechat' ? openid : ''
|
||||||
});
|
});
|
||||||
// alert(JSON.stringify(res));
|
|
||||||
if (res.data && res.data.startsWith('http')) {
|
if (method === 'wechat') {
|
||||||
// 返回链接则跳转
|
// 微信支付使用 WeixinJSBridge 调起
|
||||||
location.href = res.data;
|
this.callWechatPay(res.data);
|
||||||
} else if (res.status === 200) {
|
} else if (method === 'balance') {
|
||||||
// 余额支付成功
|
// 余额支付成功,不显示弹窗
|
||||||
this.$showSuccessToast(res.message || '支付成功');
|
this.$showSuccessToast(res.message || '支付成功');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.onPayCompleted();
|
this.onPayCompleted();
|
||||||
}, 1500);
|
}, 1500);
|
||||||
|
} else if (res.data && res.data.startsWith('http')) {
|
||||||
|
// 其他支付方式跳转链接
|
||||||
|
location.href = res.data;
|
||||||
|
this.showPayResult = true;
|
||||||
}
|
}
|
||||||
this.showPayResult = true;
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.showPayResult = false;
|
if (method !== 'balance' && method !== 'wechat') {
|
||||||
|
this.showPayResult = false;
|
||||||
|
}
|
||||||
this.$showFailToast(err.message || '支付失败');
|
this.$showFailToast(err.message || '支付失败');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
callWechatPay(payData) {
|
||||||
|
// 微信支付调起方法
|
||||||
|
const onBridgeReady = () => {
|
||||||
|
WeixinJSBridge.invoke(
|
||||||
|
'getBrandWCPayRequest', {
|
||||||
|
appId: payData.appId,
|
||||||
|
timeStamp: payData.timeStamp,
|
||||||
|
nonceStr: payData.nonceStr,
|
||||||
|
package: payData.package,
|
||||||
|
signType: payData.signType,
|
||||||
|
paySign: payData.paySign
|
||||||
|
},
|
||||||
|
(res) => {
|
||||||
|
if (res.err_msg === 'get_brand_wcpay_request:ok') {
|
||||||
|
this.$showSuccessToast('支付成功');
|
||||||
|
this.onPayCompleted();
|
||||||
|
} else {
|
||||||
|
this.showPayResult = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof WeixinJSBridge === 'undefined') {
|
||||||
|
if (document.addEventListener) {
|
||||||
|
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
|
||||||
|
} else if (document.attachEvent) {
|
||||||
|
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
|
||||||
|
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onBridgeReady();
|
||||||
|
}
|
||||||
|
},
|
||||||
onPayCompleted() {
|
onPayCompleted() {
|
||||||
this.$router.replace('/Tradelist');
|
this.$router.replace('/TradeList');
|
||||||
},
|
},
|
||||||
onRePay() {
|
onRePay() {
|
||||||
this.showPayResult = false;
|
this.showPayResult = false;
|
||||||
|
|||||||
@ -52,6 +52,7 @@
|
|||||||
<button v-if="item.state === 0" @click="cancelTrade(item)">取消订单</button>
|
<button v-if="item.state === 0" @click="cancelTrade(item)">取消订单</button>
|
||||||
<button v-if="!item.shopname" @click="$navigate(`TradeDetail?ordernum=${item.ordernum}`)">查看详情</button>
|
<button v-if="!item.shopname" @click="$navigate(`TradeDetail?ordernum=${item.ordernum}`)">查看详情</button>
|
||||||
<button v-else @click="$navigate(`MerchantTradeDetail?id=${item.ordernum}`)">查看详情</button>
|
<button v-else @click="$navigate(`MerchantTradeDetail?id=${item.ordernum}`)">查看详情</button>
|
||||||
|
<!-- <button v-if="item.state === 3 || item.state === 4" @click="showLogistics(item)">物流信息</button> -->
|
||||||
|
|
||||||
<button v-if="item.state === 3" @click="confirmReceipt(item)">确认收货</button>
|
<button v-if="item.state === 3" @click="confirmReceipt(item)">确认收货</button>
|
||||||
<button v-if="item.state === 0" @click="$navigate(`Pay?ordernum=${item.ordernum}`)">立即支付</button>
|
<button v-if="item.state === 0" @click="$navigate(`Pay?ordernum=${item.ordernum}`)">立即支付</button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user