index.vue 18 KB

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