index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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. {
  190. name: '微信支付',
  191. icon: 'icon-weixinzhifu',
  192. value: 'weixin',
  193. title: '使用微信快捷支付',
  194. payStatus: true
  195. },
  196. {
  197. name: '支付宝支付',
  198. icon: 'icon-zhifubao',
  199. value: 'alipay',
  200. title: '使用线上支付宝支付',
  201. payStatus: true
  202. },
  203. {
  204. name: '余额支付',
  205. icon: 'icon-yuezhifu',
  206. value: 'yue',
  207. title: '当前可用余额:',
  208. number: 0,
  209. payStatus: true
  210. }
  211. ],
  212. pay_close: false,
  213. pay_order_id: '',
  214. totalPrice: '0',
  215. isAuto: false, //没有授权的不会自动授权
  216. isShowAuth: false //是否隐藏授权
  217. };
  218. },
  219. computed: mapGetters(['isLogin']),
  220. onShow() {
  221. uni.removeStorageSync('form_type_cart');
  222. this.page = 1;
  223. this.loadend = false;
  224. this.orderList = [];
  225. if (this.isLogin) {
  226. this.getFun();
  227. } else {
  228. // #ifdef H5 || APP-PLUS
  229. toLogin()
  230. // #endif
  231. // #ifdef MP
  232. this.isShowAuth = true;
  233. // #endif
  234. }
  235. },
  236. /**
  237. * 生命周期函数--监听页面加载
  238. */
  239. onLoad(options) {
  240. if (options.status) this.orderStatus = (options.status==undefined && options.status!=0)?'':parseInt(options.status);
  241. },
  242. methods: {
  243. getFun(){
  244. this.getOrderData();
  245. this.getOrderList();
  246. this.getUserInfo();
  247. },
  248. onLoadFun(){
  249. this.getFun();
  250. this.isShowAuth = false;
  251. },
  252. // 授权关闭
  253. authColse: function(e) {
  254. this.isShowAuth = e;
  255. },
  256. /**
  257. * 事件回调
  258. *
  259. */
  260. onChangeFun: function(e) {
  261. let opt = e;
  262. let action = opt.action || null;
  263. let value = opt.value != undefined ? opt.value : null;
  264. action && this[action] && this[action](value);
  265. },
  266. /**
  267. * 获取用户信息
  268. *
  269. */
  270. getUserInfo: function() {
  271. let that = this;
  272. getUserInfo().then(res => {
  273. that.payMode[2].number = res.data.now_money;
  274. that.$set(that, 'payMode', that.payMode);
  275. });
  276. },
  277. /**
  278. * 关闭支付组件
  279. *
  280. */
  281. payClose: function() {
  282. this.pay_close = false;
  283. },
  284. /**
  285. * 获取订单统计数据
  286. *
  287. */
  288. getOrderData: function() {
  289. let that = this;
  290. orderData().then(res => {
  291. that.$set(that, 'orderData', res.data);
  292. that.payMode.map(item => {
  293. if (item.value == 'weixin') {
  294. item.payStatus = res.data.pay_weixin_open ? true : false;
  295. }
  296. if (item.value == 'alipay') {
  297. item.payStatus = res.data.ali_pay_status ? true : false;
  298. }
  299. if (item.value == 'yue') {
  300. item.payStatus = res.data.yue_pay_status == 1 ? true : false;
  301. }
  302. });
  303. //#ifdef MP
  304. this.payMode[1].payStatus = false;
  305. //#endif
  306. });
  307. },
  308. /**
  309. * 取消订单
  310. *
  311. */
  312. cancelOrder: function(index, order_id) {
  313. let that = this;
  314. if (!order_id)
  315. return that.$util.Tips({
  316. title: '缺少订单号无法取消订单'
  317. });
  318. uni.showModal({
  319. title: '取消订单',
  320. content: '您是否确认取消此订单',
  321. confirmText: '确认',
  322. cancelText: '再想想',
  323. success: (res) => {
  324. if (res.confirm) {
  325. orderCancel(order_id)
  326. .then(res => {
  327. return that.$util.Tips({
  328. title: res.msg,
  329. icon: 'success'
  330. },
  331. function() {
  332. that.orderList.splice(index, 1);
  333. that.$set(that, 'orderList', that.orderList);
  334. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  335. that.getOrderData();
  336. }
  337. );
  338. })
  339. .catch(err => {
  340. return that.$util.Tips({
  341. title: err
  342. });
  343. });
  344. }
  345. }
  346. })
  347. },
  348. /**
  349. * 打开支付组件
  350. *
  351. */
  352. goPay: function(pay_price, order_id) {
  353. this.$set(this, 'pay_close', true);
  354. this.$set(this, 'pay_order_id', order_id);
  355. this.$set(this, 'totalPrice', pay_price);
  356. },
  357. /**
  358. * 支付成功回调
  359. *
  360. */
  361. pay_complete: function() {
  362. this.loadend = false;
  363. this.page = 1;
  364. this.$set(this, 'orderList', []);
  365. this.pay_close = false;
  366. uni.navigateTo({
  367. url: '/pages/goods/order_pay_status/index?order_id=' + this.pay_order_id +
  368. '&msg=支付成功&type=3&totalPrice=' + this.totalPrice
  369. })
  370. this.pay_order_id = '';
  371. this.getOrderData();
  372. this.getOrderList();
  373. },
  374. /**
  375. * 支付失败回调
  376. *
  377. */
  378. pay_fail: function() {
  379. this.pay_close = false;
  380. this.pay_order_id = '';
  381. },
  382. /**
  383. * 去订单详情
  384. */
  385. goOrderDetails: function(order_id) {
  386. if (!order_id)
  387. return that.$util.Tips({
  388. title: '缺少订单号无法查看订单详情'
  389. });
  390. // #ifdef MP
  391. uni.showLoading({
  392. title: '正在加载'
  393. });
  394. openOrderSubscribe()
  395. .then(() => {
  396. uni.hideLoading();
  397. uni.navigateTo({
  398. url: '/pages/goods/order_details/index?order_id=' + order_id
  399. })
  400. })
  401. .catch(err => {
  402. uni.hideLoading();
  403. });
  404. // #endif
  405. // #ifndef MP
  406. uni.navigateTo({
  407. url: '/pages/goods/order_details/index?order_id=' + order_id
  408. });
  409. // #endif
  410. },
  411. /**
  412. * 切换类型
  413. */
  414. statusClick: function(status) {
  415. if(this.loading) return
  416. if (status === this.orderStatus) return;
  417. this.orderStatus = status;
  418. this.loadend = false;
  419. this.page = 1;
  420. this.$set(this, 'orderList', []);
  421. this.getOrderList();
  422. },
  423. /**
  424. * 获取订单列表
  425. */
  426. getOrderList: function() {
  427. let that = this;
  428. if (that.loadend) return;
  429. if (that.loading) return;
  430. that.loading = true;
  431. that.loadTitle = '加载更多';
  432. getOrderList({
  433. type: that.orderStatus,
  434. page: that.page,
  435. limit: that.limit
  436. })
  437. .then(res => {
  438. let list = res.data || [];
  439. let loadend = list.length < that.limit;
  440. that.orderList = that.$util.SplitArray(list, that.orderList);
  441. that.$set(that, 'orderList', that.orderList);
  442. that.loadend = loadend;
  443. that.loading = false;
  444. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  445. that.page = that.page + 1;
  446. })
  447. .catch(err => {
  448. that.loading = false;
  449. that.loadTitle = '加载更多';
  450. });
  451. },
  452. /**
  453. * 删除订单
  454. */
  455. delOrder: function(order_id, index) {
  456. let that = this;
  457. uni.showModal({
  458. title: '删除订单',
  459. content: '确定删除该订单',
  460. success: function (res) {
  461. if (res.confirm) {
  462. orderDel(order_id)
  463. .then(res => {
  464. that.orderList.splice(index, 1);
  465. that.$set(that, 'orderList', that.orderList);
  466. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  467. that.getOrderData();
  468. return that.$util.Tips({
  469. title: '删除成功',
  470. icon: 'success'
  471. });
  472. })
  473. .catch(err => {
  474. return that.$util.Tips({
  475. title: err
  476. });
  477. });
  478. } else if (res.cancel) {
  479. return that.$util.Tips({
  480. title: '已取消'
  481. });
  482. }
  483. }
  484. });
  485. }
  486. },
  487. onReachBottom: function() {
  488. this.getOrderList();
  489. }
  490. };
  491. </script>
  492. <style scoped lang="scss">
  493. .my-order .header {
  494. height: 260rpx;
  495. padding: 0 30rpx;
  496. }
  497. .my-order .header .picTxt {
  498. height: 190rpx;
  499. }
  500. .my-order .header .picTxt .text {
  501. color: rgba(255, 255, 255, 0.8);
  502. font-size: 26rpx;
  503. font-family: 'Guildford Pro';
  504. }
  505. .my-order .header .picTxt .text .name {
  506. font-size: 34rpx;
  507. font-weight: bold;
  508. color: #fff;
  509. margin-bottom: 20rpx;
  510. }
  511. .my-order .header .picTxt .pictrue {
  512. width: 122rpx;
  513. height: 109rpx;
  514. }
  515. .my-order .header .picTxt .pictrue image {
  516. width: 100%;
  517. height: 100%;
  518. }
  519. .my-order .nav {
  520. background-color: #fff;
  521. width: 690rpx;
  522. height: 140rpx;
  523. border-radius: 6rpx;
  524. margin: -73rpx auto 0 auto;
  525. }
  526. .my-order .nav .item {
  527. text-align: center;
  528. font-size: 26rpx;
  529. color: #282828;
  530. padding: 27rpx 0;
  531. border-bottom: 5rpx solid transparent;
  532. }
  533. .my-order .nav .item.on {
  534. /* #ifdef H5 || MP */
  535. font-weight: bold;
  536. /* #endif */
  537. /* #ifdef APP-PLUS */
  538. color: #000;
  539. /* #endif */
  540. border-color: var(--view-theme);
  541. }
  542. .my-order .nav .item .num {
  543. margin-top: 18rpx;
  544. }
  545. .my-order .list {
  546. width: 690rpx;
  547. margin: 14rpx auto 0 auto;
  548. }
  549. .my-order .list .item {
  550. background-color: #fff;
  551. border-radius: 6rpx;
  552. margin-bottom: 14rpx;
  553. }
  554. .my-order .list .item .title {
  555. height: 84rpx;
  556. padding: 0 30rpx;
  557. border-bottom: 1rpx solid #eee;
  558. font-size: 28rpx;
  559. color: #282828;
  560. }
  561. .my-order .list .item .title .sign {
  562. font-size: 24rpx;
  563. padding: 0 7rpx;
  564. height: 36rpx;
  565. margin-right: 15rpx;
  566. }
  567. .my-order .list .item .item-info {
  568. padding: 0 30rpx;
  569. margin-top: 22rpx;
  570. }
  571. .my-order .list .item .item-info .pictrue {
  572. width: 120rpx;
  573. height: 120rpx;
  574. }
  575. .my-order .list .item .item-info .pictrue image {
  576. width: 100%;
  577. height: 100%;
  578. border-radius: 6rpx;
  579. }
  580. .my-order .list .item .item-info .text {
  581. width: 486rpx;
  582. font-size: 28rpx;
  583. color: #999;
  584. }
  585. .my-order .list .item .item-info .text .name {
  586. width: 306rpx;
  587. color: #282828;
  588. height: 74rpx;
  589. }
  590. .my-order .list .item .item-info .text .money {
  591. text-align: right;
  592. }
  593. .my-order .list .item .item-info .text .money .return{
  594. // color: var(--view-priceColor);
  595. margin-top: 10rpx;
  596. font-size: 24rpx;
  597. }
  598. .my-order .list .item .totalPrice {
  599. font-size: 26rpx;
  600. color: #282828;
  601. text-align: right;
  602. margin: 27rpx 0 0 30rpx;
  603. padding: 0 30rpx 30rpx 0;
  604. border-bottom: 1rpx solid #eee;
  605. }
  606. .my-order .list .item .totalPrice .money {
  607. font-size: 28rpx;
  608. font-weight: bold;
  609. color: var(--view-priceColor);
  610. }
  611. .my-order .list .item .bottom {
  612. height: 107rpx;
  613. padding: 0 30rpx;
  614. }
  615. .my-order .list .item .bottom .bnt {
  616. width: 176rpx;
  617. height: 60rpx;
  618. text-align: center;
  619. line-height: 60rpx;
  620. color: #fff;
  621. border-radius: 50rpx;
  622. font-size: 27rpx;
  623. }
  624. .my-order .list .item .bottom .bnt.cancelBnt {
  625. border: 1rpx solid #ddd;
  626. color: #aaa;
  627. }
  628. .my-order .list .item .bottom .bnt~.bnt {
  629. margin-left: 17rpx;
  630. }
  631. .noCart {
  632. margin-top: 171rpx;
  633. padding-top: 0.1rpx;
  634. }
  635. .noCart .pictrue {
  636. width: 414rpx;
  637. height: 336rpx;
  638. margin: 78rpx auto 56rpx auto;
  639. }
  640. .noCart .pictrue image {
  641. width: 100%;
  642. height: 100%;
  643. }
  644. .line2 {
  645. word-break: break-all;
  646. }
  647. </style>