Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 878778f8f9 | |||
| eac66c965b | |||
| 149fcdd231 | |||
| 2978ac25f7 | |||
| a08afd0cfd | |||
| 4292c0f819 |
@@ -39,7 +39,9 @@
|
||||
<text class="step-text">完成订单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
<view class="door-btn-area">
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -74,7 +76,9 @@
|
||||
<text class="step-text">完成订单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
<view class="door-btn-area">
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -92,24 +96,34 @@
|
||||
|
||||
<!-- 订单信息 -->
|
||||
<view class="door-order-card" v-if="orderInfo">
|
||||
<!-- 商品列表 -->
|
||||
<view class="door-product-list" v-if="orderInfo.products && orderInfo.products.length">
|
||||
<view class="door-product-item" v-for="(p, idx) in orderInfo.products" :key="idx">
|
||||
<image class="door-product-img" :src="p.image" mode="aspectFill" />
|
||||
<view class="door-product-info">
|
||||
<text class="door-product-name">{{ p.name }}</text>
|
||||
<text class="door-product-price">¥{{ getDecimal(p.unit_price) }} x {{ p.qty }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="door-order-row">
|
||||
<text class="door-order-label">订单编号</text>
|
||||
<text class="door-order-value">{{ orderInfo.order_no }}</text>
|
||||
</view>
|
||||
<view class="door-order-row">
|
||||
<text class="door-order-label">商品数量</text>
|
||||
<text class="door-order-value">{{ orderInfo.product_count || '-' }} 件</text>
|
||||
<text class="door-order-value">{{ orderInfo.total_qty || '-' }} 件</text>
|
||||
</view>
|
||||
<view class="door-order-row total">
|
||||
<text class="door-order-label">订单金额</text>
|
||||
<text class="door-order-value door-price">¥{{ orderInfo.total_amount || '0.00' }}</text>
|
||||
<text class="door-order-value door-price">¥{{ getDecimal(orderInfo.total_amount) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="door-order-card" v-else-if="orderLoading">
|
||||
<text class="door-order-loading">加载订单信息...</text>
|
||||
</view>
|
||||
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
<view class="door-btn-area">
|
||||
<view class="door-btn-detail" @click="goOrderDetail">查看订单详情</view>
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -217,13 +231,21 @@ export default {
|
||||
},
|
||||
|
||||
// 查询订单信息
|
||||
async fetchOrder(flowId) {
|
||||
async fetchOrder(orderId) {
|
||||
if (!orderId || !this.userId) {
|
||||
this.orderLoading = false;
|
||||
return;
|
||||
}
|
||||
this.orderLoading = true;
|
||||
try {
|
||||
const res = await get('/order/getByFlowId', { flow_id: flowId });
|
||||
const res = await get('/user/orders', {
|
||||
page: 1,
|
||||
limit: 1,
|
||||
filter: JSON.stringify({ user_id: this.userId, order_id: orderId })
|
||||
});
|
||||
const ret = res.data || {};
|
||||
if (ret.code === 0 && ret.data) {
|
||||
this.orderInfo = ret.data;
|
||||
if (ret.code === 0 && Array.isArray(ret.data) && ret.data.length > 0) {
|
||||
this.orderInfo = ret.data[0];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[door-panel] 获取订单信息失败:', e);
|
||||
@@ -232,6 +254,26 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// MongoDB Decimal128 转换
|
||||
getDecimal(val) {
|
||||
if (val == null) return '0.00';
|
||||
if (typeof val === 'object' && val.$numberDecimal) return val.$numberDecimal;
|
||||
return String(val);
|
||||
},
|
||||
|
||||
// 跳转订单详情
|
||||
goOrderDetail() {
|
||||
if (this.orderInfo) {
|
||||
const orderId = this.orderInfo.order_id || '';
|
||||
uni.setStorageSync('__order_detail_cache', this.orderInfo);
|
||||
uni.navigateTo({ url: `/pages/order/detail?order_id=${orderId}` });
|
||||
} else if (this.flowId) {
|
||||
uni.navigateTo({ url: `/pages/order/detail?flow_id=${this.flowId}` });
|
||||
} else {
|
||||
uni.showToast({ title: '无法获取订单信息', icon: 'none' });
|
||||
}
|
||||
},
|
||||
|
||||
// 关闭遮罩
|
||||
handleClose() {
|
||||
this.step = '';
|
||||
@@ -500,6 +542,44 @@ export default {
|
||||
padding: 24rpx 30rpx;
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
/* 商品列表 */
|
||||
.door-product-list {
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
.door-product-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12rpx 0;
|
||||
}
|
||||
.door-product-item + .door-product-item {
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
.door-product-img {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 10rpx;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.door-product-info {
|
||||
flex: 1;
|
||||
margin-left: 16rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
}
|
||||
.door-product-name {
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.door-product-price {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.45);
|
||||
}
|
||||
.door-order-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -534,9 +614,28 @@ export default {
|
||||
padding: 16rpx 0;
|
||||
}
|
||||
|
||||
/* ====== 按钮区域 ====== */
|
||||
.door-btn-area {
|
||||
margin-top: 64rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 24rpx;
|
||||
}
|
||||
|
||||
/* ====== 查看订单详情按钮 ====== */
|
||||
.door-btn-detail {
|
||||
font-size: 30rpx;
|
||||
color: #fff;
|
||||
padding: 24rpx 80rpx;
|
||||
background: linear-gradient(135deg, #2979ff, #1e60e0);
|
||||
border-radius: 48rpx;
|
||||
letter-spacing: 2rpx;
|
||||
box-shadow: 0 8rpx 24rpx rgba(41, 121, 255, 0.35);
|
||||
}
|
||||
|
||||
/* ====== 关闭按钮 ====== */
|
||||
.door-btn-close {
|
||||
margin-top: 48rpx;
|
||||
font-size: 30rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
padding: 24rpx 100rpx;
|
||||
|
||||
+35
-13
@@ -72,6 +72,9 @@ export default {
|
||||
* 发起 OAuth 授权(静默授权,只获取 openid)
|
||||
*/
|
||||
async startAuth() {
|
||||
// 清除上次使用的 code 标记
|
||||
uni.removeStorageSync('__used_auth_code');
|
||||
|
||||
const platform = detectPlatform();
|
||||
const appNo = getAppNo(platform);
|
||||
|
||||
@@ -140,6 +143,20 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
// 防止 code 重复提交:先检查再标记
|
||||
const usedCode = uni.getStorageSync('__used_auth_code');
|
||||
if (usedCode === code) {
|
||||
console.warn('[loading] code 已使用过,跳过');
|
||||
return;
|
||||
}
|
||||
uni.setStorageSync('__used_auth_code', code);
|
||||
|
||||
// 立即清除 URL 中的 code 参数,避免刷新重复处理
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('code');
|
||||
url.searchParams.delete('state');
|
||||
window.history.replaceState({}, '', url.toString());
|
||||
|
||||
try {
|
||||
this.statusText = '正在验证身份...';
|
||||
|
||||
@@ -165,12 +182,6 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
// 清除 URL 中的 code 参数,避免刷新重复处理
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('code');
|
||||
url.searchParams.delete('state');
|
||||
window.history.replaceState({}, '', url.toString());
|
||||
|
||||
// 存储 openid
|
||||
uni.setStorageSync('openid', openid);
|
||||
|
||||
@@ -219,6 +230,9 @@ export default {
|
||||
* 发起非静默授权获取用户信息(snsapi_userinfo,弹窗确认)
|
||||
*/
|
||||
async startUserInfoAuth() {
|
||||
// 清除上次使用的 code 标记
|
||||
uni.removeStorageSync('__used_auth_code');
|
||||
|
||||
const platform = detectPlatform();
|
||||
const appNo = getAppNo(platform);
|
||||
|
||||
@@ -288,16 +302,24 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
// 防止 code 重复提交
|
||||
const usedCode = uni.getStorageSync('__used_auth_code');
|
||||
if (usedCode === code) {
|
||||
console.warn('[loading] code 已使用过,跳过');
|
||||
return;
|
||||
}
|
||||
uni.setStorageSync('__used_auth_code', code);
|
||||
|
||||
// 立即清除 URL 中的 code/action 参数,避免刷新重复处理
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('code');
|
||||
url.searchParams.delete('state');
|
||||
url.searchParams.delete('action');
|
||||
window.history.replaceState({}, '', url.toString());
|
||||
|
||||
try {
|
||||
this.statusText = '正在获取用户信息...';
|
||||
|
||||
// 清除 URL 中的 code/action 参数,避免刷新重复处理
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('code');
|
||||
url.searchParams.delete('state');
|
||||
url.searchParams.delete('action');
|
||||
window.history.replaceState({}, '', url.toString());
|
||||
|
||||
// 用 code 调用 POST /api/v1/user/info 获取用户信息(必须用 POST,GET 是另一个端点)
|
||||
console.log('[loading] 请求 POST user/info, app_no:', appNo, 'code:', code);
|
||||
const res = await gatewayPost('/api/v1/user/info', {
|
||||
|
||||
@@ -500,11 +500,8 @@ export default {
|
||||
uni.clearStorageSync();
|
||||
uni.showToast({ title: '已退出登录', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
// 跳转到干净的URL,去掉code/state参数,避免重复使用旧code
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('code');
|
||||
url.searchParams.delete('state');
|
||||
window.location.href = url.toString();
|
||||
uni.setStorageSync('__logout_flag', true);
|
||||
uni.reLaunch({ url: '/pages/index/scan' });
|
||||
}, 1000);
|
||||
},
|
||||
onVConsoleChange(e) {
|
||||
|
||||
@@ -67,6 +67,12 @@ export default {
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
// 退出登录后跳转过来,清除标记,停留在扫码页
|
||||
if (uni.getStorageSync('__logout_flag')) {
|
||||
uni.removeStorageSync('__logout_flag');
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. 检查 JWT(App.vue 已处理首次跳转,这里兜底)
|
||||
const token = uni.getStorageSync('token');
|
||||
if (!token) {
|
||||
|
||||
@@ -146,7 +146,13 @@ export default {
|
||||
},
|
||||
onLoad(options) {
|
||||
this.orderId = options.order_id || '';
|
||||
if (this.orderId) {
|
||||
// 优先从缓存读取(订单列表/交易完成页跳转时已存入)
|
||||
const cached = uni.getStorageSync('__order_detail_cache');
|
||||
if (cached) {
|
||||
this.order = cached;
|
||||
this.orderId = cached.order_id || this.orderId;
|
||||
uni.removeStorageSync('__order_detail_cache');
|
||||
} else if (this.orderId) {
|
||||
this.fetchOrder();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -335,6 +335,7 @@ export default {
|
||||
},
|
||||
|
||||
goToDetail(order) {
|
||||
uni.setStorageSync('__order_detail_cache', order);
|
||||
uni.navigateTo({ url: `/pages/order/detail?order_id=${order.order_id}` });
|
||||
},
|
||||
handlePay(order) {
|
||||
|
||||
Reference in New Issue
Block a user