list.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 class="itemList" v-for="(items, indexs) in tabItem.orderList" :key="indexs">
  13. <!-- <view class='font-size-lg padding-l-30 bg-gray padding-v-10'>
  14. {{items.time}}
  15. </view> -->
  16. <view v-for="(item, index) in items.list" :key="index" class="order-item flex">
  17. <view class="title-box">
  18. <view class="title">
  19. <text>{{ item.mark }}</text>
  20. </view>
  21. <view class="time">
  22. <text>{{ item.add_time }}</text>
  23. </view>
  24. </view>
  25. <view class="money">
  26. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  31. </scroll-view>
  32. </swiper-item>
  33. </swiper>
  34. </view>
  35. </template>
  36. <script>
  37. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  38. import empty from '@/components/empty';
  39. import { receivedLst } from '@/api/received.js';
  40. import { spreadCommission } from '@/api/wallet.js';
  41. export default {
  42. components: {
  43. uniLoadMore,
  44. empty
  45. },
  46. data() {
  47. return {
  48. tabCurrentIndex: 0,
  49. navList: [
  50. {
  51. state: 5,
  52. text: '收款',
  53. loadingType: 'more',
  54. orderList: [],
  55. page: 1, //当前页数
  56. limit: 10 //每次信息条数
  57. },
  58. {
  59. state: 6,
  60. text: '付款',
  61. loadingType: 'more',
  62. orderList: [],
  63. page: 1, //当前页数
  64. limit: 10 //每次信息条数
  65. }
  66. ]
  67. };
  68. },
  69. onLoad(options) {
  70. /**
  71. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  72. * 替换onLoad下代码即可
  73. */
  74. this.tabCurrentIndex = +options.state || 0;
  75. // #ifndef MP
  76. this.loadData();
  77. // #endif
  78. // #ifdef MP
  79. if (options.state == 0) {
  80. this.loadData();
  81. }
  82. // #endif
  83. },
  84. methods: {
  85. //加载列表
  86. loadData(source) {
  87. //这里是将订单挂载到tab列表下
  88. let index = this.tabCurrentIndex;
  89. let navItem = this.navList[index];
  90. let state = navItem.state;
  91. if (source === 'tabChange' && navItem.loaded === true) {
  92. //tab切换只有第一次需要加载数据
  93. return;
  94. }
  95. if (navItem.loadingType === 'loading') {
  96. //防止重复加载
  97. return;
  98. }
  99. if (navItem.loadingType === 'noMore') {
  100. //防止重复加载
  101. return;
  102. }
  103. // 修改当前对象状态为加载中
  104. navItem.loadingType = 'loading';
  105. // 查询我的订单
  106. spreadCommission({
  107. // pay_type: state,
  108. // way: '',
  109. page: navItem.page,
  110. limit: navItem.limit
  111. },state)
  112. .then(({ data }) => {
  113. console.log(data);
  114. let arr = data.map(e => {
  115. return e;
  116. });
  117. navItem.orderList = navItem.orderList.concat(arr);
  118. // console.log(navItem.orderList);
  119. navItem.page++;
  120. if (navItem.limit == data.length) {
  121. //判断是否还有数据, 有改为 more, 没有改为noMore
  122. navItem.loadingType = 'more';
  123. return;
  124. } else {
  125. //判断是否还有数据, 有改为 more, 没有改为noMore
  126. navItem.loadingType = 'noMore';
  127. }
  128. uni.hideLoading();
  129. this.$set(navItem, 'loaded', true);
  130. })
  131. .catch(e => {
  132. console.log(e);
  133. });
  134. },
  135. //swiper 切换
  136. changeTab(e) {
  137. this.tabCurrentIndex = e.target.current;
  138. this.loadData('tabChange');
  139. },
  140. //顶部tab点击
  141. tabClick(index) {
  142. this.tabCurrentIndex = index;
  143. }
  144. }
  145. };
  146. </script>
  147. <style lang="scss">
  148. page,
  149. .content {
  150. background: $page-color-base;
  151. height: 100%;
  152. }
  153. .swiper-box {
  154. height: calc(100% - 40px);
  155. }
  156. .list-scroll-content {
  157. height: 100%;
  158. }
  159. // 列表
  160. .item-list {
  161. }
  162. .swiper-box {
  163. padding-top: 10rpx;
  164. .order-item {
  165. padding: 20rpx 30rpx;
  166. line-height: 1.5;
  167. .title-box {
  168. .title {
  169. font-size: $font-lg;
  170. color: $font-color-base;
  171. }
  172. .time {
  173. font-size: $font-base;
  174. color: $font-color-light;
  175. }
  176. }
  177. .money {
  178. color: #fd5b23;
  179. font-size: $font-lg;
  180. }
  181. }
  182. }
  183. .navbar {
  184. display: flex;
  185. height: 40px;
  186. padding: 0 5px;
  187. background: #fff;
  188. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  189. position: relative;
  190. z-index: 10;
  191. .nav-item {
  192. flex: 1;
  193. display: flex;
  194. justify-content: center;
  195. align-items: center;
  196. height: 100%;
  197. font-size: 15px;
  198. color: $font-color-dark;
  199. position: relative;
  200. &.current {
  201. color: $base-color;
  202. &:after {
  203. content: '';
  204. position: absolute;
  205. left: 50%;
  206. bottom: 0;
  207. transform: translateX(-50%);
  208. width: 44px;
  209. height: 0;
  210. border-bottom: 2px solid $base-color;
  211. }
  212. }
  213. }
  214. }
  215. .uni-swiper-item {
  216. height: auto;
  217. }
  218. /* load-more */
  219. .uni-load-more {
  220. display: flex;
  221. flex-direction: row;
  222. height: 80rpx;
  223. align-items: center;
  224. justify-content: center;
  225. }
  226. .uni-load-more__text {
  227. font-size: 28rpx;
  228. color: #999;
  229. }
  230. .uni-load-more__img {
  231. height: 24px;
  232. width: 24px;
  233. margin-right: 10px;
  234. }
  235. .uni-load-more__img > view {
  236. position: absolute;
  237. }
  238. .uni-load-more__img > view view {
  239. width: 6px;
  240. height: 2px;
  241. border-top-left-radius: 1px;
  242. border-bottom-left-radius: 1px;
  243. background: #999;
  244. position: absolute;
  245. opacity: 0.2;
  246. transform-origin: 50%;
  247. animation: load 1.56s ease infinite;
  248. }
  249. .uni-load-more__img > view view:nth-child(1) {
  250. transform: rotate(90deg);
  251. top: 2px;
  252. left: 9px;
  253. }
  254. .uni-load-more__img > view view:nth-child(2) {
  255. transform: rotate(180deg);
  256. top: 11px;
  257. right: 0;
  258. }
  259. .uni-load-more__img > view view:nth-child(3) {
  260. transform: rotate(270deg);
  261. bottom: 2px;
  262. left: 9px;
  263. }
  264. .uni-load-more__img > view view:nth-child(4) {
  265. top: 11px;
  266. left: 0;
  267. }
  268. </style>