index.vue 17 KB

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