myaid.vue 13 KB

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