index.vue 26 KB

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