index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <app-layout>
  3. <view class="order-box">
  4. <view class="title-box">
  5. <app-switch-tab @tabEvent="clickTab" :isborderBottom="false" :bgColor="bgColor"
  6. :currentIndex="currentIndex" :list="list"></app-switch-tab>
  7. </view>
  8. <view v-if="is_show" class='content-box'>
  9. <template v-if="orders.length">
  10. <view v-for='(item, index) in orders' :key='item.id'
  11. :style="{'margin-top': index == 0 ? '104rpx' : '0'}" class='order-item-box dir-top-wrap'>
  12. <app-jump-button :url="getPageUrl(item.id, item.sign)">
  13. <view class="dir-top-nowrap" style="width: 100%">
  14. <view class='dir-left-nowrap view-1'>
  15. <view class='box-grow-1'>订单号:{{item.order_no}}</view>
  16. <template v-if='item.status == 0'>
  17. <text v-if='item.sign == "pintuan"'>{{item.is_pay == 1 ? '拼团中' : '待付款'}}</text>
  18. </template>
  19. <template v-else>
  20. <view>{{item.status_text}}</view>
  21. </template>
  22. </view>
  23. <view v-for='(dItem, dIndex) in item.detail' :key='dIndex' class='view-2'>
  24. <app-order-goods-info :goods='dItem.goods_info'></app-order-goods-info>
  25. </view>
  26. </view>
  27. </app-jump-button>
  28. <view class='dir-top-nowrap view-3'>
  29. <template v-if='currentIndex == 5'>
  30. <view v-if='item.type == 1' class='box-grow-1'>退货退款:
  31. <text class='price-color'>¥{{item.refund_price}}</text>
  32. </view>
  33. <view v-else class='box-grow-1'>换货</view>
  34. </template>
  35. <template v-else>
  36. <view class='box-grow-1 main-right cross-center price-count-box'>
  37. <text class="price-label">合计:</text>
  38. <text class='price-color'>¥{{item.total_pay_price}}</text>
  39. <text v-if="item.express_price > 0" class="price-express">(含运费¥{{item.express_price}})</text>
  40. </view>
  41. </template>
  42. <view class='box-grow-0 main-right action-button-box'>
  43. <app-jump-button>
  44. <view class="main-right action-box-view">
  45. <!-- 售后订单 -->
  46. <template v-if='currentIndex == 5'>
  47. <text :class="{'success-color': item.is_confirm == 1 ? true : false}">
  48. {{item.status_text}}
  49. </text>
  50. </template>
  51. <!-- 其它订单 -->
  52. <template v-else>
  53. <!-- 货到付款订单操作 start -->
  54. <template v-if='item.pay_type == 2'>
  55. <!-- 进行中的订单 不能进行订单操作 -->
  56. <template v-if='item.status == 1'>
  57. <!-- 待收货-->
  58. <template v-if='item.is_confirm == 0'>
  59. <block v-if='item.is_send == 1 && item.der_info.length == 1 && item.send_type == 0'>
  60. <view v-if="item.der_info[0].orderExpress.send_type == 1"
  61. @click='logistics(item)' class='order-btn'>
  62. 物流
  63. </view>
  64. </block>
  65. <view v-else-if='item.der_info.length == 0 && item.is_send == 1 && item.send_type == 0 && item.express_no && item.express'
  66. @click='logistics(item)' class='order-btn'>物流
  67. </view>
  68. <view v-else-if='item.der_info.length >= 1'
  69. @click='logistics(item)' class='order-btn'>物流
  70. </view>
  71. <view v-if="item.is_send == 1 && item.is_confirm == 0" @click='confirm(item)'
  72. class='order-btn'>确认收货
  73. </view>
  74. </template>
  75. <!-- 核销 -->
  76. <!-- 到店自提订单 在核销前有收款操作 -->
  77. <template
  78. v-if='item.send_type ==1 && item.is_confirm == 0 && item.cancel_status == 0'>
  79. <view @click='getClerkCode(item)' class='order-btn'>核销码</view>
  80. </template>
  81. <template
  82. v-if='item.is_confirm == 1 && item.is_comment == 0 && item.is_sale == 0 && item.sale_status == 0'>
  83. <view @click='appraise(item)' class='order-btn'>评价</view>
  84. </template>
  85. </template>
  86. </template>
  87. <!-- 货到付款订单操作 end -->
  88. <!-- 已支付订单操作 start -->
  89. <template v-else>
  90. <!-- 待付款 -->
  91. <template v-if='item.is_pay == 0'>
  92. <view @click="cancel(item)" class='order-btn'>取消</view>
  93. <view @click='orderPay(item)' class='order-btn'>付款</view>
  94. </template>
  95. <template v-if='item.status == 1'>
  96. <!-- 核销 -->
  97. <!-- 到店自提订单 未支付不显示核销码 | 未支付 货到付款订单显示核销码 -->
  98. <template
  99. v-if='item.send_type ==1 && item.is_confirm == 0 && ((item.is_pay == 0 && item.pay_type == 2) || (item.is_pay == 1 && item.pay_type != 2))'>
  100. <view @click='getClerkCode(item)' class='order-btn'>核销码</view>
  101. </template>
  102. <!-- 待收货-->
  103. <template v-if='item.is_pay == 1 && item.is_confirm == 0'>
  104. <block v-if='item.der_info.length == 1 && item.is_send == 1 && item.send_type == 0'>
  105. <view v-if="item.der_info[0].orderExpress.send_type == 1"
  106. @click='logistics(item)' class='order-btn'>
  107. 物流
  108. </view>
  109. </block>
  110. <view v-else-if='item.der_info.length == 0 && item.is_send == 1 && item.send_type == 0 && item.express_no && item.express'
  111. @click='logistics(item)' class='order-btn'>物流
  112. </view>
  113. <view v-else-if='item.der_info.length >= 1'
  114. @click='logistics(item)' class='order-btn'>物流
  115. </view>
  116. <view v-if="item.is_send == 1 && item.is_confirm == 0" @click='confirm(item)' class='order-btn'>确认收货</view>
  117. </template>
  118. <template
  119. v-if='item.is_confirm == 1 && item.is_comment == 0 && item.is_sale == 0 && item.sale_status == 0'>
  120. <view @click='appraise(item)' class='order-btn'>评价</view>
  121. </template>
  122. </template>
  123. </template>
  124. <!-- 已支付订单操作 end -->
  125. </template>
  126. </view>
  127. </app-jump-button>
  128. </view>
  129. </view>
  130. </view>
  131. </template>
  132. <view class="no-list" v-else>
  133. <app-no-goods background="#f7f7f7" title="暂无相关订单" :is_image="1"></app-no-goods>
  134. </view>
  135. <!-- 核销码展示 -->
  136. <view v-if='is_qrcode' class='qrcode-box'>
  137. <view class='dir-top-wrap main-center cross-center item'>
  138. <view>核销码</view>
  139. <image class='img' :src='qr_code_url'></image>
  140. <image @click='closeQrcode' src='/static/image/icon/icon-close.png' class='remove'></image>
  141. </view>
  142. </view>
  143. </view>
  144. <app-load-text v-if="is_load_show"></app-load-text>
  145. <view class="return-index-btn" v-if="show_index">
  146. <app-jump-button open_type="redirect" url="/pages/index/index">
  147. <image src="/static/image/icon/index.png" style="width: 50rpx;height: 50rpx"></image>
  148. </app-jump-button>
  149. </view>
  150. </view>
  151. </app-layout>
  152. </template>
  153. <script>
  154. import appSwitchTab from '../../../components/basic-component/app-switch-tab/app-switch-tab.vue';
  155. import appNoGoods from '../../../components/page-component/app-no-goods/app-no-goods.vue';
  156. import appOrderGoodsInfo from '../../../components/page-component/app-order-goods-info/app-order-goods-info.vue';
  157. import {mapGetters} from 'vuex';
  158. export default {
  159. data() {
  160. return {
  161. list: [{name: '全部'}, {name: '待付款'}, {name: '待发货'}, {name: '待收货'}, {name: '待评价'}],
  162. page: 1,
  163. currentIndex: 0,
  164. orders: [],
  165. pagination: null,
  166. qr_code_url: '',
  167. is_qrcode: false,
  168. is_show: false,
  169. is_load_show: false,
  170. show_index: false,
  171. bgColor: '#f7f7f7',
  172. isRequest: true,//防止数据重复加载
  173. template_message: [],
  174. }
  175. },
  176. methods: {
  177. getList() {
  178. this.isRequest = false;
  179. this.$request({
  180. url: this.$api.order.list,
  181. data: {
  182. status: this.currentIndex,
  183. page: this.page,
  184. }
  185. }).then(response => {
  186. let {code, data, msg} = response;
  187. this.$hideLoading();
  188. this.is_load_show = false;
  189. this.is_show = true;
  190. if (code == 0) {
  191. let {list, pagination} = data;
  192. if (this.page != 1) {
  193. this.orders = this.orders.concat(list)
  194. } else {
  195. this.orders = list;
  196. }
  197. this.page = list.length ? this.page + 1 : this.page;
  198. this.pagination = pagination;
  199. this.template_message = data.template_message;
  200. } else {
  201. uni.showModal({
  202. title: '',
  203. content: msg,
  204. showCancel: false,
  205. });
  206. }
  207. this.isRequest = true;
  208. }).catch(() => {
  209. this.is_load_show = false;
  210. this.$hideLoading();
  211. });
  212. },
  213. clickTab(params) {
  214. if (this.isRequest) {
  215. this.page = 1;
  216. this.currentIndex = params.currentIndex;
  217. this.is_show = false;
  218. this.$showLoading();
  219. this.getList();
  220. }
  221. },
  222. getPageUrl: function (id, sign) {
  223. if (this.currentIndex == 5) {
  224. return `/pages/order/refund-detail/refund-detail?id=${id}&sign=${sign}`
  225. } else {
  226. return `/pages/order/order-detail/order-detail?id=${id}&sign=${sign}`
  227. }
  228. },
  229. // 确认收货
  230. confirm(item) {
  231. let self = this;
  232. uni.showModal({
  233. title: '提示',
  234. content: '是否确认收货?',
  235. success: function (res) {
  236. if (res.confirm) {
  237. uni.showLoading({title: '确认收货中'});
  238. self.$request({
  239. url: self.$api.order.confirm,
  240. data: {
  241. id: item.id
  242. }
  243. }).then(response => {
  244. uni.hideLoading();
  245. if (response.code === 0) {
  246. uni.redirectTo({
  247. url: '/pages/order/index/index?status=' + 4
  248. });
  249. } else {
  250. uni.showModal({
  251. title: '',
  252. content: response.msg,
  253. showCancel: false,
  254. });
  255. }
  256. }).catch(() => {
  257. uni.hideLoading()
  258. });
  259. }
  260. }
  261. });
  262. },
  263. // 取消
  264. cancel(e) {
  265. let self = this;
  266. uni.showModal({
  267. title: '提示',
  268. content: '是否取消订单?',
  269. success: function (res) {
  270. if (res.confirm) {
  271. uni.showLoading({title: '取消中'});
  272. self.$request({
  273. url: self.$api.order.cancel,
  274. data: {
  275. id: e.id
  276. }
  277. }).then(response => {
  278. uni.hideLoading();
  279. if (response.code == 0) {
  280. uni.redirectTo({
  281. url: '/pages/order/index/index?status=' + self.currentIndex
  282. })
  283. } else {
  284. uni.showModal({
  285. title: '',
  286. content: response.msg,
  287. showCancel: false,
  288. });
  289. }
  290. }).catch(() => {
  291. uni.hideLoading();
  292. });
  293. }
  294. }
  295. });
  296. },
  297. // 物流信息
  298. logistics(orderDetail) {
  299. if (orderDetail.is_send == 1 && orderDetail.detailExpress.length == 0) {
  300. let [id, express, express_no, customer_name, cover_pic] = [orderDetail.id, orderDetail.express, orderDetail.express_no, orderDetail.customer_name, orderDetail.detail[0].goods_info.pic_url];
  301. uni.navigateTo({
  302. url: `/pages/order/express-detail/express-detail?id=${id}&express=${express}&express_no=${express_no}&customer_name=${customer_name}&cover_pic=${cover_pic}`
  303. })
  304. } else if (orderDetail.is_send == 1 && orderDetail.detailExpress.length == 1) {
  305. let express = orderDetail.detailExpress[0].express;
  306. let express_no = orderDetail.detailExpress[0].express_no;
  307. let customer_name = orderDetail.detailExpress[0].customer_name;
  308. let cover_pic = orderDetail.detailExpress[0].expressRelation[0].orderDetail.goods_info.goods_attr.cover_pic;
  309. uni.navigateTo({
  310. url: `/pages/order/express-detail/express-detail?express=` + express + `&customer_name=` + customer_name + `&express_no=` + express_no + `&cover_pic=` + cover_pic
  311. })
  312. } else if (orderDetail.detailExpress.length >= 1) {
  313. uni.navigateTo({
  314. url: '/pages/order/express-list/express-list?order_id=' + orderDetail.id
  315. });
  316. }
  317. },
  318. // 订单支付
  319. orderPay(e) {
  320. let _this = this;
  321. _this.$showLoading();
  322. _this.$request({
  323. url: _this.$api.order.list_pay_data,
  324. data: {
  325. id: e.id
  326. }
  327. }).then(response => {
  328. _this.$hideLoading();
  329. if (response.code === 0) {
  330. _this.$payment.pay(response.data.id).then(() => {
  331. // 支付成功
  332. uni.redirectTo({
  333. url: '/pages/order/index/index?status=2'
  334. })
  335. }).catch(e => {
  336. // 支付失败
  337. uni.showModal({
  338. title: '',
  339. content: e.errMsg,
  340. showCancel: false
  341. })
  342. })
  343. }
  344. }).catch(() => {
  345. _this.$hideLoading();
  346. });
  347. },
  348. // 订单评价
  349. appraise(e) {
  350. uni.navigateTo({
  351. url: `/pages/order/appraise/appraise?id=${e.id}`
  352. })
  353. },
  354. getClerkCode(e) {
  355. let self = this;
  356. self.$showLoading();
  357. self.$request({
  358. url: self.$api.order.clerk_qr_code,
  359. data: {
  360. id: e.id
  361. }
  362. }).then(response => {
  363. self.$hideLoading();
  364. if (response.code === 0) {
  365. self.qr_code_url = response.data.file_path;
  366. self.is_qrcode = true;
  367. } else {
  368. uni.showModal({
  369. title: '',
  370. content: response.msg,
  371. showCancel: false,
  372. });
  373. }
  374. }).catch(() => {
  375. self.$hideLoading();
  376. });
  377. },
  378. closeQrcode() {
  379. this.is_qrcode = false;
  380. },
  381. },
  382. onLoad(options) {
  383. this.currentIndex = options.status ? options.status : this.currentIndex;
  384. },
  385. onReachBottom() {
  386. this.is_load_show = true;
  387. this.getList()
  388. },
  389. onShow() {
  390. let self = this;
  391. let interval = setInterval(function () {
  392. if (self.isRequest) {
  393. self.page = 1;
  394. self.$showLoading();
  395. self.getList();
  396. self.$store.dispatch('gConfig/setTabBarBoolean', self.tabBarNavs.navs);
  397. }
  398. let pages = getCurrentPages();
  399. if (pages.length < 2) {
  400. self.show_index = true;
  401. }
  402. clearInterval(interval)
  403. }, 300);
  404. },
  405. computed: {
  406. ...mapGetters('mallConfig', {
  407. tabBarNavs: 'getNavBar'
  408. }),
  409. },
  410. components: {
  411. 'app-switch-tab': appSwitchTab,
  412. 'app-order-goods-info': appOrderGoodsInfo,
  413. 'app-no-goods': appNoGoods,
  414. },
  415. }
  416. </script>
  417. <style scoped lang="scss">
  418. .order-box {
  419. width: 100%;
  420. height: 100%;
  421. }
  422. .title-box {
  423. height: 80#{rpx};
  424. width: 100%;
  425. position: fixed;
  426. border-bottom: 1#{rpx} solid $uni-weak-color-one;
  427. top: 0;
  428. background: #fff;
  429. z-index: 1;
  430. }
  431. .no-list {
  432. margin-top: #{150upx};
  433. }
  434. .content-box {
  435. margin-top: 80#{rpx};
  436. }
  437. .not-order-box {
  438. height: calc(100vh - 80#{rpx});
  439. color: $uni-general-color-two;
  440. }
  441. .order-item-box {
  442. background: #fff;
  443. padding: 0 24#{rpx};
  444. margin: 0 24#{rpx};
  445. margin-bottom: 24#{rpx};
  446. border-radius: 16#{rpx};
  447. font-size: $uni-font-size-general-two;
  448. box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.06);
  449. }
  450. .order-item-box .view-1 {
  451. width: 100%;
  452. font-size: $uni-font-size-weak-one;
  453. color: $uni-important-color-black;
  454. margin: 32#{rpx} 0;
  455. }
  456. .order-item-box .view-2 {
  457. }
  458. .order-item-box .view-3 {
  459. font-size: $uni-font-size-import-two;
  460. }
  461. .order-item-box .view-3 .btn {
  462. margin-left: 15#{rpx};
  463. }
  464. .price-count-box {
  465. margin: 28#{rpx} 0;
  466. }
  467. .price-label {
  468. margin-right: 5#{rpx};
  469. }
  470. .price-color {
  471. color: $uni-important-color-black;
  472. }
  473. .price-express {
  474. font-size: $uni-font-size-weak-two;
  475. color: $uni-general-color-two;
  476. }
  477. .success-color {
  478. color: $uni-important-color-black;
  479. }
  480. .error-color {
  481. color: $uni-important-color-red;
  482. }
  483. .qrcode-box {
  484. width: 100%;
  485. height: 100%;
  486. position: fixed;
  487. top: 0;
  488. left: 0;
  489. background: rgba(0, 0, 0, 0.5);
  490. }
  491. .qrcode-box .item {
  492. position: absolute;
  493. top: 25%;
  494. width: 562#{rpx};
  495. height: 562#{rpx};
  496. background: #fff;
  497. left: 94#{rpx};
  498. z-index: 999;
  499. border-radius: 15#{rpx};
  500. }
  501. .qrcode-box .img {
  502. margin-top: 30#{rpx};
  503. width: 375#{rpx};
  504. height: 375#{rpx};
  505. }
  506. .qrcode-box .item .remove {
  507. position: absolute;
  508. top: 0;
  509. right: 0;
  510. width: 50#{rpx};
  511. height: 50#{rpx};
  512. margin: 15#{rpx};
  513. padding: #{7rpx}
  514. }
  515. .order-btn {
  516. display: inline-block;
  517. line-height: 2.3;
  518. font-size: 26#{rpx};
  519. padding: 0 30#{rpx};
  520. border: 1#{rpx} solid $uni-weak-color-one;
  521. border-radius: 30#{rpx};
  522. margin-left: 16#{rpx};
  523. }
  524. .action-button-box {
  525. margin-bottom: 24#{rpx};
  526. }
  527. .return-index-btn {
  528. position: fixed;
  529. right: 0;
  530. bottom: #{100rpx};
  531. display: inline-block;
  532. background: rgba(157, 157, 157, 0.5);
  533. padding: #{10rpx} #{20rpx};
  534. z-index: 1000;
  535. border-radius: #{10rpx} 0 0 #{10rpx};
  536. }
  537. .action-box-view {
  538. width: 100%;
  539. }
  540. </style>