diff --git a/src/api/http.js b/src/api/http.js
index 7d492fb..79ac8d9 100644
--- a/src/api/http.js
+++ b/src/api/http.js
@@ -5,7 +5,7 @@
const BASE_URL = import.meta.env.VITE_API_URL || 'http://127.0.0.1:3001';
// 默认超时时间 15 秒
-const DEFAULT_TIMEOUT = 15000;
+const DEFAULT_TIMEOUT = 30000;
// 错误码定义
const ERR_CODE = {
diff --git a/src/api/user.js b/src/api/user.js
index 30fc3ca..1a1381f 100644
--- a/src/api/user.js
+++ b/src/api/user.js
@@ -5,8 +5,10 @@ export function isLogin() {
export function formatGMT(t, format) {
// 传入的格式 "2026-04-01T14:06:56.5879258"
if (!t)
- return
+ return ''
const index = t.indexOf('T');
+ if (index === -1)
+ return t
const date = t.substring(0, index).split('-')
const time = t.substring(index + 1).split(':')
@@ -20,7 +22,7 @@ export function formatGMT(t, format) {
const sctime = time[2].split('.')
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
.replace('yyyy', year)
.replace('MM', month)
diff --git a/src/router.js b/src/router.js
index 4b8a42c..2013933 100644
--- a/src/router.js
+++ b/src/router.js
@@ -81,7 +81,7 @@ const routes = [
name: 'CV',
component: () => import('./views/User/Wallet/CV.vue'),
meta: {
- title: '会员卡额度',
+ title: '会员卡',
}
},
{
diff --git a/src/views/Trade/Pay.vue b/src/views/Trade/Pay.vue
index 52d9aea..f08c1b8 100644
--- a/src/views/Trade/Pay.vue
+++ b/src/views/Trade/Pay.vue
@@ -106,7 +106,7 @@ export default {
},
methods: {
back() {
- this.$router.push('/Tradelist');
+ this.$router.push('/TradeList');
},
async loadData() {
try {
@@ -135,28 +135,67 @@ export default {
try {
const res = await this.$post(`/v1/client/FOrdersClient/${this.ordernum}/pay`, {
- Paychannel: paychannel,
- Openid: method === 'wechat' ? openid : ''
+ paychannel: paychannel,
+ openid: method === 'wechat' ? openid : ''
});
- // alert(JSON.stringify(res));
- if (res.data && res.data.startsWith('http')) {
- // 返回链接则跳转
- location.href = res.data;
- } else if (res.status === 200) {
- // 余额支付成功
+
+ if (method === 'wechat') {
+ // 微信支付使用 WeixinJSBridge 调起
+ this.callWechatPay(res.data);
+ } else if (method === 'balance') {
+ // 余额支付成功,不显示弹窗
this.$showSuccessToast(res.message || '支付成功');
setTimeout(() => {
this.onPayCompleted();
}, 1500);
+ } else if (res.data && res.data.startsWith('http')) {
+ // 其他支付方式跳转链接
+ location.href = res.data;
+ this.showPayResult = true;
}
- this.showPayResult = true;
} catch (err) {
- this.showPayResult = false;
+ if (method !== 'balance' && method !== 'wechat') {
+ this.showPayResult = false;
+ }
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() {
- this.$router.replace('/Tradelist');
+ this.$router.replace('/TradeList');
},
onRePay() {
this.showPayResult = false;
diff --git a/src/views/Trade/Tradelist.vue b/src/views/Trade/Tradelist.vue
index e3fe1b4..128d12c 100644
--- a/src/views/Trade/Tradelist.vue
+++ b/src/views/Trade/Tradelist.vue
@@ -52,6 +52,7 @@
+