index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <!-- 下单结果页面 -->
  3. <view class="content">
  4. <image :src="getFileUrl('img/icon/success.png')" mode="widthFix" class="result-img"></image>
  5. <view class="result-title">下单成功</view>
  6. <view class="result-desc">您的菜马上就来,坐等开吃</view>
  7. <view class="result-btns">
  8. <view class="result-btn1" hover-class="hover-active" @click="handleGoAddFood">去加餐</view>
  9. <view class="result-btn2" hover-class="hover-active" @click="handleGoSettle">去结算</view>
  10. </view>
  11. </view>
  12. </template>
  13. <script setup>
  14. import { onLoad } from "@dcloudio/uni-app";
  15. import { ref } from "vue";
  16. import { go } from "@/utils/utils.js";
  17. import { getFileUrl } from "@/utils/file.js";
  18. const resultOrderId = ref(''); // 本页 URL 上的订单ID(下单成功跳转时带的 id)
  19. // 去加餐:销毁当前页再跳转点餐页(不用 go,用 redirectTo)
  20. const handleGoAddFood = () => {
  21. const tableid = uni.getStorageSync('currentTableId') ?? '';
  22. const diners = uni.getStorageSync('currentDiners') ?? '';
  23. const q = [];
  24. if (tableid !== '' && tableid != null) q.push(`tableid=${encodeURIComponent(String(tableid))}`);
  25. if (diners !== '' && diners != null) q.push(`diners=${encodeURIComponent(String(diners))}`);
  26. const url = q.length ? `/pages/orderFood/index?${q.join('&')}` : '/pages/orderFood/index';
  27. uni.redirectTo({ url });
  28. };
  29. // 去结算:带上桌号、人数、金额、备注,确认订单页才显示金额并走「确认支付」
  30. const handleGoSettle = () => {
  31. let orderId = '';
  32. let orderNo = '';
  33. let tableId = '';
  34. let tableNumber = '';
  35. let diners = '';
  36. let totalAmount = '';
  37. let remark = '';
  38. try {
  39. const raw = uni.getStorageSync('lastPlaceOrderInfo');
  40. if (raw) {
  41. const data = JSON.parse(raw);
  42. orderId = data?.orderId ?? resultOrderId.value ?? '';
  43. orderNo = data?.orderNo ?? '';
  44. tableId = data?.tableId ?? '';
  45. tableNumber = data?.tableNumber ?? '';
  46. diners = data?.diners ?? '';
  47. totalAmount = data?.totalAmount != null ? String(data.totalAmount) : '';
  48. remark = (data?.remark ?? '').trim().slice(0, 30);
  49. }
  50. if (!orderId) orderId = resultOrderId.value;
  51. } catch (e) {
  52. console.error('读取下单信息失败', e);
  53. }
  54. const q = [];
  55. if (orderId !== '') q.push(`orderId=${encodeURIComponent(String(orderId))}`);
  56. if (orderNo !== '') q.push(`orderNo=${encodeURIComponent(String(orderNo))}`);
  57. if (tableId !== '') q.push(`tableId=${encodeURIComponent(tableId)}`);
  58. if (tableNumber !== '') q.push(`tableNumber=${encodeURIComponent(tableNumber)}`);
  59. if (diners !== '') q.push(`diners=${encodeURIComponent(diners)}`);
  60. if (totalAmount !== '') q.push(`totalAmount=${encodeURIComponent(totalAmount)}`);
  61. if (remark !== '') q.push(`remark=${encodeURIComponent(remark)}`);
  62. go(q.length ? `/pages/checkout/index?${q.join('&')}` : '/pages/checkout/index');
  63. };
  64. onLoad((options) => {
  65. resultOrderId.value = options?.id ?? '';
  66. });
  67. </script>
  68. <style lang="scss" scoped>
  69. .content {
  70. background-color: #fff;
  71. width: 100%;
  72. height: 100vh;
  73. overflow: hidden;
  74. text-align: center;
  75. }
  76. .result-img {
  77. width: 84rpx;
  78. height: 84rpx;
  79. margin-top: 64rpx;
  80. }
  81. .result-title {
  82. font-weight: bold;
  83. font-size: 34rpx;
  84. color: #151515;
  85. margin-top: 30rpx;
  86. }
  87. .result-desc {
  88. font-size: 30rpx;
  89. color: #666666;
  90. margin-top: 10rpx;
  91. margin-top: 40rpx;
  92. }
  93. .result-btns {
  94. display: flex;
  95. justify-content: space-around;
  96. align-items: center;
  97. margin-top: 40rpx;
  98. width: 100%;
  99. margin-top: 52rpx;
  100. padding: 0 60rpx;
  101. .result-btn1 {
  102. width: 252rpx;
  103. height: 80rpx;
  104. box-shadow: 0rpx -11rpx 46rpx 0rpx rgba(86, 125, 244, 0.05);
  105. border-radius: 19rpx 19rpx 19rpx 19rpx;
  106. border: 2rpx solid #F47D1F;
  107. font-weight: bold;
  108. font-size: 27rpx;
  109. color: #F47D1F;
  110. display: flex;
  111. align-items: center;
  112. justify-content: center;
  113. }
  114. .result-btn2 {
  115. width: 252rpx;
  116. height: 80rpx;
  117. background: linear-gradient(90deg, #FCB73F 0%, #FC743D 100%);
  118. box-shadow: 0rpx -11rpx 46rpx 0rpx rgba(86, 125, 244, 0.05);
  119. border-radius: 19rpx 19rpx 19rpx 19rpx;
  120. font-weight: bold;
  121. font-size: 27rpx;
  122. color: #FFFFFF;
  123. display: flex;
  124. align-items: center;
  125. justify-content: center;
  126. }
  127. }
  128. </style>