index.vue 17 KB

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