takeout-info.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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">
  211. {{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. <SelectAddress ref="selectAddress" @giveAddress='giveAddress'></SelectAddress>
  225. </view>
  226. </template>
  227. <script>
  228. import {
  229. orderInfo,
  230. orderCancel,
  231. orderPay
  232. } from "@/api/order.js"
  233. import tools from "@/service/tools";
  234. import SelectAddress from "./module/select-address.vue";
  235. export default {
  236. components: {
  237. SelectAddress
  238. },
  239. data() {
  240. return {
  241. goodsData: [{
  242. name: '1'
  243. }, {
  244. name: '2'
  245. }],
  246. goodsShow: true,
  247. infoData: {},
  248. time: {
  249. day: '',
  250. h: "",
  251. m: '',
  252. s: '',
  253. },
  254. isAJAX: false,
  255. address_id: ''
  256. };
  257. },
  258. onLoad(data) {
  259. if (data) {
  260. // console.log(data);
  261. this.orderInfo(data.orderId)
  262. }
  263. },
  264. mounted() {},
  265. onUnload() {
  266. const takeOutData = {}
  267. orderInfo({
  268. order_id: this.infoData.id
  269. }).then((res) => {
  270. if (res.code == 1) {
  271. takeOutData.id = this.infoData.id
  272. takeOutData.order_status = res.data.order_status
  273. takeOutData.order_status_str = res.data.order_status_str
  274. uni.$emit('takeOutData', takeOutData)
  275. }
  276. })
  277. },
  278. methods: {
  279. contactShop(phone) {
  280. uni.makePhoneCall({
  281. phoneNumber: phone, // 电话号码
  282. success: function() {
  283. console.log('拨打电话成功');
  284. },
  285. fail: function() {
  286. console.log('拨打电话失败');
  287. }
  288. });
  289. },
  290. copy(value) {
  291. uni.setClipboardData({
  292. data: value,
  293. success() {
  294. tools.success('复制成功')
  295. },
  296. fail() {
  297. tools.error("复制失败")
  298. }
  299. })
  300. },
  301. goToUrl() {
  302. // 再来一单
  303. // uni.navigateTo({
  304. // url: '/pages-takeout/takeout'
  305. // })
  306. uni.redirectTo({
  307. url: '/pages-takeout/shop?shop_id=' + this.infoData.shop_id
  308. })
  309. },
  310. setAddress() {
  311. this.$refs.selectAddress.getList();
  312. },
  313. giveAddress(e) {
  314. this.address_id = e;
  315. this.expressOrderAddress()
  316. },
  317. expressOrderAddress() {
  318. expressOrderAddress({
  319. order_id: this.infoData.id,
  320. address_id: this.address_id
  321. }).then((res) => {
  322. if (res.code == 1) {
  323. tools.success(res.msg)
  324. this.orderInfo(this.infoData.id)
  325. } else {
  326. tools.error(res.msg)
  327. }
  328. })
  329. },
  330. pay() {
  331. this.orderPay(this.infoData.id)
  332. },
  333. orderPay(id) {
  334. // 票务支付
  335. if (this.isAJAX) {
  336. return
  337. }
  338. this.isAJAX = true;
  339. orderPay({
  340. order_id: id
  341. }).then((ret) => {
  342. if (ret.code === 1) {
  343. uni.requestPayment({
  344. provider: "wxpay", //支付类型-固定值
  345. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  346. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  347. package: ret.data.wx_pay.package, // 固定值
  348. signType: ret.data.wx_pay.signType, //固定值
  349. paySign: ret.data.wx_pay.paySign, //签名
  350. success: (ren) => {
  351. tools.success("支付成功");
  352. this.isAJAX = false;
  353. this.orderInfo(this.infoData.id)
  354. },
  355. fail: (err) => {
  356. this.isAJAX = false;
  357. tools.error("支付失败");
  358. },
  359. });
  360. } else {
  361. this.isAJAX = false;
  362. tools.error("支付失败");
  363. }
  364. })
  365. },
  366. cancelOrder() {
  367. // 外卖取消订单
  368. uni.showModal({
  369. title: '提示',
  370. content: '是否取消订单?',
  371. confirmText: '确定',
  372. confirmColor: '#FB3D03',
  373. success: (res) => {
  374. if (res.confirm === true) {
  375. if (this.isAJAX) {
  376. return
  377. }
  378. this.isAJAX = true;
  379. orderCancel({
  380. order_id: this.infoData.id
  381. }).then((res) => {
  382. if (res.code == 1) {
  383. tools.success(res.msg, 3000)
  384. setTimeout(() => {
  385. this.orderInfo(this.infoData.id)
  386. }, 3000)
  387. this.isAJAX = false;
  388. } else {
  389. tools.error(res.msg)
  390. this.isAJAX = false;
  391. }
  392. })
  393. }
  394. }
  395. });
  396. },
  397. openGoods() {
  398. this.goodsShow = !this.goodsShow
  399. },
  400. scrolltolower() {
  401. // console.log('触底');
  402. },
  403. orderInfo(id) {
  404. orderInfo({
  405. order_id: id
  406. }).then((res) => {
  407. if (res.code == 1) {
  408. this.infoData = res.data
  409. if (this.infoData.order_status == 1) {
  410. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  411. createDate.setMinutes(createDate.getMinutes() + 10)
  412. this.setCountDown(createDate)
  413. }
  414. }
  415. })
  416. },
  417. setCountDown(sTime) {
  418. let end = new Date(sTime).getTime();
  419. let now = new Date().getTime();
  420. let msec = end - now;
  421. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  422. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  423. let m = parseInt(msec / 1000 / 60 % 60);
  424. let s = parseInt(msec / 1000 % 60);
  425. this.time.h = h > 9 ? h : '0' + h;
  426. this.time.m = m > 9 ? m : '0' + m;
  427. this.time.s = s > 9 ? s : '0' + s;
  428. msec -= 1000;
  429. if (this.time.day >= 1) {
  430. this.showTime = true;
  431. } else {
  432. this.showTime = false;
  433. };
  434. if (msec >= 0) {
  435. setTimeout(() => {
  436. this.setCountDown(sTime);
  437. }, 1000);
  438. } else {
  439. this.isTimeEnd = true;
  440. this.bText = '活动结束';
  441. this.time.h = '--';
  442. this.time.m = '--';
  443. this.time.s = '--';
  444. };
  445. }
  446. },
  447. }
  448. </script>
  449. <style lang="scss" scoped>
  450. .bg-img {
  451. position: fixed;
  452. left: 0;
  453. top: 0;
  454. z-index: -1;
  455. width: 100%;
  456. height: 320rpx;
  457. }
  458. .w-33 {
  459. width: 33%;
  460. position: relative;
  461. }
  462. .item-box-button {
  463. position: absolute;
  464. width: 100%;
  465. height: 88rpx;
  466. top: 0;
  467. left: 0;
  468. z-index: 100;
  469. background-color: transparent;
  470. border: none !important;
  471. }
  472. button::after {
  473. border: none !important;
  474. }
  475. .p-24-24-0 {
  476. padding: 24rpx 24rpx 0;
  477. }
  478. .icon {
  479. width: 48rpx;
  480. height: 48rpx;
  481. }
  482. .w-420 {
  483. width: 420rpx;
  484. }
  485. .goods-img {
  486. width: 108rpx;
  487. height: 108rpx;
  488. border-radius: 8rpx;
  489. }
  490. .w-376 {
  491. width: 376rpx;
  492. }
  493. .icon-right {
  494. width: 32rpx;
  495. height: 32rpx;
  496. }
  497. .w-480 {
  498. width: 480rpx;
  499. }
  500. .icon-fz {
  501. width: 24rpx;
  502. height: 24rpx;
  503. }
  504. .goods-box {
  505. overflow: hidden;
  506. }
  507. .goodsShowOne {
  508. max-height: 508rpx;
  509. transition: all .5s linear;
  510. }
  511. .goodsShowTwo {
  512. height: auto;
  513. transition: all .5s linear;
  514. }
  515. </style>