sunshibo 1 月之前
父節點
當前提交
ea79363e16
共有 2 個文件被更改,包括 38 次插入15 次删除
  1. 7 5
      components/Modal/BasicModal.vue
  2. 31 10
      pages/numberOfDiners/index.vue

+ 7 - 5
components/Modal/BasicModal.vue

@@ -5,7 +5,7 @@
 </template>
 
 <script setup>
-	import { ref, computed, unref, watch } from 'vue';
+	import { ref, computed, unref, watch, nextTick } from 'vue';
 	const props = defineProps({
 		open: { type: Boolean, default: false },
 		isMack: { type: Boolean, default: true }
@@ -19,10 +19,12 @@
 	})
 	
 	watch(getOpen, (v) => {
-		const p = unref(popup);
-		if (!p) return;
-		v ? p.open() : p.close();
-	})
+		nextTick(() => {
+			const p = unref(popup);
+			if (!p) return;
+			v ? p.open() : p.close();
+		});
+	}, { flush: 'post', immediate: true })
 	
 	function handleChange({ show }){
 		getOpen.value = show

+ 31 - 10
pages/numberOfDiners/index.vue

@@ -13,10 +13,12 @@
 
     <view class="more-number" @click="addDiners" v-if="diners < 16">查看更多</view>
 
-    <view class="confirm-button" @click="toOrderFood" hover-class="hover-active">确定</view>
+    <view class="confirm-button" @tap.stop="toOrderFood" hover-class="hover-active">确定</view>
 
-    <!-- 未登录时弹出:手机号授权一键登录 -->
-    <LoginModal v-model:open="showLoginModal" @success="handleLoginSuccess" @cancel="handleLoginCancel" />
+    <!-- 未登录时弹出:手机号授权一键登录(需高 z-index 盖住其他内容) -->
+    <view class="login-modal-wrapper">
+      <LoginModal v-model:open="showLoginModal" @success="handleLoginSuccess" @cancel="handleLoginCancel" />
+    </view>
   </view>
 </template>
 
@@ -26,13 +28,12 @@ import { ref } from "vue";
 import { go } from "@/utils/utils.js";
 import { useUserStore } from "@/store/user.js";
 import LoginModal from "@/pages/components/LoginModal.vue";
-import * as diningApi from "@/api/dining.js";
+import { TOKEN } from "@/settings/enums.js";
 
 const userStore = useUserStore();
 const diners = ref(12);
 const currentDiners = ref(1);
 const showLoginModal = ref(false);
-const checking = ref(false); // 是否正在查询桌位就餐状态
 // 登录成功后要跳转的点餐页参数(手机号授权完成后再跳转)
 const pendingNavigate = ref(null);
 
@@ -64,15 +65,16 @@ const toOrderFood = () => {
   const dinersVal = currentDiners.value;
   if (tableid) uni.setStorageSync('currentTableId', String(tableid));
 
-  if (!userStore.getToken) {
+  const token = userStore.getToken || uni.getStorageSync(TOKEN) || '';
+  if (!token) {
     // 未登录:弹出手机号授权一键登录弹窗,登录成功后再跳转
     pendingNavigate.value = { tableid, dinersVal };
     showLoginModal.value = true;
     return;
   }
-uni.reLaunch({
-  url: `/pages/orderFood/index?tableid=${tableid}&diners=${dinersVal}`
-});
+  uni.reLaunch({
+    url: `/pages/orderFood/index?tableid=${tableid}&diners=${dinersVal}`
+  });
 }
 
 // 接口由 App.vue 统一调用;App.vue 在 inDining 为 true 且未登录时会重定向到本页并带 inDining=1,此时需弹出登录
@@ -80,7 +82,8 @@ onLoad((options) => {
   const inDining = options?.inDining === '1' || options?.inDining === 1;
   const tableid = options?.tableid || uni.getStorageSync('currentTableId') || '';
   const dinersVal = options?.diners || uni.getStorageSync('currentDiners') || 1;
-  if (inDining && tableid && !userStore.getToken) {
+  const token = userStore.getToken || uni.getStorageSync(TOKEN) || '';
+  if (inDining && tableid && !token) {
     uni.setStorageSync('currentTableId', tableid);
     uni.setStorageSync('currentDiners', dinersVal);
     pendingNavigate.value = { tableid, dinersVal };
@@ -150,5 +153,23 @@ onLoad((options) => {
   left: 50%;
   transform: translateX(-50%);
   font-size: 32rpx;
+  z-index: 100;
+}
+
+/* 登录弹窗层级(与 index 一致,确保弹窗可显示) */
+.login-modal-wrapper {
+  position: relative;
+  z-index: 99999;
+
+  :deep(.uni-popup) {
+    z-index: 99999 !important;
+    top: 0 !important;
+    left: 0 !important;
+    right: 0 !important;
+    bottom: 0 !important;
+  }
+  :deep(.uni-popup__wrapper) {
+    z-index: 99999 !important;
+  }
 }
 </style>