delegation.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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.list.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view @click="goToOrderDetail(item)" v-for="(item, index) in tabItem.list" :key="index" class="order-item">
  13. <view class="i-top b-b">
  14. <text class="time">订单编号:{{ item.order_id }}</text>
  15. <text class="state" :style="{ color: item.stateTipColor }" v-if="item.status == 1">拼团中</text>
  16. <text class="state" :style="{ color: item.stateTipColor }" v-if="item.status == 2">拼团成功</text>
  17. <text class="state" :style="{ color: item.stateTipColor }" v-if="item.status == 3">拼团失败</text>
  18. <!-- <text v-if="item.status === 3" class="del-btn iconfont icondelete" @click="deleteOrder(index)"></text> -->
  19. </view>
  20. <view class="flex_item assemble_box">
  21. <view class="goods-box">
  22. <view class="goods-item"><image class="goods-img" :src="item.image" mode=" scaleToFill"></image></view>
  23. </view>
  24. <view class="assemble">
  25. <view class="assemble_title">{{ item.title }}</view>
  26. <view class="flex_item assemble_avatar">
  27. <view v-for="ls in item.joins"><image :src="ls.avatar || '/static/error/missing-face.png'"></image></view>
  28. </view>
  29. <view class="assemble_text" v-if="item.people - item.joins_peopleweo == 0">共{{ item.joins_peopleweo }}人参与了拼团,拼团人数齐了</view>
  30. <view class="assemble_text" v-else>共{{ item.joins_peopleweo }}人参与了拼团,还差{{ item.people - item.joins_peopleweo }}人</view>
  31. </view>
  32. </view>
  33. <view class="action-box b-t">
  34. <view class="action-box-left">
  35. <view v-if="item.status == 2" class="itemText recom" :class="{ 'chayidian': item.is_refund == 1 }">
  36. <template v-if="item.is_refund == 0">
  37. 恭喜您拼中了
  38. </template>
  39. <template v-if="item.is_refund == 1">
  40. 真遗憾,差一点点就中奖了!
  41. </template>
  42. </view>
  43. </view>
  44. <view class="action-box-right">
  45. <!-- v-if="item.status == 1 && item.people - item.joins_peopleweo != 0" -->
  46. <button v-if="item.status == 1 && item.people - item.joins_peopleweo != 0" class="action-btn" style="margin-left: 0;" @click.stop="share(item)">分享</button>
  47. <button class="action-btn" @click.stop="jxcantuan(item)">继续参团</button>
  48. <!-- <button v-if="item.status == 2 || item.status == 3" class="action-btn recom" @click.stop="deleteOrder(item, index)">删除订单</button> -->
  49. </view>
  50. </view>
  51. </view>
  52. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  53. </scroll-view>
  54. </swiper-item>
  55. </swiper>
  56. </view>
  57. </template>
  58. <script>
  59. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  60. import empty from '@/components/empty';
  61. import { combination, orderList, orderCancel, orderDel, orderTake } from '@/api/order.js';
  62. export default {
  63. filters: {
  64. // 过滤金额为数字
  65. moneyNum: function(value) {
  66. return +value;
  67. }
  68. },
  69. components: {
  70. uniLoadMore,
  71. empty
  72. },
  73. data() {
  74. return {
  75. tabCurrentIndex: 0,
  76. navList: [
  77. {
  78. state: 0,
  79. text: '全部拼团',
  80. loadingType: 'more',
  81. list: [],
  82. page: 1, //当前页数
  83. limit: 10 //每次信息条数
  84. },
  85. {
  86. state: 1,
  87. text: '正在拼团',
  88. loadingType: 'more',
  89. list: [],
  90. page: 1, //当前页数
  91. limit: 10 //每次信息条数
  92. },
  93. {
  94. state: 2,
  95. text: '已成功',
  96. loadingType: 'more',
  97. list: [],
  98. page: 1, //当前页数
  99. limit: 10 //每次信息条数
  100. },
  101. {
  102. state: 3,
  103. text: '已失败',
  104. loadingType: 'more',
  105. list: [],
  106. page: 1, //当前页数
  107. limit: 10 //每次信息条数
  108. }
  109. // {
  110. // state: 4,
  111. // text: '已完成',
  112. // loadingType: 'more',
  113. // list: [],
  114. // page: 1, //当前页数
  115. // limit: 10 //每次信息条数
  116. // }
  117. ]
  118. };
  119. },
  120. onLoad(options) {
  121. /**
  122. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  123. * 替换onLoad下代码即可
  124. */
  125. this.tabCurrentIndex = +options.state;
  126. // #ifndef MP
  127. this.loadData();
  128. // #endif
  129. // #ifdef MP
  130. if (options.state == 0) {
  131. this.loadData();
  132. }
  133. // #endif
  134. },
  135. methods: {
  136. //
  137. // 确认收货
  138. orderTake(item, index) {
  139. let obj = this;
  140. uni.showModal({
  141. title: '是否确认收货?',
  142. success: () => {
  143. orderTake({
  144. uni: item.order_id
  145. })
  146. .then(e => {
  147. obj.navList[obj.tabCurrentIndex].list.splice(index, 1);
  148. uni.showToast({
  149. title: '收货成功'
  150. });
  151. })
  152. .catch(e => {
  153. console.log(e);
  154. });
  155. }
  156. });
  157. },
  158. //跳转到订单详情
  159. goToOrderDetail(e) {
  160. uni.navigateTo({
  161. url: '/pages/order/orderDetail?id=' + e.order_id
  162. });
  163. },
  164. //分享
  165. share(e) {
  166. console.log(e);
  167. uni.navigateTo({
  168. url: '/pages/product/details?pink_id=' + e.id
  169. });
  170. },
  171. // 继续参团
  172. jxcantuan(item) {
  173. uni.navigateTo({
  174. url: '/pages/product/productPink?type=2&id=' + item.cid
  175. })
  176. },
  177. // 订单支付
  178. orderPay(e) {
  179. uni.navigateTo({
  180. url: '/pages/money/pay?type=1&ordid=' + e.order_id + '&money=' + e.total_price
  181. });
  182. },
  183. //获取订单列表
  184. loadData(source) {
  185. //这里是将订单挂载到tab列表下
  186. let index = this.tabCurrentIndex;
  187. let navItem = this.navList[index];
  188. let state = navItem.state;
  189. if (source === 'tabChange' && navItem.loaded === true) {
  190. //tab切换只有第一次需要加载数据
  191. return;
  192. }
  193. if (navItem.loadingType === 'loading') {
  194. //防止重复加载
  195. return;
  196. }
  197. if (navItem.loadingType === 'noMore') {
  198. //防止重复加载
  199. return;
  200. }
  201. // 修改当前对象状态为加载中
  202. navItem.loadingType = 'loading';
  203. combination({
  204. status: state,
  205. page: navItem.page,
  206. limit: navItem.limit
  207. })
  208. .then(({ data }) => {
  209. let list = data.list.data;
  210. let arr = list.map(e => {
  211. let b = this.orderStateExp(e.status);
  212. e.stateTip = b.stateTip;
  213. e.stateTipColor = b.stateTipColor;
  214. return e;
  215. });
  216. navItem.list = navItem.list.concat(arr);
  217. navItem.page++;
  218. // console.log(list.length,navItem.limit)
  219. if (navItem.limit == list.length) {
  220. //判断是否还有数据, 有改为 more, 没有改为noMore
  221. navItem.loadingType = 'more';
  222. return;
  223. } else {
  224. //判断是否还有数据, 有改为 more, 没有改为noMore
  225. navItem.loadingType = 'noMore';
  226. }
  227. this.$set(navItem, 'loaded', true);
  228. })
  229. .catch(e => {
  230. console.log(e);
  231. });
  232. },
  233. //swiper 切换
  234. changeTab(e) {
  235. this.tabCurrentIndex = e.target.current;
  236. this.loadData('tabChange');
  237. },
  238. //顶部tab点击
  239. tabClick(index) {
  240. this.tabCurrentIndex = index;
  241. },
  242. //删除订单
  243. deleteOrder(item, index) {
  244. let obj = this;
  245. uni.showModal({
  246. content: '是否确认删除订单?',
  247. success: res => {
  248. if (res.confirm) {
  249. uni.showLoading({
  250. title: '请稍后'
  251. });
  252. orderDel({
  253. order_id: item.order_id
  254. })
  255. .then(e => {
  256. obj.navList[obj.tabCurrentIndex].list.splice(index, 1);
  257. uni.hideLoading();
  258. uni.showToast({
  259. title: '删除成功'
  260. });
  261. })
  262. .catch(e => {
  263. console.log(e);
  264. uni.hideLoading();
  265. uni.showToast({
  266. title: '删除失败',
  267. icon: 'none'
  268. });
  269. });
  270. }
  271. },
  272. fail: e => {
  273. console.log(e);
  274. }
  275. });
  276. },
  277. //取消订单
  278. cancelOrder(item) {
  279. uni.showModal({
  280. title: '订单取消',
  281. content: '是否取消订单?',
  282. success: e => {
  283. if (e.confirm) {
  284. uni.showLoading({
  285. title: '请稍后'
  286. });
  287. orderCancel({ id: item.order_id })
  288. .then(e => {
  289. uni.showToast({
  290. title: '取消成功',
  291. duration: 2000,
  292. position: 'top'
  293. });
  294. })
  295. .catch(e => {
  296. console.log(e);
  297. });
  298. //取消订单后删除待付款中该项
  299. let list = this.navList[this.tabCurrentIndex].list;
  300. let index = list.findIndex(val => val.id === item.id);
  301. index !== -1 && list.splice(index, 1);
  302. uni.hideLoading();
  303. }
  304. }
  305. });
  306. },
  307. //订单状态文字和颜色
  308. orderStateExp(state) {
  309. let stateTip = '',
  310. stateTipColor = '#EF041F';
  311. switch (+state) {
  312. case 0:
  313. stateTip = '待付款';
  314. break;
  315. case 1:
  316. stateTip = '待发货';
  317. break;
  318. case 2:
  319. stateTip = '待收货';
  320. break;
  321. case 3:
  322. stateTip = '待评价';
  323. break;
  324. case 4:
  325. stateTip = '已完成';
  326. stateTipColor = '#5dbc7c';
  327. break;
  328. case 9:
  329. stateTip = '订单已关闭';
  330. stateTipColor = '#909399';
  331. break;
  332. //更多自定义
  333. }
  334. return { stateTip, stateTipColor };
  335. }
  336. }
  337. };
  338. </script>
  339. <style lang="scss">
  340. page,
  341. .content {
  342. background: $page-color-base;
  343. height: 100%;
  344. }
  345. .swiper-box {
  346. height: calc(100% - 40px);
  347. padding: 0 20rpx;
  348. }
  349. .list-scroll-content {
  350. height: 100%;
  351. }
  352. .navbar {
  353. display: flex;
  354. height: 40px;
  355. padding: 0 5px;
  356. background: #fff;
  357. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  358. position: relative;
  359. z-index: 10;
  360. .nav-item {
  361. flex: 1;
  362. display: flex;
  363. justify-content: center;
  364. align-items: center;
  365. height: 100%;
  366. font-size: 15px;
  367. color: $font-color-dark;
  368. position: relative;
  369. &.current {
  370. color: $motif-color;
  371. &:after {
  372. content: '';
  373. position: absolute;
  374. left: 50%;
  375. bottom: 0;
  376. transform: translateX(-50%);
  377. width: 44px;
  378. height: 0;
  379. border-bottom: 2px solid $motif-color;
  380. }
  381. }
  382. }
  383. }
  384. .uni-swiper-item {
  385. height: auto;
  386. }
  387. .order-item {
  388. display: flex;
  389. flex-direction: column;
  390. padding-left: 30rpx;
  391. background: #fff;
  392. margin-top: 16rpx;
  393. border-radius: 15rpx;
  394. .i-top {
  395. display: flex;
  396. align-items: center;
  397. height: 80rpx;
  398. padding-right: 30rpx;
  399. font-size: $font-base;
  400. color: $font-color-dark;
  401. position: relative;
  402. .time {
  403. flex: 1;
  404. }
  405. .state {
  406. color: $base-color;
  407. }
  408. .del-btn {
  409. padding: 10rpx 0 10rpx 36rpx;
  410. font-size: $font-lg;
  411. color: $font-color-light;
  412. position: relative;
  413. &:after {
  414. content: '';
  415. width: 0;
  416. height: 30rpx;
  417. border-left: 1px solid $border-color-dark;
  418. position: absolute;
  419. left: 20rpx;
  420. top: 50%;
  421. transform: translateY(-50%);
  422. }
  423. }
  424. }
  425. /* 多条商品 */
  426. .goods-box {
  427. height: 160rpx;
  428. padding: 20rpx 0;
  429. white-space: nowrap;
  430. .goods-item {
  431. width: 120rpx;
  432. height: 120rpx;
  433. display: inline-block;
  434. margin-right: 24rpx;
  435. }
  436. .goods-img {
  437. display: block;
  438. width: 100%;
  439. height: 100%;
  440. }
  441. }
  442. /* 单条商品 */
  443. .goods-box-single {
  444. display: flex;
  445. padding: 20rpx 0;
  446. .goods-img {
  447. display: block;
  448. width: 200rpx;
  449. height: 118rpx;
  450. }
  451. .right {
  452. flex: 1;
  453. display: flex;
  454. flex-direction: column;
  455. padding: 0 30rpx 0 24rpx;
  456. overflow: hidden;
  457. .title {
  458. font-size: $font-base + 2rpx;
  459. color: $font-color-dark;
  460. line-height: 1;
  461. }
  462. .attr-box {
  463. font-size: $font-sm + 2rpx;
  464. color: $font-color-light;
  465. padding: 10rpx 12rpx;
  466. }
  467. .price {
  468. font-size: $font-base + 2rpx;
  469. color: $font-color-dark;
  470. &:before {
  471. content: '¥';
  472. font-size: $font-sm;
  473. margin: 0 2rpx 0 8rpx;
  474. }
  475. }
  476. }
  477. }
  478. .assemble {
  479. padding: 15rpx;
  480. width: 80%;
  481. }
  482. .assemble_title {
  483. font-size: $font-base + 2rpx;
  484. color: $font-color-dark;
  485. white-space: nowrap;
  486. overflow: hidden;
  487. text-overflow: ellipsis;
  488. }
  489. .assemble image {
  490. width: 55rpx;
  491. height: 55rpx;
  492. margin-left: -15rpx;
  493. border: 2rpx solid #ffffff;
  494. border-radius: 50rpx;
  495. }
  496. .assemble_text {
  497. font-size: 24rpx;
  498. color: #999999;
  499. }
  500. .assemble_avatar {
  501. padding-left: 15rpx;
  502. padding-top: 10rpx;
  503. }
  504. .assemble_box {
  505. width: 100%;
  506. padding-right: 15rpx;
  507. }
  508. .price-box {
  509. display: flex;
  510. justify-content: flex-end;
  511. align-items: baseline;
  512. padding: 20rpx 30rpx;
  513. font-size: $font-sm + 2rpx;
  514. color: $font-color-light;
  515. .num {
  516. margin: 0 8rpx;
  517. color: $font-color-dark;
  518. }
  519. .price {
  520. font-size: $font-lg;
  521. color: $font-color-dark;
  522. &:before {
  523. content: '¥';
  524. font-size: $font-sm;
  525. margin: 0 2rpx 0 8rpx;
  526. }
  527. }
  528. }
  529. .action-box {
  530. display: flex;
  531. justify-content: space-between ;
  532. align-items: center;
  533. height: 84rpx;
  534. position: relative;
  535. padding-right: 30rpx;
  536. .itemText {
  537. font-size: $font-sm;
  538. color: #FC4141;
  539. }
  540. .chayidian {
  541. color: #999999 !important;
  542. }
  543. .action-box-right {
  544. display: flex;
  545. }
  546. }
  547. .action-btn {
  548. width: 160rpx;
  549. height: 60rpx;
  550. margin: 0;
  551. margin-left: 24rpx;
  552. padding: 0;
  553. text-align: center;
  554. line-height: 60rpx;
  555. font-size: $font-sm + 2rpx;
  556. color: #ffffff;
  557. background-color: $background-color;
  558. border-color: $color-yellow;
  559. border-radius: 100px;
  560. &:after {
  561. border-radius: 100px;
  562. }
  563. &.recom {
  564. color: $font-color-base;
  565. background-color: #ffffff;
  566. &:after {
  567. border-color: $base-color;
  568. }
  569. }
  570. &.evaluate {
  571. color: $color-yellow;
  572. &:after {
  573. border-color: $color-yellow;
  574. }
  575. }
  576. }
  577. }
  578. /* load-more */
  579. .uni-load-more {
  580. display: flex;
  581. flex-direction: row;
  582. height: 80rpx;
  583. align-items: center;
  584. justify-content: center;
  585. }
  586. .uni-load-more__text {
  587. font-size: 28rpx;
  588. color: #999;
  589. }
  590. .uni-load-more__img {
  591. height: 24px;
  592. width: 24px;
  593. margin-right: 10px;
  594. }
  595. .uni-load-more__img > view {
  596. position: absolute;
  597. }
  598. .uni-load-more__img > view view {
  599. width: 6px;
  600. height: 2px;
  601. border-top-left-radius: 1px;
  602. border-bottom-left-radius: 1px;
  603. background: #999;
  604. position: absolute;
  605. opacity: 0.2;
  606. transform-origin: 50%;
  607. animation: load 1.56s ease infinite;
  608. }
  609. .uni-load-more__img > view view:nth-child(1) {
  610. transform: rotate(90deg);
  611. top: 2px;
  612. left: 9px;
  613. }
  614. .uni-load-more__img > view view:nth-child(2) {
  615. transform: rotate(180deg);
  616. top: 11px;
  617. right: 0;
  618. }
  619. .uni-load-more__img > view view:nth-child(3) {
  620. transform: rotate(270deg);
  621. bottom: 2px;
  622. left: 9px;
  623. }
  624. .uni-load-more__img > view view:nth-child(4) {
  625. top: 11px;
  626. left: 0;
  627. }
  628. .load1,
  629. .load2,
  630. .load3 {
  631. height: 24px;
  632. width: 24px;
  633. }
  634. .load2 {
  635. transform: rotate(30deg);
  636. }
  637. .load3 {
  638. transform: rotate(60deg);
  639. }
  640. .load1 view:nth-child(1) {
  641. animation-delay: 0s;
  642. }
  643. .load2 view:nth-child(1) {
  644. animation-delay: 0.13s;
  645. }
  646. .load3 view:nth-child(1) {
  647. animation-delay: 0.26s;
  648. }
  649. .load1 view:nth-child(2) {
  650. animation-delay: 0.39s;
  651. }
  652. .load2 view:nth-child(2) {
  653. animation-delay: 0.52s;
  654. }
  655. .load3 view:nth-child(2) {
  656. animation-delay: 0.65s;
  657. }
  658. .load1 view:nth-child(3) {
  659. animation-delay: 0.78s;
  660. }
  661. .load2 view:nth-child(3) {
  662. animation-delay: 0.91s;
  663. }
  664. .load3 view:nth-child(3) {
  665. animation-delay: 1.04s;
  666. }
  667. .load1 view:nth-child(4) {
  668. animation-delay: 1.17s;
  669. }
  670. .load2 view:nth-child(4) {
  671. animation-delay: 1.3s;
  672. }
  673. .load3 view:nth-child(4) {
  674. animation-delay: 1.43s;
  675. }
  676. @-webkit-keyframes load {
  677. 0% {
  678. opacity: 1;
  679. }
  680. 100% {
  681. opacity: 0.2;
  682. }
  683. }
  684. </style>