index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="my-order">
  4. <view class="header-group">
  5. <view class="tabs">
  6. <u-tabs :is-scroll="true" :list="navigationList" :current="tabIndex" @change="statusClick()" lineColor="#B22338"
  7. :inactiveStyle="{ color: '#999999' }" :activeStyle="{ color: '#B22338', fontWeight: 'bold' }"
  8. keyName="title"></u-tabs>
  9. </view>
  10. </view>
  11. <swiper :style="{ height: height }" :current="tabIndex" @change="swiperChange">
  12. <swiper-item v-for="(tab, i) in navigationList" :key="i">
  13. <mescroll-item ref="MescrollItem" :i="tabIndex" :index="tabIndex" :tabs="navigationList" :height="height">
  14. </mescroll-item>
  15. </swiper-item>
  16. </swiper>
  17. </view>
  18. <view class="publish">
  19. <button @click="publishGroupon">发布团购</button>
  20. </view>
  21. <!-- #ifndef MP -->
  22. <home></home>
  23. <!-- #endif -->
  24. <payment :payMode="payMode" :pay_close="pay_close" @onChangeFun="onChangeFun" :order_id="pay_order_id"
  25. :totalPrice="totalPrice"></payment>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. getUserOrderPage,
  31. postUserOrderCancel,
  32. postUserOrderRefund
  33. } from '@/api/home.js';
  34. import {
  35. getOrderList,
  36. orderData,
  37. orderCancel,
  38. orderDel,
  39. orderPay
  40. } from '@/api/order.js';
  41. import {
  42. getUserInfo
  43. } from '@/api/user.js';
  44. import {
  45. openOrderSubscribe
  46. } from '@/utils/SubscribeMessage.js';
  47. import home from '@/components/home';
  48. import payment from '@/components/payment';
  49. import {
  50. toLogin
  51. } from '@/libs/login.js';
  52. import {
  53. mapGetters
  54. } from 'vuex';
  55. // #ifdef MP
  56. import authorize from '@/components/Authorize';
  57. // #endif
  58. import emptyPage from '@/components/emptyPage.vue';
  59. import MescrollItem from "./module/mescrollUni-item.vue";
  60. import colors from '@/mixins/color.js';
  61. export default {
  62. components: {
  63. MescrollItem,
  64. payment,
  65. home,
  66. emptyPage,
  67. // #ifdef MP
  68. authorize
  69. // #endif
  70. },
  71. mixins: [colors],
  72. data () {
  73. return {
  74. height:'600px',
  75. tabIndex:0,
  76. navigationList: [{
  77. title: '全部',
  78. id: 0
  79. }
  80. ,
  81. {
  82. title: '申请中',
  83. id: 1
  84. },
  85. {
  86. title: '发布中',
  87. id: 2
  88. },
  89. {
  90. title: '已拒绝',
  91. id: 3
  92. },
  93. {
  94. title: '已结束',
  95. id: 4
  96. },
  97. ],
  98. loading: false, //是否加载中
  99. loadend: false, //是否加载完毕
  100. loadTitle: this.$t(`加载更多`), //提示语
  101. orderList: [], //订单数组
  102. orderData: {}, //订单详细统计
  103. orderStatus: 0, //订单状态
  104. page: 1,
  105. limit: 20,
  106. payMode: [{
  107. name: this.$t(`微信支付`),
  108. icon: 'icon-weixinzhifu',
  109. value: 'weixin',
  110. title: this.$t(`使用微信快捷支付`),
  111. payStatus: true
  112. },
  113. // {
  114. // name: this.$t(`支付宝支付`),
  115. // icon: 'icon-zhifubao',
  116. // value: 'alipay',
  117. // title: this.$t(`使用支付宝支付`),
  118. // payStatus: true
  119. // },
  120. // {
  121. // name: this.$t(`余额支付`),
  122. // icon: 'icon-yuezhifu',
  123. // value: 'yue',
  124. // title: this.$t(`可用余额`),
  125. // number: 0,
  126. // payStatus: true
  127. // }, {
  128. // "name": this.$t(`好友代付`),
  129. // "icon": "icon-haoyoudaizhifu",
  130. // value: 'friend',
  131. // title: this.$t(`找微信好友支付`),
  132. // payStatus: 1,
  133. // }
  134. ],
  135. pay_close: false,
  136. pay_order_id: '',
  137. pay_orderId: '',
  138. totalPrice: '0',
  139. isAuto: false, //没有授权的不会自动授权
  140. isShowAuth: false //是否隐藏授权
  141. };
  142. },
  143. computed: mapGetters(['isLogin']),
  144. onShow () {
  145. if (this.isLogin) {
  146. this.page = 1;
  147. this.orderList = []
  148. this.loadend = false;
  149. this.onLoadFun();
  150. this.getOrderList();
  151. } else {
  152. toLogin();
  153. }
  154. },
  155. methods: {
  156. publishGroupon() {
  157. uni.navigateTo({
  158. url: `/pages/groupbuying/publish_group/index`
  159. })
  160. },
  161. swiperChange(e) {
  162. this.tabIndex = e.detail.current
  163. },
  164. onLoadFun () {
  165. this.getOrderData();
  166. this.getUserInfo();
  167. },
  168. // 授权关闭
  169. authColse: function (e) {
  170. this.isShowAuth = e;
  171. },
  172. /**
  173. * 事件回调
  174. *
  175. */
  176. onChangeFun: function (e) {
  177. let opt = e;
  178. let action = opt.action || null;
  179. let value = opt.value != undefined ? opt.value : null;
  180. action && this[action] && this[action](value);
  181. },
  182. /**
  183. * 获取用户信息
  184. *
  185. */
  186. getUserInfo: function () {
  187. let that = this;
  188. getUserInfo().then(res => {
  189. that.payMode[2].number = res.data.now_money;
  190. that.$set(that, 'payMode', that.payMode);
  191. });
  192. },
  193. /**
  194. * 关闭支付组件
  195. *
  196. */
  197. payClose: function () {
  198. this.pay_close = false;
  199. },
  200. /**
  201. * 生命周期函数--监听页面加载
  202. */
  203. onLoad: function (options) {
  204. if (options.status) this.orderStatus = options.status;
  205. },
  206. /**
  207. * 获取订单统计数据
  208. *
  209. */
  210. getOrderData: function () {
  211. let that = this;
  212. // orderData().then(res => {
  213. // that.$set(that, 'orderData', res.data);
  214. // that.payMode.map(item => {
  215. // if (item.value == 'weixin') {
  216. // item.payStatus = res.data.pay_weixin_open ? true : false;
  217. // }
  218. // if (item.value == 'alipay') {
  219. // item.payStatus = res.data.ali_pay_status ? true : false;
  220. // }
  221. // if (item.value == 'yue') {
  222. // item.payStatus = res.data.yue_pay_status == 1 ? true : false;
  223. // }
  224. // if (item.value == 'friend') {
  225. // item.payStatus = res.data.friend_pay_status == 1 ? true : false;
  226. // }
  227. // });
  228. // //#ifdef MP
  229. // this.payMode[1].payStatus = false;
  230. // //#endif
  231. // });
  232. },
  233. /**
  234. * 取消订单
  235. *
  236. */
  237. cancelOrder: function (index, order_id) {
  238. let that = this;
  239. if (!order_id)
  240. return that.$util.Tips({
  241. title: that.$t(`缺少订单号无法取消订单`)
  242. });
  243. uni.showModal({
  244. title: that.$t(`取消订单`),
  245. content: that.$t(`确定取消该订单`),
  246. success: function (res) {
  247. if (res.confirm) {
  248. postUserOrderCancel({ id: order_id })
  249. .then(res => {
  250. return that.$util.Tips({
  251. title: res.msg,
  252. icon: 'success'
  253. },
  254. function () {
  255. that.orderList.splice(index, 1);
  256. that.$set(that, 'orderList', that.orderList);
  257. // that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  258. // that.getOrderList()
  259. }
  260. );
  261. })
  262. .catch(err => {
  263. return that.$util.Tips({
  264. title: err
  265. });
  266. });
  267. } else if (res.cancel) {
  268. return that.$util.Tips({
  269. title: that.$t(`已取消`)
  270. });
  271. }
  272. }
  273. });
  274. },
  275. refundOrder: function (index, order_id) {
  276. let that = this;
  277. if (!order_id)
  278. return that.$util.Tips({
  279. title: that.$t(`缺少订单号无法申请退款订单`)
  280. });
  281. uni.showModal({
  282. title: that.$t(`申请退款`),
  283. content: that.$t(`确定申请退款该订单`),
  284. success: function (res) {
  285. if (res.confirm) {
  286. postUserOrderRefund({ id: order_id })
  287. .then(res => {
  288. return that.$util.Tips({
  289. title: res.msg,
  290. icon: 'success'
  291. },
  292. function () {
  293. that.orderList.splice(index, 1);
  294. that.$set(that, 'orderList', that.orderList);
  295. // that.$set(that.orderData, 'unpaid_count', that.orderData.unpaid_count - 1);
  296. // that.getOrderData();
  297. // this.getOrderList()
  298. }
  299. );
  300. })
  301. .catch(err => {
  302. return that.$util.Tips({
  303. title: err
  304. });
  305. });
  306. } else if (res.cancel) {
  307. return that.$util.Tips({
  308. title: that.$t(`已取消`)
  309. });
  310. }
  311. }
  312. });
  313. },
  314. /**
  315. * 打开支付组件
  316. *
  317. */
  318. goPay: function (item, order_no) {
  319. this.$set(this, 'pay_close', true);
  320. this.$set(this, 'pay_order_id', order_no);
  321. this.$set(this, 'pay_orderId', item.id);
  322. this.$set(this, 'totalPrice', item.totalFee);
  323. },
  324. /**
  325. * 支付成功回调
  326. *
  327. */
  328. pay_complete: function () {
  329. this.loadend = false;
  330. this.page = 1;
  331. this.$set(this, 'orderList', []);
  332. this.pay_close = false;
  333. uni.navigateTo({
  334. url: '/pages/goods/order_pay_status/index?order_id=' + this.pay_orderId +
  335. '&msg=' + this.$t(`支付成功`) + '&type=3&totalPrice=' + this.totalPrice
  336. })
  337. this.pay_order_id = '';
  338. this.pay_orderId = '';
  339. this.getOrderData();
  340. this.getOrderList();
  341. },
  342. /**
  343. * 支付失败回调
  344. *
  345. */
  346. pay_fail: function () {
  347. this.pay_close = false;
  348. this.pay_order_id = '';
  349. },
  350. /**
  351. * 切换类型
  352. */
  353. statusClick: function (status) {
  354. console.log(status)
  355. console.log(status.index)
  356. this.tabIndex = status.index;
  357. if (status == this.orderStatus) return;
  358. this.orderStatus = status;
  359. this.loadend = false;
  360. this.page = 1;
  361. this.$set(this, 'orderList', []);
  362. this.getOrderList();
  363. },
  364. /**
  365. * 获取订单列表
  366. */
  367. getOrderList: function () {
  368. // let that = this;
  369. // if (that.loadend) return;
  370. // if (that.loading) return;
  371. // that.loading = true;
  372. // that.loadTitle = that.$t(`加载更多`);
  373. // getUserOrderPage({
  374. // userId: this.$store.state.app.uid,
  375. // current: that.page,
  376. // size: that.limit,
  377. // payFlag: this.orderStatus
  378. // })
  379. // .then(res => {
  380. // let list = res.data || [];
  381. // let loadend = list.length < that.limit;
  382. // that.orderList = that.$util.SplitArray(list, that.orderList);
  383. // that.$set(that, 'orderList', that.orderList);
  384. // that.loadend = loadend;
  385. // that.loading = false;
  386. // that.loadTitle = loadend ? that.$t(`没有更多内容啦~`) : that.$t(`加载更多`);
  387. // that.page = that.page + 1;
  388. // })
  389. // .catch(err => {
  390. // that.loading = false;
  391. // that.loadTitle = that.$t(`加载更多`);
  392. // });
  393. },
  394. /**
  395. * 删除订单
  396. */
  397. delOrder: function (order_id, index) {
  398. let that = this;
  399. uni.showModal({
  400. title: that.$t(`删除订单`),
  401. content: that.$t(`确定删除该订单`),
  402. success: function (res) {
  403. if (res.confirm) {
  404. orderDel(order_id)
  405. .then(res => {
  406. that.orderList.splice(index, 1);
  407. that.$set(that, 'orderList', that.orderList);
  408. that.$set(that.orderData, 'unpaid_count', that.orderData
  409. .unpaid_count - 1);
  410. that.getOrderData();
  411. return that.$util.Tips({
  412. title: that.$t(`删除成功`),
  413. icon: 'success'
  414. });
  415. })
  416. .catch(err => {
  417. return that.$util.Tips({
  418. title: err
  419. });
  420. });
  421. } else if (res.cancel) {
  422. return that.$util.Tips({
  423. title: that.$t(`已取消`)
  424. });
  425. }
  426. }
  427. });
  428. }
  429. },
  430. onReachBottom: function () {
  431. this.getOrderList();
  432. }
  433. };
  434. </script>
  435. <style scoped lang="scss">
  436. .my-order .nav {
  437. background-color: #F9F9F9;
  438. width: 100%;
  439. // height: 140rpx;
  440. }
  441. .my-order .nav .item {
  442. text-align: center;
  443. font-size: 26rpx;
  444. color: #282828;
  445. padding: 27rpx 0;
  446. border-bottom: 5rpx solid transparent;
  447. }
  448. .my-order .nav .item.on {
  449. /* #ifdef H5 || MP */
  450. font-weight: bold;
  451. /* #endif */
  452. /* #ifdef APP-PLUS */
  453. color: #000;
  454. /* #endif */
  455. border-color: var(--view-theme);
  456. }
  457. .my-order .nav .item .num {
  458. margin-top: 18rpx;
  459. }
  460. .list {
  461. width: 100%;
  462. background: white;
  463. margin: 14rpx auto 0 auto;
  464. padding-bottom: 30rpx;
  465. }
  466. .noCart {
  467. margin-top: 171rpx;
  468. padding-top: 0.1rpx;
  469. }
  470. .noCart .pictrue {
  471. width: 414rpx;
  472. height: 336rpx;
  473. margin: 78rpx auto 56rpx auto;
  474. }
  475. .noCart .pictrue image {
  476. width: 100%;
  477. height: 100%;
  478. }
  479. .my-order .list .item .item-info .text .money .return {
  480. // color: var(--view-priceColor);
  481. margin-top: 10rpx;
  482. font-size: 24rpx;
  483. }
  484. .myclient_list {
  485. padding: 30rpx;
  486. background: #FFFFFF;
  487. .myclient_list_name {
  488. margin-bottom: 15rpx;
  489. min-height: 44rpx;
  490. font-size: 28rpx;
  491. font-weight: 500;
  492. color: #111111;
  493. line-height: 44rpx;
  494. display: flex;
  495. .nv {
  496. flex-grow: 1;
  497. }
  498. .status {
  499. width: 300rpx;
  500. text-align: right;
  501. margin-left: 30rpx;
  502. color: #75BE00;
  503. }
  504. }
  505. .myclient_list_content {
  506. .subtitle {
  507. height: 44rpx;
  508. margin: 20rpx 0;
  509. font-size: 28rpx;
  510. font-weight: 400;
  511. color: #666666;
  512. line-height: 44rpx;
  513. }
  514. image {
  515. width: 24rpx;
  516. height: 24rpx;
  517. margin-right: 20rpx;
  518. }
  519. .phone {
  520. margin-bottom: 15rpx;
  521. height: 44rpx;
  522. font-size: 24rpx;
  523. font-weight: 400;
  524. color: #999999;
  525. line-height: 44rpx;
  526. }
  527. .time {
  528. height: 44rpx;
  529. font-size: 24rpx;
  530. font-weight: 400;
  531. color: #999999;
  532. line-height: 44rpx;
  533. }
  534. }
  535. }
  536. .all-products-body {
  537. background: white;
  538. .all-products-item {
  539. display: flex;
  540. margin-bottom: 20rpx;
  541. image {
  542. width: 128rpx;
  543. height: 128rpx;
  544. margin-right: 20rpx;
  545. border: 2rpx solid #FFFFFF;
  546. }
  547. .all-products-item-content {
  548. flex-grow: 1;
  549. display: flex;
  550. flex-direction: column;
  551. .all-products-item-content-t {
  552. flex: 1;
  553. font-size: 24rpx;
  554. font-weight: 400;
  555. color: #333333;
  556. line-height: 40rpx;
  557. }
  558. .all-products-item-content-b {
  559. flex: 1;
  560. font-size: 28rpx;
  561. font-weight: 500;
  562. line-height: 80rpx;
  563. display: flex;
  564. justify-content: space-between;
  565. .red {
  566. display: block;
  567. font-size: 28rpx;
  568. font-weight: 500;
  569. color: #B22338 !important;
  570. margin-right: 10rpx;
  571. }
  572. .line-thr {
  573. display: block;
  574. font-size: 28rpx;
  575. font-weight: 400;
  576. color: #999999;
  577. text-decoration: line-through;
  578. }
  579. .count {
  580. font-size: 24rpx;
  581. font-weight: 400;
  582. color: #999999;
  583. margin-right: 30rpx;
  584. }
  585. }
  586. }
  587. }
  588. }
  589. .a-t {
  590. padding: 0 30rpx;
  591. display: flex;
  592. justify-content: space-between;
  593. height: 44rpx;
  594. margin-bottom: 20rpx;
  595. }
  596. .a-m {
  597. padding: 0 30rpx;
  598. .am1 {
  599. display: flex;
  600. justify-content: space-between;
  601. margin-bottom: 20rpx;
  602. .am1-1 {
  603. height: 40rpx;
  604. font-size: 28rpx;
  605. font-weight: 400;
  606. color: #111111;
  607. line-height: 40rpx;
  608. }
  609. .am1-2 {
  610. height: 36rpx;
  611. font-size: 20rpx;
  612. font-weight: 400;
  613. color: #666666;
  614. line-height: 36rpx;
  615. image {
  616. margin-left: 30rpx;
  617. vertical-align: middle;
  618. height: 34rpx;
  619. width: 34rpx;
  620. }
  621. }
  622. }
  623. .am2 {
  624. margin-bottom: 20rpx;
  625. height: 34rpx;
  626. font-size: 24rpx;
  627. font-weight: 400;
  628. color: #999999;
  629. line-height: 34rpx;
  630. }
  631. }
  632. .a-b {
  633. padding: 0 30rpx;
  634. width: 100%;
  635. background: #FFF7F8;
  636. border: 1px solid dashed #333333;
  637. height: 60rpx;
  638. line-height: 60rpx;
  639. display: flex;
  640. justify-content: space-between;
  641. .a-b1 {
  642. font-size: 20rpx;
  643. font-weight: 400;
  644. color: #666666;
  645. .red {
  646. font-size: 20rpx;
  647. font-weight: 500;
  648. color: #B22338;
  649. }
  650. }
  651. .a-b2 {
  652. image {
  653. vertical-align: middle;
  654. margin-right: 30rpx;
  655. margin-left: 30rpx;
  656. height: 34rpx;
  657. width: 34rpx;
  658. }
  659. }
  660. }
  661. .self-pickup-point {
  662. background: #FFF7F8;
  663. margin: 0 30rpx;
  664. }
  665. .op-area {
  666. height: 120rpx;
  667. display: flex;
  668. justify-content: flex-end;
  669. line-height: 120rpx;
  670. padding: 20rpx 0;
  671. text-align: right;
  672. .action-btn {
  673. min-width: 200rpx;
  674. background: #FFF7F8;
  675. border-radius: 32rpx;
  676. border: 2rpx solid #B22338;
  677. margin-right: 30rpx;
  678. height: 64rpx;
  679. font-size: 24rpx;
  680. font-weight: 400;
  681. color: #B22338;
  682. line-height: 64rpx;
  683. }
  684. .info-btn {
  685. width: 200rpx;
  686. background: #F5F5F5;
  687. border-radius: 32rpx;
  688. margin-right: 30rpx;
  689. height: 64rpx;
  690. font-size: 24rpx;
  691. font-weight: 400;
  692. color: #666666;
  693. line-height: 64rpx;
  694. }
  695. }
  696. .Ended {
  697. color: #666666 !important;
  698. }
  699. .Refused {
  700. color: #B42A3E !important;
  701. }
  702. .publish {
  703. position: fixed;
  704. bottom: 0;
  705. height: 100rpx;
  706. width: 100%;
  707. background: #F9F9F9;
  708. button {
  709. width: 90%;
  710. height: 84rpx;
  711. background: #B42A3E;
  712. border-radius: 8rpx;
  713. position: relative;
  714. top: 0;
  715. margin: auto;
  716. font-size: 28rpx;
  717. font-weight: 400;
  718. color: #FFFFFF;
  719. line-height: 84rpx;
  720. }
  721. }
  722. </style>