index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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. orderCancel(order_id)
  270. .then(res => {
  271. return that.$util.Tips({
  272. title: res.msg,
  273. icon: 'success'
  274. },
  275. function() {
  276. that.orderList.splice(index, 1);
  277. that.$set(that, 'orderList', that.orderList);
  278. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  279. that.getOrderData();
  280. }
  281. );
  282. })
  283. .catch(err => {
  284. return that.$util.Tips({
  285. title: err
  286. });
  287. });
  288. },
  289. /**
  290. * 打开支付组件
  291. *
  292. */
  293. goPay: function(pay_price, order_id) {
  294. uni.navigateTo({
  295. url: `/pages/goods/cashier/index?order_id=${order_id}&from_type=order`
  296. })
  297. },
  298. /**
  299. * 去订单详情
  300. */
  301. goOrderDetails: function(order_id) {
  302. let that = this;
  303. if (!order_id)
  304. return that.$util.Tips({
  305. title: that.$t(`缺少订单号无法查看订单详情`)
  306. });
  307. // #ifdef MP
  308. uni.showLoading({
  309. title: that.$t(`正在加载中`)
  310. });
  311. openOrderSubscribe()
  312. .then(() => {
  313. uni.hideLoading();
  314. uni.navigateTo({
  315. url: '/pages/goods/order_details/index?order_id=' + order_id
  316. })
  317. })
  318. .catch(err => {
  319. uni.hideLoading();
  320. });
  321. // #endif
  322. // #ifndef MP
  323. uni.navigateTo({
  324. url: '/pages/goods/order_details/index?order_id=' + order_id
  325. });
  326. // #endif
  327. },
  328. /**
  329. * 切换类型
  330. */
  331. statusClick: function(status) {
  332. if (status == this.orderStatus) return;
  333. this.orderStatus = status;
  334. this.loadend = false;
  335. this.page = 1;
  336. this.$set(this, 'orderList', []);
  337. this.getOrderList();
  338. },
  339. /**
  340. * 获取订单列表
  341. */
  342. getOrderList: function() {
  343. let that = this;
  344. if (that.loadend) return;
  345. if (that.loading) return;
  346. that.loading = true;
  347. that.loadTitle = that.$t(`加载更多`);
  348. getOrderList({
  349. type: that.orderStatus,
  350. page: that.page,
  351. limit: that.limit
  352. })
  353. .then(res => {
  354. let list = res.data || [];
  355. let loadend = list.length < that.limit;
  356. that.orderList = that.$util.SplitArray(list, that.orderList);
  357. that.$set(that, 'orderList', that.orderList);
  358. that.loadend = loadend;
  359. that.loading = false;
  360. that.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  361. that.page = that.page + 1;
  362. })
  363. .catch(err => {
  364. that.loading = false;
  365. that.loadTitle = that.$t(`加载更多`);
  366. });
  367. },
  368. /**
  369. * 删除订单
  370. */
  371. delOrder: function(order_id, index) {
  372. let that = this;
  373. uni.showModal({
  374. title: that.$t(`删除订单`),
  375. content: that.$t(`确定删除该订单`),
  376. success: function(res) {
  377. if (res.confirm) {
  378. orderDel(order_id)
  379. .then(res => {
  380. that.orderList.splice(index, 1);
  381. that.$set(that, 'orderList', that.orderList);
  382. that.$set(that.orderData, 'unpaid_count', that.orderData
  383. .unpaid_count - 1);
  384. that.getOrderData();
  385. return that.$util.Tips({
  386. title: that.$t(`删除成功`),
  387. icon: 'success'
  388. });
  389. })
  390. .catch(err => {
  391. return that.$util.Tips({
  392. title: err
  393. });
  394. });
  395. } else if (res.cancel) {
  396. return that.$util.Tips({
  397. title: that.$t(`已取消`)
  398. });
  399. }
  400. }
  401. });
  402. }
  403. },
  404. onReachBottom: function() {
  405. this.getOrderList();
  406. },
  407. // 滚动监听
  408. onPageScroll(e) {
  409. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  410. uni.$emit('scroll');
  411. },
  412. };
  413. </script>
  414. <style scoped lang="scss">
  415. .my-order .header {
  416. height: 260rpx;
  417. padding: 0 30rpx;
  418. }
  419. .my-order .header .picTxt {
  420. height: 190rpx;
  421. }
  422. .my-order .header .picTxt .text {
  423. color: rgba(255, 255, 255, 0.8);
  424. font-size: 26rpx;
  425. font-family: 'Guildford Pro';
  426. }
  427. .my-order .header .picTxt .text .name {
  428. font-size: 34rpx;
  429. font-weight: bold;
  430. color: #fff;
  431. margin-bottom: 20rpx;
  432. }
  433. .my-order .header .picTxt .pictrue {
  434. width: 122rpx;
  435. height: 109rpx;
  436. }
  437. .my-order .header .picTxt .pictrue image {
  438. width: 100%;
  439. height: 100%;
  440. }
  441. .my-order .nav {
  442. background-color: #fff;
  443. width: 690rpx;
  444. height: 140rpx;
  445. border-radius: 6rpx;
  446. margin: -73rpx auto 0 auto;
  447. }
  448. .my-order .nav .item {
  449. text-align: center;
  450. font-size: 26rpx;
  451. color: #282828;
  452. width: 3rem;
  453. padding: 27rpx 0;
  454. border-bottom: 5rpx solid transparent;
  455. }
  456. .my-order .nav .item.on {
  457. /* #ifdef H5 || MP */
  458. font-weight: bold;
  459. /* #endif */
  460. /* #ifdef APP-PLUS */
  461. color: #000;
  462. /* #endif */
  463. border-color: var(--view-theme);
  464. }
  465. .my-order .nav .item .num {
  466. margin-top: 18rpx;
  467. }
  468. .my-order .list {
  469. width: 690rpx;
  470. margin: 14rpx auto 0 auto;
  471. }
  472. .my-order .list .item {
  473. background-color: #fff;
  474. border-radius: 6rpx;
  475. margin-bottom: 14rpx;
  476. }
  477. .my-order .list .item .title {
  478. height: 84rpx;
  479. padding: 0 30rpx;
  480. border-bottom: 1rpx solid #eee;
  481. font-size: 28rpx;
  482. color: #282828;
  483. }
  484. .my-order .list .item .title .sign {
  485. font-size: 24rpx;
  486. padding: 0 7rpx;
  487. height: 36rpx;
  488. margin-right: 15rpx;
  489. }
  490. .my-order .list .item .item-info {
  491. padding: 0 30rpx;
  492. margin-top: 22rpx;
  493. }
  494. .my-order .list .item .item-info .pictrue {
  495. width: 120rpx;
  496. height: 120rpx;
  497. /deep/,
  498. /deep/image,
  499. /deep/.easy-loadimage,
  500. /deep/uni-image {
  501. width: 120rpx;
  502. height: 120rpx;
  503. border-radius: 6rpx;
  504. }
  505. }
  506. .my-order .list .item .item-info .pictrue image {
  507. width: 100%;
  508. height: 100%;
  509. border-radius: 6rpx;
  510. }
  511. .my-order .list .item .item-info .text {
  512. width: 486rpx;
  513. font-size: 28rpx;
  514. color: #999;
  515. margin-top: 6rpx;
  516. display: flex;
  517. line-height: 39rpx;
  518. }
  519. .my-order .list .item .item-info .text .name {
  520. width: 306rpx;
  521. color: #282828;
  522. height: 78rpx;
  523. }
  524. .my-order .list .item .item-info .text .money {
  525. text-align: right;
  526. flex: 1;
  527. }
  528. .my-order .list .item .totalPrice {
  529. font-size: 26rpx;
  530. color: #282828;
  531. text-align: right;
  532. margin: 27rpx 0 0 30rpx;
  533. padding: 0 30rpx 30rpx 0;
  534. border-bottom: 1rpx solid #eee;
  535. }
  536. .my-order .list .item .totalPrice .money {
  537. font-size: 28rpx;
  538. font-weight: bold;
  539. color: var(--view-priceColor);
  540. }
  541. .my-order .list .item .bottom {
  542. height: 107rpx;
  543. padding: 0 30rpx;
  544. }
  545. .my-order .list .item .bottom .bnt {
  546. width: 176rpx;
  547. height: 60rpx;
  548. text-align: center;
  549. line-height: 60rpx;
  550. color: #fff;
  551. border-radius: 50rpx;
  552. font-size: 27rpx;
  553. }
  554. .my-order .list .item .bottom .bnt.cancelBnt {
  555. border: 1rpx solid #ddd;
  556. color: #aaa;
  557. }
  558. .my-order .list .item .bottom .bnt~.bnt {
  559. margin-left: 17rpx;
  560. }
  561. .noCart {
  562. margin-top: 171rpx;
  563. padding-top: 0.1rpx;
  564. }
  565. .noCart .pictrue {
  566. width: 414rpx;
  567. height: 336rpx;
  568. margin: 78rpx auto 56rpx auto;
  569. }
  570. .noCart .pictrue image {
  571. width: 100%;
  572. height: 100%;
  573. }
  574. .my-order .list .item .item-info .text .money .return {
  575. // color: var(--view-priceColor);
  576. margin-top: 10rpx;
  577. font-size: 24rpx;
  578. }
  579. </style>