orderDetail.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. <template>
  2. <!-- 订单详情页面 -->
  3. <view class="content">
  4. <!-- 菜品清单 -->
  5. <view class="card">
  6. <!-- 店铺信息 -->
  7. <view class="store-info">
  8. <view class="store-info-title">{{ orderDetail.storeName || '店铺名称' }}</view>
  9. <view class="store-info-address">{{ orderDetail.storeAddress || '—' }}</view>
  10. </view>
  11. <view class="card-header">
  12. <view class="card-header-title">菜品详情</view>
  13. </view>
  14. <view class="card-content">
  15. <view class="info-food">
  16. <view v-for="(item, index) in displayFoodList" :key="item.id || index" class="food-item">
  17. <image :src="getItemImage(item)" mode="aspectFill" class="food-item__image"></image>
  18. <!-- 菜品信息 -->
  19. <view class="food-item__info">
  20. <view class="food-item__name">{{ item.name }}</view>
  21. <view class="food-item__desc" v-if="item.tags && item.tags.length > 0">
  22. <text v-for="(tag, tagIndex) in item.tags" :key="tagIndex" class="food-item__tag"
  23. :class="tag.type">{{ tag.text }}<text v-if="tagIndex < item.tags.length - 1">,</text>
  24. </text>
  25. </view>
  26. </view>
  27. <!-- 价格和数量 -->
  28. <view class="food-item__right">
  29. <view class="food-item__price">
  30. <text class="price-main">¥{{ formatPrice(item.price) }}</text>
  31. </view>
  32. <view class="food-item__quantity">{{ item.quantity || 1 }}份</view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="card-header">
  38. <view class="card-header-title">价格明细</view>
  39. </view>
  40. <view class="card-content">
  41. <view class="info-item">
  42. <view class="info-item-label">菜品总价</view>
  43. <view class="info-item-value">¥{{ priceDetail.dishTotal }}</view>
  44. </view>
  45. <!-- 本版本不参与服务费
  46. <view class="info-item">
  47. <view class="info-item-label">服务费</view>
  48. <view class="info-item-value">¥{{ priceDetail.serviceFee }}</view>
  49. </view>
  50. -->
  51. <view
  52. v-if="isOrderCompleted && orderCompletedDiscountAmount > 0"
  53. class="info-item"
  54. >
  55. <view class="info-item-label">优惠金额</view>
  56. <view class="info-item-value">
  57. <text class="discount-amount-num">-¥{{ formatPrice(priceDetail.discountAmount) }}</text>
  58. </view>
  59. </view>
  60. <view class="price-line">
  61. <view class="price-line-label">合计</view>
  62. <view class="price-line-value">¥{{ formatPrice(actualPayAmount) }}</view>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 已支付 / 已完成:支付信息(支付方式、支付时间) -->
  67. <view v-if="showPaidOrderPaymentCard" class="card">
  68. <view class="card-header">
  69. <view class="card-header-title">支付信息</view>
  70. </view>
  71. <view class="card-content">
  72. <view class="info-item">
  73. <view class="info-item-label">支付方式</view>
  74. <view class="info-item-value">微信支付</view>
  75. </view>
  76. <view class="info-item">
  77. <view class="info-item-label">支付时间</view>
  78. <view class="info-item-value">{{ payTimeDisplay }}</view>
  79. </view>
  80. </view>
  81. </view>
  82. <!-- 订单卡片 -->
  83. <view class="card">
  84. <view class="card-header">
  85. <view class="card-header-title">订单信息</view>
  86. </view>
  87. <view class="card-content">
  88. <view class="info-item">
  89. <view class="info-item-label">订单编号</view>
  90. <view class="info-item-value">{{ orderDetail.orderNo || '—' }}</view>
  91. </view>
  92. <view class="info-item">
  93. <view class="info-item-label">就餐桌号</view>
  94. <view class="info-item-value">{{ orderDetail.tableNo || '—' }}</view>
  95. </view>
  96. <view class="info-item">
  97. <view class="info-item-label">用餐人数</view>
  98. <view class="info-item-value">{{ orderDetail.dinerCount != null && orderDetail.dinerCount !== '' ? orderDetail.dinerCount + '人' : '—' }}</view>
  99. </view>
  100. <view class="info-item">
  101. <view class="info-item-label">下单时间</view>
  102. <view class="info-item-value">{{ orderDetail.createTime || '—' }}</view>
  103. </view>
  104. <view class="info-item">
  105. <view class="info-item-label">联系电话</view>
  106. <view class="info-item-value">{{ orderDetail.contactPhone || '—' }}</view>
  107. </view>
  108. <view class="info-item">
  109. <view class="info-item-label">备注信息</view>
  110. <view class="info-item-value">{{ (orderDetail.remark || '').trim() || '无' }}</view>
  111. </view>
  112. </view>
  113. </view>
  114. <!-- 底部按钮:已完成(3)不显示 -->
  115. <view v-if="orderDetail.orderStatus !== 3" class="bottom-button">
  116. <view class="bottom-button-text1 " hover-class="hover-active" @click="handleConfirmOrder">去加餐</view>
  117. <view class="bottom-button-text" hover-class="hover-active" @click="handleConfirmPay">去结算</view>
  118. </view>
  119. </view>
  120. </template>
  121. <script setup>
  122. import { onLoad } from "@dcloudio/uni-app";
  123. import { ref, computed } from "vue";
  124. import { getFileUrl } from "@/utils/file.js";
  125. import { go } from "@/utils/utils.js";
  126. import { GetOrderInfo } from "@/api/dining.js";
  127. const payType = ref('confirmOrder'); // confirmOrder 确认下单 confirmPay 确认支付
  128. /** 当前订单ID,用于「去结算」传参 */
  129. const detailOrderId = ref('');
  130. // 订单详情(店铺、订单信息)
  131. // orderStatus:0 待支付,1 已支付,2 已取消,3 已完成
  132. const orderDetail = ref({
  133. storeName: '',
  134. storeAddress: '',
  135. storeId: '',
  136. orderNo: '',
  137. tableId: '', // 桌号ID,用于跳转加餐
  138. tableNo: '', // 桌号展示(tableNumber)
  139. dinerCount: '',
  140. createTime: '',
  141. contactPhone: '',
  142. remark: '',
  143. orderStatus: null,
  144. payType: '', // 支付方式编码,如 wechatPayMininProgram
  145. /** 支付完成时间 */
  146. payTime: ''
  147. });
  148. // 价格明细(两位小数)
  149. const priceDetail = ref({
  150. dishTotal: '0.00',
  151. serviceFee: '0.00',
  152. serviceFeeAmount: 0,
  153. couponDiscount: '0.00',
  154. discountAmount: 0,
  155. couponName: '',
  156. couponType: null,
  157. nominalValue: null,
  158. discountRate: null,
  159. total: '0.00',
  160. /** 接口实付(元);已完成订单详情「合计」直接绑定此字段 */
  161. payAmount: 0
  162. });
  163. // 菜品列表(接口订单明细)
  164. const foodList = ref([]);
  165. // 菜品详情展示(排除特殊占位 id=-1)
  166. const displayFoodList = computed(() =>
  167. (foodList.value ?? []).filter((it) => Number(it?.id ?? it?.cuisineId) !== -1)
  168. );
  169. // 未支付订单:按明细行累计菜品总价(与 checkout 行小计口径一致)
  170. const calculatedDishTotalFromItems = computed(() => {
  171. const list = displayFoodList.value;
  172. let sum = 0;
  173. for (const it of list) {
  174. const ls = Number(it?.lineSubtotal);
  175. // 行小计为 0 时仍可能单价×数量>0(接口占位 0),不要用 0 覆盖真实金额
  176. if (Number.isFinite(ls) && ls > 0) {
  177. sum += ls;
  178. continue;
  179. }
  180. const q = Number(it?.quantity) || 1;
  181. const u = Number(it?.price) || 0;
  182. sum += u * q;
  183. }
  184. return Math.max(0, Math.round(sum * 100) / 100);
  185. });
  186. // 合计/优惠计算用菜品基数:有明细则按行累计,否则用接口菜品总价
  187. const dishTotalBaseForOrder = computed(() => {
  188. if (displayFoodList.value.length > 0) return calculatedDishTotalFromItems.value;
  189. const dish = Number(priceDetail.value?.dishTotal);
  190. return Number.isFinite(dish) ? Math.max(0, dish) : 0;
  191. });
  192. /** 已支付:orderStatus 1 已支付、3 已完成 */
  193. function isPaidOrderStatus(status) {
  194. const s = Number(status);
  195. return s === 1 || s === 3;
  196. }
  197. /** 订单已完成 orderStatus === 3 */
  198. const isOrderCompleted = computed(() => Number(orderDetail.value?.orderStatus) === 3);
  199. // 待支付(0) / 已支付(1) 优惠金额(用于非已完成订单的合计计算)
  200. const orderDiscountDisplay = computed(() => {
  201. const st = orderDetail.value.orderStatus;
  202. if (st !== 0 && st !== 1) return 0;
  203. const p = priceDetail.value;
  204. const dishBase = dishTotalBaseForOrder.value;
  205. const type = Number(p.couponType);
  206. let raw = 0;
  207. if (type === 1) {
  208. if (p.nominalValue != null && p.nominalValue !== '') {
  209. const nv = Number(p.nominalValue);
  210. raw = Number.isNaN(nv) ? 0 : Math.max(0, nv);
  211. } else {
  212. // 无面额时不用裸 discountAmount,避免无券订单接口噪声把合计减成 0
  213. const name = (p.couponName && String(p.couponName).trim()) || '';
  214. if (name) raw = Math.max(0, Number(p.discountAmount) || 0);
  215. }
  216. } else if (type === 2) {
  217. if (p.discountRate != null && p.discountRate !== '' && dishBase > 0) {
  218. const rate = Number(p.discountRate) || 0;
  219. raw = Math.round(dishBase * (1 - rate / 10) * 100) / 100;
  220. }
  221. }
  222. const capped = Math.min(Math.max(0, raw), Math.max(0, dishBase));
  223. return Math.max(0, Math.round(capped * 100) / 100);
  224. });
  225. /** 已完成订单:接口 discountAmount(用于展示「优惠金额」行) */
  226. const orderCompletedDiscountAmount = computed(() => {
  227. if (!isOrderCompleted.value) return 0;
  228. const d = Number(priceDetail.value?.discountAmount);
  229. if (!Number.isFinite(d) || d <= 0) return 0;
  230. return Math.round(d * 100) / 100;
  231. });
  232. // 合计:已完成绑定接口 payAmount;其余状态按「菜品基数 − 优惠」计算
  233. const actualPayAmount = computed(() => {
  234. if (isOrderCompleted.value) {
  235. const pa = Number(priceDetail.value?.payAmount);
  236. if (Number.isFinite(pa) && pa >= 0) return Math.round(pa * 100) / 100;
  237. const t = Number(priceDetail.value?.total);
  238. return Number.isFinite(t) ? Math.max(0, Math.round(t * 100) / 100) : 0;
  239. }
  240. const base = dishTotalBaseForOrder.value;
  241. const d = orderDiscountDisplay.value;
  242. return Math.max(0, Math.round((base - d) * 100) / 100);
  243. });
  244. // 已支付(1) / 已完成(3) 展示支付信息卡片
  245. const showPaidOrderPaymentCard = computed(() => {
  246. const s = orderDetail.value?.orderStatus;
  247. return s === 1 || s === 3;
  248. });
  249. // 支付时间
  250. const payTimeDisplay = computed(() => {
  251. const t = orderDetail.value?.payTime;
  252. if (t != null && String(t).trim() !== '') return String(t).trim();
  253. return '—';
  254. });
  255. // 取第一张图:逗号分隔取首段,数组取首项,对象取 url/path/src(与 orderInfo/index、FoodCard 一致)
  256. function firstImage(val) {
  257. if (val == null || val === '') return '';
  258. if (Array.isArray(val)) {
  259. const first = val[0];
  260. if (first != null && first !== '') {
  261. if (typeof first === 'object' && first !== null) return first.url ?? first.path ?? first.src ?? first.link ?? '';
  262. return String(first).split(/[,,]/)[0].trim();
  263. }
  264. return '';
  265. }
  266. if (typeof val === 'object') return val.url ?? val.path ?? val.src ?? val.link ?? '';
  267. const str = String(val).trim();
  268. return str ? str.split(/[,,]/)[0].trim() : '';
  269. }
  270. function getItemImage(item) {
  271. const raw = item?.image ?? item?.cuisineImage ?? item?.imageUrl ?? item?.pic ?? item?.cover ?? item?.images ?? '';
  272. const url = firstImage(raw) || (typeof raw === 'string' ? raw.split(/[,,]/)[0]?.trim() : '');
  273. if (url && typeof url === 'string' && (url.startsWith('http') || url.startsWith('//'))) return url;
  274. return getFileUrl(url || 'img/icon/shop.png');
  275. }
  276. // 金额保留两位小数
  277. const formatPrice = (price) => {
  278. if (price === '' || price === null || price === undefined) return '0.00';
  279. const num = Number(price);
  280. return Number.isNaN(num) ? '0.00' : num.toFixed(2);
  281. };
  282. // 将 tags 统一为 [{ text, type }] 格式
  283. function normalizeTags(raw) {
  284. if (raw == null) return [];
  285. let arr = [];
  286. if (Array.isArray(raw)) arr = raw;
  287. else if (typeof raw === 'string') {
  288. const t = raw.trim();
  289. if (t.startsWith('[')) { try { arr = JSON.parse(t); if (!Array.isArray(arr)) arr = []; } catch { arr = t ? [t] : []; } }
  290. else arr = t ? t.split(/[,,、\s]+/).map(s => s.trim()).filter(Boolean) : [];
  291. } else if (raw && typeof raw === 'object') arr = Array.isArray(raw.list) ? raw.list : Array.isArray(raw.items) ? raw.items : [];
  292. return arr.map((it) => {
  293. if (it == null) return { text: '', type: '' };
  294. if (typeof it === 'string') return { text: it, type: '' };
  295. if (typeof it === 'number') return { text: String(it), type: '' };
  296. return { text: it.text ?? it.tagName ?? it.name ?? it.label ?? it.title ?? '', type: it.type ?? it.tagType ?? '' };
  297. }).filter((t) => t.text !== '' && t.text != null);
  298. }
  299. // 将接口订单项转为列表项(图片取首张;行小计与 checkout 一致,便于未支付订单合计按明细计算)
  300. function normalizeOrderItem(item) {
  301. const rawTags = item?.tags ?? item?.tagList ?? item?.tagNames ?? item?.labels ?? item?.tag;
  302. const rawImg = item?.images ?? item?.image ?? item?.cuisineImage ?? item?.imageUrl ?? item?.pic ?? item?.cover ?? '';
  303. const imageUrl = firstImage(rawImg) || (typeof rawImg === 'string' ? rawImg.split(/[,,]/)[0]?.trim() : '') || 'img/icon/shop.png';
  304. const qty = Number(item?.quantity ?? 1) || 1;
  305. let lineSubtotal = 0;
  306. if (item?.subtotalAmount != null && item.subtotalAmount !== '') {
  307. lineSubtotal = Number(item.subtotalAmount) || 0;
  308. } else if (item?.totalPrice != null && item.totalPrice !== '') {
  309. lineSubtotal = Number(item.totalPrice) || 0;
  310. } else {
  311. const unit = Number(item?.unitPrice ?? item?.price ?? item?.salePrice ?? 0) || 0;
  312. lineSubtotal = unit * qty;
  313. }
  314. // 接口可能把小计写成 0,但单价/数量有效,回退为单价×数量,与列表展示一致
  315. if (lineSubtotal <= 0) {
  316. const unit = Number(item?.unitPrice ?? item?.price ?? item?.salePrice ?? 0) || 0;
  317. const fallback = unit * qty;
  318. if (fallback > 0) lineSubtotal = fallback;
  319. }
  320. const unitForDisplay =
  321. Number(item?.unitPrice ?? item?.price ?? 0) ||
  322. (qty > 0 ? lineSubtotal / qty : 0);
  323. return {
  324. id: item?.id ?? item?.cuisineId ?? item?.orderItemId ?? item?.skuId,
  325. name:
  326. item?.cuisineName ??
  327. item?.name ??
  328. item?.goodsName ??
  329. item?.skuName ??
  330. item?.productName ??
  331. '',
  332. price: unitForDisplay,
  333. lineSubtotal,
  334. image: imageUrl,
  335. quantity: qty,
  336. tags: normalizeTags(rawTags)
  337. };
  338. }
  339. // 从接口数据填充 orderDetail、priceDetail、foodList
  340. function applyOrderData(data) {
  341. const raw = data?.data ?? data ?? {};
  342. const nested = raw?.order && typeof raw.order === 'object' ? raw.order : {};
  343. const store = raw?.storeInfo ?? raw?.store ?? {};
  344. orderDetail.value = {
  345. storeName: store?.storeName ?? raw?.storeName ?? '',
  346. storeAddress: store?.storeAddress ?? store?.address ?? raw?.storeAddress ?? raw?.address ?? '',
  347. storeId: store?.storeId ?? store?.id ?? raw?.storeId ?? raw?.store_id ?? nested?.storeId ?? '',
  348. orderNo: raw?.orderNo ?? raw?.orderId ?? nested?.orderNo ?? '',
  349. tableId:
  350. raw?.tableId ??
  351. nested?.tableId ??
  352. raw?.storeTableId ??
  353. nested?.storeTableId ??
  354. raw?.diningTableId ??
  355. nested?.diningTableId ??
  356. '', // 桌台主键,加餐/购物车用
  357. tableNo: raw?.tableNumber ?? raw?.tableNo ?? raw?.tableName ?? '',
  358. dinerCount: raw?.dinerCount ?? '',
  359. createTime: raw?.createdTime ?? raw?.createTime ?? raw?.orderTime ?? '',
  360. contactPhone: raw?.contactPhone ?? raw?.phone ?? '',
  361. remark: raw?.remark ?? '',
  362. orderStatus: raw?.orderStatus ?? raw?.status ?? null,
  363. payType: raw?.payType ?? raw?.payMethod ?? '',
  364. payTime:
  365. raw?.payTime ??
  366. raw?.paymentTime ??
  367. raw?.paidTime ??
  368. raw?.payFinishTime ??
  369. raw?.paySuccessTime ??
  370. ''
  371. };
  372. const couponInfo = raw?.couponInfo ?? raw?.coupon ?? {};
  373. const dishTotal = raw?.totalAmount ?? raw?.dishTotal ?? raw?.orderAmount ?? raw?.foodAmount ?? 0;
  374. const couponDiscount = raw?.couponAmount ?? raw?.couponDiscount ?? 0;
  375. const discountAmountVal = Number(raw?.discountAmount ?? raw?.couponAmount ?? raw?.couponDiscount ?? 0) || 0;
  376. const totalFallback =
  377. Number(raw?.totalAmount ?? raw?.totalPrice ?? raw?.orderAmount ?? raw?.foodAmount ?? 0) || 0;
  378. const explicitPay = raw?.payAmount ?? raw?.realPayAmount ?? raw?.paidAmount;
  379. const payAmountNum =
  380. explicitPay != null && explicitPay !== ''
  381. ? Number(explicitPay) || 0
  382. : totalFallback;
  383. const serviceFeeRaw =
  384. Number(raw?.serviceFee ?? raw?.serviceCharge ?? raw?.tablewareFee ?? 0) || 0;
  385. const rawDiscountRate =
  386. raw?.discountRate ?? couponInfo?.discountRate ?? raw?.coupon?.discountRate;
  387. const discountRateVal = rawDiscountRate != null && rawDiscountRate !== '' ? (Number(rawDiscountRate) || 0) / 10 : null;
  388. priceDetail.value = {
  389. dishTotal: formatPrice(dishTotal),
  390. serviceFee: formatPrice(serviceFeeRaw),
  391. serviceFeeAmount: serviceFeeRaw,
  392. couponDiscount: formatPrice(couponDiscount),
  393. discountAmount: discountAmountVal,
  394. couponName: raw?.couponName ?? couponInfo?.couponName ?? couponInfo?.name ?? '',
  395. couponType: raw?.couponType ?? couponInfo?.couponType ?? null,
  396. nominalValue: raw?.nominalValue ?? couponInfo?.nominalValue ?? couponInfo?.amount ?? null,
  397. discountRate: discountRateVal,
  398. total: formatPrice(payAmountNum),
  399. payAmount: payAmountNum
  400. };
  401. const list =
  402. raw?.orderItemList ??
  403. raw?.orderItems ??
  404. raw?.orderLines ??
  405. raw?.orderLineList ??
  406. raw?.detailList ??
  407. raw?.order?.orderItemList ??
  408. raw?.order?.orderItems ??
  409. (Array.isArray(raw?.items) ? raw.items : []);
  410. foodList.value = (Array.isArray(list) ? list : []).map(normalizeOrderItem);
  411. }
  412. // 去加餐:使用本单桌台主键(与列表页一致),redirectTo 触发点餐页重新 onLoad 拉取该桌购物车
  413. const handleConfirmOrder = () => {
  414. const od = orderDetail.value;
  415. const tableid = String(od?.tableId ?? '').trim();
  416. const diners = od?.dinerCount ?? '';
  417. const storeId = od?.storeId ?? '';
  418. if (!tableid) {
  419. uni.showToast({ title: '订单缺少桌台信息,无法加餐', icon: 'none' });
  420. return;
  421. }
  422. if (storeId !== '' && storeId != null) {
  423. uni.setStorageSync('currentStoreId', String(storeId));
  424. }
  425. uni.setStorageSync('currentTableId', tableid);
  426. const q = [
  427. `tableid=${encodeURIComponent(tableid)}`,
  428. `tableId=${encodeURIComponent(tableid)}`
  429. ];
  430. if (diners !== '' && diners != null) q.push(`diners=${encodeURIComponent(String(diners))}`);
  431. if (storeId !== '' && storeId != null) q.push(`storeId=${encodeURIComponent(String(storeId))}`);
  432. go(`/pages/orderFood/index?${q.join('&')}`, 'redirectTo');
  433. };
  434. // 去结算:跳转确认订单页,携带订单ID、订单号、桌号、就餐人数、订单金额(用于调起支付)
  435. const handleConfirmPay = () => {
  436. const orderId = detailOrderId.value || '';
  437. const orderNo = orderDetail.value?.orderNo ?? '';
  438. const tableId = orderDetail.value?.tableId || orderDetail.value?.tableNo || '';
  439. const tableNumber = orderDetail.value?.tableNo ?? orderDetail.value?.tableNumber ?? '';
  440. const diners = orderDetail.value?.dinerCount ?? '';
  441. const totalAmount = formatPrice(actualPayAmount.value);
  442. const remark = (orderDetail.value?.remark ?? '').trim().slice(0, 30);
  443. const q = [];
  444. if (orderId !== '') q.push(`orderId=${encodeURIComponent(String(orderId))}`);
  445. if (orderNo !== '') q.push(`orderNo=${encodeURIComponent(String(orderNo))}`);
  446. if (tableId !== '') q.push(`tableId=${encodeURIComponent(String(tableId))}`);
  447. if (tableNumber !== '') q.push(`tableNumber=${encodeURIComponent(String(tableNumber))}`);
  448. if (diners !== '') q.push(`diners=${encodeURIComponent(String(diners))}`);
  449. if (totalAmount !== '' && totalAmount != null) q.push(`totalAmount=${encodeURIComponent(String(totalAmount))}`);
  450. if (remark !== '') q.push(`remark=${encodeURIComponent(remark)}`);
  451. uni.navigateTo({ url: q.length ? `/pages/checkout/index?${q.join('&')}` : '/pages/checkout/index' });
  452. };
  453. onLoad(async (e) => {
  454. if (e.payType) payType.value = e.payType;
  455. const orderId = e?.orderId ?? e?.id ?? '';
  456. detailOrderId.value = orderId;
  457. if (!orderId) {
  458. uni.showToast({ title: '缺少订单ID', icon: 'none' });
  459. return;
  460. }
  461. try {
  462. const res = await GetOrderInfo(orderId);
  463. applyOrderData(res);
  464. } catch (err) {
  465. console.error('订单详情加载失败:', err);
  466. uni.showToast({ title: '加载失败', icon: 'none' });
  467. }
  468. });
  469. </script>
  470. <style lang="scss" scoped>
  471. .content {
  472. padding: 0 30rpx 300rpx;
  473. }
  474. .card {
  475. background-color: #fff;
  476. border-radius: 24rpx;
  477. padding: 30rpx 0;
  478. margin-top: 20rpx;
  479. .card-header {
  480. display: flex;
  481. justify-content: space-between;
  482. align-items: center;
  483. padding: 0 30rpx;
  484. height: 40rpx;
  485. position: relative;
  486. font-size: 27rpx;
  487. color: #151515;
  488. font-weight: bold;
  489. }
  490. .tag {
  491. width: 10rpx;
  492. height: 42rpx;
  493. background: linear-gradient(35deg, #FCB73F 0%, #FC733D 100%);
  494. border-radius: 0rpx 0rpx 0rpx 0rpx;
  495. position: absolute;
  496. left: 0;
  497. top: 0;
  498. }
  499. .card-content {
  500. padding: 0 30rpx;
  501. }
  502. .info-item {
  503. display: flex;
  504. justify-content: space-between;
  505. align-items: center;
  506. margin-top: 20rpx;
  507. font-size: 27rpx;
  508. .info-item-label {
  509. color: #666666;
  510. }
  511. .info-item-value {
  512. color: #151515;
  513. .discount-amount-num {
  514. color: #e61f19;
  515. }
  516. }
  517. }
  518. .info-item-textarea {
  519. width: 100%;
  520. height: 115rpx;
  521. border-radius: 8rpx;
  522. border: 1rpx solid #F2F2F2;
  523. margin-top: 20rpx;
  524. font-size: 23rpx;
  525. color: #AAAAAA;
  526. box-sizing: border-box;
  527. padding: 20rpx;
  528. }
  529. .info-food {
  530. margin-top: 20rpx;
  531. }
  532. .food-item {
  533. display: flex;
  534. align-items: center;
  535. padding: 20rpx 0;
  536. &:last-child {
  537. border-bottom: none;
  538. }
  539. &__image {
  540. width: 118rpx;
  541. height: 118rpx;
  542. border-radius: 8rpx;
  543. flex-shrink: 0;
  544. background-color: #f5f5f5;
  545. }
  546. &__info {
  547. flex: 1;
  548. margin-left: 20rpx;
  549. display: flex;
  550. flex-direction: column;
  551. justify-content: center;
  552. }
  553. &__name {
  554. font-size: 28rpx;
  555. font-weight: bold;
  556. color: #151515;
  557. margin-bottom: 8rpx;
  558. }
  559. &__desc {
  560. font-size: 24rpx;
  561. color: #666666;
  562. line-height: 1.5;
  563. }
  564. &__tag {
  565. font-size: 24rpx;
  566. color: #666666;
  567. &.signature {
  568. color: #FC793D;
  569. }
  570. &.spicy {
  571. color: #2E2E2E;
  572. }
  573. }
  574. &__right {
  575. display: flex;
  576. flex-direction: column;
  577. align-items: flex-end;
  578. justify-content: center;
  579. margin-left: 20rpx;
  580. }
  581. &__price {
  582. display: flex;
  583. align-items: baseline;
  584. color: #151515;
  585. font-weight: bold;
  586. margin-bottom: 8rpx;
  587. .price-symbol {
  588. font-size: 20rpx;
  589. margin-right: 2rpx;
  590. }
  591. .price-main {
  592. font-size: 28rpx;
  593. }
  594. .price-decimal {
  595. font-size: 24rpx;
  596. }
  597. }
  598. &__quantity {
  599. font-size: 24rpx;
  600. color: #797979;
  601. }
  602. }
  603. .price-line {
  604. display: flex;
  605. justify-content: space-between;
  606. align-items: center;
  607. margin-top: 20rpx;
  608. font-size: 27rpx;
  609. color: #151515;
  610. border-top: 1rpx solid rgba(170, 170, 170, 0.15);
  611. font-weight: bold;
  612. padding-top: 20rpx;
  613. }
  614. }
  615. .bottom-button {
  616. width: 100%;
  617. background-color: #fff;
  618. padding: 20rpx 30rpx;
  619. box-sizing: border-box;
  620. position: fixed;
  621. bottom: 0;
  622. left: 0;
  623. right: 0;
  624. z-index: 999;
  625. padding-bottom: env(safe-area-inset-bottom);
  626. box-shadow: 0rpx -11rpx 46rpx 0rpx rgba(0, 0, 0, 0.05);
  627. display: flex;
  628. justify-content: space-between;
  629. align-items: center;
  630. .bottom-button-text1 {
  631. font-size: 32rpx;
  632. font-weight: bold;
  633. color: #fff;
  634. width: 324rpx;
  635. height: 80rpx;
  636. border-radius: 23rpx 23rpx 23rpx 23rpx;
  637. border: 2rpx solid #F47D1F;
  638. display: flex;
  639. align-items: center;
  640. color: #F47D1F;
  641. justify-content: center;
  642. }
  643. .bottom-button-text {
  644. font-size: 32rpx;
  645. font-weight: bold;
  646. color: #fff;
  647. background: linear-gradient(90deg, #FCB73F 0%, #FC743D 100%);
  648. border-radius: 23rpx 23rpx 23rpx 23rpx;
  649. display: flex;
  650. align-items: center;
  651. justify-content: center;
  652. width: 324rpx;
  653. height: 80rpx;
  654. }
  655. }
  656. .store-info {
  657. border-bottom: 1rpx solid rgba(170, 170, 170, 0.15);
  658. box-sizing: border-box;
  659. margin: 0 30rpx 30rpx;
  660. .store-info-title {
  661. font-size: 27rpx;
  662. color: #151515;
  663. font-weight: bold;
  664. margin-bottom: 10rpx;
  665. }
  666. .store-info-address {
  667. font-size: 23rpx;
  668. color: #AAAAAA;
  669. margin-bottom: 30rpx;
  670. }
  671. }
  672. </style>