takeout-info.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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">
  137. <view class="fs-28 fc-9">
  138. 桌号
  139. </view>
  140. <view class="fs-28 fc-3 w-480 text-align-right">
  141. {{infoData.table_number}}
  142. </view>
  143. </view>
  144. <view class="display-flex flex-justify-space">
  145. <view class="fs-28 fc-9">
  146. 取餐号
  147. </view>
  148. <view class="fs-28 fc-3 w-480 text-align-right">
  149. {{infoData.number?infoData.number:'无'}}
  150. </view>
  151. </view>
  152. </view>
  153. </scroll-view>
  154. <view class="bot-box box-border-box align-items-center flex-justify-end bgc-f" v-if="infoData.order_status != 1">
  155. <view class="item-but fc-f fs-28 text-align-center b-rad-200" @click="goToUrl()">
  156. 再来一单
  157. </view>
  158. </view>
  159. </view>
  160. </template>
  161. <script>
  162. import cartStore from '@/utils/cartStore';
  163. import {
  164. commonRefundReason
  165. } from "@/api/common.js"
  166. import {
  167. orderInfo,
  168. orderCancel,
  169. orderPay
  170. } from "@/api/order.js"
  171. import tools from "@/service/tools";
  172. export default {
  173. components: {},
  174. data() {
  175. return {
  176. goodsShow: true,
  177. infoData: {
  178. item: [],
  179. },
  180. time: {
  181. day: '',
  182. h: "",
  183. m: '',
  184. s: '',
  185. },
  186. isAJAX: false
  187. };
  188. },
  189. onLoad(data) {
  190. if (data.orderId) {
  191. this.orderInfo(data.orderId)
  192. }
  193. },
  194. mounted() {},
  195. onUnload() {},
  196. methods: {
  197. goToUrl(item) {
  198. // 再来一单
  199. tools.showLoading()
  200. const success = cartStore.reorderFromOrderData(
  201. uni.getStorageSync('shop_id'),
  202. this.infoData.shopping_cart
  203. );
  204. if (success) {
  205. // 延迟跳转,让用户看到成功提示
  206. setTimeout(() => {
  207. // 跳转到店铺页面
  208. tools.hideLoading()
  209. uni.redirectTo({
  210. url: '/pages-takeout/new-shop'
  211. })
  212. }, 1500);
  213. } else {
  214. tools.error('再来一单失败');
  215. }
  216. },
  217. lookFinishImage(img) {
  218. tools.lookBigImg(1, img)
  219. },
  220. contactShop(phone) {
  221. uni.makePhoneCall({
  222. phoneNumber: phone, // 电话号码
  223. success: function() {
  224. console.log('拨打电话成功');
  225. },
  226. fail: function() {
  227. console.log('拨打电话失败');
  228. }
  229. });
  230. },
  231. copy(value) {
  232. uni.setClipboardData({
  233. data: value,
  234. success() {
  235. tools.success('复制成功')
  236. },
  237. fail() {
  238. tools.error("复制失败")
  239. }
  240. })
  241. },
  242. setAddress() {
  243. this.$refs.selectAddress.getList();
  244. },
  245. pay() {
  246. this.orderPay(this.infoData.id)
  247. },
  248. orderPay(id) {
  249. // 外卖支付
  250. uni.redirectTo({
  251. url: `/pages-takeout/pay-page?orderId=${id}`
  252. });
  253. },
  254. openGoods() {
  255. this.goodsShow = !this.goodsShow
  256. },
  257. scrolltolower() {
  258. // console.log('触底');
  259. },
  260. orderInfo(id) {
  261. tools.showLoading()
  262. orderInfo({
  263. order_id: id
  264. }).then((res) => {
  265. if (res.code == 1) {
  266. this.infoData = res.data
  267. if (this.infoData.order_status == 1) {
  268. tools.hideLoading()
  269. // 替换“-”为“/”,转换为 iOS 支持的格式
  270. let compatibleDateString = (res.data.created_at).replace(/-/g, '/');
  271. let createDate = new Date(compatibleDateString); //格式化订单创建时候的时间
  272. createDate.setMinutes(createDate.getMinutes() + 30)
  273. this.setCountDown(createDate)
  274. }
  275. }
  276. })
  277. },
  278. setCountDown(sTime) {
  279. let end = new Date(sTime).getTime();
  280. let now = new Date().getTime();
  281. let msec = end - now;
  282. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  283. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  284. let m = parseInt(msec / 1000 / 60 % 60);
  285. let s = parseInt(msec / 1000 % 60);
  286. this.time.h = h > 9 ? h : '0' + h;
  287. this.time.m = m > 9 ? m : '0' + m;
  288. this.time.s = s > 9 ? s : '0' + s;
  289. msec -= 1000;
  290. if (this.time.day >= 1) {
  291. this.showTime = true;
  292. } else {
  293. this.showTime = false;
  294. };
  295. if (msec >= 0) {
  296. setTimeout(() => {
  297. this.setCountDown(sTime);
  298. }, 1000);
  299. } else {
  300. this.time.h = '--';
  301. this.time.m = '--';
  302. this.time.s = '--';
  303. };
  304. }
  305. },
  306. }
  307. </script>
  308. <style lang="scss" scoped>
  309. .w376 {
  310. width: 376rpx;
  311. }
  312. .min-h-108 {
  313. min-height: 108rpx;
  314. }
  315. .shop-icon {
  316. width: 48rpx;
  317. height: 48rpx;
  318. }
  319. .p-24-24-136-24 {
  320. padding: 24rpx 24rpx 136rpx;
  321. }
  322. .item-but {
  323. width: 200rpx;
  324. height: 80rpx;
  325. line-height: 80rpx;
  326. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  327. }
  328. .z-3 {
  329. position: relative;
  330. z-index: 3;
  331. }
  332. .order-bg {
  333. width: 100%;
  334. height: 14vh;
  335. position: fixed;
  336. left: 0;
  337. top: 0;
  338. }
  339. .bg-img {
  340. position: fixed;
  341. left: 0;
  342. top: 0;
  343. z-index: -1;
  344. width: 100%;
  345. height: 320rpx;
  346. }
  347. .w-33 {
  348. width: 33%;
  349. position: relative;
  350. }
  351. button::after {
  352. border: none !important;
  353. }
  354. .p-24-24-0 {
  355. padding: 24rpx 24rpx 0;
  356. }
  357. .icon {
  358. width: 48rpx;
  359. height: 48rpx;
  360. }
  361. .w-420 {
  362. width: 420rpx;
  363. }
  364. .goods-img {
  365. width: 108rpx;
  366. height: 108rpx;
  367. border-radius: 8rpx;
  368. }
  369. .w-376 {
  370. width: 376rpx;
  371. }
  372. .icon-right {
  373. width: 32rpx;
  374. height: 32rpx;
  375. }
  376. .w-480 {
  377. width: 480rpx;
  378. }
  379. .icon-fz {
  380. width: 24rpx;
  381. height: 24rpx;
  382. }
  383. .goods-box {
  384. overflow: hidden;
  385. }
  386. .goodsShowOne {
  387. max-height: 508rpx;
  388. transition: all .5s linear;
  389. }
  390. .goodsShowTwo {
  391. height: auto;
  392. transition: all .5s linear;
  393. }
  394. .popup-reason-box {
  395. width: 100%;
  396. height: 45vh;
  397. overflow: auto;
  398. border-radius: 20rpx 20rpx 0 0;
  399. background: #fff;
  400. padding: 24rpx 0 0;
  401. box-sizing: border-box;
  402. }
  403. .bot-box {
  404. width: 100%;
  405. position: fixed;
  406. padding: 16rpx 32rpx calc(env(safe-area-inset-bottom) + 16rpx);
  407. bottom: 0;
  408. left: 0;
  409. }
  410. </style>