index.vue 18 KB

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