index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. // 去加餐:从缓存取桌号、人数并带上,点餐页依赖 tableid、diners 拉取列表和购物车
  19. const handleGoAddFood = () => {
  20. const tableid = uni.getStorageSync('currentTableId') ?? '';
  21. const diners = uni.getStorageSync('currentDiners') ?? '';
  22. const q = [];
  23. if (tableid !== '' && tableid != null) q.push(`tableid=${encodeURIComponent(String(tableid))}`);
  24. if (diners !== '' && diners != null) q.push(`diners=${encodeURIComponent(String(diners))}`);
  25. go(q.length ? `/pages/orderFood/index?${q.join('&')}` : '/pages/orderFood/index');
  26. };
  27. // 去结算:带上桌号、人数、金额、备注,确认订单页才显示金额并走「确认支付」
  28. const handleGoSettle = () => {
  29. let tableId = '';
  30. let diners = '';
  31. let totalAmount = '';
  32. let remark = '';
  33. try {
  34. const raw = uni.getStorageSync('lastPlaceOrderInfo');
  35. if (raw) {
  36. const data = JSON.parse(raw);
  37. tableId = data?.tableId ?? '';
  38. diners = data?.diners ?? '';
  39. totalAmount = data?.totalAmount != null ? String(data.totalAmount) : '';
  40. remark = (data?.remark ?? '').trim().slice(0, 30);
  41. }
  42. } catch (e) {
  43. console.error('读取下单信息失败', e);
  44. }
  45. const q = [];
  46. if (tableId !== '') q.push(`tableId=${encodeURIComponent(tableId)}`);
  47. if (diners !== '') q.push(`diners=${encodeURIComponent(diners)}`);
  48. if (totalAmount !== '') q.push(`totalAmount=${encodeURIComponent(totalAmount)}`);
  49. if (remark !== '') q.push(`remark=${encodeURIComponent(remark)}`);
  50. go(q.length ? `/pages/placeOrder/index?${q.join('&')}` : '/pages/placeOrder/index');
  51. };
  52. onLoad((e) => {
  53. });
  54. </script>
  55. <style lang="scss" scoped>
  56. .content {
  57. background-color: #fff;
  58. width: 100%;
  59. height: 100vh;
  60. overflow: hidden;
  61. text-align: center;
  62. }
  63. .result-img {
  64. width: 84rpx;
  65. height: 84rpx;
  66. margin-top: 64rpx;
  67. }
  68. .result-title {
  69. font-weight: bold;
  70. font-size: 34rpx;
  71. color: #151515;
  72. margin-top: 30rpx;
  73. }
  74. .result-desc {
  75. font-size: 30rpx;
  76. color: #666666;
  77. margin-top: 10rpx;
  78. margin-top: 40rpx;
  79. }
  80. .result-btns {
  81. display: flex;
  82. justify-content: space-around;
  83. align-items: center;
  84. margin-top: 40rpx;
  85. width: 100%;
  86. margin-top: 52rpx;
  87. padding: 0 60rpx;
  88. .result-btn1 {
  89. width: 252rpx;
  90. height: 80rpx;
  91. box-shadow: 0rpx -11rpx 46rpx 0rpx rgba(86, 125, 244, 0.05);
  92. border-radius: 19rpx 19rpx 19rpx 19rpx;
  93. border: 2rpx solid #F47D1F;
  94. font-weight: bold;
  95. font-size: 27rpx;
  96. color: #F47D1F;
  97. display: flex;
  98. align-items: center;
  99. justify-content: center;
  100. }
  101. .result-btn2 {
  102. width: 252rpx;
  103. height: 80rpx;
  104. background: linear-gradient(90deg, #FCB73F 0%, #FC743D 100%);
  105. box-shadow: 0rpx -11rpx 46rpx 0rpx rgba(86, 125, 244, 0.05);
  106. border-radius: 19rpx 19rpx 19rpx 19rpx;
  107. font-weight: bold;
  108. font-size: 27rpx;
  109. color: #FFFFFF;
  110. display: flex;
  111. align-items: center;
  112. justify-content: center;
  113. }
  114. }
  115. </style>