Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b336b901d3 | |||
| 9439bcf9d7 | |||
| d862cad1a0 | |||
| 85d5193071 | |||
| 9551d9d8b2 | |||
| 81bec5ba3b | |||
| 729bc3c70e | |||
| 2e84a00f6e | |||
| 8b5d68592b | |||
| 42c2b8de07 | |||
| 580350cb33 | |||
| 020e131df0 | |||
| 533170f0a9 | |||
| b1924e2623 | |||
| e12663052f | |||
| 842defea21 | |||
| d392ff98b7 | |||
| 18870f3e7d | |||
| 878778f8f9 | |||
| eac66c965b | |||
| 149fcdd231 | |||
| 2978ac25f7 | |||
| a08afd0cfd | |||
| 4292c0f819 |
@@ -92,11 +92,15 @@ jobs:
|
||||
# 3. 安装依赖 & 构建 Uni-app (H5)
|
||||
###############################################
|
||||
- name: Install dependencies and Build H5
|
||||
env:
|
||||
DEPLOY_ENV: ${{ steps.detect.outputs.env }}
|
||||
run: |
|
||||
set -e
|
||||
# pnpm真实路径
|
||||
PNPM_PATH="/root/.nvm/versions/node/v20.20.2/bin/pnpm"
|
||||
|
||||
echo "构建环境: DEPLOY_ENV=$DEPLOY_ENV"
|
||||
|
||||
# 1. 配置镜像并安装依赖
|
||||
$PNPM_PATH config set registry https://registry.npmmirror.com
|
||||
$PNPM_PATH install --frozen-lockfile
|
||||
@@ -110,9 +114,16 @@ jobs:
|
||||
- name: Upload dist to server
|
||||
run: |
|
||||
TARGET="${{ steps.detect.outputs.target }}"
|
||||
ENV_NAME="${{ steps.detect.outputs.env }}"
|
||||
# 请根据你的实际构建输出路径调整
|
||||
H5_SOURCE_DIR="dist/build/h5"
|
||||
|
||||
# 根据发布类型选择项目路径
|
||||
if [ "$ENV_NAME" = "staging" ]; then
|
||||
WEB_ROOT="${{ vars.STG_PROJECT_DIR }}"
|
||||
else
|
||||
WEB_ROOT="${{ vars.PROJECT_DIR }}"
|
||||
fi
|
||||
|
||||
echo "部署到: $TARGET"
|
||||
echo "源目录: $H5_SOURCE_DIR"
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
<view class="icon-door-right"></view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="door-state-title">柜门已打开</text>
|
||||
<text class="door-state-desc">请取走商品后随手关门</text>
|
||||
<text class="door-state-title">门锁已打开</text>
|
||||
<text class="door-state-desc">请先拉开柜门,取走商品后随手关门</text>
|
||||
<view class="door-state-divider"></view>
|
||||
<view class="door-steps">
|
||||
<view class="step-item">
|
||||
@@ -39,9 +39,11 @@
|
||||
<text class="step-text">完成订单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="door-btn-area">
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 已关门 -->
|
||||
<view v-if="step === 'closed'" class="door-state-bg">
|
||||
@@ -74,9 +76,11 @@
|
||||
<text class="step-text">完成订单</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="door-btn-area">
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 订单完成 -->
|
||||
<view v-if="step === 'complete'" class="door-state-bg">
|
||||
@@ -92,31 +96,42 @@
|
||||
|
||||
<!-- 订单信息 -->
|
||||
<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-area">
|
||||
<view class="door-btn-detail" @click="goOrderDetail">查看订单详情</view>
|
||||
<view class="door-btn-close" @click="handleClose">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { get, post } from '@/utils/request.js';
|
||||
import { detectPlatform } from '@/utils/env.js';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -137,17 +152,20 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
// 外部调用:启动开门流程
|
||||
async open() {
|
||||
async open(userId) {
|
||||
if (this.step) return;
|
||||
|
||||
this.cancelled = false;
|
||||
this.step = 'opening';
|
||||
|
||||
const uid = userId || this.userId;
|
||||
|
||||
try {
|
||||
const res = await post('/device-scan/open', {
|
||||
device_id: this.deviceId,
|
||||
door_index: 0,
|
||||
user_id: this.userId
|
||||
user_id: uid,
|
||||
platform: detectPlatform()
|
||||
});
|
||||
|
||||
const ret = res.data || {};
|
||||
@@ -177,6 +195,7 @@ export default {
|
||||
const maxRetries = 30;
|
||||
const interval = 2000;
|
||||
let remaining = maxRetries;
|
||||
let lastStep = '';
|
||||
|
||||
while (remaining > 0) {
|
||||
if (this.step === 'complete' || this.cancelled) return;
|
||||
@@ -190,18 +209,24 @@ export default {
|
||||
const ret = res.data || {};
|
||||
if (ret.code === 0 && Array.isArray(ret.data) && ret.data.length > 0) {
|
||||
const latestStatus = ret.data[0].status;
|
||||
let newStep = '';
|
||||
|
||||
if (latestStatus === 101) {
|
||||
remaining = maxRetries;
|
||||
this.step = 'opened';
|
||||
newStep = 'opened';
|
||||
} else if (latestStatus === 103) {
|
||||
remaining = maxRetries;
|
||||
this.step = 'closed';
|
||||
newStep = 'closed';
|
||||
} else if (latestStatus === 201) {
|
||||
this.step = 'complete';
|
||||
this.fetchOrder(flowId);
|
||||
return;
|
||||
}
|
||||
|
||||
// 状态真正变化时才重置计数器
|
||||
if (newStep && newStep !== lastStep) {
|
||||
this.step = newStep;
|
||||
lastStep = newStep;
|
||||
remaining = maxRetries;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[door-panel] 轮询失败:', e);
|
||||
@@ -211,19 +236,29 @@ export default {
|
||||
await new Promise(resolve => setTimeout(resolve, interval));
|
||||
}
|
||||
|
||||
// 超时
|
||||
// 轮询结束
|
||||
if (this.step === 'opening') {
|
||||
this.step = '';
|
||||
uni.showToast({ title: '开门超时,请重试', icon: 'none' });
|
||||
}
|
||||
},
|
||||
|
||||
// 查询订单信息
|
||||
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 +267,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 = '';
|
||||
@@ -300,7 +355,7 @@ export default {
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: linear-gradient(160deg, #0a1628 0%, #132743 40%, #1a3a5c 100%);
|
||||
background: #fff;
|
||||
z-index: 3000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -327,20 +382,22 @@ export default {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 48rpx;
|
||||
/* 动效环 scale(1.6) 会超出容器,预留空间避免被裁剪 */
|
||||
margin-top: 60rpx;
|
||||
}
|
||||
.door-state-ring {
|
||||
position: absolute;
|
||||
width: 180rpx;
|
||||
height: 180rpx;
|
||||
border-radius: 50%;
|
||||
border: 4rpx solid rgba(41, 121, 255, 0.4);
|
||||
border: 4rpx solid rgba(41, 121, 255, 0.3);
|
||||
animation: ring-pulse 2s ease-out infinite;
|
||||
}
|
||||
.warning-ring {
|
||||
border-color: rgba(250, 173, 20, 0.4);
|
||||
border-color: rgba(250, 173, 20, 0.3);
|
||||
}
|
||||
.success-ring {
|
||||
border-color: rgba(82, 196, 26, 0.4);
|
||||
border-color: rgba(82, 196, 26, 0.3);
|
||||
}
|
||||
@keyframes ring-pulse {
|
||||
0% { transform: scale(0.8); opacity: 1; }
|
||||
@@ -360,7 +417,7 @@ export default {
|
||||
.icon-door-left {
|
||||
width: 28rpx;
|
||||
height: 56rpx;
|
||||
background: rgba(41, 121, 255, 0.9);
|
||||
background: #2979ff;
|
||||
border-radius: 6rpx;
|
||||
transform: perspective(200rpx) rotateY(25deg);
|
||||
animation: door-left-open 0.8s ease-out forwards;
|
||||
@@ -368,7 +425,7 @@ export default {
|
||||
.icon-door-right {
|
||||
width: 28rpx;
|
||||
height: 56rpx;
|
||||
background: rgba(41, 121, 255, 0.9);
|
||||
background: #2979ff;
|
||||
border-radius: 6rpx;
|
||||
transform: perspective(200rpx) rotateY(-25deg);
|
||||
animation: door-right-open 0.8s ease-out forwards;
|
||||
@@ -391,7 +448,7 @@ export default {
|
||||
.lock-body {
|
||||
width: 48rpx;
|
||||
height: 36rpx;
|
||||
background: rgba(250, 173, 20, 0.9);
|
||||
background: #faad14;
|
||||
border-radius: 6rpx;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
@@ -399,7 +456,7 @@ export default {
|
||||
.lock-hole {
|
||||
width: 28rpx;
|
||||
height: 24rpx;
|
||||
border: 5rpx solid rgba(250, 173, 20, 0.9);
|
||||
border: 5rpx solid #faad14;
|
||||
border-radius: 14rpx 14rpx 0 0;
|
||||
border-bottom: none;
|
||||
position: absolute;
|
||||
@@ -412,8 +469,8 @@ export default {
|
||||
.icon-check {
|
||||
width: 40rpx;
|
||||
height: 24rpx;
|
||||
border-left: 5rpx solid #fff;
|
||||
border-bottom: 5rpx solid #fff;
|
||||
border-left: 5rpx solid #52c41a;
|
||||
border-bottom: 5rpx solid #52c41a;
|
||||
transform: rotate(-45deg);
|
||||
margin-top: -8rpx;
|
||||
}
|
||||
@@ -422,13 +479,13 @@ export default {
|
||||
.door-state-title {
|
||||
font-size: 44rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
color: #333;
|
||||
margin-bottom: 16rpx;
|
||||
letter-spacing: 4rpx;
|
||||
}
|
||||
.door-state-desc {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
color: #999;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
@@ -436,7 +493,7 @@ export default {
|
||||
.door-state-divider {
|
||||
width: 80rpx;
|
||||
height: 4rpx;
|
||||
background: linear-gradient(90deg, transparent, rgba(41, 121, 255, 0.6), transparent);
|
||||
background: linear-gradient(90deg, transparent, #2979ff, transparent);
|
||||
border-radius: 2rpx;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
@@ -456,50 +513,87 @@ export default {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.15);
|
||||
background: #f5f5f5;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 22rpx;
|
||||
color: rgba(255, 255, 255, 0.35);
|
||||
color: #999;
|
||||
}
|
||||
.step-dot.active {
|
||||
background: rgba(41, 121, 255, 0.2);
|
||||
background: rgba(41, 121, 255, 0.1);
|
||||
border-color: #2979ff;
|
||||
color: #2979ff;
|
||||
box-shadow: 0 0 16rpx rgba(41, 121, 255, 0.3);
|
||||
}
|
||||
.step-dot.done {
|
||||
background: rgba(41, 121, 255, 0.15);
|
||||
border-color: rgba(41, 121, 255, 0.5);
|
||||
color: rgba(41, 121, 255, 0.8);
|
||||
background: rgba(41, 121, 255, 0.1);
|
||||
border-color: #2979ff;
|
||||
color: #2979ff;
|
||||
font-size: 20rpx;
|
||||
}
|
||||
.step-text {
|
||||
font-size: 22rpx;
|
||||
color: rgba(255, 255, 255, 0.45);
|
||||
color: #999;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.step-line {
|
||||
width: 60rpx;
|
||||
height: 2rpx;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
background: #e0e0e0;
|
||||
margin-bottom: 36rpx;
|
||||
}
|
||||
.step-line.done {
|
||||
background: rgba(41, 121, 255, 0.4);
|
||||
background: #2979ff;
|
||||
}
|
||||
|
||||
/* ====== 订单卡片 ====== */
|
||||
.door-order-card {
|
||||
width: 100%;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.08);
|
||||
background: #f8f8f8;
|
||||
border: 1rpx solid #f0f0f0;
|
||||
border-radius: 20rpx;
|
||||
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 #f0f0f0;
|
||||
}
|
||||
.door-product-img {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 10rpx;
|
||||
background: #f0f0f0;
|
||||
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: #333;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.door-product-price {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
.door-order-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -507,41 +601,59 @@ export default {
|
||||
padding: 16rpx 0;
|
||||
}
|
||||
.door-order-row + .door-order-row {
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.06);
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
}
|
||||
.door-order-row.total {
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.1);
|
||||
border-top: 1rpx solid #e0e0e0;
|
||||
margin-top: 8rpx;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
.door-order-label {
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.5);
|
||||
color: #999;
|
||||
}
|
||||
.door-order-value {
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
color: #333;
|
||||
}
|
||||
.door-price {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #ff6b6b;
|
||||
color: #e4393c;
|
||||
}
|
||||
.door-order-loading {
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
color: #999;
|
||||
text-align: center;
|
||||
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;
|
||||
}
|
||||
|
||||
/* ====== 关闭按钮 ====== */
|
||||
.door-btn-close {
|
||||
margin-top: 48rpx;
|
||||
font-size: 30rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
color: #2979ff;
|
||||
padding: 24rpx 100rpx;
|
||||
background: rgba(41, 121, 255, 0.15);
|
||||
border: 1rpx solid rgba(41, 121, 255, 0.4);
|
||||
background: #fff;
|
||||
border: 2rpx solid #2979ff;
|
||||
border-radius: 48rpx;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
|
||||
+16
-2
@@ -1,16 +1,30 @@
|
||||
/**
|
||||
* 环境配置入口
|
||||
* 根据编译模式自动选择 dev / prod 配置
|
||||
* 根据编译模式自动选择 dev / staging / prod 配置
|
||||
*
|
||||
* DEPLOY_ENV 环境变量:
|
||||
* - 'staging' → 预发布环境
|
||||
* - 'production' → 生产环境(默认)
|
||||
* - 未设置且 NODE_ENV !== 'production' → 开发环境
|
||||
*/
|
||||
import common from './index.js';
|
||||
import dev from './dev.js';
|
||||
import staging from './staging.js';
|
||||
import prod from './prod.js';
|
||||
|
||||
// uni-app 编译时通过 define 注译 __UNI_PLATFORM__
|
||||
// H5 开发模式下 process.env.NODE_ENV === 'development'
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
const deployEnv = process.env.DEPLOY_ENV;
|
||||
|
||||
const envConfig = isProd ? prod : dev;
|
||||
let envConfig;
|
||||
if (!isProd) {
|
||||
envConfig = dev;
|
||||
} else if (deployEnv === 'staging') {
|
||||
envConfig = staging;
|
||||
} else {
|
||||
envConfig = prod;
|
||||
}
|
||||
|
||||
const config = {
|
||||
...common,
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
const prod = {
|
||||
// 业务 API 地址(vms-api)
|
||||
apiBaseUrl: 'http://101.200.86.98:4000',
|
||||
apiBaseUrl: 'https://vmsapi.arklinksmart.cn',
|
||||
|
||||
// 网关地址(vms-gateway)— 用户授权、短信等接口走网关
|
||||
apiGatewayUrl: 'https://gateway.arklinksmart.cn',
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 预发布环境配置
|
||||
*/
|
||||
const staging = {
|
||||
// 业务 API 地址(vms-api)
|
||||
apiBaseUrl: 'https://vmsapi.arklinksmart.cn',
|
||||
|
||||
// 网关地址(vms-gateway)— 用户授权、短信等接口走网关
|
||||
apiGatewayUrl: 'https://gateway.arklinksmart.cn',
|
||||
|
||||
// 授权回调地址(微信 OAuth redirect_uri,必须 HTTPS,指向前端页面)
|
||||
authRedirectUri: 'https://pre-m.arklinksmart.cn/pages/auth/loading',
|
||||
|
||||
// 生产环境 Token 从登录流程获取,此处为空
|
||||
bearerToken: '',
|
||||
|
||||
enableRequestLog: false,
|
||||
};
|
||||
|
||||
export default staging;
|
||||
@@ -47,24 +47,6 @@
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/door/opened",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/door/closed",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/door/complete",
|
||||
"style": {
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
|
||||
+82
-46
@@ -30,10 +30,29 @@ export default {
|
||||
}
|
||||
|
||||
// 从 URL 参数获取 code(App.vue 跳转时带过来)
|
||||
let code = options.code || '';
|
||||
// 支付宝回调参数名是 auth_code,微信是 code
|
||||
let code = options.code || options.auth_code || '';
|
||||
if (!code) {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
code = urlParams.get('code') || '';
|
||||
code = urlParams.get('code') || urlParams.get('auth_code') || '';
|
||||
}
|
||||
|
||||
// 解析 state 参数(OAuth 标准保证 state 原样回传,包含 action 和 device_id)
|
||||
if (!this.action || !this.deviceId) {
|
||||
const stateRaw = options.state || '';
|
||||
if (stateRaw) {
|
||||
try {
|
||||
const stateObj = JSON.parse(decodeURIComponent(stateRaw));
|
||||
if (!this.action && stateObj.action) {
|
||||
this.action = stateObj.action;
|
||||
}
|
||||
if (!this.deviceId && stateObj.device_id) {
|
||||
this.deviceId = stateObj.device_id;
|
||||
}
|
||||
} catch (_) {
|
||||
// state 解析失败,继续用 localStorage 兜底
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 兜底:从 localStorage 恢复(页面复用时 onLoad 不触发,localStorage 由跳转函数清理)
|
||||
@@ -72,6 +91,9 @@ export default {
|
||||
* 发起 OAuth 授权(静默授权,只获取 openid)
|
||||
*/
|
||||
async startAuth() {
|
||||
// 清除上次使用的 code 标记
|
||||
uni.removeStorageSync('__used_auth_code');
|
||||
|
||||
const platform = detectPlatform();
|
||||
const appNo = getAppNo(platform);
|
||||
|
||||
@@ -94,29 +116,26 @@ export default {
|
||||
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
|
||||
);
|
||||
|
||||
// 使用 snsapi_base 静默授权,不弹窗
|
||||
// 静默授权:微信用 snsapi_base,支付宝用 auth_base
|
||||
const scopes = platform === 'alipay' ? 'auth_base' : 'snsapi_base';
|
||||
|
||||
// 构建 state(包含 device_id,回调时原样回传)
|
||||
const stateObj = {};
|
||||
if (this.deviceId) {
|
||||
stateObj.device_id = this.deviceId;
|
||||
}
|
||||
|
||||
const res = await gatewayGet('/api/v1/user/auth/url', {
|
||||
app_no: appNo,
|
||||
scopes: 'snsapi_base',
|
||||
scopes: scopes,
|
||||
redirect_uri: redirectUri,
|
||||
state: Object.keys(stateObj).length > 0 ? JSON.stringify(stateObj) : '',
|
||||
});
|
||||
|
||||
const data = res.data || {};
|
||||
if (data.code === 0 && data.data && data.data.auth_url) {
|
||||
// 通过 state 传递 device_id(OAuth 标准保证 state 原样回传)
|
||||
let authUrl = data.data.auth_url;
|
||||
if (this.deviceId) {
|
||||
const stateVal = encodeURIComponent(JSON.stringify({ device_id: this.deviceId }));
|
||||
try {
|
||||
const urlObj = new URL(authUrl);
|
||||
urlObj.searchParams.set('state', stateVal);
|
||||
authUrl = urlObj.toString();
|
||||
} catch (_) {
|
||||
authUrl += (authUrl.includes('?') ? '&' : '?') + 'state=' + stateVal;
|
||||
}
|
||||
}
|
||||
// 跳转微信授权页(静默,不弹窗)
|
||||
window.location.href = authUrl;
|
||||
// 后端已将 state 写入授权 URL,直接跳转
|
||||
window.location.href = data.data.auth_url;
|
||||
} else {
|
||||
uni.showToast({ title: data.message || '获取授权失败', icon: 'none' });
|
||||
setTimeout(() => this.goToScan(), 1500);
|
||||
@@ -140,6 +159,21 @@ 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('auth_code');
|
||||
url.searchParams.delete('state');
|
||||
window.history.replaceState({}, '', url.toString());
|
||||
|
||||
try {
|
||||
this.statusText = '正在验证身份...';
|
||||
|
||||
@@ -165,12 +199,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 +247,9 @@ export default {
|
||||
* 发起非静默授权获取用户信息(snsapi_userinfo,弹窗确认)
|
||||
*/
|
||||
async startUserInfoAuth() {
|
||||
// 清除上次使用的 code 标记
|
||||
uni.removeStorageSync('__used_auth_code');
|
||||
|
||||
const platform = detectPlatform();
|
||||
const appNo = getAppNo(platform);
|
||||
|
||||
@@ -242,30 +273,26 @@ export default {
|
||||
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
|
||||
);
|
||||
|
||||
const res = await gatewayGet('/api/v1/user/auth/url', {
|
||||
app_no: appNo,
|
||||
scopes: 'snsapi_userinfo',
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
// 用户信息授权:微信用 snsapi_userinfo,支付宝用 auth_user
|
||||
const scopes = platform === 'alipay' ? 'auth_user' : 'snsapi_userinfo';
|
||||
|
||||
const data = res.data || {};
|
||||
if (data.code === 0 && data.data && data.data.auth_url) {
|
||||
// 通过 state 传递 action 和 device_id(OAuth 标准保证 state 原样回传)
|
||||
// 构建 state(包含 action 和 device_id,回调时原样回传)
|
||||
const stateObj = { action: 'userinfo' };
|
||||
if (this.deviceId) {
|
||||
stateObj.device_id = this.deviceId;
|
||||
}
|
||||
const stateVal = encodeURIComponent(JSON.stringify(stateObj));
|
||||
let authUrl = data.data.auth_url;
|
||||
try {
|
||||
const urlObj = new URL(authUrl);
|
||||
urlObj.searchParams.set('state', stateVal);
|
||||
authUrl = urlObj.toString();
|
||||
} catch (_) {
|
||||
authUrl += (authUrl.includes('?') ? '&' : '?') + 'state=' + stateVal;
|
||||
}
|
||||
// 跳转微信授权页(弹窗确认)
|
||||
window.location.href = authUrl;
|
||||
|
||||
const res = await gatewayGet('/api/v1/user/auth/url', {
|
||||
app_no: appNo,
|
||||
scopes: scopes,
|
||||
redirect_uri: redirectUri,
|
||||
state: JSON.stringify(stateObj),
|
||||
});
|
||||
|
||||
const data = res.data || {};
|
||||
if (data.code === 0 && data.data && data.data.auth_url) {
|
||||
// 后端已将 state 写入授权 URL,直接跳转
|
||||
window.location.href = data.data.auth_url;
|
||||
} else {
|
||||
uni.showToast({ title: data.message || '获取授权失败', icon: 'none' });
|
||||
setTimeout(() => this.goToHomeWithAction(), 1500);
|
||||
@@ -288,16 +315,25 @@ export default {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.statusText = '正在获取用户信息...';
|
||||
// 防止 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 参数,避免刷新重复处理
|
||||
// 立即清除 URL 中的 code/action 参数,避免刷新重复处理
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('code');
|
||||
url.searchParams.delete('auth_code');
|
||||
url.searchParams.delete('state');
|
||||
url.searchParams.delete('action');
|
||||
window.history.replaceState({}, '', url.toString());
|
||||
|
||||
try {
|
||||
this.statusText = '正在获取用户信息...';
|
||||
|
||||
// 用 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', {
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
<template>
|
||||
<view class="door-page">
|
||||
<!-- 顶部状态区域 -->
|
||||
<view class="status-section">
|
||||
<view class="status-icon closed">
|
||||
<view class="icon-lock">
|
||||
<view class="lock-body"></view>
|
||||
<view class="lock-hole"></view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="status-title">柜门已关闭</text>
|
||||
<text class="status-desc">订单处理中,请稍候...</text>
|
||||
</view>
|
||||
|
||||
<!-- 设备信息 -->
|
||||
<view class="info-card">
|
||||
<view class="info-row">
|
||||
<text class="info-label">设备编号</text>
|
||||
<text class="info-value">{{ deviceId }}</text>
|
||||
</view>
|
||||
<view class="info-row" v-if="flowId">
|
||||
<text class="info-label">流水号</text>
|
||||
<text class="info-value">{{ flowId }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 提示信息 -->
|
||||
<view class="tips-card">
|
||||
<view class="tips-title">温馨提示</view>
|
||||
<view class="tips-list">
|
||||
<text class="tips-item">• 系统正在处理您的订单</text>
|
||||
<text class="tips-item">• 请在"我的订单"中查看订单状态</text>
|
||||
<text class="tips-item">• 如有问题请联系客服</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="bottom-actions">
|
||||
<view class="btn-outline" @click="handleViewOrder">查看订单</view>
|
||||
<view class="btn-primary" @click="handleBack">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
deviceId: '',
|
||||
flowId: ''
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
this.deviceId = options.device_id || '';
|
||||
this.flowId = options.flow_id || '';
|
||||
},
|
||||
methods: {
|
||||
handleViewOrder() {
|
||||
uni.navigateTo({ url: '/pages/order/order' });
|
||||
},
|
||||
handleBack() {
|
||||
uni.navigateBack({ delta: 10 });
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
page {
|
||||
height: 100%;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.door-page {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
/* 状态区域 */
|
||||
.status-section {
|
||||
background: linear-gradient(135deg, #faad14, #d48806);
|
||||
padding: 80rpx 40rpx 60rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.icon-lock {
|
||||
position: relative;
|
||||
width: 48rpx;
|
||||
height: 56rpx;
|
||||
}
|
||||
|
||||
.lock-body {
|
||||
width: 48rpx;
|
||||
height: 36rpx;
|
||||
background: #fff;
|
||||
border-radius: 6rpx;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.lock-hole {
|
||||
width: 28rpx;
|
||||
height: 24rpx;
|
||||
border: 5rpx solid #fff;
|
||||
border-radius: 14rpx 14rpx 0 0;
|
||||
border-bottom: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.status-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.status-desc {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
||||
/* 信息卡片 */
|
||||
.info-card {
|
||||
background: #fff;
|
||||
margin: 30rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 10rpx 30rpx;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 28rpx 0;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.info-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 提示卡片 */
|
||||
.tips-card {
|
||||
background: #fff;
|
||||
margin: 0 30rpx 30rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.tips-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.tips-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.tips-item {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
.bottom-actions {
|
||||
margin-top: auto;
|
||||
padding: 30rpx;
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
flex: 1;
|
||||
background: #fff;
|
||||
color: #2979ff;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
padding: 28rpx;
|
||||
border-radius: 48rpx;
|
||||
border: 2rpx solid #2979ff;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
flex: 1;
|
||||
background: linear-gradient(135deg, #2979ff, #1e60e0);
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
padding: 28rpx;
|
||||
border-radius: 48rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,305 +0,0 @@
|
||||
<template>
|
||||
<view class="door-page">
|
||||
<!-- 顶部状态区域 -->
|
||||
<view class="status-section">
|
||||
<view class="status-icon success">
|
||||
<view class="icon-check"></view>
|
||||
</view>
|
||||
<text class="status-title">订单已完成</text>
|
||||
<text class="status-desc">感谢您的购买</text>
|
||||
</view>
|
||||
|
||||
<!-- 订单信息 -->
|
||||
<view class="order-card">
|
||||
<view class="card-title">订单信息</view>
|
||||
<view v-if="orderLoading" class="loading-tip">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="orderInfo">
|
||||
<view class="info-row">
|
||||
<text class="info-label">订单编号</text>
|
||||
<text class="info-value">{{ orderInfo.order_no }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">下单时间</text>
|
||||
<text class="info-value">{{ orderInfo.created_at }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">商品数量</text>
|
||||
<text class="info-value">{{ orderInfo.product_count || '-' }} 件</text>
|
||||
</view>
|
||||
<view class="info-row total">
|
||||
<text class="info-label">订单金额</text>
|
||||
<text class="info-value price">¥{{ orderInfo.total_amount || '0.00' }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty-tip">
|
||||
<text>暂无订单信息</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 商品明细 -->
|
||||
<view v-if="orderInfo && orderInfo.items && orderInfo.items.length" class="products-card">
|
||||
<view class="card-title">商品明细</view>
|
||||
<view class="product-item" v-for="(item, idx) in orderInfo.items" :key="idx">
|
||||
<view class="product-info">
|
||||
<text class="product-name">{{ item.name }}</text>
|
||||
<text class="product-spec">{{ item.spec || '' }}</text>
|
||||
</view>
|
||||
<view class="product-right">
|
||||
<text class="product-price">¥{{ item.price }}</text>
|
||||
<text class="product-qty">x{{ item.quantity }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="bottom-actions">
|
||||
<view class="btn-outline" @click="handleViewOrder">查看全部订单</view>
|
||||
<view class="btn-primary" @click="handleBack">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { get } from '@/utils/request.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
deviceId: '',
|
||||
flowId: '',
|
||||
orderInfo: null,
|
||||
orderLoading: false
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
this.deviceId = options.device_id || '';
|
||||
this.flowId = options.flow_id || '';
|
||||
this.fetchOrderInfo();
|
||||
},
|
||||
methods: {
|
||||
async fetchOrderInfo() {
|
||||
if (!this.flowId) return;
|
||||
|
||||
this.orderLoading = true;
|
||||
try {
|
||||
// 通过 flow_id 查询订单信息
|
||||
const res = await get('/order/getByFlowId', {
|
||||
flow_id: this.flowId
|
||||
});
|
||||
|
||||
const ret = res.data || {};
|
||||
if (ret.code === 0 && ret.data) {
|
||||
this.orderInfo = ret.data;
|
||||
} else {
|
||||
console.warn('[complete] 获取订单信息失败:', ret.message);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[complete] 获取订单信息异常:', e);
|
||||
} finally {
|
||||
this.orderLoading = false;
|
||||
}
|
||||
},
|
||||
handleViewOrder() {
|
||||
uni.navigateTo({ url: '/pages/order/order' });
|
||||
},
|
||||
handleBack() {
|
||||
uni.navigateBack({ delta: 10 });
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
page {
|
||||
height: 100%;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.door-page {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
/* 状态区域 */
|
||||
.status-section {
|
||||
background: linear-gradient(135deg, #52c41a, #389e0d);
|
||||
padding: 80rpx 40rpx 60rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.status-icon.success .icon-check {
|
||||
width: 50rpx;
|
||||
height: 28rpx;
|
||||
border-left: 6rpx solid #fff;
|
||||
border-bottom: 6rpx solid #fff;
|
||||
transform: rotate(-45deg);
|
||||
margin-top: -10rpx;
|
||||
}
|
||||
|
||||
.status-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.status-desc {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
||||
/* 通用卡片 */
|
||||
.order-card,
|
||||
.products-card {
|
||||
background: #fff;
|
||||
margin: 30rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 24rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
/* 订单信息行 */
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.info-row.total {
|
||||
padding-top: 24rpx;
|
||||
margin-top: 12rpx;
|
||||
border-top: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.info-value.price {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #e4393c;
|
||||
}
|
||||
|
||||
/* 商品明细 */
|
||||
.product-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.product-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.product-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.product-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.product-spec {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.product-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 8rpx;
|
||||
}
|
||||
|
||||
.product-price {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.product-qty {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
/* 加载/空状态 */
|
||||
.loading-tip,
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
padding: 40rpx;
|
||||
color: #999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
.bottom-actions {
|
||||
margin-top: auto;
|
||||
padding: 30rpx;
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
flex: 1;
|
||||
background: #fff;
|
||||
color: #2979ff;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
padding: 28rpx;
|
||||
border-radius: 48rpx;
|
||||
border: 2rpx solid #2979ff;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
flex: 1;
|
||||
background: linear-gradient(135deg, #2979ff, #1e60e0);
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
padding: 28rpx;
|
||||
border-radius: 48rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -1,189 +0,0 @@
|
||||
<template>
|
||||
<view class="door-page">
|
||||
<!-- 顶部状态区域 -->
|
||||
<view class="status-section">
|
||||
<view class="status-icon success">
|
||||
<view class="icon-check"></view>
|
||||
</view>
|
||||
<text class="status-title">柜门已打开</text>
|
||||
<text class="status-desc">请取走商品后关闭柜门</text>
|
||||
</view>
|
||||
|
||||
<!-- 设备信息 -->
|
||||
<view class="info-card">
|
||||
<view class="info-row">
|
||||
<text class="info-label">设备编号</text>
|
||||
<text class="info-value">{{ deviceId }}</text>
|
||||
</view>
|
||||
<view class="info-row" v-if="flowId">
|
||||
<text class="info-label">流水号</text>
|
||||
<text class="info-value">{{ flowId }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 提示信息 -->
|
||||
<view class="tips-card">
|
||||
<view class="tips-title">温馨提示</view>
|
||||
<view class="tips-list">
|
||||
<text class="tips-item">• 取走商品后请随手关门</text>
|
||||
<text class="tips-item">• 关门后系统将自动完成订单</text>
|
||||
<text class="tips-item">• 如有问题请联系客服</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="bottom-actions">
|
||||
<view class="btn-primary" @click="handleBack">返回首页</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
deviceId: '',
|
||||
flowId: ''
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
this.deviceId = options.device_id || '';
|
||||
this.flowId = options.flow_id || '';
|
||||
},
|
||||
methods: {
|
||||
handleBack() {
|
||||
uni.navigateBack({ delta: 10 });
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
page {
|
||||
height: 100%;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.door-page {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f5f5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
padding-bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
|
||||
/* 状态区域 */
|
||||
.status-section {
|
||||
background: linear-gradient(135deg, #52c41a, #389e0d);
|
||||
padding: 80rpx 40rpx 60rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.status-icon {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.status-icon.success .icon-check {
|
||||
width: 50rpx;
|
||||
height: 28rpx;
|
||||
border-left: 6rpx solid #fff;
|
||||
border-bottom: 6rpx solid #fff;
|
||||
transform: rotate(-45deg);
|
||||
margin-top: -10rpx;
|
||||
}
|
||||
|
||||
.status-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.status-desc {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
||||
/* 信息卡片 */
|
||||
.info-card {
|
||||
background: #fff;
|
||||
margin: 30rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 10rpx 30rpx;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 28rpx 0;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.info-row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 提示卡片 */
|
||||
.tips-card {
|
||||
background: #fff;
|
||||
margin: 0 30rpx 30rpx;
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.tips-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.tips-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.tips-item {
|
||||
font-size: 26rpx;
|
||||
color: #666;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
/* 底部按钮 */
|
||||
.bottom-actions {
|
||||
margin-top: auto;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, #2979ff, #1e60e0);
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
padding: 28rpx;
|
||||
border-radius: 48rpx;
|
||||
}
|
||||
</style>
|
||||
+2
-22
@@ -44,17 +44,7 @@ export default {
|
||||
faqList: [
|
||||
{
|
||||
question: '如何购买商品?',
|
||||
answer: '在首页浏览商品,点击商品卡片选择商品,确认后即可完成购买。支持微信支付和支付宝支付。',
|
||||
expanded: false
|
||||
},
|
||||
{
|
||||
question: '如何开门取货?',
|
||||
answer: '下单成功后,点击首页底部中间的"开门"按钮,柜门会自动打开,取出商品后关闭柜门即可。',
|
||||
expanded: false
|
||||
},
|
||||
{
|
||||
question: '商品质量问题怎么办?',
|
||||
answer: '如发现商品有质量问题,请在24小时内通过"联系客服"反馈,我们会为您办理退款或换货。',
|
||||
answer: '使用微信或支付宝扫描柜体上的二维码,进入开门页面,如果是首次使用需先进行授权登录与注册,浏览设备中售卖的商品及价格,点击开门,待门锁打开后,拉开门选购商品,关门即完成购买,约1-2分钟内系统将自动识别并完成扣款。',
|
||||
expanded: false
|
||||
},
|
||||
{
|
||||
@@ -62,16 +52,6 @@ export default {
|
||||
answer: '进入"我的"页面,点击"我的订单"可查看所有订单记录,包括待付款、已完成、已退款等状态。',
|
||||
expanded: false
|
||||
},
|
||||
{
|
||||
question: '忘记密码怎么办?',
|
||||
answer: '在登录页面点击"忘记密码",输入注册手机号,通过短信验证码即可重置密码。',
|
||||
expanded: false
|
||||
},
|
||||
{
|
||||
question: '如何修改收货地址?',
|
||||
answer: '进入"我的"页面,点击"收货地址",可以新增、编辑或删除收货地址信息。',
|
||||
expanded: false
|
||||
},
|
||||
{
|
||||
question: '支持哪些支付方式?',
|
||||
answer: '目前支持微信支付、支付宝支付两种方式,后续将开通更多支付渠道。',
|
||||
@@ -79,7 +59,7 @@ export default {
|
||||
},
|
||||
{
|
||||
question: '退款多久到账?',
|
||||
answer: '退款申请审核通过后,微信支付1-3个工作日到账,支付宝1-5个工作日到账,具体以银行处理时间为准。',
|
||||
answer: '审核通过后,一般1-3个工作日到账,具体到账时间以支付渠道为准。',
|
||||
expanded: false
|
||||
}
|
||||
]
|
||||
|
||||
+33
-40
@@ -181,7 +181,7 @@ export default {
|
||||
loading: false,
|
||||
categoryList: [],
|
||||
activeCategory: 'all',
|
||||
userInfo: { nickname: '', phone: '', avatar: '' },
|
||||
userInfo: { user_id: '', nickname: '', phone: '', avatar: '' },
|
||||
avatarClickCount: 0,
|
||||
avatarClickTimer: null,
|
||||
fromPage: '', // 记录从哪个页面跳转过来的
|
||||
@@ -199,8 +199,7 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
userId() {
|
||||
const info = getCachedUserInfo();
|
||||
return (info && info.user_id) || '';
|
||||
return this.userInfo.user_id || '';
|
||||
},
|
||||
canGoBack() {
|
||||
// 有上一页,或者从 tab 切换过来的,都可以返回
|
||||
@@ -304,7 +303,7 @@ export default {
|
||||
if (cached) {
|
||||
this.userInfo = { ...this.userInfo, ...cached };
|
||||
} else {
|
||||
this.userInfo = { nickname: '', phone: '', avatar: '' };
|
||||
this.userInfo = { user_id: '', nickname: '', phone: '', avatar: '' };
|
||||
}
|
||||
console.log('[index] this.userInfo:', JSON.stringify(this.userInfo, null, 2));
|
||||
},
|
||||
@@ -317,6 +316,7 @@ export default {
|
||||
this.userInfo = { ...this.userInfo, ...cached };
|
||||
} else {
|
||||
this.userInfo = {
|
||||
user_id: config.mockUser.user_info.user_id || '',
|
||||
nickname: config.mockUser.user_info.nickname || '',
|
||||
phone: config.mockUser.user_info.phone || '',
|
||||
avatar: config.mockUser.user_info.avatar || '',
|
||||
@@ -344,34 +344,28 @@ export default {
|
||||
window.location.origin.replace(/^http:/, 'https:') + window.location.pathname
|
||||
);
|
||||
|
||||
// 获取非静默授权链接(会弹窗确认)
|
||||
const res = await gatewayGet('/api/v1/user/auth/url', {
|
||||
app_no: appNo,
|
||||
scopes: 'snsapi_userinfo',
|
||||
redirect_uri: redirectUri,
|
||||
});
|
||||
|
||||
const data = res.data || {};
|
||||
if (data.code === 0 && data.data && data.data.auth_url) {
|
||||
// 通过 state 传递 action 和 device_id(OAuth 标准保证 state 原样回传)
|
||||
// 构建 state(包含 action 和 device_id,回调时原样回传)
|
||||
const stateObj = { action: 'userinfo' };
|
||||
if (this.deviceId) {
|
||||
stateObj.device_id = this.deviceId;
|
||||
}
|
||||
const stateVal = encodeURIComponent(JSON.stringify(stateObj));
|
||||
// 解析 auth_url,安全地设置 state 参数(避免重复)
|
||||
let authUrl = data.data.auth_url;
|
||||
try {
|
||||
const urlObj = new URL(authUrl);
|
||||
urlObj.searchParams.set('state', stateVal);
|
||||
authUrl = urlObj.toString();
|
||||
} catch (_) {
|
||||
// URL 解析失败时直接拼接
|
||||
authUrl += (authUrl.includes('?') ? '&' : '?') + 'state=' + stateVal;
|
||||
}
|
||||
console.log('[index] 跳转授权页:', authUrl);
|
||||
// 跳转微信授权页(弹窗确认)
|
||||
window.location.href = authUrl;
|
||||
|
||||
// 用户信息授权:微信用 snsapi_userinfo,支付宝用 auth_user
|
||||
const platform = uni.getStorageSync('platform') || 'wechat';
|
||||
const scopes = platform === 'alipay' ? 'auth_user' : 'snsapi_userinfo';
|
||||
|
||||
const res = await gatewayGet('/api/v1/user/auth/url', {
|
||||
app_no: appNo,
|
||||
scopes: scopes,
|
||||
redirect_uri: redirectUri,
|
||||
state: JSON.stringify(stateObj),
|
||||
});
|
||||
|
||||
const data = res.data || {};
|
||||
if (data.code === 0 && data.data && data.data.auth_url) {
|
||||
console.log('[index] 跳转授权页:', data.data.auth_url);
|
||||
// 后端已将 state 写入授权 URL,直接跳转
|
||||
window.location.href = data.data.auth_url;
|
||||
} else {
|
||||
console.warn('[index] 获取授权链接失败:', data.message);
|
||||
}
|
||||
@@ -415,16 +409,18 @@ export default {
|
||||
// 检查用户信息,若缓存中没有则调接口获取
|
||||
if (!this.userId) {
|
||||
try {
|
||||
const infoRes = await gatewayGet('/api/v1/user/info', {});
|
||||
const openId = uni.getStorageSync('openid') || '';
|
||||
const infoRes = await gatewayGet('/api/v1/user/info', { open_id: openId });
|
||||
const infoData = (infoRes.data || {}).data || {};
|
||||
if (infoData.user_id) {
|
||||
const userInfo = infoData.user_info || {};
|
||||
if (userInfo.user_id) {
|
||||
const existing = getCachedUserInfo() || {};
|
||||
uni.setStorageSync('user_info', {
|
||||
...existing,
|
||||
user_id: infoData.user_id,
|
||||
nickname: infoData.nickname || existing.nickname || '',
|
||||
avatar: infoData.avatar || existing.avatar || '',
|
||||
phone: infoData.phone || existing.phone || '',
|
||||
user_id: userInfo.user_id,
|
||||
nickname: userInfo.nickname || existing.nickname || '',
|
||||
avatar: userInfo.avatar || existing.avatar || '',
|
||||
phone: userInfo.phone || existing.phone || '',
|
||||
});
|
||||
this.loadUserInfo();
|
||||
}
|
||||
@@ -439,7 +435,7 @@ export default {
|
||||
}
|
||||
|
||||
// 调用组件方法启动开门流程
|
||||
this.$refs.doorPanel.open();
|
||||
this.$refs.doorPanel.open(this.userId);
|
||||
},
|
||||
handleMenuClick(item) {
|
||||
switch (item.action) {
|
||||
@@ -500,11 +496,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) {
|
||||
|
||||
@@ -183,23 +183,32 @@ export default {
|
||||
});
|
||||
|
||||
const ret = res.data || {};
|
||||
console.log('[register] 注册响应:', JSON.stringify(ret, null, 2));
|
||||
|
||||
if (ret.code === 0 && ret.data) {
|
||||
// 保存 token
|
||||
uni.setStorageSync('token', ret.data.token);
|
||||
|
||||
// Mock 模式下,合并真实注册信息和 mock 配置
|
||||
// 存储 user_info(接口返回 user_info.user_id 和 phone)
|
||||
const existing = uni.getStorageSync('user_info') || {};
|
||||
const apiUserInfo = ret.data.user_info || {};
|
||||
const userInfo = {
|
||||
user_id: apiUserInfo.user_id || existing.user_id || '',
|
||||
phone: apiUserInfo.phone || this.phone || existing.phone || '',
|
||||
nickname: existing.nickname || '',
|
||||
avatar: existing.avatar || '',
|
||||
};
|
||||
|
||||
// Mock 模式下补充 mock 数据
|
||||
if (config.mockWechatLogin) {
|
||||
const mockInfo = config.mockUser.user_info;
|
||||
const userInfo = {
|
||||
user_id: ret.data.user_id || mockInfo.user_id,
|
||||
phone: this.phone, // 使用真实注册的手机号
|
||||
nickname: mockInfo.nickname,
|
||||
avatar: mockInfo.avatar,
|
||||
};
|
||||
uni.setStorageSync('user_info', userInfo);
|
||||
console.log('[register] Mock 模式,合并用户信息:', userInfo);
|
||||
userInfo.nickname = userInfo.nickname || mockInfo.nickname;
|
||||
userInfo.avatar = userInfo.avatar || mockInfo.avatar;
|
||||
}
|
||||
|
||||
uni.setStorageSync('user_info', userInfo);
|
||||
console.log('[register] 存储 user_info:', userInfo);
|
||||
|
||||
// 清除临时数据
|
||||
uni.removeStorageSync('temp_token');
|
||||
uni.removeStorageSync('auth_info');
|
||||
|
||||
+3
-3
@@ -6,9 +6,9 @@
|
||||
// app_no 编码表:platform + terminalType → app_no
|
||||
const APP_NO_MAP = {
|
||||
'wechat_h5': '60000001102001',
|
||||
'wechat_mp': '600102101',
|
||||
'alipay_h5': '600112001',
|
||||
'alipay_mp': '600112101',
|
||||
'wechat_mp': '60000001102101',
|
||||
'alipay_h5': '60000001112001',
|
||||
'alipay_mp': '60000001112101',
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,10 @@ function servePublicFiles() {
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [servePublicFiles(), uni()],
|
||||
// 将构建时的 DEPLOY_ENV 环境变量注入到客户端代码中
|
||||
define: {
|
||||
'process.env.DEPLOY_ENV': JSON.stringify(process.env.DEPLOY_ENV || ''),
|
||||
},
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
scss: {
|
||||
|
||||
Reference in New Issue
Block a user