ygOrder.vue 18 KB

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