list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. console.log(arr,'arr++++++')
  118. navItem.orderList = navItem.orderList.concat(arr);
  119. // console.log(navItem.orderList);
  120. navItem.page++;
  121. if (navItem.limit == data.length) {
  122. //判断是否还有数据, 有改为 more, 没有改为noMore
  123. navItem.loadingType = 'more';
  124. return;
  125. } else {
  126. //判断是否还有数据, 有改为 more, 没有改为noMore
  127. navItem.loadingType = 'noMore';
  128. }
  129. uni.hideLoading();
  130. this.$set(navItem, 'loaded', true);
  131. })
  132. .catch(e => {
  133. console.log(e);
  134. });
  135. },
  136. //swiper 切换
  137. changeTab(e) {
  138. this.tabCurrentIndex = e.target.current;
  139. this.loadData('tabChange');
  140. },
  141. //顶部tab点击
  142. tabClick(index) {
  143. this.tabCurrentIndex = index;
  144. }
  145. }
  146. };
  147. </script>
  148. <style lang="scss">
  149. page,
  150. .content {
  151. background: $page-color-base;
  152. height: 100%;
  153. }
  154. .swiper-box {
  155. height: calc(100% - 40px);
  156. }
  157. .list-scroll-content {
  158. height: 100%;
  159. }
  160. // 列表
  161. .item-list {
  162. }
  163. .swiper-box {
  164. padding-top: 10rpx;
  165. .order-item {
  166. padding: 20rpx 30rpx;
  167. line-height: 1.5;
  168. .title-box {
  169. .title {
  170. font-size: $font-lg;
  171. color: $font-color-base;
  172. }
  173. .time {
  174. font-size: $font-base;
  175. color: $font-color-light;
  176. }
  177. }
  178. .money {
  179. color: #fd5b23;
  180. font-size: $font-lg;
  181. }
  182. }
  183. }
  184. .navbar {
  185. display: flex;
  186. height: 40px;
  187. padding: 0 5px;
  188. background: #fff;
  189. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  190. position: relative;
  191. z-index: 10;
  192. .nav-item {
  193. flex: 1;
  194. display: flex;
  195. justify-content: center;
  196. align-items: center;
  197. height: 100%;
  198. font-size: 15px;
  199. color: $font-color-dark;
  200. position: relative;
  201. &.current {
  202. color: $base-color;
  203. &:after {
  204. content: '';
  205. position: absolute;
  206. left: 50%;
  207. bottom: 0;
  208. transform: translateX(-50%);
  209. width: 44px;
  210. height: 0;
  211. border-bottom: 2px solid $base-color;
  212. }
  213. }
  214. }
  215. }
  216. .uni-swiper-item {
  217. height: auto;
  218. }
  219. /* load-more */
  220. .uni-load-more {
  221. display: flex;
  222. flex-direction: row;
  223. height: 80rpx;
  224. align-items: center;
  225. justify-content: center;
  226. }
  227. .uni-load-more__text {
  228. font-size: 28rpx;
  229. color: #999;
  230. }
  231. .uni-load-more__img {
  232. height: 24px;
  233. width: 24px;
  234. margin-right: 10px;
  235. }
  236. .uni-load-more__img > view {
  237. position: absolute;
  238. }
  239. .uni-load-more__img > view view {
  240. width: 6px;
  241. height: 2px;
  242. border-top-left-radius: 1px;
  243. border-bottom-left-radius: 1px;
  244. background: #999;
  245. position: absolute;
  246. opacity: 0.2;
  247. transform-origin: 50%;
  248. animation: load 1.56s ease infinite;
  249. }
  250. .uni-load-more__img > view view:nth-child(1) {
  251. transform: rotate(90deg);
  252. top: 2px;
  253. left: 9px;
  254. }
  255. .uni-load-more__img > view view:nth-child(2) {
  256. transform: rotate(180deg);
  257. top: 11px;
  258. right: 0;
  259. }
  260. .uni-load-more__img > view view:nth-child(3) {
  261. transform: rotate(270deg);
  262. bottom: 2px;
  263. left: 9px;
  264. }
  265. .uni-load-more__img > view view:nth-child(4) {
  266. top: 11px;
  267. left: 0;
  268. }
  269. </style>