takeout-info.vue 15 KB

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