index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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' :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 || currentIndex == 6'>
  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: [
  146. { name: '全部', id: 0 },
  147. { name: '待付款', id: 1 },
  148. { name: '待发货', id: 2 },
  149. { name: '待收货', id: 3 },
  150. { name: '已完成', id: 4 },
  151. { name: '已取消', id: 6 },
  152. ],
  153. page: 1,
  154. currentIndex: 0,
  155. orders: [],
  156. search: {
  157. keyword: '',
  158. dateArr: []
  159. },
  160. pagination: null,
  161. qr_code_url: '',
  162. is_qrcode: false,
  163. is_show: false,
  164. is_load_show: false,
  165. bgColor: '#f7f7f7',
  166. isRequest: true, //防止数据重复加载
  167. template_message: [],
  168. recommend_list: []
  169. }
  170. },
  171. methods: {
  172. getList() {
  173. this.isRequest = false;
  174. this.$request({
  175. url: this.$api.order.list,
  176. data: {
  177. status: this.currentIndex,
  178. keyword: this.search ? this.search.keyword : '',
  179. dateArr: this.search ? JSON.stringify(this.search.dateArr) : JSON.stringify([]),
  180. page: this.page,
  181. }
  182. }).then(response => {
  183. let { code, data, msg } = response;
  184. this.$hideLoading();
  185. this.is_load_show = false;
  186. this.is_show = true;
  187. if (code === 0) {
  188. let { list, pagination } = data;
  189. if (this.page !== 1) {
  190. this.orders = this.orders.concat(list);
  191. } else {
  192. this.orders = list;
  193. }
  194. this.page = list.length ? this.page + 1 : this.page;
  195. this.pagination = pagination;
  196. this.template_message = data.template_message;
  197. } else {
  198. uni.showModal({
  199. title: '',
  200. content: msg,
  201. showCancel: false,
  202. });
  203. }
  204. this.isRequest = true;
  205. }).catch(() => {
  206. this.is_load_show = false;
  207. this.$hideLoading();
  208. });
  209. },
  210. loadRecommend() {
  211. this.$request({
  212. url: this.$api.goods.new_recommend,
  213. data: {
  214. type: 'order_pay'
  215. }
  216. }).then(response => {
  217. if (response.code === 0) {
  218. this.recommend_list = response.data.list;
  219. }
  220. });
  221. },
  222. clickTab(params) {
  223. if (this.isRequest) {
  224. this.page = 1;
  225. this.currentIndex = params.currentTarget.dataset.id;
  226. this.is_show = false;
  227. this.$showLoading();
  228. this.getList();
  229. }
  230. },
  231. getPageUrl: function(id, sign) {
  232. if (sign === 'community') {
  233. return `/plugins/community/order-detail/order-detail?id=${id}&is_user=1`
  234. } else if (this.currentIndex == 5) {
  235. return `/pages/order/refund-detail/refund-detail?id=${id}&sign=${sign}`
  236. } else {
  237. return `/pages/order/order-detail/order-detail?id=${id}&sign=${sign}`
  238. }
  239. },
  240. // 确认收货
  241. confirm(item) {
  242. let self = this;
  243. uni.showModal({
  244. title: '提示',
  245. content: '是否确认收货?',
  246. success: function(res) {
  247. if (res.confirm) {
  248. uni.showLoading({ title: '确认收货中' });
  249. self.$request({
  250. url: self.$api.order.confirm,
  251. data: {
  252. id: item.id
  253. }
  254. }).then(response => {
  255. uni.hideLoading();
  256. if (response.code === 0) {
  257. uni.redirectTo({
  258. url: '/pages/order/index/index?status=' + 4
  259. });
  260. } else {
  261. uni.showModal({
  262. title: '',
  263. content: response.msg,
  264. showCancel: false,
  265. });
  266. }
  267. }).catch(() => {
  268. uni.hideLoading()
  269. });
  270. }
  271. }
  272. });
  273. },
  274. // 取消
  275. cancel(e) {
  276. let self = this;
  277. uni.showModal({
  278. title: '提示',
  279. content: '是否取消订单?',
  280. success: function(res) {
  281. if (res.confirm) {
  282. uni.showLoading({ title: '取消中' });
  283. self.$request({
  284. url: self.$api.order.cancel,
  285. data: {
  286. id: e.id
  287. }
  288. }).then(response => {
  289. uni.hideLoading();
  290. if (response.code == 0) {
  291. uni.redirectTo({
  292. url: '/pages/order/index/index?status=' + self.currentIndex
  293. })
  294. } else {
  295. uni.showModal({
  296. title: '',
  297. content: response.msg,
  298. showCancel: false,
  299. });
  300. }
  301. }).catch(() => {
  302. uni.hideLoading();
  303. });
  304. }
  305. }
  306. });
  307. },
  308. // 物流信息
  309. logistics(orderDetail) {
  310. if (orderDetail.is_send == 1 && orderDetail.detailExpress.length == 0) {
  311. // 兼容
  312. 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];
  313. uni.navigateTo({
  314. url: `/pages/order/express-detail/express-detail?id=${id}&express=${express}&express_no=${express_no}&customer_name=${customer_name}&cover_pic=${cover_pic}`
  315. })
  316. } else if (orderDetail.is_send == 1 && orderDetail.detailExpress.length == 1 && orderDetail.send_type != 2) {
  317. let express = orderDetail.detailExpress[0].express;
  318. let express_no = orderDetail.detailExpress[0].express_no;
  319. let customer_name = orderDetail.detailExpress[0].customer_name;
  320. let cover_pic = orderDetail.detailExpress[0].expressRelation[0].orderDetail.goods_info.goods_attr.cover_pic;
  321. uni.navigateTo({
  322. url: `/pages/order/express-detail/express-detail?express=` + express + `&customer_name=` + customer_name + `&express_no=` + express_no + `&cover_pic=` + cover_pic
  323. })
  324. } else if (orderDetail.detailExpress.length >= 1) {
  325. uni.navigateTo({
  326. url: '/pages/order/express-list/express-list?order_id=' + orderDetail.id
  327. });
  328. }
  329. },
  330. // 订单支付
  331. orderPay(e) {
  332. let _this = this;
  333. _this.$showLoading();
  334. _this.$request({
  335. url: _this.$api.order.list_pay_data,
  336. data: {
  337. id: e.id
  338. }
  339. }).then(response => {
  340. _this.$hideLoading();
  341. if (response.code === 0) {
  342. _this.$payment.pay(response.data.id).then(() => {
  343. // 支付成功
  344. uni.redirectTo({
  345. url: '/pages/order/index/index?status=2'
  346. })
  347. }).catch(e => {
  348. // 支付失败
  349. uni.showModal({
  350. title: '',
  351. content: e.errMsg,
  352. showCancel: false
  353. })
  354. })
  355. }
  356. }).catch(() => {
  357. _this.$hideLoading();
  358. });
  359. },
  360. // 订单评价
  361. appraise(e) {
  362. uni.navigateTo({
  363. url: `/pages/order/appraise/appraise?id=${e.id}`
  364. })
  365. },
  366. getClerkCode(e) {
  367. let self = this;
  368. self.$showLoading();
  369. self.$request({
  370. url: self.$api.order.clerk_qr_code,
  371. data: {
  372. id: e.id
  373. }
  374. }).then(response => {
  375. self.$hideLoading();
  376. if (response.code === 0) {
  377. self.qr_code_url = response.data.file_path;
  378. self.is_qrcode = true;
  379. } else {
  380. uni.showModal({
  381. title: '',
  382. content: response.msg,
  383. showCancel: false,
  384. });
  385. }
  386. }).catch(() => {
  387. self.$hideLoading();
  388. });
  389. },
  390. closeQrcode() {
  391. this.is_qrcode = false;
  392. },
  393. toSearch() {
  394. uni.navigateTo({
  395. url: `/pages/order/search/search`
  396. })
  397. },
  398. isShowExpressButton: function(order) {
  399. if (order.is_send) {
  400. if (order.detailExpress.length == 1 && order.detailExpress[0].send_type == 2 && order.send_type == 0) {
  401. return false;
  402. }
  403. if (order.is_confirm == 0) {
  404. return true;
  405. }
  406. }
  407. return false;
  408. }
  409. },
  410. onLoad(options) {
  411. this.currentIndex = options.status ? options.status : this.currentIndex;
  412. this.loadRecommend();
  413. uni.removeStorage({key: 'search'});
  414. },
  415. onReachBottom() {
  416. this.is_load_show = true;
  417. this.getList();
  418. },
  419. onShow() {
  420. let self = this;
  421. setTimeout(function() {
  422. uni.getStorage({
  423. key: 'search',
  424. success(res) {
  425. self.search = res.data;
  426. let interval = setInterval(function() {
  427. if (self.isRequest) {
  428. self.page = 1;
  429. self.$showLoading();
  430. self.getList();
  431. self.$store.dispatch('gConfig/setTabBarBoolean', self.tabBarNavs.navs);
  432. }
  433. clearInterval(interval)
  434. }, 300);
  435. },
  436. fail() {
  437. let interval = setInterval(function() {
  438. if (self.isRequest) {
  439. self.page = 1;
  440. self.$showLoading();
  441. self.getList();
  442. self.$store.dispatch('gConfig/setTabBarBoolean', self.tabBarNavs.navs);
  443. }
  444. clearInterval(interval)
  445. }, 300);
  446. }
  447. });
  448. }, 0)
  449. },
  450. computed: {
  451. ...mapGetters('mallConfig', {
  452. tabBarNavs: 'getNavBar',
  453. getTheme: 'getTheme',
  454. })
  455. },
  456. components: {
  457. 'app-tab-nav': appTabNav,
  458. 'app-order-goods-info': appOrderGoodsInfo,
  459. 'app-related-suggestion-product': appRelatedSuggestionProduct,
  460. 'app-no-goods': appNoGoods,
  461. },
  462. }
  463. </script>
  464. <style scoped lang="scss">
  465. .search-area {
  466. position: fixed;
  467. z-index: 3;
  468. top: 0;
  469. left: 0;
  470. right: 0;
  471. height: #{88rpx};
  472. line-height: #{88rpx};
  473. width: 100%;
  474. background-color: #efeff4;
  475. padding: #{12rpx} #{24rpx};
  476. .search {
  477. height: #{64rpx};
  478. line-height: #{64rpx};
  479. border-radius: #{32rpx};
  480. background-color: #fff;
  481. color: #b2b2b2;
  482. font-size:#{26rpx};
  483. &.be-search {
  484. color: #353535;
  485. padding-left: 32rpx;
  486. .icon-search {
  487. margin-right: 10rpx;
  488. }
  489. }
  490. .icon-search {
  491. height: #{24rpx};
  492. width: #{24rpx};
  493. margin-top: #{20rpx};
  494. &+text {
  495. color: #b2b2b2;
  496. margin:0 #{8rpx};
  497. }
  498. }
  499. }
  500. }
  501. .search-placeholder {
  502. width: 100%;
  503. height: #{88rpx};
  504. }
  505. .order-box {
  506. width: 100%;
  507. height: 100%;
  508. }
  509. .title-box {
  510. height: 80#{rpx};
  511. width: 100%;
  512. position: fixed;
  513. border-bottom: 1#{rpx} solid $uni-weak-color-one;
  514. top: 0;
  515. background: #fff;
  516. z-index: 1;
  517. }
  518. .no-list {
  519. margin-top: #{120upx};
  520. }
  521. .not-order-box {
  522. height: calc(100vh - 80#{rpx});
  523. color: $uni-general-color-two;
  524. }
  525. .order-item-box {
  526. background: #fff;
  527. padding: 0 24#{rpx};
  528. margin: 0 24#{rpx};
  529. margin-bottom: 24#{rpx};
  530. border-radius: 16#{rpx};
  531. font-size: $uni-font-size-general-two;
  532. box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.06);
  533. }
  534. .order-item-box .view-1 {
  535. width: 100%;
  536. font-size: $uni-font-size-weak-one;
  537. color: $uni-important-color-black;
  538. margin: 32#{rpx} 0;
  539. }
  540. .order-item-box .view-2 {}
  541. .order-item-box .view-3 {
  542. font-size: $uni-font-size-import-two;
  543. }
  544. .order-item-box .view-3 .btn {
  545. margin-left: 15#{rpx};
  546. }
  547. .price-count-box {
  548. margin: 28#{rpx} 0;
  549. }
  550. .price-label {
  551. margin-right: 5#{rpx};
  552. font-size: $uni-font-size-weak-one;
  553. color: $uni-general-color-two;
  554. }
  555. .price-color {
  556. color: $uni-important-color-black;
  557. }
  558. .price-express {
  559. font-size: $uni-font-size-weak-one;
  560. color: $uni-general-color-two;
  561. }
  562. .success-color {
  563. color: $uni-important-color-black;
  564. }
  565. .error-color {
  566. color: $uni-important-color-red;
  567. }
  568. .qrcode-box {
  569. width: 100%;
  570. height: 100%;
  571. position: fixed;
  572. top: 0;
  573. left: 0;
  574. background: rgba(0, 0, 0, 0.5);
  575. }
  576. .qrcode-box .item {
  577. position: absolute;
  578. top: 25%;
  579. width: 562#{rpx};
  580. height: 562#{rpx};
  581. background: #fff;
  582. left: 94#{rpx};
  583. z-index: 999;
  584. border-radius: 15#{rpx};
  585. }
  586. .qrcode-box .img {
  587. margin-top: 30#{rpx};
  588. width: 375#{rpx};
  589. height: 375#{rpx};
  590. }
  591. .qrcode-box .item .remove {
  592. position: absolute;
  593. top: 0;
  594. right: 0;
  595. width: 50#{rpx};
  596. height: 50#{rpx};
  597. margin: 15#{rpx};
  598. padding: #{7rpx}
  599. }
  600. .order-btn {
  601. display: inline-block;
  602. line-height: 2.3;
  603. font-size: 26#{rpx};
  604. padding: 0 30#{rpx};
  605. border: 1#{rpx} solid $uni-weak-color-one;
  606. border-radius: 30#{rpx};
  607. margin-left: 16#{rpx};
  608. }
  609. .action-button-box {
  610. margin-bottom: 24#{rpx};
  611. }
  612. .action-box-view {
  613. width: 100%;
  614. }
  615. </style>