takeout-info.vue 14 KB

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