takeout-info.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  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 v-if="infoData.finish_image" class="fs-28 fc-3 w-480 text-align-right fc-41ABF5" @click="lookFinishImage(infoData.finish_image)">
  203. 点击查看
  204. </view>
  205. <view v-else class="">
  206. 无
  207. </view>
  208. </view>
  209. <view class="display-flex flex-justify-space mb-26" v-if="infoData.order_status == 7">
  210. <view class="fs-28 fc-9">
  211. 完成时间
  212. </view>
  213. <view class="fs-28 fc-3 w-480 text-align-right">
  214. {{infoData.finish_time?infoData.finish_time:'无'}}
  215. </view>
  216. </view>
  217. <view class="display-flex flex-justify-space mb-26">
  218. <view class="fs-28 fc-9">
  219. 备注
  220. </view>
  221. <view class="fs-28 fc-3 w-480 text-align-right">
  222. {{infoData.note?infoData.note:'无'}}
  223. </view>
  224. </view>
  225. </view>
  226. </scroll-view>
  227. <uni-popup ref="popupReason" type="bottom" :is-mask-click="false" background-color="#fff" border-radius="10px 10px 0 0">
  228. <view class="popup-reason-box flex-direction">
  229. <view class="text-align-center fs-38 fw-600 fc-3 mb-18">
  230. 选择取消原因
  231. </view>
  232. <picker-view @change="bindChange" class="picker-view flex-1" :immediate-change='true'>
  233. <picker-view-column>
  234. <view class="picker-view-item" v-for="(item,index) in refundReason" :key="index">
  235. {{item.refund_msg}}
  236. </view>
  237. </picker-view-column>
  238. </picker-view>
  239. <view class="align-items-center flex-justify-space plr-24 box-border-box">
  240. <view class="flex-1 mr-20 pop-b text-align-center fs-36 b-r-ccc" @click="popCancel">
  241. 取消
  242. </view>
  243. <view class="flex-1 pop-b text-align-center bgc-41ABF5 fc-f fs-36" @click="popSure">
  244. 确定
  245. </view>
  246. </view>
  247. </view>
  248. </uni-popup>
  249. </view>
  250. </template>
  251. <script>
  252. import {
  253. commonRefundReason
  254. } from "@/api/common.js"
  255. import {
  256. orderInfo,
  257. orderCancel,
  258. orderPay
  259. } from "@/api/order.js"
  260. import tools from "@/service/tools";
  261. export default {
  262. components: {},
  263. data() {
  264. return {
  265. goodsData: [{
  266. name: '1'
  267. }, {
  268. name: '2'
  269. }],
  270. goodsShow: true,
  271. infoData: {},
  272. time: {
  273. day: '',
  274. h: "",
  275. m: '',
  276. s: '',
  277. },
  278. isAJAX: false,
  279. address_id: '',
  280. refund_msg: '', // 退款理由
  281. refundReason: [] //退款原因
  282. };
  283. },
  284. onLoad(data) {
  285. if (data) {
  286. // console.log(data);
  287. this.orderInfo(data.orderId)
  288. }
  289. },
  290. mounted() {},
  291. onUnload() {
  292. const takeOutData = {}
  293. orderInfo({
  294. order_id: this.infoData.id
  295. }).then((res) => {
  296. if (res.code == 1) {
  297. takeOutData.id = this.infoData.id
  298. takeOutData.order_status = res.data.order_status
  299. takeOutData.order_status_str = res.data.order_status_str
  300. uni.$emit('takeOutData', takeOutData)
  301. }
  302. })
  303. },
  304. methods: {
  305. lookFinishImage(img) {
  306. tools.lookBigImg(1,img)
  307. },
  308. contactShop(phone) {
  309. uni.makePhoneCall({
  310. phoneNumber: phone, // 电话号码
  311. success: function() {
  312. console.log('拨打电话成功');
  313. },
  314. fail: function() {
  315. console.log('拨打电话失败');
  316. }
  317. });
  318. },
  319. copy(value) {
  320. uni.setClipboardData({
  321. data: value,
  322. success() {
  323. tools.success('复制成功')
  324. },
  325. fail() {
  326. tools.error("复制失败")
  327. }
  328. })
  329. },
  330. goToUrl() {
  331. // 再来一单
  332. // uni.navigateTo({
  333. // url: '/pages-takeout/takeout'
  334. // })
  335. uni.redirectTo({
  336. url: '/pages-takeout/shop?shop_id=' + this.infoData.shop_id
  337. })
  338. },
  339. setAddress() {
  340. this.$refs.selectAddress.getList();
  341. },
  342. giveAddress(e) {
  343. this.address_id = e;
  344. this.expressOrderAddress()
  345. },
  346. expressOrderAddress() {
  347. expressOrderAddress({
  348. order_id: this.infoData.id,
  349. address_id: this.address_id
  350. }).then((res) => {
  351. if (res.code == 1) {
  352. tools.success(res.msg)
  353. this.orderInfo(this.infoData.id)
  354. } else {
  355. tools.error(res.msg)
  356. }
  357. })
  358. },
  359. pay() {
  360. this.orderPay(this.infoData.id)
  361. },
  362. orderPay(id) {
  363. // 外卖支付
  364. uni.redirectTo({
  365. url: `/pages-takeout/pay-page?orderId=${id}`
  366. });
  367. // if (this.isAJAX) {
  368. // return
  369. // }
  370. // this.isAJAX = true;
  371. // orderPay({
  372. // order_id: id
  373. // }).then((ret) => {
  374. // if (ret.code === 1) {
  375. // uni.requestPayment({
  376. // provider: "wxpay", //支付类型-固定值
  377. // timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  378. // nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  379. // package: ret.data.wx_pay.package, // 固定值
  380. // signType: ret.data.wx_pay.signType, //固定值
  381. // paySign: ret.data.wx_pay.paySign, //签名
  382. // success: (ren) => {
  383. // tools.success("支付成功");
  384. // this.isAJAX = false;
  385. // this.orderInfo(this.infoData.id)
  386. // },
  387. // fail: (err) => {
  388. // this.isAJAX = false;
  389. // tools.error("支付失败");
  390. // },
  391. // });
  392. // } else {
  393. // this.isAJAX = false;
  394. // tools.error("支付失败");
  395. // }
  396. // })
  397. },
  398. cancelOrder() {
  399. // 外卖取消订单
  400. commonRefundReason().then((res) => {
  401. if (res.code === 1) {
  402. this.refundReason = res.data
  403. this.refund_msg = res.data[0].refund_msg
  404. }
  405. })
  406. this.$refs.popupReason.open()
  407. },
  408. popCancel() {
  409. // 退款取消
  410. this.$refs.popupReason.close()
  411. },
  412. popSure() {
  413. // 退款确认
  414. if (this.isAJAX) {
  415. return
  416. }
  417. this.isAJAX = true;
  418. orderCancel({
  419. order_id: this.infoData.id,
  420. refund_msg: this.refund_msg
  421. }).then((res) => {
  422. if (res.code == 1) {
  423. tools.success(res.msg)
  424. this.$refs.popupReason.close()
  425. setTimeout(() => {
  426. this.orderInfo(this.infoData.id)
  427. }, 1500)
  428. this.isAJAX = false;
  429. } else {
  430. tools.error(res.msg)
  431. this.isAJAX = false;
  432. }
  433. })
  434. },
  435. openGoods() {
  436. this.goodsShow = !this.goodsShow
  437. },
  438. scrolltolower() {
  439. // console.log('触底');
  440. },
  441. orderInfo(id) {
  442. orderInfo({
  443. order_id: id
  444. }).then((res) => {
  445. if (res.code == 1) {
  446. this.infoData = res.data
  447. if (this.infoData.order_status == 1) {
  448. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  449. createDate.setMinutes(createDate.getMinutes() + 10)
  450. this.setCountDown(createDate)
  451. }
  452. }
  453. })
  454. },
  455. setCountDown(sTime) {
  456. let end = new Date(sTime).getTime();
  457. let now = new Date().getTime();
  458. let msec = end - now;
  459. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  460. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  461. let m = parseInt(msec / 1000 / 60 % 60);
  462. let s = parseInt(msec / 1000 % 60);
  463. this.time.h = h > 9 ? h : '0' + h;
  464. this.time.m = m > 9 ? m : '0' + m;
  465. this.time.s = s > 9 ? s : '0' + s;
  466. msec -= 1000;
  467. if (this.time.day >= 1) {
  468. this.showTime = true;
  469. } else {
  470. this.showTime = false;
  471. };
  472. if (msec >= 0) {
  473. setTimeout(() => {
  474. this.setCountDown(sTime);
  475. }, 1000);
  476. } else {
  477. this.isTimeEnd = true;
  478. this.bText = '活动结束';
  479. this.time.h = '--';
  480. this.time.m = '--';
  481. this.time.s = '--';
  482. };
  483. }
  484. },
  485. }
  486. </script>
  487. <style lang="scss" scoped>
  488. .bg-img {
  489. position: fixed;
  490. left: 0;
  491. top: 0;
  492. z-index: -1;
  493. width: 100%;
  494. height: 320rpx;
  495. }
  496. .w-33 {
  497. width: 33%;
  498. position: relative;
  499. }
  500. .item-box-button {
  501. position: absolute;
  502. width: 100%;
  503. height: 88rpx;
  504. top: 0;
  505. left: 0;
  506. z-index: 100;
  507. background-color: transparent;
  508. border: none !important;
  509. }
  510. button::after {
  511. border: none !important;
  512. }
  513. .p-24-24-0 {
  514. padding: 24rpx 24rpx 0;
  515. }
  516. .icon {
  517. width: 48rpx;
  518. height: 48rpx;
  519. }
  520. .w-420 {
  521. width: 420rpx;
  522. }
  523. .goods-img {
  524. width: 108rpx;
  525. height: 108rpx;
  526. border-radius: 8rpx;
  527. }
  528. .w-376 {
  529. width: 376rpx;
  530. }
  531. .icon-right {
  532. width: 32rpx;
  533. height: 32rpx;
  534. }
  535. .w-480 {
  536. width: 480rpx;
  537. }
  538. .icon-fz {
  539. width: 24rpx;
  540. height: 24rpx;
  541. }
  542. .goods-box {
  543. overflow: hidden;
  544. }
  545. .goodsShowOne {
  546. max-height: 508rpx;
  547. transition: all .5s linear;
  548. }
  549. .goodsShowTwo {
  550. height: auto;
  551. transition: all .5s linear;
  552. }
  553. .popup-reason-box {
  554. width: 100%;
  555. height: 45vh;
  556. overflow: auto;
  557. border-radius: 20rpx 20rpx 0 0;
  558. background: #fff;
  559. padding: 24rpx 0 0;
  560. box-sizing: border-box;
  561. }
  562. .picker-view {
  563. width: 100%;
  564. // height: 70%;
  565. }
  566. .picker-view-item {
  567. // height: 90rpx;
  568. line-height: 68rpx;
  569. text-align: center;
  570. background: #F5F5F5;
  571. }
  572. .pop-b {
  573. height: 80rpx;
  574. line-height: 80rpx;
  575. border-radius: 20rpx;
  576. }
  577. </style>