index.vue 17 KB

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