takeout-info.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <view class="flex-common-css iPhone-bottom box-border-box bgc-F5F4F9">
  3. <image class="order-bg" src="@/static/img/order-food/ss-bg.png" mode=""></image>
  4. <newNav :textType="false" class="mb-20" leftIconColor='#333'></newNav>
  5. <view class="p-24-24-0 box-border-box mb-32 z-3">
  6. <view class="" v-if="infoData.order_status == 1">
  7. <view class="fs-40 fc-3 fw-600 mb-8">
  8. {{infoData.order_status_str}},剩余{{time.m}}:{{time.s}}
  9. </view>
  10. <view class="fs-24 fc-FB3D03">
  11. 30分钟内未支付,订单将自动取消
  12. </view>
  13. </view>
  14. <view class="" v-else>
  15. <view class="fs-48 fc-3 fw-600">
  16. {{infoData.order_status_str || ''}}
  17. </view>
  18. </view>
  19. </view>
  20. <view class="plr-24 box-border-box" v-if="infoData.number">
  21. <view class="bgc-f b-rad-20 p-32-24 box-border-box fs-36 fw-600 fc-3">
  22. 取餐号:{{infoData.number?infoData.number:'无'}}
  23. </view>
  24. </view>
  25. <scroll-view :scroll-y="true" class="scroll-view-css box-border-box p-24-24-136-24"
  26. @scrolltolower="scrolltolower">
  27. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  28. <view class="align-items-center mb-24">
  29. <image class="shop-icon" src="/static/img/order-food/shop-icon.png" mode=""></image>
  30. <view class="w-420 fc-3 fs-28 text-overflow-ellipsis-one">
  31. {{infoData.shop.shop_name || ''}}
  32. </view>
  33. </view>
  34. <view class="goods-box" :class="infoData.item.length >= 4 && goodsShow?'goodsShowOne':'goodsShowTwo'">
  35. <view class="align-items-flex-start mb-28" v-for="(item,index) in infoData.item">
  36. <image class="goods-img mr-16 flex-shrink0" :src="item.goods_img" mode="aspectFill"></image>
  37. <view class="flex-1 flex-justify-space min-h-108">
  38. <view class="w376 flex-direction flex-justify-space">
  39. <view class="">
  40. <view class="fs-28 fc-3 fw-600 w-376 text-overflow-ellipsis-one mr-36">
  41. {{item.goods_name || ''}}
  42. </view>
  43. <view class="mb-2 fs-24 fc-9">
  44. {{item.goods_attr || ''}}
  45. </view>
  46. </view>
  47. <view class="fs-24 fc-9">
  48. x{{item.goods_number || ''}}
  49. </view>
  50. </view>
  51. <view class="fs-32 fc-3 fw-600">
  52. ¥{{ (Number(item.goods_money)).toFixed(2) }}
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="align-items-center flex-justify-center p-24 b-b-F9F9F9 mb-32" @click="openGoods"
  58. v-if="infoData.item.length > 4">
  59. <view class="fs-24 fc-9 mr-4">
  60. {{goodsShow?'展开':'收起'}}{{infoData.item.length - 4}}件商品
  61. </view>
  62. <image v-if="goodsShow" class="icon-right" src="@/static/img/order/top.png" mode=""></image>
  63. <image v-else class="icon-right" src="@/static/img/order/bottom.png" mode=""></image>
  64. </view>
  65. <view class="align-items-center flex-justify-space mb-24" v-if="infoData.order_type === 2">
  66. <view class="fs-28 fc-3">
  67. 打包费
  68. </view>
  69. <view class="fs-32 fc-3">
  70. ¥{{infoData.pack_price}}
  71. </view>
  72. </view>
  73. <!-- <view class="align-items-center flex-justify-space pb-36 b-b-F9F9F9 mb-22">
  74. <view class="align-items-center">
  75. <image class="mr-6 icon-right" src="@/static/img/order/yhq.png" mode=""></image>
  76. <view class="fs-28 fc-3">
  77. 店铺优惠
  78. </view>
  79. </view>
  80. <view class="fs-32 fc-FB3D03">
  81. -¥{{infoData.coupon_money}}
  82. </view>
  83. </view> -->
  84. <view class="align-items-center flex-justify-end">
  85. <view class="fs-28 fc-9">
  86. 共{{infoData.goods_number}}件,
  87. </view>
  88. <view class="fs-28 fc-3">
  89. 实付
  90. </view>
  91. <view class="fs-24 fw-600 fc-3">
  92. ¥
  93. </view>
  94. <view class="fs-36 fw-600 fc-3">
  95. {{infoData.pay_money || ''}}
  96. </view>
  97. </view>
  98. </view>
  99. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  100. <view class="display-flex flex-justify-space mb-26">
  101. <view class="fs-28 fc-9">
  102. 备注
  103. </view>
  104. <view class="fs-28 fc-3 w-480 text-align-right">
  105. {{infoData.note?infoData.note:'无'}}
  106. </view>
  107. </view>
  108. <view class="display-flex flex-justify-space mb-26">
  109. <view class="fs-28 fc-9">
  110. 订单编号
  111. </view>
  112. <view class="align-items-center flex-justify-end">
  113. <view class="fs-28 fc-3 w-480 mr-8 text-align-right">
  114. {{infoData.order_sn}}
  115. </view>
  116. <image class="icon-fz" src="@/static/img/order/fz.png" mode="" @click="copy(infoData.order_sn)">
  117. </image>
  118. </view>
  119. </view>
  120. <view class="display-flex flex-justify-space mb-26">
  121. <view class="fs-28 fc-9">
  122. 下单时间
  123. </view>
  124. <view class="fs-28 fc-3 w-480 text-align-right">
  125. {{infoData.created_at}}
  126. </view>
  127. </view>
  128. <view class="display-flex flex-justify-space mb-26">
  129. <view class="fs-28 fc-9">
  130. 支付方式
  131. </view>
  132. <view class="fs-28 fc-3 w-480 text-align-right">
  133. {{infoData.pay_type_str}}
  134. </view>
  135. </view>
  136. <view class="display-flex flex-justify-space mb-26" v-if="infoData.is_reserve === 1">
  137. <view class="fs-28 fc-9">
  138. 预约时间
  139. </view>
  140. <view class="fs-28 fc-3 w-480 text-align-right">
  141. {{infoData.reserve_time}}
  142. </view>
  143. </view>
  144. <view class="display-flex flex-justify-space mb-26">
  145. <view class="fs-28 fc-9">
  146. 桌号
  147. </view>
  148. <view class="fs-28 fc-3 w-480 text-align-right">
  149. {{infoData.table_number}}
  150. </view>
  151. </view>
  152. <view class="display-flex flex-justify-space">
  153. <view class="fs-28 fc-9">
  154. 取餐号
  155. </view>
  156. <view class="fs-28 fc-3 w-480 text-align-right">
  157. {{infoData.number?infoData.number:'无'}}
  158. </view>
  159. </view>
  160. </view>
  161. </scroll-view>
  162. <view class="bot-box box-border-box align-items-center flex-justify-end bgc-f" v-if="infoData.order_status != 1">
  163. <view class="item-but fc-f fs-28 text-align-center b-rad-200" @click="goToUrl()">
  164. 再来一单
  165. </view>
  166. </view>
  167. </view>
  168. </template>
  169. <script>
  170. import cartStore from '@/utils/cartStore';
  171. import {
  172. commonRefundReason
  173. } from "@/api/common.js"
  174. import {
  175. orderInfo,
  176. orderCancel,
  177. orderPay
  178. } from "@/api/order.js"
  179. import tools from "@/service/tools";
  180. export default {
  181. components: {},
  182. data() {
  183. return {
  184. goodsShow: true,
  185. infoData: {
  186. item: [],
  187. },
  188. time: {
  189. day: '',
  190. h: "",
  191. m: '',
  192. s: '',
  193. },
  194. isAJAX: false
  195. };
  196. },
  197. onLoad(data) {
  198. if (data.orderId) {
  199. this.orderInfo(data.orderId)
  200. }
  201. },
  202. mounted() {},
  203. onUnload() {},
  204. methods: {
  205. goToUrl(item) {
  206. // 再来一单
  207. tools.showLoading()
  208. const success = cartStore.reorderFromOrderData(
  209. uni.getStorageSync('shop_id'),
  210. this.infoData.shopping_cart
  211. );
  212. if (success) {
  213. // 延迟跳转,让用户看到成功提示
  214. setTimeout(() => {
  215. // 跳转到店铺页面
  216. tools.hideLoading()
  217. uni.redirectTo({
  218. url: '/pages-takeout/new-shop'
  219. })
  220. }, 1500);
  221. } else {
  222. tools.error('再来一单失败');
  223. }
  224. },
  225. lookFinishImage(img) {
  226. tools.lookBigImg(1, img)
  227. },
  228. contactShop(phone) {
  229. uni.makePhoneCall({
  230. phoneNumber: phone, // 电话号码
  231. success: function() {
  232. console.log('拨打电话成功');
  233. },
  234. fail: function() {
  235. console.log('拨打电话失败');
  236. }
  237. });
  238. },
  239. copy(value) {
  240. uni.setClipboardData({
  241. data: value,
  242. success() {
  243. tools.success('复制成功')
  244. },
  245. fail() {
  246. tools.error("复制失败")
  247. }
  248. })
  249. },
  250. setAddress() {
  251. this.$refs.selectAddress.getList();
  252. },
  253. pay() {
  254. this.orderPay(this.infoData.id)
  255. },
  256. orderPay(id) {
  257. // 外卖支付
  258. uni.redirectTo({
  259. url: `/pages-takeout/pay-page?orderId=${id}`
  260. });
  261. },
  262. openGoods() {
  263. this.goodsShow = !this.goodsShow
  264. },
  265. scrolltolower() {
  266. // console.log('触底');
  267. },
  268. orderInfo(id) {
  269. tools.showLoading()
  270. orderInfo({
  271. order_id: id
  272. }).then((res) => {
  273. if (res.code == 1) {
  274. this.infoData = res.data
  275. if (this.infoData.order_status == 1) {
  276. tools.hideLoading()
  277. // 替换“-”为“/”,转换为 iOS 支持的格式
  278. let compatibleDateString = (res.data.created_at).replace(/-/g, '/');
  279. let createDate = new Date(compatibleDateString); //格式化订单创建时候的时间
  280. createDate.setMinutes(createDate.getMinutes() + 30)
  281. this.setCountDown(createDate)
  282. }
  283. }
  284. })
  285. },
  286. setCountDown(sTime) {
  287. let end = new Date(sTime).getTime();
  288. let now = new Date().getTime();
  289. let msec = end - now;
  290. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  291. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  292. let m = parseInt(msec / 1000 / 60 % 60);
  293. let s = parseInt(msec / 1000 % 60);
  294. this.time.h = h > 9 ? h : '0' + h;
  295. this.time.m = m > 9 ? m : '0' + m;
  296. this.time.s = s > 9 ? s : '0' + s;
  297. msec -= 1000;
  298. if (this.time.day >= 1) {
  299. this.showTime = true;
  300. } else {
  301. this.showTime = false;
  302. };
  303. if (msec >= 0) {
  304. setTimeout(() => {
  305. this.setCountDown(sTime);
  306. }, 1000);
  307. } else {
  308. this.time.h = '--';
  309. this.time.m = '--';
  310. this.time.s = '--';
  311. };
  312. }
  313. },
  314. }
  315. </script>
  316. <style lang="scss" scoped>
  317. .w376 {
  318. width: 376rpx;
  319. }
  320. .min-h-108 {
  321. min-height: 108rpx;
  322. }
  323. .shop-icon {
  324. width: 48rpx;
  325. height: 48rpx;
  326. }
  327. .p-24-24-136-24 {
  328. padding: 24rpx 24rpx 136rpx;
  329. }
  330. .item-but {
  331. width: 200rpx;
  332. height: 80rpx;
  333. line-height: 80rpx;
  334. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  335. }
  336. .z-3 {
  337. position: relative;
  338. z-index: 3;
  339. }
  340. .order-bg {
  341. width: 100%;
  342. height: 14vh;
  343. position: fixed;
  344. left: 0;
  345. top: 0;
  346. }
  347. .bg-img {
  348. position: fixed;
  349. left: 0;
  350. top: 0;
  351. z-index: -1;
  352. width: 100%;
  353. height: 320rpx;
  354. }
  355. .w-33 {
  356. width: 33%;
  357. position: relative;
  358. }
  359. button::after {
  360. border: none !important;
  361. }
  362. .p-24-24-0 {
  363. padding: 24rpx 24rpx 0;
  364. }
  365. .icon {
  366. width: 48rpx;
  367. height: 48rpx;
  368. }
  369. .w-420 {
  370. width: 420rpx;
  371. }
  372. .goods-img {
  373. width: 108rpx;
  374. height: 108rpx;
  375. border-radius: 8rpx;
  376. }
  377. .w-376 {
  378. width: 376rpx;
  379. }
  380. .icon-right {
  381. width: 32rpx;
  382. height: 32rpx;
  383. }
  384. .w-480 {
  385. width: 480rpx;
  386. }
  387. .icon-fz {
  388. width: 24rpx;
  389. height: 24rpx;
  390. }
  391. .goods-box {
  392. overflow: hidden;
  393. }
  394. .goodsShowOne {
  395. max-height: 508rpx;
  396. transition: all .5s linear;
  397. }
  398. .goodsShowTwo {
  399. height: auto;
  400. transition: all .5s linear;
  401. }
  402. .popup-reason-box {
  403. width: 100%;
  404. height: 45vh;
  405. overflow: auto;
  406. border-radius: 20rpx 20rpx 0 0;
  407. background: #fff;
  408. padding: 24rpx 0 0;
  409. box-sizing: border-box;
  410. }
  411. .bot-box {
  412. width: 100%;
  413. position: fixed;
  414. padding: 16rpx 32rpx calc(env(safe-area-inset-bottom) + 16rpx);
  415. bottom: 0;
  416. left: 0;
  417. }
  418. </style>