takeout-info.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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-show="infoData.order_status == 3 || infoData.order_status == 7 || infoData.order_status == 8 || infoData.order_status == 9 || infoData.order_status == 10">
  24. 感谢你对君子校园的信任,期待你再次光临
  25. </view>
  26. <view class="align-items-center flex-wrap-wrap">
  27. <view class="w-33 flex-direction align-items-center" @click="pay"
  28. v-show="infoData.order_status == 1">
  29. <image class="mb-4 icon" src="@/static/img/order/qzf.png" mode=""></image>
  30. <view class="fs-24 fc-41ABF5">
  31. 去支付
  32. </view>
  33. </view>
  34. <!-- <view @click="setAddress" class="w-33 flex-direction align-items-center"
  35. v-show="infoData.order_status == 1 || infoData.order_status == 2">
  36. <image class="mb-4 icon" src="@/static/img/order/xgdd.png" mode=""></image>
  37. <view class="fs-24 fc-3">
  38. 修改收货地址
  39. </view>
  40. </view> -->
  41. <view @click="goToUrl" class="w-33 flex-direction align-items-center"
  42. v-show="infoData.order_status == 3 || infoData.order_status == 7 || infoData.order_status == 8 || infoData.order_status == 9 || infoData.order_status == 10">
  43. <image class="mb-4 icon" src="@/static/img/order/zlyd.png" mode=""></image>
  44. <view class="fs-24 fc-41ABF5">
  45. 再来一单
  46. </view>
  47. </view>
  48. <view class="w-33 flex-direction align-items-center">
  49. <button class="item-box-button" open-type="contact" :bindcontact="handleContact"></button>
  50. <image class="mb-4 icon" src="@/static/img/order/lxkf.png" mode=""></image>
  51. <view class="fs-24 fc-3">
  52. 联系客服
  53. </view>
  54. </view>
  55. <view class="w-33 flex-direction align-items-center" v-show="infoData.order_status == 2 || infoData.order_status == 4"
  56. @click="cancelOrder">
  57. <image class="mb-4 icon" src="@/static/img/order/qxdd.png" mode=""></image>
  58. <view class="fs-24 fc-3">
  59. 取消订单
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <scroll-view :scroll-y="true" class="scroll-view-css p-24 box-border-box" @scrolltolower="scrolltolower">
  66. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  67. <view class="w-420 fc-3 fs-32 fw-600 text-overflow-ellipsis-one mb-24">
  68. {{infoData.shop_name}}
  69. </view>
  70. <view class="goods-box" :class="infoData.item.length >= 4 && goodsShow?'goodsShowOne':'goodsShowTwo'">
  71. <view class="align-items-center flex-justify-space mb-20" v-for="(item,index) in infoData.item">
  72. <image class="goods-img mr-16" :src="item.goods_image" mode="aspectFit"></image>
  73. <view class="">
  74. <view class="align-items-center flex-justify-space mb-2">
  75. <view class="fs-28 fc-3 w-376 text-overflow-ellipsis-one mr-36">
  76. {{item.goods_name}}
  77. </view>
  78. <view class="fs-32 fc-3 fw-600">
  79. ¥{{item.goods_price}}
  80. </view>
  81. </view>
  82. <view class="mb-2 fs-24 fc-9">
  83. {{item.goods_attr}}
  84. </view>
  85. <view class="fs-24 fc-9">
  86. x{{item.goods_number}}
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="align-items-center flex-justify-center p-24 b-b-F9F9F9 mb-32" @click="openGoods"
  92. v-if="infoData.item.length > 4">
  93. <view class="fs-24 fc-9 mr-4">
  94. {{goodsShow?'展开':'收起'}}{{infoData.item.length - 4}}件商品
  95. </view>
  96. <image v-if="goodsShow" class="icon-right" src="@/static/img/order/top.png" mode=""></image>
  97. <image v-else class="icon-right" src="@/static/img/order/bottom.png" mode=""></image>
  98. </view>
  99. <view class="align-items-center flex-justify-space mb-24">
  100. <view class="fs-28 fc-3">
  101. 打包费
  102. </view>
  103. <view class="fs-32 fc-3">
  104. {{infoData.pack_price}}
  105. </view>
  106. </view>
  107. <view class="align-items-center flex-justify-space mb-24">
  108. <view class="fs-28 fc-3">
  109. 配送费
  110. </view>
  111. <view class="fs-32 fc-3">
  112. {{infoData.delivery_money}}
  113. </view>
  114. </view>
  115. <view class="align-items-center flex-justify-space pb-36 b-b-F9F9F9 mb-22">
  116. <view class="align-items-center">
  117. <image class="mr-6 icon-right" src="@/static/img/order/yhq.png" mode=""></image>
  118. <view class="fs-28 fc-3">
  119. 优惠券
  120. </view>
  121. </view>
  122. <view class="fs-32 fc-FB3D03">
  123. -¥{{infoData.coupon_money}}
  124. </view>
  125. </view>
  126. <view class="align-items-center flex-justify-end">
  127. <view class="fs-28 fc-9">
  128. 共{{infoData.goods_number}}件,
  129. </view>
  130. <view class="fs-28 fc-3">
  131. 金额
  132. </view>
  133. <view class="fs-24 fw-600 fc-3">
  134. ¥
  135. </view>
  136. <view class="fs-36 fw-600 fc-3">
  137. {{infoData.pay_money}}
  138. </view>
  139. </view>
  140. </view>
  141. <view class="bgc-f b-rad-20 p-24 box-border-box mb-20">
  142. <view class="display-flex flex-justify-space mb-26">
  143. <view class="fs-28 fc-9">
  144. 配送地址
  145. </view>
  146. <view class="fs-28 fc-3 w-480 text-align-right">
  147. {{infoData.school_name}}{{infoData.dorm_name}}{{infoData.address}}{{infoData.consignee}}{{infoData.consignee_tel}}
  148. </view>
  149. </view>
  150. <view class="display-flex flex-justify-space mb-26">
  151. <view class="fs-28 fc-9">
  152. 配送时间
  153. </view>
  154. <view class="fs-28 fc-3 w-480 text-align-right">
  155. {{infoData.time}}
  156. </view>
  157. </view>
  158. <view class="display-flex flex-justify-space pb-20 b-b-F9F9F9 mb-26"
  159. v-show="infoData.order_status == 6">
  160. <view class="fs-28 fc-9">
  161. 骑手信息
  162. </view>
  163. <view class="fs-28 fc-3 w-480 text-align-right">
  164. {{infoData.rider.rider_name}}{{infoData.rider.phone}}
  165. </view>
  166. </view>
  167. <view class="display-flex flex-justify-space mb-26">
  168. <view class="fs-28 fc-9">
  169. 订单编号
  170. </view>
  171. <view class="align-items-center flex-justify-end">
  172. <view class="fs-28 fc-3 w-480 mr-8 text-align-right">
  173. {{infoData.order_sn}}
  174. </view>
  175. <image class="icon-fz" src="@/static/img/order/fz.png" mode=""></image>
  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="fs-28 fc-3 w-480 text-align-right">
  183. {{infoData.created_at}}
  184. </view>
  185. </view>
  186. <view class="display-flex flex-justify-space mb-26">
  187. <view class="fs-28 fc-9">
  188. 支付方式
  189. </view>
  190. <view class="fs-28 fc-3 w-480 text-align-right">
  191. {{infoData.pay_type_str}}
  192. </view>
  193. </view>
  194. <view class="display-flex flex-justify-space mb-26">
  195. <view class="fs-28 fc-9">
  196. 备注
  197. </view>
  198. <view class="fs-28 fc-3 w-480 text-align-right">
  199. {{infoData.note?infoData.note:'无'}}
  200. </view>
  201. </view>
  202. </view>
  203. </scroll-view>
  204. <SelectAddress ref="selectAddress" @giveAddress='giveAddress'></SelectAddress>
  205. </view>
  206. </template>
  207. <script>
  208. import {
  209. orderInfo,
  210. orderCancel,
  211. orderPay
  212. } from "@/api/order.js"
  213. import tools from "@/service/tools";
  214. import SelectAddress from "./module/select-address.vue";
  215. export default {
  216. components: {
  217. SelectAddress
  218. },
  219. data() {
  220. return {
  221. goodsData: [{
  222. name: '1'
  223. }, {
  224. name: '2'
  225. }],
  226. goodsShow: true,
  227. infoData: {},
  228. time: {
  229. day: '',
  230. h: "",
  231. m: '',
  232. s: '',
  233. },
  234. isAJAX: false,
  235. address_id: ''
  236. };
  237. },
  238. onLoad(data) {
  239. if (data) {
  240. console.log(data);
  241. this.orderInfo(data.orderId)
  242. }
  243. },
  244. mounted() {},
  245. methods: {
  246. goToUrl() {
  247. // 再来一单
  248. uni.navigateTo({
  249. url: '/pages-takeout/takeout'
  250. })
  251. },
  252. setAddress() {
  253. this.$refs.selectAddress.getList();
  254. },
  255. giveAddress(e) {
  256. this.address_id = e;
  257. this.expressOrderAddress()
  258. },
  259. expressOrderAddress() {
  260. expressOrderAddress({
  261. order_id: this.infoData.id,
  262. address_id: this.address_id
  263. }).then((res) => {
  264. if (res.code == 1) {
  265. tools.success(res.msg)
  266. this.orderInfo(this.infoData.id)
  267. } else {
  268. tools.error(res.msg)
  269. }
  270. })
  271. },
  272. pay() {
  273. this.orderPay(this.infoData.id)
  274. },
  275. orderPay(id) {
  276. // 支付
  277. orderPay({
  278. order_id: id
  279. }).then((ret) => {
  280. if (ret.code === 1) {
  281. uni.requestPayment({
  282. provider: "wxpay", //支付类型-固定值
  283. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  284. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  285. package: ret.data.wx_pay.package, // 固定值
  286. signType: ret.data.wx_pay.signType, //固定值
  287. paySign: ret.data.wx_pay.paySign, //签名
  288. success: (ren) => {
  289. tools.success("支付成功");
  290. this.isAJAX = false;
  291. this.orderInfo(this.infoData.id)
  292. },
  293. fail: (err) => {
  294. this.isAJAX = false;
  295. tools.error("支付失败");
  296. },
  297. });
  298. } else {
  299. this.isAJAX = false;
  300. tools.error("支付失败");
  301. }
  302. })
  303. },
  304. cancelOrder() {
  305. // 代取取消订单
  306. orderCancel({
  307. order_id: infoData.id
  308. }).then((res) => {
  309. if (res.code == 1) {
  310. tools.success(res.msg)
  311. this.orderInfo(this.infoData.id)
  312. } else {
  313. tools.error(res.msg)
  314. }
  315. })
  316. },
  317. openGoods() {
  318. this.goodsShow = !this.goodsShow
  319. },
  320. scrolltolower() {
  321. // console.log('触底');
  322. },
  323. orderInfo(id) {
  324. orderInfo({
  325. order_id: id
  326. }).then((res) => {
  327. if (res.code == 1) {
  328. this.infoData = res.data
  329. if (this.infoData.order_status == 1) {
  330. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  331. createDate.setMinutes(createDate.getMinutes() + 10)
  332. this.setCountDown(createDate)
  333. }
  334. }
  335. })
  336. },
  337. setCountDown(sTime) {
  338. let end = new Date(sTime).getTime();
  339. let now = new Date().getTime();
  340. let msec = end - now;
  341. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  342. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  343. let m = parseInt(msec / 1000 / 60 % 60);
  344. let s = parseInt(msec / 1000 % 60);
  345. this.time.h = h > 9 ? h : '0' + h;
  346. this.time.m = m > 9 ? m : '0' + m;
  347. this.time.s = s > 9 ? s : '0' + s;
  348. msec -= 1000;
  349. if (this.time.day >= 1) {
  350. this.showTime = true;
  351. } else {
  352. this.showTime = false;
  353. };
  354. if (msec >= 0) {
  355. setTimeout(() => {
  356. this.setCountDown(sTime);
  357. }, 1000);
  358. } else {
  359. this.isTimeEnd = true;
  360. this.bText = '活动结束';
  361. this.time.h = '--';
  362. this.time.m = '--';
  363. this.time.s = '--';
  364. };
  365. }
  366. },
  367. }
  368. </script>
  369. <style lang="scss" scoped>
  370. .bg-img {
  371. position: fixed;
  372. left: 0;
  373. top: 0;
  374. z-index: -1;
  375. width: 100%;
  376. height: 320rpx;
  377. }
  378. .w-33 {
  379. width: 33%;
  380. position: relative;
  381. }
  382. .item-box-button {
  383. position: absolute;
  384. width: 100%;
  385. height: 88rpx;
  386. top: 0;
  387. left: 0;
  388. z-index: 100;
  389. background-color: transparent;
  390. border: none !important;
  391. }
  392. button::after {
  393. border: none !important;
  394. }
  395. .p-24-24-0 {
  396. padding: 24rpx 24rpx 0;
  397. }
  398. .icon {
  399. width: 48rpx;
  400. height: 48rpx;
  401. }
  402. .w-420 {
  403. width: 420rpx;
  404. }
  405. .goods-img {
  406. width: 108rpx;
  407. height: 108rpx;
  408. border-radius: 8rpx;
  409. }
  410. .w-376 {
  411. width: 376rpx;
  412. }
  413. .icon-right {
  414. width: 32rpx;
  415. height: 32rpx;
  416. }
  417. .w-480 {
  418. width: 480rpx;
  419. }
  420. .icon-fz {
  421. width: 24rpx;
  422. height: 24rpx;
  423. }
  424. .goods-box {
  425. overflow: hidden;
  426. }
  427. .goodsShowOne {
  428. max-height: 508rpx;
  429. transition: all .5s linear;
  430. }
  431. .goodsShowTwo {
  432. height: auto;
  433. transition: all .5s linear;
  434. }
  435. </style>