|
@@ -15,15 +15,6 @@
|
|
|
|
|
|
|
|
<!-- 商品内容 -->
|
|
<!-- 商品内容 -->
|
|
|
<view v-else class="content">
|
|
<view v-else class="content">
|
|
|
- <!-- 顶部设备信息 -->
|
|
|
|
|
- <view class="device-header">
|
|
|
|
|
- <view class="device-name">{{ templateName || '智能零售柜' }}</view>
|
|
|
|
|
- <view class="device-info">
|
|
|
|
|
- <text class="info-tag">{{ deviceTypeText }}</text>
|
|
|
|
|
- <text class="info-tag">共{{ shelfNum }}层</text>
|
|
|
|
|
- </view>
|
|
|
|
|
- </view>
|
|
|
|
|
-
|
|
|
|
|
<!-- 双门柜Tab切换 -->
|
|
<!-- 双门柜Tab切换 -->
|
|
|
<view v-if="hasRightDoor" class="door-tabs">
|
|
<view v-if="hasRightDoor" class="door-tabs">
|
|
|
<view
|
|
<view
|
|
@@ -120,6 +111,8 @@
|
|
|
import { ref, computed } from 'vue';
|
|
import { ref, computed } from 'vue';
|
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
import { onLoad } from '@dcloudio/uni-app';
|
|
|
import { getDeviceProducts, scanDoor } from '@/api/device';
|
|
import { getDeviceProducts, scanDoor } from '@/api/device';
|
|
|
|
|
+import { checkPayscoreEnabled } from '@/api/payscore';
|
|
|
|
|
+import { isLoggedIn } from '@/utils/auth';
|
|
|
import type { FloorConfig } from '@/api/device';
|
|
import type { FloorConfig } from '@/api/device';
|
|
|
|
|
|
|
|
// 页面参数
|
|
// 页面参数
|
|
@@ -156,8 +149,30 @@ const currentFloors = computed(() => {
|
|
|
|
|
|
|
|
// 页面加载
|
|
// 页面加载
|
|
|
onLoad((options: any) => {
|
|
onLoad((options: any) => {
|
|
|
|
|
+ let id = '';
|
|
|
|
|
+
|
|
|
if (options?.deviceId) {
|
|
if (options?.deviceId) {
|
|
|
- deviceId.value = options.deviceId;
|
|
|
|
|
|
|
+ // 普通页面跳转传参
|
|
|
|
|
+ id = options.deviceId;
|
|
|
|
|
+ } else if (options?.q) {
|
|
|
|
|
+ // 微信扫码调起小程序,链接通过 q 参数传入(URL编码)
|
|
|
|
|
+ // 链接格式: https://dev-haha.kuaiyuman.cn/B150534
|
|
|
|
|
+ try {
|
|
|
|
|
+ const url = decodeURIComponent(options.q);
|
|
|
|
|
+ console.log('扫码链接:', url);
|
|
|
|
|
+ // 从 URL 路径中提取设备ID
|
|
|
|
|
+ const match = url.match(/\/([A-Za-z0-9]+)(?:\?|$)/);
|
|
|
|
|
+ if (match && match[1]) {
|
|
|
|
|
+ id = match[1];
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('解析扫码链接失败:', e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (id) {
|
|
|
|
|
+ console.log('设备ID:', id);
|
|
|
|
|
+ deviceId.value = id;
|
|
|
loadProducts();
|
|
loadProducts();
|
|
|
} else {
|
|
} else {
|
|
|
errorMsg.value = '缺少设备ID参数';
|
|
errorMsg.value = '缺少设备ID参数';
|
|
@@ -188,6 +203,40 @@ const loadProducts = async () => {
|
|
|
// 开门购物
|
|
// 开门购物
|
|
|
const handleOpenDoor = async () => {
|
|
const handleOpenDoor = async () => {
|
|
|
if (opening.value) return;
|
|
if (opening.value) return;
|
|
|
|
|
+
|
|
|
|
|
+ // 1. 登录校验
|
|
|
|
|
+ if (!isLoggedIn()) {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ content: '请先登录后再开门购物',
|
|
|
|
|
+ showCancel: false,
|
|
|
|
|
+ success: () => {
|
|
|
|
|
+ uni.reLaunch({
|
|
|
|
|
+ url: '/pages/login/login?redirect=/pages/products/products?deviceId=' + deviceId.value
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 支付分校验
|
|
|
|
|
+ try {
|
|
|
|
|
+ const payscoreResult = await checkPayscoreEnabled();
|
|
|
|
|
+ if (!payscoreResult.enabled) {
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/pages/payscore/enable'
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error: any) {
|
|
|
|
|
+ console.error('检查支付分状态失败:', error);
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/pages/payscore/enable'
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 执行开门
|
|
|
opening.value = true;
|
|
opening.value = true;
|
|
|
|
|
|
|
|
uni.showLoading({
|
|
uni.showLoading({
|
|
@@ -300,29 +349,6 @@ const goBack = () => {
|
|
|
font-weight: bold;
|
|
font-weight: bold;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* 设备信息头部 */
|
|
|
|
|
-.device-header {
|
|
|
|
|
- background: linear-gradient(135deg, #FFD700, #FFA500);
|
|
|
|
|
- padding: 30rpx;
|
|
|
|
|
- color: #333;
|
|
|
|
|
-}
|
|
|
|
|
-.device-name {
|
|
|
|
|
- font-size: 36rpx;
|
|
|
|
|
- font-weight: bold;
|
|
|
|
|
-}
|
|
|
|
|
-.device-info {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- gap: 16rpx;
|
|
|
|
|
- margin-top: 12rpx;
|
|
|
|
|
-}
|
|
|
|
|
-.info-tag {
|
|
|
|
|
- font-size: 24rpx;
|
|
|
|
|
- background: rgba(255,255,255,0.5);
|
|
|
|
|
- padding: 4rpx 16rpx;
|
|
|
|
|
- border-radius: 20rpx;
|
|
|
|
|
- color: #555;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
/* 门Tab切换 */
|
|
/* 门Tab切换 */
|
|
|
.door-tabs {
|
|
.door-tabs {
|
|
|
display: flex;
|
|
display: flex;
|