index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  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. <!-- #ifdef MP -->
  134. <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
  135. <!-- #endif -->
  136. </view>
  137. </template>
  138. <script>
  139. import {
  140. getOrderList,
  141. orderData,
  142. orderCancel,
  143. orderDel,
  144. orderPay
  145. } from '@/api/order.js';
  146. import {
  147. getUserInfo
  148. } from '@/api/user.js';
  149. import {
  150. openOrderSubscribe
  151. } from '@/utils/SubscribeMessage.js';
  152. import home from '@/components/home';
  153. import payment from '@/components/payment';
  154. import {
  155. toLogin
  156. } from '@/libs/login.js';
  157. import {
  158. mapGetters
  159. } from 'vuex';
  160. import emptyPage from '@/components/emptyPage.vue';
  161. import colors from '@/mixins/color.js';
  162. import Loading from '@/components/Loading/index.vue'
  163. export default {
  164. components: {
  165. Loading,
  166. payment,
  167. home,
  168. emptyPage
  169. },
  170. mixins:[colors],
  171. data() {
  172. return {
  173. loaded: false,
  174. loading: false, //是否加载中
  175. loadend: false, //是否加载完毕
  176. loadTitle: '加载更多', //提示语
  177. orderList: [], //订单数组
  178. orderData: {}, //订单详细统计
  179. orderStatus: '', //订单状态
  180. page: 1,
  181. limit: 20,
  182. payMode: [{
  183. name: '微信支付',
  184. icon: 'icon-weixinzhifu',
  185. value: 'weixin',
  186. title: '使用微信快捷支付',
  187. payStatus: true
  188. },
  189. {
  190. name: '支付宝支付',
  191. icon: 'icon-zhifubao',
  192. value: 'alipay',
  193. title: '使用线上支付宝支付',
  194. payStatus: true
  195. },
  196. {
  197. name: '余额支付',
  198. icon: 'icon-yuezhifu',
  199. value: 'yue',
  200. title: '当前可用余额:',
  201. number: 0,
  202. payStatus: true
  203. }
  204. ],
  205. pay_close: false,
  206. pay_order_id: '',
  207. totalPrice: '0',
  208. isAuto: false, //没有授权的不会自动授权
  209. isShowAuth: false //是否隐藏授权
  210. };
  211. },
  212. computed: mapGetters(['isLogin']),
  213. onShow() {
  214. uni.removeStorageSync('form_type_cart');
  215. this.page = 1;
  216. this.loadend = false;
  217. this.orderList = [];
  218. if (this.isLogin) {
  219. this.getFun();
  220. } else {
  221. // #ifdef H5 || APP-PLUS
  222. toLogin()
  223. // #endif
  224. // #ifdef MP
  225. this.isShowAuth = true;
  226. // #endif
  227. }
  228. },
  229. /**
  230. * 生命周期函数--监听页面加载
  231. */
  232. onLoad(options) {
  233. if (options.status) this.orderStatus = (options.status==undefined && options.status!=0)?'':parseInt(options.status);
  234. },
  235. methods: {
  236. getFun(){
  237. this.getOrderData();
  238. this.getOrderList();
  239. this.getUserInfo();
  240. },
  241. onLoadFun(){
  242. this.getFun();
  243. this.isShowAuth = false;
  244. },
  245. // 授权关闭
  246. authColse: function(e) {
  247. this.isShowAuth = e;
  248. },
  249. /**
  250. * 事件回调
  251. *
  252. */
  253. onChangeFun: function(e) {
  254. let opt = e;
  255. let action = opt.action || null;
  256. let value = opt.value != undefined ? opt.value : null;
  257. action && this[action] && this[action](value);
  258. },
  259. /**
  260. * 获取用户信息
  261. *
  262. */
  263. getUserInfo: function() {
  264. let that = this;
  265. getUserInfo().then(res => {
  266. that.payMode[2].number = res.data.now_money;
  267. that.$set(that, 'payMode', that.payMode);
  268. });
  269. },
  270. /**
  271. * 关闭支付组件
  272. *
  273. */
  274. payClose: function() {
  275. this.pay_close = false;
  276. },
  277. /**
  278. * 获取订单统计数据
  279. *
  280. */
  281. getOrderData: function() {
  282. let that = this;
  283. orderData().then(res => {
  284. that.$set(that, 'orderData', res.data);
  285. that.payMode.map(item => {
  286. if (item.value == 'weixin') {
  287. item.payStatus = res.data.pay_weixin_open ? true : false;
  288. }
  289. if (item.value == 'alipay') {
  290. item.payStatus = res.data.ali_pay_status ? true : false;
  291. }
  292. if (item.value == 'yue') {
  293. item.payStatus = res.data.yue_pay_status == 1 ? true : false;
  294. }
  295. });
  296. //#ifdef MP
  297. this.payMode[1].payStatus = false;
  298. //#endif
  299. });
  300. },
  301. /**
  302. * 取消订单
  303. *
  304. */
  305. cancelOrder: function(index, order_id) {
  306. let that = this;
  307. if (!order_id)
  308. return that.$util.Tips({
  309. title: '缺少订单号无法取消订单'
  310. });
  311. orderCancel(order_id)
  312. .then(res => {
  313. return that.$util.Tips({
  314. title: res.msg,
  315. icon: 'success'
  316. },
  317. function() {
  318. that.orderList.splice(index, 1);
  319. that.$set(that, 'orderList', that.orderList);
  320. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  321. that.getOrderData();
  322. }
  323. );
  324. })
  325. .catch(err => {
  326. return that.$util.Tips({
  327. title: err
  328. });
  329. });
  330. },
  331. /**
  332. * 打开支付组件
  333. *
  334. */
  335. goPay: function(pay_price, order_id) {
  336. this.$set(this, 'pay_close', true);
  337. this.$set(this, 'pay_order_id', order_id);
  338. this.$set(this, 'totalPrice', pay_price);
  339. },
  340. /**
  341. * 支付成功回调
  342. *
  343. */
  344. pay_complete: function() {
  345. this.loadend = false;
  346. this.page = 1;
  347. this.$set(this, 'orderList', []);
  348. this.pay_close = false;
  349. uni.navigateTo({
  350. url: '/pages/goods/order_pay_status/index?order_id=' + this.pay_order_id +
  351. '&msg=支付成功&type=3&totalPrice=' + this.totalPrice
  352. })
  353. this.pay_order_id = '';
  354. this.getOrderData();
  355. this.getOrderList();
  356. },
  357. /**
  358. * 支付失败回调
  359. *
  360. */
  361. pay_fail: function() {
  362. this.pay_close = false;
  363. this.pay_order_id = '';
  364. },
  365. /**
  366. * 去订单详情
  367. */
  368. goOrderDetails: function(order_id) {
  369. if (!order_id)
  370. return that.$util.Tips({
  371. title: '缺少订单号无法查看订单详情'
  372. });
  373. // #ifdef MP
  374. uni.showLoading({
  375. title: '正在加载'
  376. });
  377. openOrderSubscribe()
  378. .then(() => {
  379. uni.hideLoading();
  380. uni.navigateTo({
  381. url: '/pages/goods/order_details/index?order_id=' + order_id
  382. })
  383. })
  384. .catch(err => {
  385. uni.hideLoading();
  386. });
  387. // #endif
  388. // #ifndef MP
  389. uni.navigateTo({
  390. url: '/pages/goods/order_details/index?order_id=' + order_id
  391. });
  392. // #endif
  393. },
  394. /**
  395. * 切换类型
  396. */
  397. statusClick: function(status) {
  398. if(this.loading) return
  399. if (status === this.orderStatus) return;
  400. this.orderStatus = status;
  401. this.loadend = false;
  402. this.page = 1;
  403. this.$set(this, 'orderList', []);
  404. this.getOrderList();
  405. },
  406. /**
  407. * 获取订单列表
  408. */
  409. getOrderList: function() {
  410. let that = this;
  411. if (that.loadend) return;
  412. if (that.loading) return;
  413. that.loading = true;
  414. that.loadTitle = '加载更多';
  415. getOrderList({
  416. type: that.orderStatus,
  417. page: that.page,
  418. limit: that.limit
  419. })
  420. .then(res => {
  421. let list = res.data || [];
  422. let loadend = list.length < that.limit;
  423. that.orderList = that.$util.SplitArray(list, that.orderList);
  424. that.$set(that, 'orderList', that.orderList);
  425. that.loadend = loadend;
  426. that.loading = false;
  427. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  428. that.page = that.page + 1;
  429. })
  430. .catch(err => {
  431. that.loading = false;
  432. that.loadTitle = '加载更多';
  433. });
  434. },
  435. /**
  436. * 删除订单
  437. */
  438. delOrder: function(order_id, index) {
  439. let that = this;
  440. uni.showModal({
  441. title: '删除订单',
  442. content: '确定删除该订单',
  443. success: function (res) {
  444. if (res.confirm) {
  445. orderDel(order_id)
  446. .then(res => {
  447. that.orderList.splice(index, 1);
  448. that.$set(that, 'orderList', that.orderList);
  449. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  450. that.getOrderData();
  451. return that.$util.Tips({
  452. title: '删除成功',
  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: '已取消'
  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: 260rpx;
  478. padding: 0 30rpx;
  479. }
  480. .my-order .header .picTxt {
  481. height: 190rpx;
  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. }
  568. .my-order .list .item .item-info .text .name {
  569. width: 306rpx;
  570. color: #282828;
  571. height: 74rpx;
  572. }
  573. .my-order .list .item .item-info .text .money {
  574. text-align: right;
  575. }
  576. .my-order .list .item .item-info .text .money .return{
  577. // color: var(--view-priceColor);
  578. margin-top: 10rpx;
  579. font-size: 24rpx;
  580. }
  581. .my-order .list .item .totalPrice {
  582. font-size: 26rpx;
  583. color: #282828;
  584. text-align: right;
  585. margin: 27rpx 0 0 30rpx;
  586. padding: 0 30rpx 30rpx 0;
  587. border-bottom: 1rpx solid #eee;
  588. }
  589. .my-order .list .item .totalPrice .money {
  590. font-size: 28rpx;
  591. font-weight: bold;
  592. color: var(--view-priceColor);
  593. }
  594. .my-order .list .item .bottom {
  595. height: 107rpx;
  596. padding: 0 30rpx;
  597. }
  598. .my-order .list .item .bottom .bnt {
  599. width: 176rpx;
  600. height: 60rpx;
  601. text-align: center;
  602. line-height: 60rpx;
  603. color: #fff;
  604. border-radius: 50rpx;
  605. font-size: 27rpx;
  606. }
  607. .my-order .list .item .bottom .bnt.cancelBnt {
  608. border: 1rpx solid #ddd;
  609. color: #aaa;
  610. }
  611. .my-order .list .item .bottom .bnt~.bnt {
  612. margin-left: 17rpx;
  613. }
  614. .noCart {
  615. margin-top: 171rpx;
  616. padding-top: 0.1rpx;
  617. }
  618. .noCart .pictrue {
  619. width: 414rpx;
  620. height: 336rpx;
  621. margin: 78rpx auto 56rpx auto;
  622. }
  623. .noCart .pictrue image {
  624. width: 100%;
  625. height: 100%;
  626. }
  627. .line2 {
  628. word-break: break-all;
  629. }
  630. </style>