room-confirm.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="hotel-customer-theme rc-page">
  3. <!-- 加载中 -->
  4. <view v-if="loading" class="rc-loading">
  5. <view class="rc-spinner" />
  6. <text class="rc-loading-text">正在验证房间信息...</text>
  7. </view>
  8. <!-- 错误状态 -->
  9. <view v-else-if="errorMsg" class="rc-error">
  10. <view class="rc-error-icon">!</view>
  11. <text class="rc-error-title">验证失败</text>
  12. <text class="rc-error-msg">{{ errorMsg }}</text>
  13. <view class="rc-error-btn" @click="retry">重新加载</view>
  14. </view>
  15. <!-- 房间确认 -->
  16. <view v-else class="rc-content">
  17. <!-- 顶部品牌区 -->
  18. <view class="rc-brand">
  19. <view class="rc-brand-icon">
  20. <text class="rc-brand-icon-text">🏨</text>
  21. </view>
  22. <text class="rc-brand-name">亚朵酒店</text>
  23. <text class="rc-brand-slogan">ATOUR HOTEL · 客房送餐服务</text>
  24. </view>
  25. <!-- 房间卡片 -->
  26. <view class="rc-card">
  27. <view class="rc-room-no">{{ roomInfo.roomNo }}</view>
  28. <view class="rc-room-type" v-if="roomInfo.roomTypeName">{{ roomInfo.roomTypeName }}</view>
  29. <view class="rc-verify-ok">
  30. <text class="rc-verify-icon">✓</text>
  31. <text>扫码验证成功</text>
  32. </view>
  33. <view class="rc-info-row">
  34. <text class="rc-info-icon">🕐</text>
  35. <text>营业时间:{{ businessHoursText }}</text>
  36. </view>
  37. <view class="rc-info-row">
  38. <text class="rc-info-icon">🛎️</text>
  39. <text>预计送达:约 {{ deliveryTime }} 分钟</text>
  40. </view>
  41. <view class="rc-info-row">
  42. <text class="rc-info-icon">💰</text>
  43. <text>配送费:{{ deliveryFee > 0 ? '¥' + deliveryFee : '免配送费' }}</text>
  44. </view>
  45. <view class="rc-start-btn" @click="goToMenu">开始点餐</view>
  46. </view>
  47. <view class="rc-wrong-link" @click="handleWrongRoom">
  48. 这不是我的房间?联系前台
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script setup>
  54. import { onMounted, ref } from 'vue'
  55. import { useHotelOrderStore } from '@/store'
  56. import api from '@/api'
  57. const orderStore = useHotelOrderStore()
  58. const loading = ref(true)
  59. const errorMsg = ref('')
  60. const roomInfo = ref({})
  61. const businessHoursText = ref('10:00 - 22:00')
  62. const deliveryTime = ref('25-35')
  63. const deliveryFee = ref(0)
  64. let shortCode = ''
  65. let sign = ''
  66. onMounted(async () => {
  67. const pages = getCurrentPages()
  68. const currentPage = pages[pages.length - 1]
  69. const options = currentPage?.$page?.options || currentPage?.options || {}
  70. shortCode = options.c || options.shortCode || ''
  71. sign = options.s || options.sign || ''
  72. if (!shortCode || !sign) {
  73. errorMsg.value = '二维码参数缺失,请重新扫描'
  74. loading.value = false
  75. return
  76. }
  77. await loadRoomInfo()
  78. })
  79. async function loadRoomInfo() {
  80. loading.value = true
  81. errorMsg.value = ''
  82. try {
  83. const res = await api.hotelCustomerScan({ shortCode, sign })
  84. const data = res?.data || res
  85. if (!data || !data.bound) {
  86. errorMsg.value = '该二维码尚未绑定房间,请联系前台处理'
  87. loading.value = false
  88. return
  89. }
  90. roomInfo.value = {
  91. roomId: data.room?.roomId,
  92. roomNo: data.room?.roomNo || '',
  93. roomTypeName: data.room?.roomTypeName || '',
  94. }
  95. // 存入 Store
  96. orderStore.setTenantId(data.tenantId)
  97. orderStore.setRoomInfo(roomInfo.value)
  98. // 加载酒店配置(暂时使用默认值,后续可扩展接口)
  99. orderStore.setHotelConfig({
  100. deliveryFee: 0,
  101. deliveryTime: '25-35',
  102. })
  103. deliveryFee.value = 0
  104. deliveryTime.value = '25-35'
  105. loading.value = false
  106. } catch (err) {
  107. loading.value = false
  108. errorMsg.value = err?.message || '无法识别该二维码,请检查是否有效'
  109. }
  110. }
  111. function retry() {
  112. loadRoomInfo()
  113. }
  114. function goToMenu() {
  115. uni.redirectTo({ url: '/pages/hotel/customer/menu' })
  116. }
  117. function handleWrongRoom() {
  118. uni.showModal({
  119. title: '提示',
  120. content: '如房间信息有误,请联系酒店前台确认',
  121. showCancel: false,
  122. })
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .rc-page {
  127. min-height: 100vh;
  128. background: var(--h-bg, #F7F7F7);
  129. }
  130. /* Loading */
  131. .rc-loading {
  132. display: flex;
  133. flex-direction: column;
  134. align-items: center;
  135. justify-content: center;
  136. min-height: 100vh;
  137. gap: 24rpx;
  138. }
  139. .rc-spinner {
  140. width: 64rpx;
  141. height: 64rpx;
  142. border: 6rpx solid #E8F0E3;
  143. border-top-color: var(--h-pri, #2D5016);
  144. border-radius: 50%;
  145. animation: rc-spin 0.8s linear infinite;
  146. }
  147. @keyframes rc-spin {
  148. to { transform: rotate(360deg); }
  149. }
  150. .rc-loading-text {
  151. color: var(--h-txt-sub, #666);
  152. font-size: 28rpx;
  153. }
  154. /* Error */
  155. .rc-error {
  156. display: flex;
  157. flex-direction: column;
  158. align-items: center;
  159. justify-content: center;
  160. min-height: 100vh;
  161. padding: 48rpx;
  162. gap: 16rpx;
  163. }
  164. .rc-error-icon {
  165. width: 120rpx;
  166. height: 120rpx;
  167. border-radius: 50%;
  168. background: var(--h-dang-lt, #FEE2E2);
  169. color: var(--h-dang, #DC2626);
  170. font-size: 56rpx;
  171. font-weight: 700;
  172. display: flex;
  173. align-items: center;
  174. justify-content: center;
  175. margin-bottom: 8rpx;
  176. }
  177. .rc-error-title {
  178. font-size: 36rpx;
  179. font-weight: 700;
  180. color: var(--h-txt, #1A1A1A);
  181. }
  182. .rc-error-msg {
  183. font-size: 26rpx;
  184. color: var(--h-txt-sub, #666);
  185. text-align: center;
  186. line-height: 1.6;
  187. }
  188. .rc-error-btn {
  189. margin-top: 16rpx;
  190. padding: 20rpx 64rpx;
  191. border-radius: 48rpx;
  192. background: var(--h-pri, #2D5016);
  193. color: #fff;
  194. font-size: 28rpx;
  195. font-weight: 600;
  196. }
  197. /* Content */
  198. .rc-content {
  199. display: flex;
  200. flex-direction: column;
  201. align-items: center;
  202. min-height: 100vh;
  203. padding-bottom: env(safe-area-inset-bottom);
  204. }
  205. /* Brand */
  206. .rc-brand {
  207. width: 100%;
  208. display: flex;
  209. flex-direction: column;
  210. align-items: center;
  211. padding: 80rpx 0 60rpx;
  212. background: linear-gradient(180deg, var(--h-pri, #2D5016) 0%, var(--h-pri-lt, #3A6B35) 60%, var(--h-bg, #F7F7F7) 100%);
  213. }
  214. .rc-brand-icon {
  215. width: 120rpx;
  216. height: 120rpx;
  217. border-radius: 32rpx;
  218. background: rgba(255, 255, 255, 0.15);
  219. display: flex;
  220. align-items: center;
  221. justify-content: center;
  222. margin-bottom: 20rpx;
  223. }
  224. .rc-brand-icon-text {
  225. font-size: 56rpx;
  226. }
  227. .rc-brand-name {
  228. font-size: 40rpx;
  229. font-weight: 800;
  230. color: #fff;
  231. letter-spacing: 4rpx;
  232. }
  233. .rc-brand-slogan {
  234. font-size: 22rpx;
  235. color: rgba(255, 255, 255, 0.7);
  236. margin-top: 8rpx;
  237. letter-spacing: 2rpx;
  238. }
  239. /* Card */
  240. .rc-card {
  241. width: calc(100% - 64rpx);
  242. margin: -40rpx 32rpx 0;
  243. background: #fff;
  244. border-radius: var(--h-rad-lg, 32rpx);
  245. padding: 56rpx 48rpx 48rpx;
  246. box-shadow: var(--h-shd-lg, 0 16rpx 48rpx rgba(0, 0, 0, 0.1));
  247. display: flex;
  248. flex-direction: column;
  249. align-items: center;
  250. }
  251. .rc-room-no {
  252. font-size: 96rpx;
  253. font-weight: 900;
  254. color: var(--h-pri, #2D5016);
  255. letter-spacing: 8rpx;
  256. line-height: 1.1;
  257. }
  258. .rc-room-type {
  259. font-size: 26rpx;
  260. color: var(--h-txt-sub, #666);
  261. margin-top: 4rpx;
  262. margin-bottom: 16rpx;
  263. }
  264. .rc-verify-ok {
  265. display: flex;
  266. align-items: center;
  267. gap: 8rpx;
  268. background: var(--h-succ-lt, #DCFCE7);
  269. color: var(--h-succ, #16A34A);
  270. padding: 12rpx 32rpx;
  271. border-radius: 40rpx;
  272. font-size: 26rpx;
  273. font-weight: 600;
  274. margin-bottom: 36rpx;
  275. }
  276. .rc-verify-icon {
  277. font-weight: 700;
  278. }
  279. .rc-info-row {
  280. display: flex;
  281. align-items: center;
  282. gap: 12rpx;
  283. font-size: 24rpx;
  284. color: var(--h-txt-light, #999);
  285. margin-bottom: 16rpx;
  286. width: 100%;
  287. }
  288. .rc-info-icon {
  289. font-size: 28rpx;
  290. }
  291. .rc-start-btn {
  292. width: 100%;
  293. margin-top: 32rpx;
  294. padding: 28rpx;
  295. border-radius: 48rpx;
  296. background: var(--h-pri, #2D5016);
  297. color: #fff;
  298. font-size: 30rpx;
  299. font-weight: 700;
  300. text-align: center;
  301. letter-spacing: 4rpx;
  302. box-shadow: 0 8rpx 24rpx rgba(45, 80, 22, 0.3);
  303. }
  304. .rc-start-btn:active {
  305. opacity: 0.85;
  306. transform: scale(0.98);
  307. }
  308. .rc-wrong-link {
  309. margin-top: 32rpx;
  310. font-size: 24rpx;
  311. color: var(--h-txt-light, #999);
  312. }
  313. </style>