index.vue 18 KB

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