takeout-info.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <view class="flex-common-css">
  3. <Nav title=" " leftIconColor="#333" titleColor="#333" bgckgroundBox='transparent'></Nav>
  4. <image class="bg-img" src="@/static/img/order/bg.png" mode=""></image>
  5. <view class="p-24-24-0 box-border-box">
  6. <view class="mb-24" v-if="infoData.order_status == 1">
  7. <view class="fs-40 fc-3 mb-8">
  8. {{infoData.order_status_str}},剩余{{time.m}}:{{time.s}}
  9. </view>
  10. <view class="fs-24 fc-FB3D03">
  11. 10分钟内未支付,订单将自动取消
  12. </view>
  13. </view>
  14. <view class="mb-24" v-else>
  15. <view class="fs-48 fc-3 fw-600">
  16. {{infoData.order_status_str}}
  17. </view>
  18. </view>
  19. <view class="bgc-f b-rad-20 p-24 box-border-box">
  20. <view class="p-b-20 mb-24 b-b-F9F9F9 fs-32 fc-3" v-show="infoData.order_status == 1">
  21. 请尽快支付
  22. </view>
  23. <view class="p-b-20 mb-24 b-b-F9F9F9 fs-32 fc-3"
  24. v-if="infoData.order_status == 8 && infoData.refund_status == 1">
  25. 申请成功,请及时联系商家退款,避免已出餐
  26. </view>
  27. <view class="p-b-20 mb-24 b-b-F9F9F9 fs-32 fc-3"
  28. v-else-if="infoData.order_status == 3 || infoData.order_status == 7 || infoData.order_status == 8 || infoData.order_status == 9 || infoData.order_status == 10">
  29. 感谢你对君子校园的信任,期待你再次光临
  30. </view>
  31. <view class="align-items-center flex-wrap-wrap">
  32. <view class="w-33 flex-direction align-items-center" @click="pay"
  33. v-show="infoData.order_status == 1">
  34. <image class="mb-4 icon" src="@/static/img/order/qzf.png" mode=""></image>
  35. <view class="fs-24 fc-41ABF5">
  36. 去支付
  37. </view>
  38. </view>
  39. <view @click="goToUrl" class="w-33 flex-direction align-items-center"
  40. v-show="infoData.order_status == 3 || infoData.order_status == 7 || infoData.order_status == 8 || infoData.order_status == 9 || infoData.order_status == 10">
  41. <image class="mb-4 icon" src="@/static/img/order/zlyd.png" mode=""></image>
  42. <view class="fs-24 fc-41ABF5">
  43. 再来一单
  44. </view>
  45. </view>
  46. <view class="w-33 flex-direction align-items-center">
  47. <button class="item-box-button" open-type="contact" :bindcontact="handleContact"></button>
  48. <image class="mb-4 icon" src="@/static/img/order/lxkf.png" mode=""></image>
  49. <view class="fs-24 fc-3">
  50. 联系客服
  51. </view>
  52. </view>
  53. <view class="w-33 flex-direction align-items-center" @click="contactShop(infoData.shop.shop_phone)">
  54. <image class="mb-4 icon" src="@/static/img/order/lxsj.png" mode=""></image>
  55. <view class="fs-24 fc-3">
  56. 联系商家
  57. </view>
  58. </view>
  59. <view class="w-33 flex-direction align-items-center"
  60. v-show="infoData.order_status == 2 || infoData.order_status == 4" @click="cancelOrder">
  61. <image class="mb-4 icon" src="@/static/img/order/qxdd.png" mode=""></image>
  62. <view class="fs-24 fc-3">
  63. 取消订单
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <scroll-view :scroll-y="true" class="scroll-view-css p-24 box-border-box" @scrolltolower="scrolltolower">
  70. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  71. <view class="w-420 fc-3 fs-32 fw-600 text-overflow-ellipsis-one mb-24">
  72. {{infoData.shop.shop_name}}
  73. </view>
  74. <view class="goods-box" :class="infoData.item.length >= 4 && goodsShow?'goodsShowOne':'goodsShowTwo'">
  75. <view class="align-items-center flex-justify-space mb-20" v-for="(item,index) in infoData.item">
  76. <image class="goods-img mr-16 flex-shrink0" :src="item.goods_img" mode="aspectFit"></image>
  77. <view class="">
  78. <view class="align-items-center flex-justify-space mb-2">
  79. <view class="fs-28 fc-3 w-376 text-overflow-ellipsis-one mr-36">
  80. {{item.goods_name}}
  81. </view>
  82. <view class="fs-32 fc-3 fw-600">
  83. ¥{{ (Number(item.goods_number) * Number(item.goods_price)).toFixed(2) }}
  84. </view>
  85. </view>
  86. <view class="mb-2 fs-24 fc-9">
  87. {{item.goods_attr}}
  88. </view>
  89. <view class="fs-24 fc-9">
  90. x{{item.goods_number}}
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="align-items-center flex-justify-center p-24 b-b-F9F9F9 mb-32" @click="openGoods"
  96. v-if="infoData.item.length > 4">
  97. <view class="fs-24 fc-9 mr-4">
  98. {{goodsShow?'展开':'收起'}}{{infoData.item.length - 4}}件商品
  99. </view>
  100. <image v-if="goodsShow" class="icon-right" src="@/static/img/order/top.png" mode=""></image>
  101. <image v-else class="icon-right" src="@/static/img/order/bottom.png" mode=""></image>
  102. </view>
  103. <view class="align-items-center flex-justify-space mb-24">
  104. <view class="fs-28 fc-3">
  105. 打包费
  106. </view>
  107. <view class="fs-32 fc-3">
  108. ¥{{infoData.pack_price}}
  109. </view>
  110. </view>
  111. <view class="align-items-center flex-justify-space mb-24">
  112. <view class="fs-28 fc-3">
  113. 配送费
  114. </view>
  115. <view class="fs-32 fc-3">
  116. ¥{{infoData.delivery_money}}
  117. </view>
  118. </view>
  119. <view class="align-items-center flex-justify-space pb-36 b-b-F9F9F9 mb-22">
  120. <view class="align-items-center">
  121. <image class="mr-6 icon-right" src="@/static/img/order/yhq.png" mode=""></image>
  122. <view class="fs-28 fc-3">
  123. 优惠券
  124. </view>
  125. </view>
  126. <view class="fs-32 fc-FB3D03">
  127. -¥{{infoData.coupon_money}}
  128. </view>
  129. </view>
  130. <view class="align-items-center flex-justify-end">
  131. <view class="fs-28 fc-9">
  132. 共{{infoData.goods_number}}件,
  133. </view>
  134. <view class="fs-28 fc-3">
  135. 金额
  136. </view>
  137. <view class="fs-24 fw-600 fc-3">
  138. ¥
  139. </view>
  140. <view class="fs-36 fw-600 fc-3">
  141. {{infoData.pay_money}}
  142. </view>
  143. </view>
  144. </view>
  145. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  146. <view class="display-flex flex-justify-space mb-26">
  147. <view class="fs-28 fc-9">
  148. 配送地址
  149. </view>
  150. <view class="fs-28 fc-3 w-480 text-align-right">
  151. {{infoData.school_name}}{{infoData.dorm_name}}{{infoData.address}}{{infoData.consignee}}{{infoData.consignee_tel}}
  152. </view>
  153. </view>
  154. <view class="display-flex flex-justify-space mb-26">
  155. <view class="fs-28 fc-9">
  156. 期望时间
  157. </view>
  158. <view class="fs-28 fc-3 w-480 text-align-right">
  159. {{infoData.time}}
  160. </view>
  161. </view>
  162. <view class="display-flex flex-justify-space pb-20 b-b-F9F9F9 mb-26">
  163. <view class="fs-28 fc-9">
  164. 骑手信息
  165. </view>
  166. <view class="fs-28 fc-3 w-480 text-align-right">
  167. {{infoData.rider.rider_name?infoData.rider.rider_name:'无'}}{{infoData.rider.phone}}
  168. </view>
  169. </view>
  170. <view class="display-flex flex-justify-space mb-26">
  171. <view class="fs-28 fc-9">
  172. 订单编号
  173. </view>
  174. <view class="align-items-center flex-justify-end">
  175. <view class="fs-28 fc-3 w-480 mr-8 text-align-right">
  176. {{infoData.order_sn}}
  177. </view>
  178. <image class="icon-fz" src="@/static/img/order/fz.png" mode="" @click="copy(infoData.order_sn)">
  179. </image>
  180. </view>
  181. </view>
  182. <view class="display-flex flex-justify-space mb-26">
  183. <view class="fs-28 fc-9">
  184. 下单时间
  185. </view>
  186. <view class="fs-28 fc-3 w-480 text-align-right">
  187. {{infoData.created_at}}
  188. </view>
  189. </view>
  190. <view class="display-flex flex-justify-space mb-26">
  191. <view class="fs-28 fc-9">
  192. 支付方式
  193. </view>
  194. <view class="fs-28 fc-3 w-480 text-align-right">
  195. {{infoData.pay_type_str}}
  196. </view>
  197. </view>
  198. <view class="display-flex flex-justify-space mb-26" v-if="infoData.order_status == 7">
  199. <view class="fs-28 fc-9">
  200. 送达图片
  201. </view>
  202. <view class="fs-28 fc-3 w-480 text-align-right fc-41ABF5" @click="lookFinishImage(infoData.finish_image)">
  203. 点击查看
  204. </view>
  205. </view>
  206. <view class="display-flex flex-justify-space mb-26" v-if="infoData.order_status == 7">
  207. <view class="fs-28 fc-9">
  208. 完成时间
  209. </view>
  210. <view class="fs-28 fc-3 w-480 text-align-right">
  211. {{infoData.finish_time?infoData.finish_time:'无'}}
  212. </view>
  213. </view>
  214. <view class="display-flex flex-justify-space mb-26">
  215. <view class="fs-28 fc-9">
  216. 备注
  217. </view>
  218. <view class="fs-28 fc-3 w-480 text-align-right">
  219. {{infoData.note?infoData.note:'无'}}
  220. </view>
  221. </view>
  222. </view>
  223. </scroll-view>
  224. <uni-popup ref="popupReason" type="bottom" :is-mask-click="false" background-color="#fff" border-radius="10px 10px 0 0">
  225. <view class="popup-reason-box flex-direction">
  226. <view class="text-align-center fs-38 fw-600 fc-3 mb-18">
  227. 选择取消原因
  228. </view>
  229. <picker-view @change="bindChange" class="picker-view flex-1" :immediate-change='true'>
  230. <picker-view-column>
  231. <view class="picker-view-item" v-for="(item,index) in refundReason" :key="index">
  232. {{item.refund_msg}}
  233. </view>
  234. </picker-view-column>
  235. </picker-view>
  236. <view class="align-items-center flex-justify-space plr-24 box-border-box">
  237. <view class="flex-1 mr-20 pop-b text-align-center fs-36 b-r-ccc" @click="popCancel">
  238. 取消
  239. </view>
  240. <view class="flex-1 pop-b text-align-center bgc-41ABF5 fc-f fs-36" @click="popSure">
  241. 确定
  242. </view>
  243. </view>
  244. </view>
  245. </uni-popup>
  246. </view>
  247. </template>
  248. <script>
  249. import {
  250. commonRefundReason
  251. } from "@/api/common.js"
  252. import {
  253. orderInfo,
  254. orderCancel,
  255. orderPay
  256. } from "@/api/order.js"
  257. import tools from "@/service/tools";
  258. export default {
  259. components: {},
  260. data() {
  261. return {
  262. goodsData: [{
  263. name: '1'
  264. }, {
  265. name: '2'
  266. }],
  267. goodsShow: true,
  268. infoData: {},
  269. time: {
  270. day: '',
  271. h: "",
  272. m: '',
  273. s: '',
  274. },
  275. isAJAX: false,
  276. address_id: '',
  277. refund_msg: '', // 退款理由
  278. refundReason: [] //退款原因
  279. };
  280. },
  281. onLoad(data) {
  282. if (data) {
  283. // console.log(data);
  284. this.orderInfo(data.orderId)
  285. }
  286. },
  287. mounted() {},
  288. onUnload() {
  289. const takeOutData = {}
  290. orderInfo({
  291. order_id: this.infoData.id
  292. }).then((res) => {
  293. if (res.code == 1) {
  294. takeOutData.id = this.infoData.id
  295. takeOutData.order_status = res.data.order_status
  296. takeOutData.order_status_str = res.data.order_status_str
  297. uni.$emit('takeOutData', takeOutData)
  298. }
  299. })
  300. },
  301. methods: {
  302. lookFinishImage(img) {
  303. tools.lookBigImg(1,img)
  304. },
  305. contactShop(phone) {
  306. uni.makePhoneCall({
  307. phoneNumber: phone, // 电话号码
  308. success: function() {
  309. console.log('拨打电话成功');
  310. },
  311. fail: function() {
  312. console.log('拨打电话失败');
  313. }
  314. });
  315. },
  316. copy(value) {
  317. uni.setClipboardData({
  318. data: value,
  319. success() {
  320. tools.success('复制成功')
  321. },
  322. fail() {
  323. tools.error("复制失败")
  324. }
  325. })
  326. },
  327. goToUrl() {
  328. // 再来一单
  329. // uni.navigateTo({
  330. // url: '/pages-takeout/takeout'
  331. // })
  332. uni.redirectTo({
  333. url: '/pages-takeout/shop?shop_id=' + this.infoData.shop_id
  334. })
  335. },
  336. setAddress() {
  337. this.$refs.selectAddress.getList();
  338. },
  339. giveAddress(e) {
  340. this.address_id = e;
  341. this.expressOrderAddress()
  342. },
  343. expressOrderAddress() {
  344. expressOrderAddress({
  345. order_id: this.infoData.id,
  346. address_id: this.address_id
  347. }).then((res) => {
  348. if (res.code == 1) {
  349. tools.success(res.msg)
  350. this.orderInfo(this.infoData.id)
  351. } else {
  352. tools.error(res.msg)
  353. }
  354. })
  355. },
  356. pay() {
  357. this.orderPay(this.infoData.id)
  358. },
  359. orderPay(id) {
  360. // 外卖支付
  361. uni.redirectTo({
  362. url: `/pages-takeout/pay-page?orderId=${id}`
  363. });
  364. // if (this.isAJAX) {
  365. // return
  366. // }
  367. // this.isAJAX = true;
  368. // orderPay({
  369. // order_id: id
  370. // }).then((ret) => {
  371. // if (ret.code === 1) {
  372. // uni.requestPayment({
  373. // provider: "wxpay", //支付类型-固定值
  374. // timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  375. // nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  376. // package: ret.data.wx_pay.package, // 固定值
  377. // signType: ret.data.wx_pay.signType, //固定值
  378. // paySign: ret.data.wx_pay.paySign, //签名
  379. // success: (ren) => {
  380. // tools.success("支付成功");
  381. // this.isAJAX = false;
  382. // this.orderInfo(this.infoData.id)
  383. // },
  384. // fail: (err) => {
  385. // this.isAJAX = false;
  386. // tools.error("支付失败");
  387. // },
  388. // });
  389. // } else {
  390. // this.isAJAX = false;
  391. // tools.error("支付失败");
  392. // }
  393. // })
  394. },
  395. cancelOrder() {
  396. // 外卖取消订单
  397. commonRefundReason().then((res) => {
  398. if (res.code === 1) {
  399. this.refundReason = res.data
  400. this.refund_msg = res.data[0].refund_msg
  401. }
  402. })
  403. this.$refs.popupReason.open()
  404. },
  405. popCancel() {
  406. // 退款取消
  407. this.$refs.popupReason.close()
  408. },
  409. popSure() {
  410. // 退款确认
  411. if (this.isAJAX) {
  412. return
  413. }
  414. this.isAJAX = true;
  415. orderCancel({
  416. order_id: this.infoData.id,
  417. refund_msg: this.refund_msg
  418. }).then((res) => {
  419. if (res.code == 1) {
  420. tools.success(res.msg)
  421. this.$refs.popupReason.close()
  422. setTimeout(() => {
  423. this.orderInfo(this.infoData.id)
  424. }, 1500)
  425. this.isAJAX = false;
  426. } else {
  427. tools.error(res.msg)
  428. this.isAJAX = false;
  429. }
  430. })
  431. },
  432. openGoods() {
  433. this.goodsShow = !this.goodsShow
  434. },
  435. scrolltolower() {
  436. // console.log('触底');
  437. },
  438. orderInfo(id) {
  439. orderInfo({
  440. order_id: id
  441. }).then((res) => {
  442. if (res.code == 1) {
  443. this.infoData = res.data
  444. if (this.infoData.order_status == 1) {
  445. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  446. createDate.setMinutes(createDate.getMinutes() + 10)
  447. this.setCountDown(createDate)
  448. }
  449. }
  450. })
  451. },
  452. setCountDown(sTime) {
  453. let end = new Date(sTime).getTime();
  454. let now = new Date().getTime();
  455. let msec = end - now;
  456. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  457. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  458. let m = parseInt(msec / 1000 / 60 % 60);
  459. let s = parseInt(msec / 1000 % 60);
  460. this.time.h = h > 9 ? h : '0' + h;
  461. this.time.m = m > 9 ? m : '0' + m;
  462. this.time.s = s > 9 ? s : '0' + s;
  463. msec -= 1000;
  464. if (this.time.day >= 1) {
  465. this.showTime = true;
  466. } else {
  467. this.showTime = false;
  468. };
  469. if (msec >= 0) {
  470. setTimeout(() => {
  471. this.setCountDown(sTime);
  472. }, 1000);
  473. } else {
  474. this.isTimeEnd = true;
  475. this.bText = '活动结束';
  476. this.time.h = '--';
  477. this.time.m = '--';
  478. this.time.s = '--';
  479. };
  480. }
  481. },
  482. }
  483. </script>
  484. <style lang="scss" scoped>
  485. .bg-img {
  486. position: fixed;
  487. left: 0;
  488. top: 0;
  489. z-index: -1;
  490. width: 100%;
  491. height: 320rpx;
  492. }
  493. .w-33 {
  494. width: 33%;
  495. position: relative;
  496. }
  497. .item-box-button {
  498. position: absolute;
  499. width: 100%;
  500. height: 88rpx;
  501. top: 0;
  502. left: 0;
  503. z-index: 100;
  504. background-color: transparent;
  505. border: none !important;
  506. }
  507. button::after {
  508. border: none !important;
  509. }
  510. .p-24-24-0 {
  511. padding: 24rpx 24rpx 0;
  512. }
  513. .icon {
  514. width: 48rpx;
  515. height: 48rpx;
  516. }
  517. .w-420 {
  518. width: 420rpx;
  519. }
  520. .goods-img {
  521. width: 108rpx;
  522. height: 108rpx;
  523. border-radius: 8rpx;
  524. }
  525. .w-376 {
  526. width: 376rpx;
  527. }
  528. .icon-right {
  529. width: 32rpx;
  530. height: 32rpx;
  531. }
  532. .w-480 {
  533. width: 480rpx;
  534. }
  535. .icon-fz {
  536. width: 24rpx;
  537. height: 24rpx;
  538. }
  539. .goods-box {
  540. overflow: hidden;
  541. }
  542. .goodsShowOne {
  543. max-height: 508rpx;
  544. transition: all .5s linear;
  545. }
  546. .goodsShowTwo {
  547. height: auto;
  548. transition: all .5s linear;
  549. }
  550. .popup-reason-box {
  551. width: 100%;
  552. height: 45vh;
  553. overflow: auto;
  554. border-radius: 20rpx 20rpx 0 0;
  555. background: #fff;
  556. padding: 24rpx 0 0;
  557. box-sizing: border-box;
  558. }
  559. .picker-view {
  560. width: 100%;
  561. // height: 70%;
  562. }
  563. .picker-view-item {
  564. // height: 90rpx;
  565. line-height: 68rpx;
  566. text-align: center;
  567. background: #F5F5F5;
  568. }
  569. .pop-b {
  570. height: 80rpx;
  571. line-height: 80rpx;
  572. border-radius: 20rpx;
  573. }
  574. </style>