index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <!-- 下单页面 -->
  3. <view class="content">
  4. <!-- 订单卡片 -->
  5. <view class="card">
  6. <view class="card-header">
  7. <view class='tag'></view>
  8. <view class="card-header-title">订单信息</view>
  9. </view>
  10. <view class="card-content">
  11. <view class="info-item">
  12. <view class="info-item-label">就餐桌号</view>
  13. <view class="info-item-value">1234567890</view>
  14. </view>
  15. <view class="info-item">
  16. <view class="info-item-label">用餐人数</view>
  17. <view class="info-item-value">1234567890</view>
  18. </view>
  19. <view class="info-item">
  20. <view class="info-item-label">联系电话</view>
  21. <view class="info-item-value">1234567890</view>
  22. </view>
  23. <view class="info-item">
  24. <view class="info-item-label">备注信息</view>
  25. <view class="info-item-value"></view>
  26. </view>
  27. <textarea placeholder="请输入特殊需求,如少辣、不要香菜等" class="info-item-textarea"></textarea>
  28. </view>
  29. </view>
  30. <!-- 菜品清单 -->
  31. <view class="card">
  32. <view class="card-header">
  33. <view class='tag'></view>
  34. <view class="card-header-title">菜品清单</view>
  35. </view>
  36. <view class="card-content">
  37. <view class="info-food">
  38. <view v-for="(item, index) in foodList" :key="item.id || index" class="food-item">
  39. <!-- 菜品图片 -->
  40. <image :src="getFileUrl(item.image)" mode="aspectFill" class="food-item__image"></image>
  41. <!-- 菜品信息 -->
  42. <view class="food-item__info">
  43. <view class="food-item__name">{{ item.name }}</view>
  44. <view class="food-item__desc" v-if="item.tags && item.tags.length > 0">
  45. <text v-for="(tag, tagIndex) in item.tags" :key="tagIndex" class="food-item__tag">
  46. {{ tag.text }}<text v-if="tagIndex < item.tags.length - 1">,</text>
  47. </text>
  48. </view>
  49. </view>
  50. <!-- 价格和数量 -->
  51. <view class="food-item__right">
  52. <view class="food-item__price">
  53. <text class="price-main">¥{{ item.price }}</text>
  54. </view>
  55. <view class="food-item__quantity">{{ item.quantity || 1 }}份</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 总价 -->
  62. <view class="card">
  63. <view class="card-header">
  64. <view class='tag'></view>
  65. <view class="card-header-title">价格明细</view>
  66. </view>
  67. <view class="card-content">
  68. <view class="info-item">
  69. <view class="info-item-label">菜品总价</view>
  70. <view class="info-item-value">1234567890</view>
  71. </view>
  72. <view class="info-item">
  73. <view class="info-item-label">餐具费</view>
  74. <view class="info-item-value">1234567890</view>
  75. </view>
  76. <view class="info-item">
  77. <view class="info-item-label">优惠券</view>
  78. <view class="info-item-value">1234567890</view>
  79. </view>
  80. <view class="price-line">
  81. <view class="price-line-label">应付金额</view>
  82. <view class="price-line-value">¥890</view>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 底部按钮 -->
  87. <view class="bottom-button">
  88. <view class="bottom-button-text" hover-class="hover-active" @click="handleConfirmOrder" v-if="payType === 'confirmOrder'">确认下单</view>
  89. <view class="bottom-button-text" hover-class="hover-active" @click="handleConfirmPay" v-if="payType === 'confirmPay'">确认支付 ¥890</view>
  90. </view>
  91. </view>
  92. </template>
  93. <script setup>
  94. import { onLoad } from "@dcloudio/uni-app";
  95. import { ref } from "vue";
  96. import { go } from "@/utils/utils.js";
  97. import { getFileUrl } from "@/utils/file.js";
  98. const payType = ref('confirmOrder'); // confirmOrder 确认下单 confirmPay 确认支付
  99. // 菜品列表数据(示例数据,实际应该从购物车或订单数据中获取)
  100. const foodList = ref([
  101. {
  102. id: 1,
  103. name: '石板肉酱豆腐',
  104. price: 19.9,
  105. image: '/static/demo.png',
  106. tags: [
  107. { text: '份', type: 'normal' },
  108. { text: '微辣', type: 'spicy' }
  109. ],
  110. quantity: 1
  111. },
  112. {
  113. id: 2,
  114. name: '经典三杯鸡',
  115. price: 26.9,
  116. image: '/static/demo.png',
  117. tags: [
  118. { text: '份', type: 'normal' }
  119. ],
  120. quantity: 1
  121. }
  122. ]);
  123. const handleConfirmOrder = () => {
  124. go('/pages/result/index');
  125. };
  126. onLoad((e) => {
  127. if(e.payType) payType.value = e.payType;
  128. // TODO: 从存储或接口获取订单菜品数据
  129. // const cartList = uni.getStorageSync('cartList') || [];
  130. // foodList.value = cartList.filter(item => item.quantity > 0);
  131. });
  132. </script>
  133. <style lang="scss" scoped>
  134. .content {
  135. padding: 0 30rpx 300rpx;
  136. }
  137. .card {
  138. background-color: #fff;
  139. border-radius: 24rpx;
  140. padding: 30rpx 0;
  141. margin-top: 20rpx;
  142. .card-header {
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: center;
  146. padding: 0 30rpx;
  147. height: 40rpx;
  148. position: relative;
  149. font-size: 27rpx;
  150. color: #151515;
  151. font-weight: bold;
  152. }
  153. .tag {
  154. width: 10rpx;
  155. height: 42rpx;
  156. background: linear-gradient(35deg, #FCB73F 0%, #FC733D 100%);
  157. border-radius: 0rpx 0rpx 0rpx 0rpx;
  158. position: absolute;
  159. left: 0;
  160. top: 0;
  161. }
  162. .card-content {
  163. padding: 0 30rpx;
  164. }
  165. .info-item {
  166. display: flex;
  167. justify-content: space-between;
  168. align-items: center;
  169. margin-top: 20rpx;
  170. font-size: 27rpx;
  171. .info-item-label {
  172. color: #666666;
  173. }
  174. .info-item-value {
  175. color: #151515;
  176. }
  177. }
  178. .info-item-textarea {
  179. width: 100%;
  180. height: 115rpx;
  181. border-radius: 8rpx;
  182. border: 1rpx solid #F2F2F2;
  183. margin-top: 20rpx;
  184. font-size: 23rpx;
  185. color: #AAAAAA;
  186. box-sizing: border-box;
  187. padding: 20rpx;
  188. }
  189. .info-food {
  190. margin-top: 20rpx;
  191. }
  192. .food-item {
  193. display: flex;
  194. align-items: center;
  195. padding: 20rpx 0;
  196. &:last-child {
  197. border-bottom: none;
  198. }
  199. &__image {
  200. width: 118rpx;
  201. height: 118rpx;
  202. border-radius: 8rpx;
  203. flex-shrink: 0;
  204. background-color: #f5f5f5;
  205. }
  206. &__info {
  207. flex: 1;
  208. margin-left: 20rpx;
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: center;
  212. }
  213. &__name {
  214. font-size: 28rpx;
  215. font-weight: bold;
  216. color: #151515;
  217. margin-bottom: 8rpx;
  218. }
  219. &__desc {
  220. font-size: 24rpx;
  221. color: #666666;
  222. line-height: 1.5;
  223. }
  224. &__tag {
  225. font-size: 24rpx;
  226. color: #666666;
  227. }
  228. &__right {
  229. display: flex;
  230. flex-direction: column;
  231. align-items: flex-end;
  232. justify-content: center;
  233. margin-left: 20rpx;
  234. }
  235. &__price {
  236. display: flex;
  237. align-items: baseline;
  238. color: #151515;
  239. font-weight: bold;
  240. margin-bottom: 8rpx;
  241. .price-symbol {
  242. font-size: 20rpx;
  243. margin-right: 2rpx;
  244. }
  245. .price-main {
  246. font-size: 28rpx;
  247. }
  248. .price-decimal {
  249. font-size: 24rpx;
  250. }
  251. }
  252. &__quantity {
  253. font-size: 24rpx;
  254. color: #797979;
  255. }
  256. }
  257. .price-line {
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. margin-top: 20rpx;
  262. font-size: 27rpx;
  263. color: #151515;
  264. border-top: 1rpx solid rgba(170, 170, 170, 0.15);
  265. font-weight: bold;
  266. padding-top: 20rpx;
  267. }
  268. }
  269. .bottom-button {
  270. width: 100%;
  271. background-color: #fff;
  272. padding: 20rpx 30rpx;
  273. box-sizing: border-box;
  274. position: fixed;
  275. bottom: 0;
  276. left: 0;
  277. right: 0;
  278. z-index: 999;
  279. padding-bottom: env(safe-area-inset-bottom);
  280. box-shadow: 0rpx -11rpx 46rpx 0rpx rgba(0, 0, 0, 0.05);
  281. .bottom-button-text {
  282. font-size: 32rpx;
  283. font-weight: bold;
  284. color: #fff;
  285. width: 695rpx;
  286. height: 80rpx;
  287. background: linear-gradient(90deg, #FCB73F 0%, #FC743D 100%);
  288. border-radius: 23rpx 23rpx 23rpx 23rpx;
  289. display: flex;
  290. align-items: center;
  291. justify-content: center;
  292. }
  293. }
  294. </style>