myaid.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view>
  6. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view @click="goToOrderDetail(item)" v-for="(item, index) in tabItem.orderList" :key="index" class="order-item">
  13. <view class="item-top flex">
  14. <view class="item-number">
  15. 项目编号:{{item.numb}}
  16. </view>
  17. <view class="item-status" v-if="item.status === 1" style="color: #FA7E67;">审核中</view>
  18. <view class="item-status" v-if="item.status === 2" style="color: #FA7E67;">进行中</view>
  19. <view class="item-status" v-if="item.status === 3" style="color: #FA7E67;">已完成</view>
  20. <view class="item-status" v-if="item.status === 4" style="color: #999999">已失败</view>
  21. </view>
  22. <view class="item-main flex">
  23. <image src="" mode=""></image>
  24. <view class="item-info">
  25. <view class="info-title">
  26. {{item.title}}
  27. </view>
  28. <view class="info-content">
  29. 项目进度:您的捐赠{{item.status === 1 ? '正在审核中,请耐心等待':item.status !== 4 ? ' 审核未通过,感谢您的爱心!' : '审核已通过' }}
  30. </view>
  31. <view class="info-time">
  32. 申请时间{{item.add_time}}
  33. </view>
  34. </view>
  35. </view>
  36. <view class="item-bottom flex" v-if="item.status !== 4 && item.status !== 1">
  37. <view class="yxs" @click="navTo('/pages/user/intent')">
  38. 捐献意向书
  39. </view>
  40. <view class="zs" @click="navTo('/pages/user/thank')">
  41. 捐赠证书
  42. </view>
  43. </view>
  44. </view>
  45. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  46. </scroll-view>
  47. </swiper-item>
  48. </swiper>
  49. </view>
  50. </template>
  51. <script>
  52. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  53. import empty from '@/components/empty';
  54. import { mapState } from 'vuex';
  55. import { saveUrl } from '@/utils/loginUtils.js';
  56. import { orderList, orderCancel, orderDel, orderTake } from '@/api/order.js';
  57. import { getProjectInfo, createProject, getDonationInfo, getMyorder} from '../../api/money.js';
  58. export default {
  59. filters: {
  60. },
  61. components: {
  62. uniLoadMore,
  63. empty
  64. },
  65. data() {
  66. return {
  67. tabCurrentIndex: 0,
  68. state: '',
  69. showModal: false,
  70. navList: [
  71. {
  72. state: -2,
  73. text: '全部',
  74. loadingType: 'more',
  75. orderList: [
  76. {
  77. numb: 1234567890,
  78. status: 2,
  79. img: '',
  80. title: '夏天的清凉',
  81. add_time: '2021-06-10',
  82. }
  83. ],
  84. page: 1, //当前页数
  85. limit: 10 //每次信息条数
  86. },
  87. {
  88. state: -1,
  89. text: '审核中',
  90. loadingType: 'more',
  91. orderList: [],
  92. page: 1, //当前页数
  93. limit: 10 //每次信息条数
  94. },
  95. {
  96. state: 0,
  97. text: '进行中',
  98. loadingType: 'more',
  99. orderList: [],
  100. page: 1, //当前页数
  101. limit: 10 //每次信息条数
  102. },
  103. {
  104. state: 1,
  105. text: '已完成',
  106. loadingType: 'more',
  107. orderList: [],
  108. page: 1, //当前页数
  109. limit: 10 //每次信息条数
  110. }
  111. ]
  112. };
  113. },
  114. onLoad(options) {
  115. this.state = options.state;
  116. saveUrl();
  117. /**
  118. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  119. * 替换onLoad下代码即可
  120. */
  121. this.tabCurrentIndex = +options.state;
  122. // #ifndef MP
  123. this.loadData();
  124. // #endif
  125. // #ifdef MP
  126. if (options.state == 0) {
  127. this.loadData();
  128. }
  129. // #endif
  130. this.getMyorder()
  131. },
  132. computed: {
  133. ...mapState(['userInfo'])
  134. },
  135. methods: {
  136. // 确认收货
  137. orderTake(item, index) {
  138. let obj = this;
  139. uni.showModal({
  140. title: '是否确认收货?',
  141. success: function(res) {
  142. if (res.confirm) {
  143. orderTake({
  144. uni: item.order_id
  145. })
  146. .then(e => {
  147. obj.navList[obj.tabCurrentIndex].orderList.splice(index, 1);
  148. uni.showToast({
  149. title: '收货成功',
  150. icon: 'none'
  151. });
  152. })
  153. .catch(e => {
  154. console.log(e);
  155. });
  156. } else if (res.cancel) {
  157. console.log('用户点击取消');
  158. }
  159. }
  160. });
  161. },
  162. // 跳转到查询快递页面
  163. expressCheck(item) {
  164. uni.navigateTo({
  165. url: '/pages/order/expressInfo?id=' + item.id
  166. });
  167. },
  168. //跳转到订单详情
  169. goToOrderDetail(e) {
  170. uni.navigateTo({
  171. url: '/pages/order/orderDetail?id=' + e.order_id
  172. });
  173. },
  174. //分享
  175. share(e) {
  176. console.log(e);
  177. uni.navigateTo({
  178. url: '/pages/product/details?pink_id=' + e.pink_id
  179. });
  180. },
  181. // 申请退款
  182. orderRefund(e) {
  183. uni.navigateTo({
  184. url: '/pages/order/orderRefund?id=' + e.order_id
  185. });
  186. },
  187. // 订单支付
  188. orderPay(e) {
  189. if (e.combination_id > 0) {
  190. uni.navigateTo({
  191. url: '/pages/money/pay?type=1&ordid=' + e.order_id + '&money=' + e.pay_price + '&goodsType=2'
  192. });
  193. } else {
  194. uni.navigateTo({
  195. url: '/pages/money/pay?type=1&ordid=' + e.order_id + '&money=' + e.pay_price
  196. });
  197. }
  198. },
  199. //获取订单列表
  200. loadData(source) {
  201. //这里是将订单挂载到tab列表下
  202. let index = this.tabCurrentIndex;
  203. let navItem = this.navList[index];
  204. let state = navItem.state;
  205. if (source === 'tabChange' && navItem.loaded === true) {
  206. //tab切换只有第一次需要加载数据
  207. return;
  208. }
  209. if (navItem.loadingType === 'loading') {
  210. //防止重复加载
  211. return;
  212. }
  213. if (navItem.loadingType === 'noMore') {
  214. //防止重复加载
  215. return;
  216. }
  217. // 修改当前对象状态为加载中
  218. navItem.loadingType = 'loading';
  219. getMyorder({
  220. page: navItem.page,
  221. limit: navItem.limit,
  222. status: navItem.state
  223. })
  224. // orderList({
  225. // type: state,
  226. // page: navItem.page,
  227. // limit: navItem.limit
  228. // })
  229. // .then(({ data }) => {
  230. // let arr = data.map(e => {
  231. // let b = this.orderStateExp(e.status);
  232. // e.stateTip = b.stateTip;
  233. // e.stateTipColor = b.stateTipColor;
  234. // return e;
  235. // });
  236. // navItem.orderList = navItem.orderList.concat(arr);
  237. // // console.log(navItem.orderList);
  238. // navItem.page++;
  239. // if (navItem.limit == data.length) {
  240. // //判断是否还有数据, 有改为 more, 没有改为noMore
  241. // navItem.loadingType = 'more';
  242. // return;
  243. // } else {
  244. // //判断是否还有数据, 有改为 more, 没有改为noMore
  245. // navItem.loadingType = 'noMore';
  246. // }
  247. // this.$set(navItem, 'loaded', true);
  248. // })
  249. // .catch(e => {
  250. // console.log(e);
  251. // });
  252. },
  253. //swiper 切换
  254. changeTab(e) {
  255. this.tabCurrentIndex = e.target.current;
  256. this.loadData('tabChange');
  257. },
  258. //顶部tab点击
  259. tabClick(index) {
  260. this.tabCurrentIndex = index;
  261. this.loadData('tabChange');
  262. },
  263. //删除订单
  264. deleteOrder(item, index) {
  265. uni.showModal({
  266. content: '是否确认删除订单?',
  267. success: res => {
  268. uni.showLoading({
  269. title: '请稍后'
  270. });
  271. setTimeout((e) => {
  272. orderDel({
  273. uni: item.order_id
  274. })
  275. .then(e => {
  276. this.navList[this.tabCurrentIndex].orderList.splice(index, 1);
  277. uni.hideLoading();
  278. })
  279. .catch(e => {
  280. console.log(e);
  281. uni.hideLoading();
  282. });
  283. },1000)
  284. },
  285. fail: e => {
  286. console.log(e);
  287. }
  288. });
  289. },
  290. //订单状态文字和颜色
  291. orderStateExp(state) {
  292. let stateTip = '',
  293. stateTipColor = '#EF041F';
  294. switch (+state) {
  295. case 0:
  296. stateTip = '全部';
  297. break;
  298. case 1:
  299. stateTip = '待付款';
  300. break;
  301. case 2:
  302. stateTip = '待发货';
  303. break;
  304. case 3:
  305. stateTip = '待收货';
  306. break;
  307. case 4:
  308. stateTip = '已完成';
  309. stateTipColor = '#5dbc7c';
  310. break;
  311. case 9:
  312. stateTip = '订单已关闭';
  313. stateTipColor = '#909399';
  314. break;
  315. //更多自定义
  316. }
  317. return { stateTip, stateTipColor };
  318. },
  319. navTo(url) {
  320. uni.navigateTo({
  321. url: url
  322. })
  323. },
  324. getMyorder() {
  325. getMyorder({
  326. status: 2
  327. }).then(res => {
  328. console.log(res,'88888888888')
  329. })
  330. }
  331. }
  332. };
  333. </script>
  334. <style lang="scss">
  335. page,
  336. .content {
  337. background: $page-color-base;
  338. height: 100%;
  339. }
  340. .swiper-box {
  341. height: calc(100% - 40px);
  342. // padding: 0 20rpx;
  343. }
  344. .list-scroll-content {
  345. height: 100%;
  346. }
  347. .navbar {
  348. display: flex;
  349. height: 40px;
  350. padding: 0 5px;
  351. background: #fff;
  352. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  353. position: relative;
  354. z-index: 10;
  355. .nav-item {
  356. flex: 1;
  357. display: flex;
  358. justify-content: center;
  359. align-items: center;
  360. height: 100%;
  361. font-size: 15px;
  362. color: $font-color-dark;
  363. position: relative;
  364. &.current {
  365. color: #FF0000;
  366. &:after {
  367. content: '';
  368. position: absolute;
  369. left: 50%;
  370. bottom: 0;
  371. transform: translateX(-50%);
  372. width: 44px;
  373. height: 0;
  374. border-bottom: 2px solid #FF0000;
  375. }
  376. }
  377. }
  378. }
  379. .uni-swiper-item {
  380. height: auto;
  381. }
  382. .order-item {
  383. background-color: #fff;
  384. padding: 0 20rpx;
  385. .item-top {
  386. justify-content: space-between;
  387. height: 79rpx;
  388. border-bottom: 1px solid #E1E1E5;
  389. line-height: 79rpx;
  390. font-size: 26rpx;
  391. font-family: PingFang SC;
  392. font-weight: bold;
  393. color: #333333;
  394. }
  395. .item-main {
  396. height: 210rpx;
  397. align-items: center;
  398. image {
  399. width: 220rpx;
  400. height: 170rpx;
  401. background: #FFFFFF;
  402. border: 1px solid #DDDDDD;
  403. border-radius: 10rpx;
  404. margin: 18rpx;
  405. }
  406. .item-info {
  407. width: 471rpx;
  408. height: 170rpx;
  409. position: relative;
  410. .info-title {
  411. font-size: 32rpx;
  412. font-family: PingFang SC;
  413. font-weight: bold;
  414. color: #323232;
  415. line-height: 1;
  416. // position: absolute;
  417. // top: 0;
  418. }
  419. .info-content {
  420. padding-top: 14rpx;
  421. font-size: 22rpx;
  422. font-family: PingFang SC;
  423. font-weight: 500;
  424. color: #666666;
  425. line-height: 1.5;
  426. }
  427. .info-time {
  428. font-size: 22rpx;
  429. font-family: PingFang SC;
  430. font-weight: 500;
  431. color: #999999;
  432. position: absolute;
  433. right: 0;
  434. bottom: 0;
  435. }
  436. }
  437. }
  438. .item-bottom {
  439. height: 96rpx;
  440. border-top: 1px solid #E1E1E5;
  441. justify-content: flex-end;
  442. align-items: center;
  443. view {
  444. width: 144rpx;
  445. height: 55rpx;
  446. line-height: 55rpx;
  447. text-align: center;
  448. border-radius: 28rpx;
  449. font-size: 24rpx;
  450. font-family: PingFang SC;
  451. font-weight: 500;
  452. }
  453. .yxs {
  454. border: 2px solid #FA7E67;
  455. color: #FA7E67;
  456. line-height: 50rpx;
  457. }
  458. .zs {
  459. background: #FA7E67;
  460. color: #fff;
  461. margin-left: 15rpx;
  462. }
  463. }
  464. }
  465. // 积分投注弹窗
  466. .mask {
  467. z-index: 10;
  468. position: fixed;
  469. top: 0;
  470. right: 0;
  471. bottom: 0;
  472. left: 0;
  473. background-color: rgba(0, 0, 0, 0.5);
  474. width: 100%;
  475. height: 100%;
  476. display: flex;
  477. justify-content: center;
  478. align-items: center;
  479. flex-direction: column;
  480. .pop {
  481. z-index: 12;
  482. width: 560rpx;
  483. height: 379rpx;
  484. background: rgba(255, 255, 255, 1);
  485. border-radius: 30px;
  486. .pop-box {
  487. width: 100%;
  488. height: 100%;
  489. display: flex;
  490. flex-direction: column;
  491. text-align: center;
  492. align-items: center;
  493. margin-top: -72rpx !important;
  494. .pop-img {
  495. width: 177rpx;
  496. height: 186rpx;
  497. margin-bottom: 34rpx;
  498. }
  499. .pop-title {
  500. height: 34rpx;
  501. font-size: 36rpx;
  502. font-weight: 500;
  503. color: rgba(51, 51, 51, 1);
  504. margin-bottom: 32rpx;
  505. }
  506. .number {
  507. width: 454rpx;
  508. height: 78rpx;
  509. background: rgba(234, 234, 234, 1);
  510. background: #eaeaea;
  511. }
  512. }
  513. //关闭按钮
  514. .close-box {
  515. margin-top: 130rpx;
  516. text-align: center;
  517. .close {
  518. width: 83rpx;
  519. height: 83rpx;
  520. }
  521. }
  522. }
  523. }
  524. /* load-more */
  525. .uni-load-more {
  526. display: flex;
  527. flex-direction: row;
  528. height: 80rpx;
  529. align-items: center;
  530. justify-content: center;
  531. }
  532. .uni-load-more__text {
  533. font-size: 28rpx;
  534. color: #999;
  535. }
  536. .uni-load-more__img {
  537. height: 24px;
  538. width: 24px;
  539. margin-right: 10px;
  540. }
  541. .uni-load-more__img > view {
  542. position: absolute;
  543. }
  544. .uni-load-more__img > view view {
  545. width: 6px;
  546. height: 2px;
  547. border-top-left-radius: 1px;
  548. border-bottom-left-radius: 1px;
  549. background: #999;
  550. position: absolute;
  551. opacity: 0.2;
  552. transform-origin: 50%;
  553. animation: load 1.56s ease infinite;
  554. }
  555. .uni-load-more__img > view view:nth-child(1) {
  556. transform: rotate(90deg);
  557. top: 2px;
  558. left: 9px;
  559. }
  560. .uni-load-more__img > view view:nth-child(2) {
  561. transform: rotate(180deg);
  562. top: 11px;
  563. right: 0;
  564. }
  565. .uni-load-more__img > view view:nth-child(3) {
  566. transform: rotate(270deg);
  567. bottom: 2px;
  568. left: 9px;
  569. }
  570. .uni-load-more__img > view view:nth-child(4) {
  571. top: 11px;
  572. left: 0;
  573. }
  574. .load1,
  575. .load2,
  576. .load3 {
  577. height: 24px;
  578. width: 24px;
  579. }
  580. .load2 {
  581. transform: rotate(30deg);
  582. }
  583. .load3 {
  584. transform: rotate(60deg);
  585. }
  586. .load1 view:nth-child(1) {
  587. animation-delay: 0s;
  588. }
  589. .load2 view:nth-child(1) {
  590. animation-delay: 0.13s;
  591. }
  592. .load3 view:nth-child(1) {
  593. animation-delay: 0.26s;
  594. }
  595. .load1 view:nth-child(2) {
  596. animation-delay: 0.39s;
  597. }
  598. .load2 view:nth-child(2) {
  599. animation-delay: 0.52s;
  600. }
  601. .load3 view:nth-child(2) {
  602. animation-delay: 0.65s;
  603. }
  604. .load1 view:nth-child(3) {
  605. animation-delay: 0.78s;
  606. }
  607. .load2 view:nth-child(3) {
  608. animation-delay: 0.91s;
  609. }
  610. .load3 view:nth-child(3) {
  611. animation-delay: 1.04s;
  612. }
  613. .load1 view:nth-child(4) {
  614. animation-delay: 1.17s;
  615. }
  616. .load2 view:nth-child(4) {
  617. animation-delay: 1.3s;
  618. }
  619. .load3 view:nth-child(4) {
  620. animation-delay: 1.43s;
  621. }
  622. @-webkit-keyframes load {
  623. 0% {
  624. opacity: 1;
  625. }
  626. 100% {
  627. opacity: 0.2;
  628. }
  629. }
  630. </style>