index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <!-- index.wxml -->
  3. <view class="wrap">
  4. <view class="order_t">
  5. <!-- order_status //1正常 2已完成 0关闭 -->
  6. <!-- ship_status // //0待发货/待自提 1已发货/已自提 -->
  7. <!-- fare_type //0邮寄 1自提 -->
  8. <view class="order_status" v-if="orderInfo.fare_type == 1">
  9. {{
  10. orderInfo.order_status == 2
  11. ? '已完成'
  12. : orderInfo.order_status == 0
  13. ? '已关闭'
  14. : orderInfo.pay_status != 1
  15. ? '待支付'
  16. : orderInfo.ship_status
  17. ? '已自提'
  18. : '待自提'
  19. }}
  20. </view>
  21. <view class="order_status" v-if="orderInfo.fare_type == 0">
  22. {{
  23. orderInfo.order_status == 2
  24. ? '已完成'
  25. : orderInfo.order_status == 0
  26. ? '已关闭'
  27. : orderInfo.pay_status != 1
  28. ? '待支付'
  29. : orderInfo.ship_status
  30. ? '配送中' + count_time
  31. : '待配送'
  32. }}
  33. </view>
  34. <view class="order_tips" v-if="orderInfo.order_status == 1 && orderInfo.fare_type == 1 && orderInfo.ship_status == 0">请您及时取餐,如有问题提前与商家沟通</view>
  35. <view class="order_tips" v-if="orderInfo.order_status == 0">感谢您对羊汤馆的支持,欢迎再次光临</view>
  36. <view class="order_btns">
  37. <!-- <view class="btn cancel">联系商家</view> -->
  38. <view class="btn cancel" v-if="orderInfo.ship_status == 0 && orderInfo.order_status == 1" @tap="cancleOrder">取消订单</view>
  39. <view class="btn cancel" v-if="orderInfo.pay_status == 1 && orderInfo.ship_status == 1 && orderInfo.order_status == 1" @tap="receiveOrder">收货</view>
  40. <view class="btn" @tap="goTopay" v-if="orderInfo.order_status == 1 && orderInfo.pay_status != 1">立即支付</view>
  41. <view class="btn" @tap="toGoods" v-if="orderInfo.order_status == 0 || orderInfo.order_status == 2 || (orderInfo.order_status == 1 && orderInfo.ship_status == 1)">
  42. 再来一单
  43. </view>
  44. </view>
  45. <image class="order_tag" :src="orderInfo.fare_type ? '/statics/img/ziqu_order.png' : '/statics/img/waimai_order.png'"></image>
  46. </view>
  47. <view class="order_m">
  48. <view class="shop_info">
  49. <view class="shop_info_l">
  50. <view class="shop_name">{{ orderInfo.store.title }}</view>
  51. <view class="shop_adress">{{ orderInfo.store.address }}</view>
  52. </view>
  53. <image class="shop_phone" src="/static/statics/img/icon_phone.png" @tap="onMakePhone"></image>
  54. </view>
  55. <view class="order_goods">
  56. <view class="goods_item" v-for="(item, index) in orderInfo.order_good" :key="index">
  57. <view class="goods_item_l">
  58. <image class="goods_tu" :src="imgUrl + item.good_thumb"></image>
  59. <view class="goods_info">
  60. <view class="goods_title">{{ item.good_title }}</view>
  61. <view class="goods_labels" v-if="item.good_specs">
  62. <view class="label">{{ item.good_specs.title }}</view>
  63. <!-- <view class="label">甜辣</view>
  64. <view class="label">鸭翅</view> -->
  65. </view>
  66. </view>
  67. </view>
  68. <view class="goods_item_r">
  69. <view class="goods_price" v-if="!item.add_good_rule_id">
  70. <text class="unit">¥</text>
  71. {{ orderInfo.user.is_member ? item.member_price : item.price }}
  72. </view>
  73. <view class="goods_price" v-if="item.add_good_rule_id">
  74. <text class="unit">¥</text>
  75. {{ item.add_price }}
  76. </view>
  77. <view class="goods_num">x{{ item.nums }}</view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="delivery" v-if="orderInfo.fare_type == 0">
  82. <view class="text">配送费</view>
  83. <view class="price">
  84. <text class="unit">¥</text>
  85. {{ orderInfo.delivery_fee }}
  86. </view>
  87. </view>
  88. <view class="quan" v-if="orderInfo.user_coupon">
  89. <view class="quan_l">
  90. <image class="quan_icon" src="/static/statics/img/icon_quan.png"></image>
  91. <view class="quan_wenzi">优惠券</view>
  92. </view>
  93. <view class="quan_price">
  94. <text class="unit">-¥</text>
  95. {{ orderInfo.coupon_price }}
  96. </view>
  97. </view>
  98. <view class="total_price">
  99. <text class="" v-if="orderInfo.user_coupon">已优惠</text>
  100. <text class="discount" v-if="orderInfo.user_coupon">¥{{ orderInfo.coupon_price }}</text>
  101. <text class="">小计</text>
  102. <text class="price">
  103. <text class="unit">¥</text>
  104. {{ orderInfo.pay_price }}
  105. </text>
  106. </view>
  107. </view>
  108. <view class="section_wrap">
  109. <view class="section_name">配送信息</view>
  110. <view class="section">
  111. <view class="item">
  112. <view class="item_l">取货方式</view>
  113. <view class="item_r">{{ orderInfo.fare_type ? '自提订单' : '外卖订单' }}</view>
  114. </view>
  115. <view class="item">
  116. <view class="item_l">服务门店</view>
  117. <view class="item_r">{{ orderInfo.store.title }}</view>
  118. </view>
  119. <view class="item" v-if="orderInfo.fare_type == 0">
  120. <view class="item_l">配送地址</view>
  121. <view class="item_r">{{ orderInfo.address }}</view>
  122. </view>
  123. <view class="item" v-if="orderInfo.fare_type == 0">
  124. <view class="item_r">{{ orderInfo.person + ' ' + orderInfo.phone }}</view>
  125. </view>
  126. <view class="item" v-if="orderInfo.fare_type == 1">
  127. <view class="item_l">预留电话</view>
  128. <view class="item_r">{{ orderInfo.user.phone }}</view>
  129. </view>
  130. <view class="item" v-if="orderInfo.fare_type == 1">
  131. <view class="item_l">商家地址</view>
  132. <view class="item_r">{{ orderInfo.store.address }}</view>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="section_wrap">
  137. <view class="section_name">订单信息</view>
  138. <view class="section">
  139. <view class="item">
  140. <view class="item_l">订单编号</view>
  141. <view class="item_r">{{ orderInfo.order_num }}</view>
  142. </view>
  143. <view class="item">
  144. <view class="item_l">下单时间</view>
  145. <view class="item_r">{{ orderInfo.created_at }}</view>
  146. </view>
  147. <view class="item">
  148. <view class="item_l">支付方式</view>
  149. <view class="item_r">
  150. <view class="item_pay">{{ orderInfo.pay_name }}</view>
  151. <!-- <view class="item_pay" wx:if="{{ orderInfo.user_coupon }}">优惠券</view> -->
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. </view>
  157. <!-- loading -->
  158. <!-- <van-overlay show="{{ loading }}" z-index="100">
  159. <van-loading custom-class="custom_loading" />
  160. </van-overlay> -->
  161. </template>
  162. <script>
  163. // index.js
  164. let myPro = require('../../../../utils/wxRequest.js');
  165. let util = require('../../../../utils/util.js');
  166. export default {
  167. data() {
  168. return {
  169. imgUrl: getApp().globalData.imgUrl,
  170. loading: false,
  171. orderInfo: null,
  172. timer: null,
  173. // 配送倒计时
  174. count_time: '',
  175. order_id: '',
  176. title: '',
  177. address: '',
  178. phone: ''
  179. };
  180. },
  181. onLoad: function (options) {
  182. // Do some initialize when page load.
  183. let that = this;
  184. that.setData({
  185. order_id: options.order_id
  186. });
  187. },
  188. onShow: function () {
  189. // Do something when page show.
  190. let that = this; // 获取订单信息
  191. that.getOrderDetail();
  192. },
  193. onReady: function () {
  194. // Do something when page ready.
  195. },
  196. onHide: function () {
  197. // Do something when page hide.
  198. },
  199. onUnload: function () {
  200. // Do something when page close.
  201. },
  202. onPullDownRefresh: function () {
  203. // Do something when pull down.
  204. },
  205. onReachBottom: function () {
  206. // Do something when page reach bottom.
  207. },
  208. onPageScroll: function () {
  209. // Do something when page scroll
  210. },
  211. onResize: function () {
  212. // Do something when page resize
  213. },
  214. methods: {
  215. // 获取订单信息
  216. getOrderDetail() {
  217. let that = this;
  218. let params = {
  219. order_id: that.order_id
  220. };
  221. myPro
  222. .wxRequest('user/v2/order/detail', 'GET', params)
  223. .then((res) => {
  224. that.setData({
  225. orderInfo: res.result
  226. }); // console.log('订单状态',that.data.orderInfo.order_status)
  227. let orderInfo = res.result; // 当前订单为外卖单且正在配送,开启倒计时
  228. if (orderInfo.fare_type == 0 && orderInfo.order_status == 1 && orderInfo.ship_status == 1) {
  229. clearInterval(that.timer);
  230. that.timer = setInterval(function () {
  231. let ship_at = orderInfo.ship_at;
  232. let shijian = util.daojishi(ship_at, 30);
  233. if (shijian['isend']) {
  234. clearInterval(that.timer);
  235. } else {
  236. that.setData({
  237. count_time: shijian['timeStr']
  238. });
  239. }
  240. }, 1000);
  241. }
  242. })
  243. .catch((err) => {
  244. console.log('报错信息', err);
  245. uni.showToast({
  246. title: err,
  247. icon: 'none'
  248. });
  249. });
  250. },
  251. // 再来一单
  252. toGoods() {
  253. let that = this;
  254. uni.reLaunch({
  255. url: '/pages/goods/index'
  256. });
  257. },
  258. // 取消订单
  259. cancleOrder() {
  260. let that = this;
  261. let store = that.orderInfo.store;
  262. let orderInfo = that.orderInfo; // 未支付的订单可以取消
  263. if (orderInfo.order_status == 1 && orderInfo.pay_status != 1) {
  264. // 取消订单
  265. myPro
  266. .wxRequest('user/v2/order/cancelorder', 'POST', {
  267. order_id: orderInfo.id
  268. })
  269. .then((res) => {
  270. uni.showToast({
  271. title: res.msg,
  272. icon: 'none'
  273. });
  274. that.getOrderDetail();
  275. })
  276. .catch((err) => {
  277. console.log('报错信息', err);
  278. uni.showToast({
  279. title: err,
  280. icon: 'none'
  281. });
  282. });
  283. } else {
  284. uni.showModal({
  285. title: '可联系商家取消',
  286. content: '商家电话' + store.phone,
  287. showCancel: false,
  288. confirmText: '我知道了',
  289. confirmColor: '#000000'
  290. });
  291. }
  292. },
  293. // 收货
  294. receiveOrder() {
  295. let that = this;
  296. let params = {
  297. order_id: that.order_id
  298. };
  299. myPro
  300. .wxRequest('user/order/commit', 'POST', params)
  301. .then((res) => {
  302. uni.showToast({
  303. title: res.msg,
  304. icon: 'none'
  305. });
  306. that.getOrderDetail();
  307. })
  308. .catch((err) => {
  309. console.log('报错信息', err);
  310. uni.showToast({
  311. title: err,
  312. icon: 'none'
  313. });
  314. });
  315. },
  316. // 去支付
  317. goTopay() {
  318. let that = this;
  319. uni.navigateTo({
  320. url: '/pages/pay-order/index?order_id=' + that.order_id
  321. });
  322. },
  323. // 拨打店铺电话
  324. onMakePhone() {
  325. let that = this;
  326. uni.makePhoneCall({
  327. phoneNumber: that.orderInfo.store.phone
  328. });
  329. }
  330. }
  331. };
  332. </script>
  333. <style>
  334. /**index.wxss**/
  335. .wrap {
  336. min-height: 100vh;
  337. background: #f6f6f6;
  338. padding: 30rpx;
  339. }
  340. .order_t {
  341. width: 690rpx;
  342. margin-bottom: 20rpx;
  343. background: #ffffff;
  344. border-radius: 5rpx;
  345. font-size: 30rpx;
  346. color: #000000;
  347. text-align: center;
  348. position: relative;
  349. }
  350. .order_t .order_status {
  351. padding-top: 30rpx;
  352. }
  353. .order_t .order_tips {
  354. padding-top: 28rpx;
  355. font-size: 28rpx;
  356. color: rgba(0, 0, 0, 0.54);
  357. }
  358. .order_t .order_btns {
  359. padding: 24rpx 0;
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. }
  364. .order_t .order_btns .btn {
  365. width: 180rpx;
  366. height: 60rpx;
  367. background: rgba(41, 92, 86, 0.05);
  368. border: 1px solid #295c56;
  369. border-radius: 5rpx;
  370. font-size: 30rpx;
  371. color: #295c56;
  372. display: flex;
  373. align-items: center;
  374. justify-content: center;
  375. margin-left: 18rpx;
  376. }
  377. .order_t .order_btns .btn.cancel {
  378. border-color: #999999;
  379. color: #999999;
  380. background: transparent;
  381. }
  382. .order_t .order_tag {
  383. width: 119rpx;
  384. height: 124rpx;
  385. position: absolute;
  386. top: -4rpx;
  387. left: -4rpx;
  388. }
  389. .order_t .line_bg {
  390. width: 690rpx;
  391. height: 30rpx;
  392. border-radius: 0 0 5rpx 5rpx;
  393. background-repeat: repeat;
  394. background-size: 18rpx 30rpx;
  395. }
  396. /* 商品 */
  397. .order_m {
  398. width: 690rpx;
  399. border-radius: 5rpx;
  400. background: #ffffff;
  401. padding: 0 30rpx;
  402. }
  403. .order_m .shop_info {
  404. padding: 40rpx 0rpx 30rpx;
  405. display: flex;
  406. align-items: center;
  407. justify-content: space-between;
  408. }
  409. .shop_info .shop_name {
  410. font-size: 30rpx;
  411. color: #080808;
  412. font-weight: bold;
  413. }
  414. .shop_info .shop_adress {
  415. padding-top: 16rpx;
  416. font-size: 24rpx;
  417. color: rgba(51, 51, 51, 0.54);
  418. }
  419. .shop_info .shop_phone {
  420. width: 44rpx;
  421. height: 44rpx;
  422. }
  423. /* 配送费 & 券 */
  424. .order_m .delivery {
  425. padding: 20rpx 0;
  426. display: flex;
  427. align-items: center;
  428. justify-content: space-between;
  429. font-size: 30rpx;
  430. color: #000000;
  431. border-bottom: 1rpx dashed rgba(0, 0, 0, 0.12);
  432. }
  433. .order_m .delivery .price {
  434. font-size: 34rpx;
  435. color: #080808;
  436. }
  437. .order_m .delivery .price .unit {
  438. font-size: 22rpx;
  439. }
  440. .order_m .quan {
  441. padding: 37rpx 0;
  442. display: flex;
  443. align-items: center;
  444. justify-content: space-between;
  445. border-bottom: 1rpx dashed rgba(0, 0, 0, 0.12);
  446. }
  447. .order_m .quan_l {
  448. display: flex;
  449. align-items: center;
  450. font-size: 30rpx;
  451. color: #000000;
  452. }
  453. .order_m .quan_icon {
  454. width: 48rpx;
  455. height: 41rpx;
  456. margin-right: 20rpx;
  457. }
  458. .order_m .quan_price {
  459. color: #d54c43;
  460. font-size: 34rpx;
  461. }
  462. .order_m .quan_price .unit {
  463. font-size: 22rpx;
  464. }
  465. .order_m .total_price {
  466. padding: 30rpx 0;
  467. font-size: 26rpx;
  468. color: #000000;
  469. text-align: right;
  470. }
  471. .order_m .total_price .discount {
  472. padding: 0 18rpx 0 16rpx;
  473. font-size: 28rpx;
  474. color: #333333;
  475. }
  476. .order_m .total_price .price {
  477. font-size: 44rpx;
  478. color: #333333;
  479. font-weight: bold;
  480. padding-left: 14rpx;
  481. }
  482. .order_m .total_price .price .unit {
  483. font-size: 22rpx;
  484. }
  485. /* 配送信息&订单信息 */
  486. .section_wrap {
  487. width: 690rpx;
  488. background: #ffffff;
  489. border-radius: 5rpx;
  490. margin-top: 20rpx;
  491. }
  492. .section_wrap .section_name {
  493. padding: 30rpx;
  494. }
  495. .section {
  496. padding-bottom: 30rpx;
  497. }
  498. .section .item {
  499. padding: 30rpx 30rpx 0;
  500. display: flex;
  501. font-size: 26rpx;
  502. color: rgba(0, 0, 0, 0.87);
  503. }
  504. .section .item .item_l {
  505. color: rgba(0, 0, 0, 0.54);
  506. }
  507. .section .item .item_r {
  508. flex: 1;
  509. text-align: right;
  510. padding-left: 10rpx;
  511. }
  512. .section .item .item_pay:not(:last-child)::after {
  513. content: '';
  514. display: inline-block;
  515. width: 2rpx;
  516. height: 14rpx;
  517. background: #666666;
  518. margin: 0 18rpx;
  519. }
  520. </style>