takeout-info.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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. uni.redirectTo({
  252. url: '/pages-takeout/shop?shop_id=' + this.infoData.shop_id
  253. })
  254. },
  255. setAddress() {
  256. this.$refs.selectAddress.getList();
  257. },
  258. giveAddress(e) {
  259. this.address_id = e;
  260. this.expressOrderAddress()
  261. },
  262. expressOrderAddress() {
  263. expressOrderAddress({
  264. order_id: this.infoData.id,
  265. address_id: this.address_id
  266. }).then((res) => {
  267. if (res.code == 1) {
  268. tools.success(res.msg)
  269. this.orderInfo(this.infoData.id)
  270. } else {
  271. tools.error(res.msg)
  272. }
  273. })
  274. },
  275. pay() {
  276. this.orderPay(this.infoData.id)
  277. },
  278. orderPay(id) {
  279. // 支付
  280. orderPay({
  281. order_id: id
  282. }).then((ret) => {
  283. if (ret.code === 1) {
  284. uni.requestPayment({
  285. provider: "wxpay", //支付类型-固定值
  286. timeStamp: ret.data.wx_pay.timeStamp + "", // 时间戳(单位:秒)
  287. nonceStr: ret.data.wx_pay.nonceStr, // 随机字符串
  288. package: ret.data.wx_pay.package, // 固定值
  289. signType: ret.data.wx_pay.signType, //固定值
  290. paySign: ret.data.wx_pay.paySign, //签名
  291. success: (ren) => {
  292. tools.success("支付成功");
  293. this.isAJAX = false;
  294. this.orderInfo(this.infoData.id)
  295. },
  296. fail: (err) => {
  297. this.isAJAX = false;
  298. tools.error("支付失败");
  299. },
  300. });
  301. } else {
  302. this.isAJAX = false;
  303. tools.error("支付失败");
  304. }
  305. })
  306. },
  307. cancelOrder() {
  308. // 外卖取消订单
  309. orderCancel({
  310. order_id: this.infoData.id
  311. }).then((res) => {
  312. if (res.code == 1) {
  313. tools.success(res.msg)
  314. this.orderInfo(this.infoData.id)
  315. } else {
  316. tools.error(res.msg)
  317. }
  318. })
  319. },
  320. openGoods() {
  321. this.goodsShow = !this.goodsShow
  322. },
  323. scrolltolower() {
  324. // console.log('触底');
  325. },
  326. orderInfo(id) {
  327. orderInfo({
  328. order_id: id
  329. }).then((res) => {
  330. if (res.code == 1) {
  331. this.infoData = res.data
  332. if (this.infoData.order_status == 1) {
  333. let createDate = new Date(res.data.created_at); //格式化订单创建时候的时间
  334. createDate.setMinutes(createDate.getMinutes() + 10)
  335. this.setCountDown(createDate)
  336. }
  337. }
  338. })
  339. },
  340. setCountDown(sTime) {
  341. let end = new Date(sTime).getTime();
  342. let now = new Date().getTime();
  343. let msec = end - now;
  344. this.time.day = parseInt(msec / 1000 / 60 / 60 / 24);
  345. let h = parseInt(msec / 1000 / 60 / 60 % 24);
  346. let m = parseInt(msec / 1000 / 60 % 60);
  347. let s = parseInt(msec / 1000 % 60);
  348. this.time.h = h > 9 ? h : '0' + h;
  349. this.time.m = m > 9 ? m : '0' + m;
  350. this.time.s = s > 9 ? s : '0' + s;
  351. msec -= 1000;
  352. if (this.time.day >= 1) {
  353. this.showTime = true;
  354. } else {
  355. this.showTime = false;
  356. };
  357. if (msec >= 0) {
  358. setTimeout(() => {
  359. this.setCountDown(sTime);
  360. }, 1000);
  361. } else {
  362. this.isTimeEnd = true;
  363. this.bText = '活动结束';
  364. this.time.h = '--';
  365. this.time.m = '--';
  366. this.time.s = '--';
  367. };
  368. }
  369. },
  370. }
  371. </script>
  372. <style lang="scss" scoped>
  373. .bg-img {
  374. position: fixed;
  375. left: 0;
  376. top: 0;
  377. z-index: -1;
  378. width: 100%;
  379. height: 320rpx;
  380. }
  381. .w-33 {
  382. width: 33%;
  383. position: relative;
  384. }
  385. .item-box-button {
  386. position: absolute;
  387. width: 100%;
  388. height: 88rpx;
  389. top: 0;
  390. left: 0;
  391. z-index: 100;
  392. background-color: transparent;
  393. border: none !important;
  394. }
  395. button::after {
  396. border: none !important;
  397. }
  398. .p-24-24-0 {
  399. padding: 24rpx 24rpx 0;
  400. }
  401. .icon {
  402. width: 48rpx;
  403. height: 48rpx;
  404. }
  405. .w-420 {
  406. width: 420rpx;
  407. }
  408. .goods-img {
  409. width: 108rpx;
  410. height: 108rpx;
  411. border-radius: 8rpx;
  412. }
  413. .w-376 {
  414. width: 376rpx;
  415. }
  416. .icon-right {
  417. width: 32rpx;
  418. height: 32rpx;
  419. }
  420. .w-480 {
  421. width: 480rpx;
  422. }
  423. .icon-fz {
  424. width: 24rpx;
  425. height: 24rpx;
  426. }
  427. .goods-box {
  428. overflow: hidden;
  429. }
  430. .goodsShowOne {
  431. max-height: 508rpx;
  432. transition: all .5s linear;
  433. }
  434. .goodsShowTwo {
  435. height: auto;
  436. transition: all .5s linear;
  437. }
  438. </style>