index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="my-order">
  4. <view class="header bg-color">
  5. <view class="picTxt acea-row row-between-wrapper">
  6. <view class="text">
  7. <view class="name">{{$t(`订单信息`)}}</view>
  8. <view>{{$t(`消费订单`)}}:{{ orderData.order_count || 0 }}
  9. {{$t(`总消费`)}}:{{$t(`¥`)}}{{ orderData.sum_price || 0 }}
  10. </view>
  11. </view>
  12. <view class="pictrue">
  13. <image src="../static/orderTime.png"></image>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="nav acea-row row-around">
  18. <view class="item" :class="orderStatus == 9 ? 'on' : ''" @click="statusClick(9)">
  19. <view>{{$t(`全部`)}}</view>
  20. <view class="num">{{ orderData.order_count || 0 }}</view>
  21. </view>
  22. <view class="item" :class="orderStatus == 0 ? 'on' : ''" @click="statusClick(0)">
  23. <view>{{$t(`待付款`)}}</view>
  24. <view class="num">{{ orderData.unpaid_count || 0 }}</view>
  25. </view>
  26. <view class="item" :class="orderStatus == 1 ? 'on' : ''" @click="statusClick(1)">
  27. <view>{{$t(`待发货`)}}</view>
  28. <view class="num">{{ orderData.unshipped_count || 0 }}</view>
  29. </view>
  30. <view class="item" :class="orderStatus == 2 ? 'on' : ''" @click="statusClick(2)">
  31. <view>{{$t(`待收货`)}}</view>
  32. <view class="num ">{{ orderData.received_count || 0 }}</view>
  33. </view>
  34. <view class="item" :class="orderStatus == 3 ? 'on' : ''" @click="statusClick(3)">
  35. <view>{{$t(`待评价`)}}</view>
  36. <view class="num">{{ orderData.evaluated_count || 0 }}</view>
  37. </view>
  38. </view>
  39. <view class="list">
  40. <view class="item" v-for="(item, index) in orderList" :key="index">
  41. <view @click="goOrderDetails(item.order_id)">
  42. <view class="title acea-row row-between-wrapper">
  43. <view class="acea-row row-middle">
  44. <text class="sign cart-color acea-row row-center-wrapper"
  45. v-if="item.type == 2">{{$t(`砍价`)}}</text>
  46. <text class="sign cart-color acea-row row-center-wrapper"
  47. v-else-if="item.type == 3">{{$t(`拼团`)}}</text>
  48. <text class="sign cart-color acea-row row-center-wrapper"
  49. v-else-if="item.type == 1">{{$t(`秒杀`)}}</text>
  50. <text class="sign cart-color acea-row row-center-wrapper"
  51. v-else-if="item.type == 4">{{$t(`预售`)}}</text>
  52. <view>{{ item._add_time }}</view>
  53. </view>
  54. <view v-if="item._status._type == 9" class="font-color">{{$t(`线下付款,未支付`)}}</view>
  55. <view v-else-if="item._status._type == 0" class="font-color">{{$t(`待付款`)}}</view>
  56. <view v-else-if="item._status._type == 1 && item.shipping_type == 1" class="font-color">
  57. {{$t(`待发货`)}}
  58. <text v-if="item.refund.length">,{{item.is_all_refund?$t(`退款中`):$t(`部分退款中`)}}</text>
  59. </view>
  60. <view v-else-if="item._status._type == 1 && item.shipping_type == 2" class="font-color">
  61. {{$t(`待核销`)}}
  62. <text v-if="item.refund.length">,{{item.is_all_refund?$t(`退款中`):$t(`部分退款中`)}}</text>
  63. </view>
  64. <view v-else-if="item._status._type == 2" class="font-color">{{$t(`待收货`)}}
  65. <text v-if="item.refund.length">,{{item.is_all_refund?$t(`退款中`):$t(`部分退款中`)}}</text>
  66. </view>
  67. <view v-else-if="item._status._type == 3" class="font-color">{{$t(`待评价`)}}
  68. <text v-if="item.refund.length">,{{item.is_all_refund?$t(`退款中`):$t(`部分退款中`)}}</text>
  69. </view>
  70. <view v-else-if="item._status._type == 4" class="font-color">{{$t(`已完成`)}}
  71. <text v-if="item.refund.length">,{{item.is_all_refund?$t(`退款中`):$t(`部分退款中`)}}</text>
  72. </view>
  73. <view v-else-if="item._status._type == 5 && item.status == 0" class="font-color">
  74. {{$t(`未核销`)}}
  75. <text v-if="item.refund.length">,{{item.is_all_refund?$t(`退款中`):$t(`部分退款中`)}}</text>
  76. </view>
  77. <view v-else-if="item._status._type == -2" class="font-color">{{$t(`已退款`)}}
  78. </view>
  79. </view>
  80. <view class="item-info acea-row row-between row-top" v-for="(items, indexCat) in item.cartInfo"
  81. :key="indexCat">
  82. <view class="pictrue">
  83. <easy-loadimage mode="widthFix" :image-src="items.productInfo.image"></easy-loadimage>
  84. <!-- <image :src="items.productInfo.image"></image> -->
  85. </view>
  86. <view class="text row-between">
  87. <text class="name line2">{{ items.productInfo.store_name }}</text>
  88. <view class="money">
  89. <view v-if="items.productInfo.attrInfo">
  90. {{$t(`¥`)}}{{ items.productInfo.attrInfo.price }}
  91. </view>
  92. <view v-else>{{$t(`¥`)}}{{ items.productInfo.price }}</view>
  93. <view>x{{ items.cart_num }}</view>
  94. <view v-if="items.refund_num && item._status._type != -2" class="return">
  95. {{ items.refund_num }}{{$t(`件退款中`)}}
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="totalPrice">
  101. {{$t(`共`)}}{{ item.total_num || 0 }}{{$t(`件商品,总金额`)}}
  102. <text class="money">{{$t(`¥`)}}{{ item.pay_price }}</text>
  103. </view>
  104. </view>
  105. <view class="bottom acea-row row-right row-middle">
  106. <view class="bnt cancelBnt" v-if="item._status._type == 0 || item._status._type == 9"
  107. @click="cancelOrder(index, item.order_id)">{{$t(`取消订单`)}}</view>
  108. <view class="bnt bg-color" v-if="item._status._type == 0"
  109. @click="goPay(item.pay_price, item.order_id)">{{$t(`立即付款`)}}</view>
  110. <!-- <view class="bnt bg-color" v-else-if="item._status._type == 3"
  111. @click="goOrderDetails(item.order_id)">去评价</view> -->
  112. <!-- <view class="bnt bg-color"
  113. v-else-if="item.seckill_id < 1 && item.bargain_id < 1 && item.combination_id < 1 && item._status._type == 4"
  114. @click="goOrderDetails(item.order_id)">
  115. 再次购买
  116. </view> -->
  117. <view class="bnt cancelBnt" v-if="item._status._type == 4"
  118. @click="delOrder(item.order_id, index)">{{$t(`删除订单`)}}</view>
  119. <view class="bnt bg-color" @click="goOrderDetails(item.order_id)">{{$t(`查看详情`)}}</view>
  120. </view>
  121. </view>
  122. </view>
  123. <view class="loadingicon acea-row row-center-wrapper" v-if="orderList.length > 0">
  124. <text class="loading iconfont icon-jiazai" :hidden="loading == false"></text>
  125. {{ loadTitle }}
  126. </view>
  127. <view v-if="orderList.length == 0">
  128. <emptyPage v-if="!loading" :title="$t(`暂无订单`)"></emptyPage>
  129. <view class="loadingicon acea-row row-center-wrapper">
  130. <text class="loading iconfont icon-jiazai" :hidden="loading == false"></text>
  131. </view>
  132. </view>
  133. </view>
  134. <!-- #ifndef MP -->
  135. <home></home>
  136. <!-- #endif -->
  137. </view>
  138. </template>
  139. <script>
  140. import {
  141. getOrderList,
  142. orderData,
  143. orderCancel,
  144. orderDel,
  145. orderPay
  146. } from '@/api/order.js';
  147. import {
  148. openOrderSubscribe
  149. } from '@/utils/SubscribeMessage.js';
  150. import home from '@/components/home';
  151. import {
  152. toLogin
  153. } from '@/libs/login.js';
  154. import {
  155. mapGetters
  156. } from 'vuex';
  157. // #ifdef MP
  158. import authorize from '@/components/Authorize';
  159. // #endif
  160. import emptyPage from '@/components/emptyPage.vue';
  161. import colors from '@/mixins/color.js';
  162. export default {
  163. components: {
  164. home,
  165. emptyPage,
  166. // #ifdef MP
  167. authorize
  168. // #endif
  169. },
  170. mixins: [colors],
  171. data() {
  172. return {
  173. loading: false, //是否加载中
  174. loadend: false, //是否加载完毕
  175. loadTitle: this.$t(`加载更多`), //提示语
  176. orderList: [], //订单数组
  177. orderData: {}, //订单详细统计
  178. orderStatus: 9, //订单状态
  179. page: 1,
  180. limit: 20,
  181. pay_close: false,
  182. pay_order_id: '',
  183. totalPrice: '0',
  184. initIn: false,
  185. isAuto: false, //没有授权的不会自动授权
  186. isShowAuth: false //是否隐藏授权
  187. };
  188. },
  189. computed: mapGetters(['isLogin']),
  190. /**
  191. * 生命周期函数--监听页面加载
  192. */
  193. onLoad: function(options) {
  194. if (options.status) this.orderStatus = options.status;
  195. let EnOptions = wx.getEnterOptionsSync();
  196. if (EnOptions.scene == '1038' && EnOptions.referrerInfo.appId == 'wxef277996acc166c3' && this.initIn) {
  197. // 代表从收银台小程序返回
  198. let extraData = EnOptions.referrerInfo.extraData;
  199. this.initIn = false
  200. if (!extraData) {
  201. this.getOrderList();
  202. // "当前通过物理按键返回,未接收到返参,建议自行查询交易结果";
  203. } else {
  204. if (extraData.code == 'success') {
  205. this.getOrderList();
  206. } else if (extraData.code == 'cancel') {} else {
  207. // "支付失败:" + extraData.errmsg;
  208. }
  209. }
  210. }
  211. },
  212. onShow() {
  213. if (this.isLogin) {
  214. this.page = 1;
  215. this.orderList = []
  216. this.loadend = false;
  217. this.pay_close = false;
  218. this.onLoadFun();
  219. this.getOrderList();
  220. } else {
  221. toLogin();
  222. }
  223. },
  224. methods: {
  225. onLoadFun() {
  226. this.getOrderData();
  227. },
  228. // 授权关闭
  229. authColse: function(e) {
  230. this.isShowAuth = e;
  231. },
  232. /**
  233. * 事件回调
  234. *
  235. */
  236. onChangeFun: function(e) {
  237. let opt = e;
  238. let action = opt.action || null;
  239. let value = opt.value != undefined ? opt.value : null;
  240. action && this[action] && this[action](value);
  241. },
  242. /**
  243. * 关闭支付组件
  244. *
  245. */
  246. payClose: function() {
  247. this.pay_close = false;
  248. },
  249. /**
  250. * 获取订单统计数据
  251. *
  252. */
  253. getOrderData: function() {
  254. let that = this;
  255. orderData().then(res => {
  256. that.$set(that, 'orderData', res.data);
  257. });
  258. },
  259. /**
  260. * 取消订单
  261. *
  262. */
  263. cancelOrder: function(index, order_id) {
  264. let that = this;
  265. if (!order_id)
  266. return that.$util.Tips({
  267. title: that.$t(`缺少订单号无法取消订单`)
  268. });
  269. uni.showModal({
  270. title: this.$t(`提示`),
  271. content: this.$t(`确认取消该订单`),
  272. success: function(res) {
  273. if (res.confirm) {
  274. orderCancel(order_id)
  275. .then(res => {
  276. return that.$util.Tips({
  277. title: res.msg,
  278. icon: 'success'
  279. },
  280. function() {
  281. that.orderList.splice(index, 1);
  282. that.$set(that, 'orderList', that.orderList);
  283. that.$set(that.orderData, 'unpaid_count', that
  284. .orderData.unpaid_count - 1);
  285. that.getOrderData();
  286. }
  287. );
  288. })
  289. .catch(err => {
  290. return that.$util.Tips({
  291. title: err
  292. });
  293. });
  294. } else if (res.cancel) {}
  295. }
  296. });
  297. },
  298. /**
  299. * 打开支付组件
  300. *
  301. */
  302. goPay: function(pay_price, order_id) {
  303. uni.navigateTo({
  304. url: `/pages/goods/cashier/index?order_id=${order_id}&from_type=order`
  305. })
  306. },
  307. /**
  308. * 去订单详情
  309. */
  310. goOrderDetails: function(order_id) {
  311. let that = this;
  312. if (!order_id)
  313. return that.$util.Tips({
  314. title: that.$t(`缺少订单号无法查看订单详情`)
  315. });
  316. // #ifdef MP
  317. uni.showLoading({
  318. title: that.$t(`正在加载中`)
  319. });
  320. openOrderSubscribe()
  321. .then(() => {
  322. uni.hideLoading();
  323. uni.navigateTo({
  324. url: '/pages/goods/order_details/index?order_id=' + order_id
  325. })
  326. })
  327. .catch(err => {
  328. uni.hideLoading();
  329. });
  330. // #endif
  331. // #ifndef MP
  332. uni.navigateTo({
  333. url: '/pages/goods/order_details/index?order_id=' + order_id
  334. });
  335. // #endif
  336. },
  337. /**
  338. * 切换类型
  339. */
  340. statusClick: function(status) {
  341. if (status == this.orderStatus) return;
  342. this.orderStatus = status;
  343. this.loadend = false;
  344. this.page = 1;
  345. this.$set(this, 'orderList', []);
  346. this.getOrderList();
  347. },
  348. /**
  349. * 获取订单列表
  350. */
  351. getOrderList: function() {
  352. let that = this;
  353. if (that.loadend) return;
  354. if (that.loading) return;
  355. that.loading = true;
  356. that.loadTitle = that.$t(`加载更多`);
  357. getOrderList({
  358. type: that.orderStatus,
  359. page: that.page,
  360. limit: that.limit
  361. })
  362. .then(res => {
  363. let list = res.data || [];
  364. let loadend = list.length < that.limit;
  365. that.orderList = that.$util.SplitArray(list, that.orderList);
  366. that.$set(that, 'orderList', that.orderList);
  367. that.loadend = loadend;
  368. that.loading = false;
  369. that.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  370. that.page = that.page + 1;
  371. })
  372. .catch(err => {
  373. that.loading = false;
  374. that.loadTitle = that.$t(`加载更多`);
  375. });
  376. },
  377. /**
  378. * 删除订单
  379. */
  380. delOrder: function(order_id, index) {
  381. let that = this;
  382. uni.showModal({
  383. title: that.$t(`删除订单`),
  384. content: that.$t(`确定删除该订单`),
  385. success: function(res) {
  386. if (res.confirm) {
  387. orderDel(order_id)
  388. .then(res => {
  389. that.orderList.splice(index, 1);
  390. that.$set(that, 'orderList', that.orderList);
  391. that.$set(that.orderData, 'unpaid_count', that.orderData
  392. .unpaid_count - 1);
  393. that.getOrderData();
  394. return that.$util.Tips({
  395. title: that.$t(`删除成功`),
  396. icon: 'success'
  397. });
  398. })
  399. .catch(err => {
  400. return that.$util.Tips({
  401. title: err
  402. });
  403. });
  404. } else if (res.cancel) {
  405. return that.$util.Tips({
  406. title: that.$t(`已取消`)
  407. });
  408. }
  409. }
  410. });
  411. }
  412. },
  413. onReachBottom: function() {
  414. this.getOrderList();
  415. },
  416. // 滚动监听
  417. onPageScroll(e) {
  418. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  419. uni.$emit('scroll');
  420. },
  421. };
  422. </script>
  423. <style scoped lang="scss">
  424. .my-order .header {
  425. height: 260rpx;
  426. padding: 0 30rpx;
  427. }
  428. .my-order .header .picTxt {
  429. height: 190rpx;
  430. }
  431. .my-order .header .picTxt .text {
  432. color: rgba(255, 255, 255, 0.8);
  433. font-size: 26rpx;
  434. font-family: 'Guildford Pro';
  435. }
  436. .my-order .header .picTxt .text .name {
  437. font-size: 34rpx;
  438. font-weight: bold;
  439. color: #fff;
  440. margin-bottom: 20rpx;
  441. }
  442. .my-order .header .picTxt .pictrue {
  443. width: 122rpx;
  444. height: 109rpx;
  445. }
  446. .my-order .header .picTxt .pictrue image {
  447. width: 100%;
  448. height: 100%;
  449. }
  450. .my-order .nav {
  451. background-color: #fff;
  452. width: 690rpx;
  453. height: 140rpx;
  454. border-radius: 6rpx;
  455. margin: -73rpx auto 0 auto;
  456. }
  457. .my-order .nav .item {
  458. text-align: center;
  459. font-size: 26rpx;
  460. color: #282828;
  461. width: 3rem;
  462. padding: 27rpx 0;
  463. border-bottom: 5rpx solid transparent;
  464. }
  465. .my-order .nav .item.on {
  466. /* #ifdef H5 || MP */
  467. font-weight: bold;
  468. /* #endif */
  469. /* #ifdef APP-PLUS */
  470. color: #000;
  471. /* #endif */
  472. border-color: var(--view-theme);
  473. }
  474. .my-order .nav .item .num {
  475. margin-top: 18rpx;
  476. }
  477. .my-order .list {
  478. width: 690rpx;
  479. margin: 14rpx auto 0 auto;
  480. }
  481. .my-order .list .item {
  482. background-color: #fff;
  483. border-radius: 6rpx;
  484. margin-bottom: 14rpx;
  485. }
  486. .my-order .list .item .title {
  487. height: 84rpx;
  488. padding: 0 30rpx;
  489. border-bottom: 1rpx solid #eee;
  490. font-size: 28rpx;
  491. color: #282828;
  492. }
  493. .my-order .list .item .title .sign {
  494. font-size: 24rpx;
  495. padding: 0 7rpx;
  496. height: 36rpx;
  497. margin-right: 15rpx;
  498. }
  499. .my-order .list .item .item-info {
  500. padding: 0 30rpx;
  501. margin-top: 22rpx;
  502. }
  503. .my-order .list .item .item-info .pictrue {
  504. width: 120rpx;
  505. height: 120rpx;
  506. /deep/,
  507. /deep/image,
  508. /deep/.easy-loadimage,
  509. /deep/uni-image {
  510. width: 120rpx;
  511. height: 120rpx;
  512. border-radius: 6rpx;
  513. }
  514. }
  515. .my-order .list .item .item-info .pictrue image {
  516. width: 100%;
  517. height: 100%;
  518. border-radius: 6rpx;
  519. }
  520. .my-order .list .item .item-info .text {
  521. width: 486rpx;
  522. font-size: 28rpx;
  523. color: #999;
  524. margin-top: 6rpx;
  525. display: flex;
  526. line-height: 39rpx;
  527. }
  528. .my-order .list .item .item-info .text .name {
  529. width: 306rpx;
  530. color: #282828;
  531. height: 78rpx;
  532. }
  533. .my-order .list .item .item-info .text .money {
  534. text-align: right;
  535. flex: 1;
  536. }
  537. .my-order .list .item .totalPrice {
  538. font-size: 26rpx;
  539. color: #282828;
  540. text-align: right;
  541. margin: 27rpx 0 0 30rpx;
  542. padding: 0 30rpx 30rpx 0;
  543. border-bottom: 1rpx solid #eee;
  544. }
  545. .my-order .list .item .totalPrice .money {
  546. font-size: 28rpx;
  547. font-weight: bold;
  548. color: var(--view-priceColor);
  549. }
  550. .my-order .list .item .bottom {
  551. height: 107rpx;
  552. padding: 0 30rpx;
  553. }
  554. .my-order .list .item .bottom .bnt {
  555. width: 176rpx;
  556. height: 60rpx;
  557. text-align: center;
  558. line-height: 60rpx;
  559. color: #fff;
  560. border-radius: 50rpx;
  561. font-size: 27rpx;
  562. }
  563. .my-order .list .item .bottom .bnt.cancelBnt {
  564. border: 1rpx solid #ddd;
  565. color: #aaa;
  566. }
  567. .my-order .list .item .bottom .bnt~.bnt {
  568. margin-left: 17rpx;
  569. }
  570. .noCart {
  571. margin-top: 171rpx;
  572. padding-top: 0.1rpx;
  573. }
  574. .noCart .pictrue {
  575. width: 414rpx;
  576. height: 336rpx;
  577. margin: 78rpx auto 56rpx auto;
  578. }
  579. .noCart .pictrue image {
  580. width: 100%;
  581. height: 100%;
  582. }
  583. .my-order .list .item .item-info .text .money .return {
  584. // color: var(--view-priceColor);
  585. margin-top: 10rpx;
  586. font-size: 24rpx;
  587. }
  588. </style>