takeout-info.vue 9.8 KB

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