takeout-info.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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" v-if="infoData.order_status == 8 && infoData.refund_status == 1">
  24. 申请成功,请及时联系商家退款,避免已出餐
  25. </view>
  26. <view class="p-b-20 mb-24 b-b-F9F9F9 fs-32 fc-3"
  27. v-else-if="infoData.order_status == 3 || infoData.order_status == 7 || infoData.order_status == 8 || infoData.order_status == 9 || infoData.order_status == 10">
  28. 感谢你对君子校园的信任,期待你再次光临
  29. </view>
  30. <view class="align-items-center flex-wrap-wrap">
  31. <view class="w-33 flex-direction align-items-center" @click="pay"
  32. v-show="infoData.order_status == 1">
  33. <image class="mb-4 icon" src="@/static/img/order/qzf.png" mode=""></image>
  34. <view class="fs-24 fc-41ABF5">
  35. 去支付
  36. </view>
  37. </view>
  38. <!-- <view @click="setAddress" class="w-33 flex-direction align-items-center"
  39. v-show="infoData.order_status == 1 || infoData.order_status == 2">
  40. <image class="mb-4 icon" src="@/static/img/order/xgdd.png" mode=""></image>
  41. <view class="fs-24 fc-3">
  42. 修改收货地址
  43. </view>
  44. </view> -->
  45. <view @click="goToUrl" class="w-33 flex-direction align-items-center"
  46. v-show="infoData.order_status == 3 || infoData.order_status == 7 || infoData.order_status == 8 || infoData.order_status == 9 || infoData.order_status == 10">
  47. <image class="mb-4 icon" src="@/static/img/order/zlyd.png" mode=""></image>
  48. <view class="fs-24 fc-41ABF5">
  49. 再来一单
  50. </view>
  51. </view>
  52. <view class="w-33 flex-direction align-items-center">
  53. <button class="item-box-button" open-type="contact" :bindcontact="handleContact"></button>
  54. <image class="mb-4 icon" src="@/static/img/order/lxkf.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_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" :src="item.goods_image" 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. ¥{{item.goods_price}}
  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. v-show="infoData.order_status == 6">
  164. <view class="fs-28 fc-9">
  165. 骑手信息
  166. </view>
  167. <view class="fs-28 fc-3 w-480 text-align-right">
  168. {{infoData.rider.rider_name}}{{infoData.rider.phone}}
  169. </view>
  170. </view>
  171. <view class="display-flex flex-justify-space mb-26">
  172. <view class="fs-28 fc-9">
  173. 订单编号
  174. </view>
  175. <view class="align-items-center flex-justify-end">
  176. <view class="fs-28 fc-3 w-480 mr-8 text-align-right">
  177. {{infoData.order_sn}}
  178. </view>
  179. <image class="icon-fz" src="@/static/img/order/fz.png" mode=""></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">
  199. <view class="fs-28 fc-9">
  200. 备注
  201. </view>
  202. <view class="fs-28 fc-3 w-480 text-align-right">
  203. {{infoData.note?infoData.note:'无'}}
  204. </view>
  205. </view>
  206. </view>
  207. </scroll-view>
  208. <SelectAddress ref="selectAddress" @giveAddress='giveAddress'></SelectAddress>
  209. </view>
  210. </template>
  211. <script>
  212. import {
  213. orderInfo,
  214. orderCancel,
  215. orderPay
  216. } from "@/api/order.js"
  217. import tools from "@/service/tools";
  218. import SelectAddress from "./module/select-address.vue";
  219. export default {
  220. components: {
  221. SelectAddress
  222. },
  223. data() {
  224. return {
  225. goodsData: [{
  226. name: '1'
  227. }, {
  228. name: '2'
  229. }],
  230. goodsShow: true,
  231. infoData: {},
  232. time: {
  233. day: '',
  234. h: "",
  235. m: '',
  236. s: '',
  237. },
  238. isAJAX: false,
  239. address_id: ''
  240. };
  241. },
  242. onLoad(data) {
  243. if (data) {
  244. // console.log(data);
  245. this.orderInfo(data.orderId)
  246. }
  247. },
  248. mounted() {},
  249. methods: {
  250. goToUrl() {
  251. // 再来一单
  252. // uni.navigateTo({
  253. // url: '/pages-takeout/takeout'
  254. // })
  255. uni.redirectTo({
  256. url: '/pages-takeout/shop?shop_id=' + this.infoData.shop_id
  257. })
  258. },
  259. setAddress() {
  260. this.$refs.selectAddress.getList();
  261. },
  262. giveAddress(e) {
  263. this.address_id = e;
  264. this.expressOrderAddress()
  265. },
  266. expressOrderAddress() {
  267. expressOrderAddress({
  268. order_id: this.infoData.id,
  269. address_id: this.address_id
  270. }).then((res) => {
  271. if (res.code == 1) {
  272. tools.success(res.msg)
  273. this.orderInfo(this.infoData.id)
  274. } else {
  275. tools.error(res.msg)
  276. }
  277. })
  278. },
  279. pay() {
  280. this.orderPay(this.infoData.id)
  281. },
  282. orderPay(id) {
  283. // 票务支付
  284. if (this.isAJAX) {
  285. return
  286. }
  287. this.isAJAX = true;
  288. orderPay({
  289. order_id: id
  290. }).then((ret) => {
  291. if (ret.code === 1) {
  292. uni.requestPayment({
  293. provider: "wxpay", //支付类型-固定值
  294. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  295. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  296. package: ret.data.wx_pay.package, // 固定值
  297. signType: ret.data.wx_pay.signType, //固定值
  298. paySign: ret.data.wx_pay.paySign, //签名
  299. success: (ren) => {
  300. tools.success("支付成功");
  301. this.isAJAX = false;
  302. this.orderInfo(this.infoData.id)
  303. },
  304. fail: (err) => {
  305. this.isAJAX = false;
  306. tools.error("支付失败");
  307. },
  308. });
  309. } else {
  310. this.isAJAX = false;
  311. tools.error("支付失败");
  312. }
  313. })
  314. },
  315. cancelOrder() {
  316. // 外卖取消订单
  317. uni.showModal({
  318. title: '提示',
  319. content: '是否取消订单?',
  320. confirmText: '确定',
  321. confirmColor: '#FB3D03',
  322. success: (res) => {
  323. if (res.confirm === true) {
  324. if (this.isAJAX) {
  325. return
  326. }
  327. this.isAJAX = true;
  328. orderCancel({
  329. order_id: this.infoData.id
  330. }).then((res) => {
  331. if (res.code == 1) {
  332. tools.success(res.msg)
  333. setTimeout(() =>{
  334. this.orderInfo(this.infoData.id)
  335. }, 1500)
  336. this.isAJAX = false;
  337. } else {
  338. tools.error(res.msg)
  339. this.isAJAX = false;
  340. }
  341. })
  342. }
  343. }
  344. });
  345. },
  346. openGoods() {
  347. this.goodsShow = !this.goodsShow
  348. },
  349. scrolltolower() {
  350. // console.log('触底');
  351. },
  352. orderInfo(id) {
  353. orderInfo({
  354. order_id: id
  355. }).then((res) => {
  356. if (res.code == 1) {
  357. this.infoData = res.data
  358. if (this.infoData.order_status == 1) {
  359. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  360. createDate.setMinutes(createDate.getMinutes() + 10)
  361. this.setCountDown(createDate)
  362. }
  363. }
  364. })
  365. },
  366. setCountDown(sTime) {
  367. let end = new Date(sTime).getTime();
  368. let now = new Date().getTime();
  369. let msec = end - now;
  370. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  371. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  372. let m = parseInt(msec / 1000 / 60 % 60);
  373. let s = parseInt(msec / 1000 % 60);
  374. this.time.h = h > 9 ? h : '0' + h;
  375. this.time.m = m > 9 ? m : '0' + m;
  376. this.time.s = s > 9 ? s : '0' + s;
  377. msec -= 1000;
  378. if (this.time.day >= 1) {
  379. this.showTime = true;
  380. } else {
  381. this.showTime = false;
  382. };
  383. if (msec >= 0) {
  384. setTimeout(() => {
  385. this.setCountDown(sTime);
  386. }, 1000);
  387. } else {
  388. this.isTimeEnd = true;
  389. this.bText = '活动结束';
  390. this.time.h = '--';
  391. this.time.m = '--';
  392. this.time.s = '--';
  393. };
  394. }
  395. },
  396. }
  397. </script>
  398. <style lang="scss" scoped>
  399. .bg-img {
  400. position: fixed;
  401. left: 0;
  402. top: 0;
  403. z-index: -1;
  404. width: 100%;
  405. height: 320rpx;
  406. }
  407. .w-33 {
  408. width: 33%;
  409. position: relative;
  410. }
  411. .item-box-button {
  412. position: absolute;
  413. width: 100%;
  414. height: 88rpx;
  415. top: 0;
  416. left: 0;
  417. z-index: 100;
  418. background-color: transparent;
  419. border: none !important;
  420. }
  421. button::after {
  422. border: none !important;
  423. }
  424. .p-24-24-0 {
  425. padding: 24rpx 24rpx 0;
  426. }
  427. .icon {
  428. width: 48rpx;
  429. height: 48rpx;
  430. }
  431. .w-420 {
  432. width: 420rpx;
  433. }
  434. .goods-img {
  435. width: 108rpx;
  436. height: 108rpx;
  437. border-radius: 8rpx;
  438. }
  439. .w-376 {
  440. width: 376rpx;
  441. }
  442. .icon-right {
  443. width: 32rpx;
  444. height: 32rpx;
  445. }
  446. .w-480 {
  447. width: 480rpx;
  448. }
  449. .icon-fz {
  450. width: 24rpx;
  451. height: 24rpx;
  452. }
  453. .goods-box {
  454. overflow: hidden;
  455. }
  456. .goodsShowOne {
  457. max-height: 508rpx;
  458. transition: all .5s linear;
  459. }
  460. .goodsShowTwo {
  461. height: auto;
  462. transition: all .5s linear;
  463. }
  464. </style>