takeout-info.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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. tools.showLoading()
  257. orderInfo({
  258. order_id: id
  259. }).then((res) => {
  260. if (res.code == 1) {
  261. this.infoData = res.data
  262. if (this.infoData.order_status == 1) {
  263. tools.hideLoading()
  264. // 替换“-”为“/”,转换为 iOS 支持的格式
  265. let compatibleDateString = (res.data.created_at).replace(/-/g, '/');
  266. let createDate = new Date(compatibleDateString); //格式化订单创建时候的时间
  267. createDate.setMinutes(createDate.getMinutes() + 30)
  268. this.setCountDown(createDate)
  269. }
  270. }
  271. })
  272. },
  273. setCountDown(sTime) {
  274. let end = new Date(sTime).getTime();
  275. let now = new Date().getTime();
  276. let msec = end - now;
  277. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  278. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  279. let m = parseInt(msec / 1000 / 60 % 60);
  280. let s = parseInt(msec / 1000 % 60);
  281. this.time.h = h > 9 ? h : '0' + h;
  282. this.time.m = m > 9 ? m : '0' + m;
  283. this.time.s = s > 9 ? s : '0' + s;
  284. msec -= 1000;
  285. if (this.time.day >= 1) {
  286. this.showTime = true;
  287. } else {
  288. this.showTime = false;
  289. };
  290. if (msec >= 0) {
  291. setTimeout(() => {
  292. this.setCountDown(sTime);
  293. }, 1000);
  294. } else {
  295. this.time.h = '--';
  296. this.time.m = '--';
  297. this.time.s = '--';
  298. };
  299. }
  300. },
  301. }
  302. </script>
  303. <style lang="scss" scoped>
  304. .p-24-24-136-24 {
  305. padding: 24rpx 24rpx 136rpx;
  306. }
  307. .item-but {
  308. width: 200rpx;
  309. height: 80rpx;
  310. line-height: 80rpx;
  311. background: linear-gradient(270deg, #FF3333 0%, #FE6122 100%);
  312. }
  313. .z-3 {
  314. position: relative;
  315. z-index: 3;
  316. }
  317. .order-bg {
  318. width: 100%;
  319. height: 14vh;
  320. position: fixed;
  321. left: 0;
  322. top: 0;
  323. }
  324. .bg-img {
  325. position: fixed;
  326. left: 0;
  327. top: 0;
  328. z-index: -1;
  329. width: 100%;
  330. height: 320rpx;
  331. }
  332. .w-33 {
  333. width: 33%;
  334. position: relative;
  335. }
  336. button::after {
  337. border: none !important;
  338. }
  339. .p-24-24-0 {
  340. padding: 24rpx 24rpx 0;
  341. }
  342. .icon {
  343. width: 48rpx;
  344. height: 48rpx;
  345. }
  346. .w-420 {
  347. width: 420rpx;
  348. }
  349. .goods-img {
  350. width: 108rpx;
  351. height: 108rpx;
  352. border-radius: 8rpx;
  353. }
  354. .w-376 {
  355. width: 376rpx;
  356. }
  357. .icon-right {
  358. width: 32rpx;
  359. height: 32rpx;
  360. }
  361. .w-480 {
  362. width: 480rpx;
  363. }
  364. .icon-fz {
  365. width: 24rpx;
  366. height: 24rpx;
  367. }
  368. .goods-box {
  369. overflow: hidden;
  370. }
  371. .goodsShowOne {
  372. max-height: 508rpx;
  373. transition: all .5s linear;
  374. }
  375. .goodsShowTwo {
  376. height: auto;
  377. transition: all .5s linear;
  378. }
  379. .popup-reason-box {
  380. width: 100%;
  381. height: 45vh;
  382. overflow: auto;
  383. border-radius: 20rpx 20rpx 0 0;
  384. background: #fff;
  385. padding: 24rpx 0 0;
  386. box-sizing: border-box;
  387. }
  388. .bot-box {
  389. width: 100%;
  390. position: fixed;
  391. padding: 16rpx 32rpx calc(env(safe-area-inset-bottom) + 16rpx);
  392. bottom: 0;
  393. left: 0;
  394. }
  395. </style>