index.vue 26 KB

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