ygOrder.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="my-order">
  4. <view class="nav acea-row row-around" style="position: fixed;top: 0;">
  5. <view class="item" :class="orderStatus === 0 ? 'on' : ''" @click="statusClick(0)">
  6. <view>待服务</view>
  7. <!-- <view class="num">{{ orderData.order_count || 0 }}</view> -->
  8. </view>
  9. <!-- <view class="item" :class="orderStatus === 1 ? 'on' : ''" @click="statusClick(1)">
  10. <view>进行中</view>
  11. </view> -->
  12. <view class="item" :class="orderStatus == 2 ? 'on' : ''" @click="statusClick(2)">
  13. <view>已完成</view>
  14. <!-- <view class="num">{{ orderData.unshipped_count || 0 }}</view> -->
  15. </view>
  16. <view class="item" :class="orderStatus == 3 ? 'on' : ''" @click="statusClick(3)">
  17. <view>已退款</view>
  18. <!-- <view class="num ">{{ orderData.received_count || 0 }}</view> -->
  19. </view>
  20. </view>
  21. <view class="nav">
  22. </view>
  23. <Loading :loaded="loaded" :loading="loading"></Loading>
  24. <view class="list">
  25. <view class="item" v-for="(item, index) in orderList" :key="index" v-if="showOrder(item)">
  26. <view >
  27. <view class="title acea-row row-between-wrapper">
  28. <view class="acea-row row-middle">
  29. 订单ID:{{item.order_id}}
  30. </view>
  31. </view>
  32. <view class="item-info acea-row row-between row-top" v-for="(items, index) in item.info"
  33. :key="index">
  34. <view class="pictrue">
  35. <image :src="items.slider_image"></image>
  36. </view>
  37. <view class="text acea-row row-between">
  38. <view class="name line2">{{ items.store_name }}</view>
  39. <view class="money">
  40. <view >¥{{ items.pay_price }}</view>
  41. <view>x1</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="totalPrice showstore">
  46. <view class="">
  47. 下单时间: {{ showTime(item.add_time) }}
  48. </view>
  49. <view class="">
  50. 预约时间: {{ showTime(item.reservation_time) }}
  51. </view>
  52. </view>
  53. <view class="totalPrice">
  54. 共{{ item.info.length || 0 }}件商品,总金额
  55. <text class="money">¥{{ showTolPrice(item.info) }}</text>
  56. </view>
  57. </view>
  58. <view class="bottom acea-row row-right row-middle" >
  59. <view class="bnt bg-color" v-if="item.status == 0"
  60. @click="goEnd(item,index)">完成订单</view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="loadingicon acea-row row-center-wrapper" v-if="orderList.length > 0">
  65. <text class="loading iconfont icon-jiazai" :hidden="loading == false"></text>
  66. {{ loadTitle }}
  67. </view>
  68. <view v-if="orderList.length == 0 && !loading">
  69. <emptyPage title="暂无订单信息~"></emptyPage>
  70. </view>
  71. </view>
  72. <home v-if="navigation"></home>
  73. </view>
  74. </template>
  75. <script>
  76. import {
  77. getOrderList,
  78. orderData,
  79. orderCancel,
  80. orderDel,
  81. orderPay,
  82. storecompleteSubscribe
  83. } from '@/api/order.js';
  84. import {
  85. getUserInfo,
  86. orderSubscribe
  87. } from '@/api/user.js';
  88. import {
  89. openOrderSubscribe
  90. } from '@/utils/SubscribeMessage.js';
  91. import home from '@/components/home';
  92. import payment from '@/components/payment';
  93. import {
  94. toLogin
  95. } from '@/libs/login.js';
  96. import {
  97. mapGetters
  98. } from 'vuex';
  99. import emptyPage from '@/components/emptyPage.vue';
  100. import colors from '@/mixins/color.js';
  101. import Loading from '@/components/Loading/index.vue'
  102. export default {
  103. components: {
  104. Loading,
  105. payment,
  106. home,
  107. emptyPage
  108. },
  109. mixins:[colors],
  110. data() {
  111. return {
  112. loaded: false,
  113. loading: false, //是否加载中
  114. loadend: false, //是否加载完毕
  115. loadTitle: '加载更多', //提示语
  116. orderList: [], //订单数组
  117. orderData: {}, //订单详细统计
  118. orderStatus: 0, //订单状态
  119. page: 1,
  120. limit: 20,
  121. payMode: [{
  122. name: '微信支付',
  123. icon: 'icon-weixinzhifu',
  124. value: 'weixin',
  125. title: '使用微信快捷支付',
  126. payStatus: true
  127. },
  128. {
  129. name: '支付宝支付',
  130. icon: 'icon-zhifubao',
  131. value: 'alipay',
  132. title: '使用线上支付宝支付',
  133. payStatus: true
  134. },
  135. {
  136. name: '余额支付',
  137. icon: 'icon-yuezhifu',
  138. value: 'yue',
  139. title: '当前可用余额:',
  140. number: 0,
  141. payStatus: true
  142. }
  143. ],
  144. pay_close: false,
  145. pay_order_id: '',
  146. totalPrice: '0',
  147. isAuto: false, //没有授权的不会自动授权
  148. isShowAuth: false //是否隐藏授权
  149. };
  150. },
  151. computed: mapGetters(['isLogin']),
  152. onShow() {
  153. uni.removeStorageSync('form_type_cart');
  154. this.page = 1;
  155. this.loadend = false;
  156. this.orderList = [];
  157. if (this.isLogin) {
  158. this.getFun();
  159. } else {
  160. toLogin()
  161. }
  162. },
  163. /**
  164. * 生命周期函数--监听页面加载
  165. */
  166. onLoad(options) {
  167. if (options.status) this.orderStatus = (options.status==undefined && options.status!=0)?'':parseInt(options.status);
  168. },
  169. methods: {
  170. showOrder(item) {
  171. return item.info[0].paid != 0
  172. },
  173. showTime(time) {
  174. var date = new Date(time*1000);
  175. var year = date.getFullYear(); // 获取年份
  176. var month = ("0" + (date.getMonth() + 1)).slice(-2); // 获取月份(注意月份从 0 开始,需要加 1)
  177. var day = ("0" + date.getDate()).slice(-2); // 获取日期
  178. var hours = ("0" + date.getHours()).slice(-2); // 获取小时
  179. var minutes = ("0" + date.getMinutes()).slice(-2); // 获取分钟
  180. var seconds = ("0" + date.getSeconds()).slice(-2); // 获取秒钟
  181. var dateString = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds; // 自定义时间格式
  182. return dateString
  183. },
  184. showTolPrice(list) {
  185. let price = 0;
  186. list.forEach(item => {
  187. price += item.pay_price*1
  188. })
  189. return price.toFixed(2)
  190. },
  191. getFun(){
  192. // this.getOrderData();
  193. this.getUserInfo();
  194. },
  195. /**
  196. * 获取用户信息
  197. *
  198. */
  199. getUserInfo: function() {
  200. let that = this;
  201. getUserInfo().then(res => {
  202. that.userInfo = res.data
  203. that.getOrderList();
  204. that.payMode[2].number = res.data.now_money;
  205. that.$set(that, 'payMode', that.payMode);
  206. });
  207. },
  208. /**
  209. * 获取订单统计数据
  210. *
  211. */
  212. getOrderData: function() {
  213. let that = this;
  214. orderData().then(res => {
  215. that.$set(that, 'orderData', res.data);
  216. that.payMode.map(item => {
  217. if (item.value == 'weixin') {
  218. item.payStatus = res.data.pay_weixin_open ? true : false;
  219. }
  220. if (item.value == 'alipay') {
  221. item.payStatus = res.data.ali_pay_status ? true : false;
  222. }
  223. if (item.value == 'yue') {
  224. item.payStatus = res.data.yue_pay_status == 1 ? true : false;
  225. }
  226. });
  227. //#ifdef MP
  228. this.payMode[1].payStatus = false;
  229. //#endif
  230. });
  231. },
  232. goEnd(item,index) {
  233. let that = this;
  234. uni.showModal({
  235. title: '完成订单',
  236. content: '您是否确认完成此订单',
  237. confirmText: '确认',
  238. cancelText: '取消',
  239. success: (res) => {
  240. if (res.confirm) {
  241. storecompleteSubscribe({
  242. order_id: item.order_id
  243. })
  244. .then(res => {
  245. return that.$util.Tips({
  246. title: res.msg,
  247. icon: 'success'
  248. },
  249. function() {
  250. that.orderList.splice(index, 1);
  251. that.$set(that, 'orderList', that.orderList);
  252. that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  253. that.getOrderData();
  254. }
  255. );
  256. })
  257. .catch(err => {
  258. return that.$util.Tips({
  259. title: err
  260. });
  261. });
  262. }
  263. }
  264. })
  265. },
  266. /**
  267. * 切换类型
  268. */
  269. statusClick: function(status) {
  270. if(this.loading) return
  271. if (status === this.orderStatus) return;
  272. this.orderStatus = status;
  273. this.loadend = false;
  274. this.page = 1;
  275. this.$set(this, 'orderList', []);
  276. this.getOrderList();
  277. },
  278. /**
  279. * 获取订单列表
  280. */
  281. getOrderList: function() {
  282. let that = this;
  283. if (that.loadend) return;
  284. if (that.loading) return;
  285. that.loading = true;
  286. that.loadTitle = '加载更多';
  287. orderSubscribe({
  288. // work_member_id: 5,
  289. status: that.orderStatus,
  290. page: that.page,
  291. limit: that.limit
  292. })
  293. .then(res => {
  294. let list = res.data.list || [];
  295. console.log(list,'list')
  296. if(that.orderStatus == 0) {
  297. that.orderData.order_count = res.data.count;
  298. }else if(that.orderStatus == 1) {
  299. that.orderData.unpaid_count = res.data.count;
  300. }else if(that.orderStatus == 2) {
  301. that.orderData.unshipped_count = res.data.count;
  302. }else if(that.orderStatus == 3) {
  303. that.orderData.received_count = res.data.count;
  304. }
  305. let loadend = list.length < that.limit;
  306. that.orderList = that.$util.SplitArray(list, that.orderList);
  307. that.$set(that, 'orderList', that.orderList);
  308. that.loadend = loadend;
  309. that.loading = false;
  310. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  311. that.page = that.page + 1;
  312. })
  313. .catch(err => {
  314. that.loading = false;
  315. that.loadTitle = '加载更多';
  316. });
  317. },
  318. },
  319. onReachBottom: function() {
  320. this.getOrderList();
  321. }
  322. };
  323. </script>
  324. <style scoped lang="scss">
  325. .my-order .header {
  326. height: 260rpx;
  327. padding: 0 30rpx;
  328. }
  329. .my-order .header .picTxt {
  330. height: 190rpx;
  331. }
  332. .my-order .header .picTxt .text {
  333. color: rgba(255, 255, 255, 0.8);
  334. font-size: 26rpx;
  335. font-family: 'Guildford Pro';
  336. }
  337. .my-order .header .picTxt .text .name {
  338. font-size: 34rpx;
  339. font-weight: bold;
  340. color: #fff;
  341. margin-bottom: 20rpx;
  342. }
  343. .my-order .header .picTxt .pictrue {
  344. width: 122rpx;
  345. height: 109rpx;
  346. }
  347. .my-order .header .picTxt .pictrue image {
  348. width: 100%;
  349. height: 100%;
  350. }
  351. .my-order .nav {
  352. background-color: #fff;
  353. width: 750rpx;
  354. height: 90rpx;
  355. border-radius: 6rpx;
  356. margin: 0 auto ;
  357. }
  358. .my-order .nav .item {
  359. text-align: center;
  360. font-size: 26rpx;
  361. color: #282828;
  362. padding: 27rpx 0;
  363. border-bottom: 5rpx solid transparent;
  364. }
  365. .my-order .nav .item.on {
  366. /* #ifdef H5 || MP */
  367. font-weight: bold;
  368. /* #endif */
  369. /* #ifdef APP-PLUS */
  370. color: #000;
  371. /* #endif */
  372. border-color: var(--view-theme);
  373. }
  374. .my-order .nav .item .num {
  375. margin-top: 18rpx;
  376. }
  377. .my-order .list {
  378. width: 690rpx;
  379. margin: 14rpx auto 0 auto;
  380. }
  381. .my-order .list .item {
  382. background-color: #fff;
  383. border-radius: 6rpx;
  384. margin-bottom: 14rpx;
  385. }
  386. .my-order .list .item .title {
  387. height: 84rpx;
  388. padding: 0 30rpx;
  389. border-bottom: 1rpx solid #eee;
  390. font-size: 28rpx;
  391. color: #282828;
  392. }
  393. .my-order .list .item .title .sign {
  394. font-size: 24rpx;
  395. padding: 0 7rpx;
  396. height: 36rpx;
  397. margin-right: 15rpx;
  398. }
  399. .my-order .list .item .item-info {
  400. padding: 0 30rpx;
  401. margin-top: 22rpx;
  402. }
  403. .my-order .list .item .item-info .pictrue {
  404. width: 120rpx;
  405. height: 120rpx;
  406. }
  407. .my-order .list .item .item-info .pictrue image {
  408. width: 100%;
  409. height: 100%;
  410. border-radius: 6rpx;
  411. }
  412. .my-order .list .item .item-info .text {
  413. width: 486rpx;
  414. font-size: 28rpx;
  415. color: #999;
  416. }
  417. .my-order .list .item .item-info .text .name {
  418. width: 306rpx;
  419. color: #282828;
  420. height: 74rpx;
  421. }
  422. .my-order .list .item .item-info .text .money {
  423. text-align: right;
  424. }
  425. .my-order .list .item .item-info .text .money .return{
  426. // color: var(--view-priceColor);
  427. margin-top: 10rpx;
  428. font-size: 24rpx;
  429. }
  430. .my-order .list .item .totalPrice {
  431. font-size: 26rpx;
  432. color: #282828;
  433. text-align: right;
  434. margin: 27rpx 0 0 30rpx;
  435. padding: 0 30rpx 30rpx 0;
  436. border-bottom: 1rpx solid #eee;
  437. }
  438. .my-order .list .item .totalPrice .money {
  439. font-size: 28rpx;
  440. font-weight: bold;
  441. color: var(--view-priceColor);
  442. }
  443. .my-order .list .item .bottom {
  444. height: 107rpx;
  445. padding: 0 30rpx;
  446. }
  447. .my-order .list .item .bottom .bnt {
  448. width: 176rpx;
  449. height: 60rpx;
  450. text-align: center;
  451. line-height: 60rpx;
  452. color: #fff;
  453. border-radius: 50rpx;
  454. font-size: 27rpx;
  455. }
  456. .my-order .list .item .bottom .bnt.cancelBnt {
  457. border: 1rpx solid #ddd;
  458. color: #aaa;
  459. }
  460. .my-order .list .item .bottom .bnt~.bnt {
  461. margin-left: 17rpx;
  462. }
  463. .noCart {
  464. margin-top: 171rpx;
  465. padding-top: 0.1rpx;
  466. }
  467. .noCart .pictrue {
  468. width: 414rpx;
  469. height: 336rpx;
  470. margin: 78rpx auto 56rpx auto;
  471. }
  472. .noCart .pictrue image {
  473. width: 100%;
  474. height: 100%;
  475. }
  476. .line2 {
  477. word-break: break-all;
  478. }
  479. .showstore {
  480. border-bottom: none !important;
  481. text-align: left !important;
  482. padding-bottom: 10rpx !important;
  483. }
  484. .icon {
  485. .iconfont {
  486. width: 44rpx;
  487. height: 44rpx;
  488. background: var(--view-minorColorT);
  489. font-size: 20rpx;
  490. border-radius: 50%;
  491. text-align: center;
  492. line-height: 44rpx;
  493. color: var(--view-theme);
  494. margin-left: 26rpx;
  495. }
  496. }
  497. </style>