zzjl.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 :style="{'height':height}" :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 :style="{'height':height}" class="list-scroll-content" scroll-y @scrolltolower="loadData">
  9. <!-- 空白页 -->
  10. <view class="emptyBox" v-if="tabItem.loaded === true && tabItem.orderList.length === 0"><empty ></empty></view>
  11. <!-- 订单列表 -->
  12. <view class="box" v-for="(item, index) in tabItem.orderList" :key="index" >
  13. <view class="i-top b-b flex">
  14. <view class="time">订单编号:{{ item.order_id }}</view>
  15. </view>
  16. <view class="order-item flex">
  17. <view class="title-box">
  18. <view class="title" v-if="tabCurrentIndex == 0">
  19. <text>转给{{'“' + item.to_user + '”' }}</text>
  20. </view>
  21. <view class="title" v-if="tabCurrentIndex == 1">
  22. <text>{{'“' + item.to_user + '”'}}转入</text>
  23. </view>
  24. <view class="time">
  25. <text>{{ item._add_time }}</text>
  26. </view>
  27. </view>
  28. <view class="money">
  29. <text>{{ item.money }}</text>
  30. </view>
  31. </view>
  32. </view>
  33. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  34. </scroll-view>
  35. </swiper-item>
  36. </swiper>
  37. </view>
  38. </template>
  39. <script>
  40. import empty from '@/components/empty';
  41. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  42. import { zhuanList } from '@/api/wallet.js';
  43. export default {
  44. components: {
  45. empty,
  46. uniLoadMore
  47. },
  48. data() {
  49. return {
  50. height:'',
  51. tabCurrentIndex: 0,
  52. navList: [
  53. {
  54. state: 0,
  55. text: '转出',
  56. loadingType: 'more',
  57. orderList: [],
  58. page: 1, //当前页数
  59. limit: 10 //每次信息条数
  60. },
  61. {
  62. state: 1,
  63. text: '转入',
  64. loadingType: 'more',
  65. orderList: [],
  66. page: 1, //当前页数
  67. limit: 10 //每次信息条数
  68. }
  69. ]
  70. };
  71. },
  72. onLoad(options) {},
  73. onShow() {
  74. this.loadData();
  75. },
  76. onReady(res) {
  77. var obj = this;
  78. uni.getSystemInfo({
  79. success: resu => {
  80. const query = uni.createSelectorQuery();
  81. query.select('.swiper-box').boundingClientRect();
  82. query.exec(function(res) {
  83. console.log(res, 'ddddddddddddd');
  84. obj.height = resu.windowHeight - res[0].top + 'px';
  85. console.log('打印页面的剩余高度', obj.height);
  86. });
  87. },
  88. fail: res => {}
  89. });
  90. },
  91. methods: {
  92. //获取收入支出信息
  93. async loadData(source) {
  94. //这里是将订单挂载到tab列表下
  95. let index = this.tabCurrentIndex;
  96. let navItem = this.navList[index];
  97. let state = navItem.state;
  98. if (source === 'tabChange' && navItem.loaded === true) {
  99. //tab切换只有第一次需要加载数据
  100. return;
  101. }
  102. if (navItem.loadingType === 'loading') {
  103. //防止重复加载
  104. return;
  105. }
  106. // 修改当前对象状态为加载中
  107. navItem.loadingType = 'loading';
  108. zhuanList({
  109. page: navItem.page,
  110. limit: navItem.limit,
  111. pm: navItem.state
  112. })
  113. .then(({ data }) => {
  114. console.log(data.data);
  115. if (data.data.length > 0) {
  116. navItem.orderList = navItem.orderList.concat(data.data);
  117. console.log(navItem.orderList);
  118. navItem.page++;
  119. }
  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,.center {
  149. background: #f8f8f8;
  150. height: 100%;
  151. }
  152. .emptyBox {
  153. width: 100%;
  154. height: 100%;
  155. }
  156. .navbar {
  157. display: flex;
  158. height: 40px;
  159. padding: 0 5px;
  160. background: #fff;
  161. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  162. position: relative;
  163. z-index: 10;
  164. .nav-item {
  165. flex: 1;
  166. display: flex;
  167. justify-content: center;
  168. align-items: center;
  169. height: 100%;
  170. font-size: 15px;
  171. color: $font-color-dark;
  172. position: relative;
  173. &.current {
  174. color: #ff4c4c;
  175. &:after {
  176. content: '';
  177. position: absolute;
  178. left: 50%;
  179. bottom: 0;
  180. transform: translateX(-50%);
  181. width: 44px;
  182. height: 0;
  183. border-bottom: 2px solid #ff4c4c;
  184. }
  185. }
  186. }
  187. }
  188. .i-top {
  189. background-color: #ffffff;
  190. width: 100%;
  191. height: 80rpx;
  192. padding: 0 30rpx;
  193. font-size: $font-base;
  194. color: $font-color-dark;
  195. position: relative;
  196. margin-top: 20rpx;
  197. }
  198. .box {
  199. background-color: #fff;
  200. margin-top: 10rpx;
  201. }
  202. .swiper-box {
  203. padding-top: 10rpx;
  204. .order-item {
  205. padding: 20rpx 30rpx;
  206. line-height: 1.5;
  207. .title-box {
  208. .title {
  209. font-size: $font-lg;
  210. color: $font-color-base;
  211. }
  212. .time {
  213. font-size: $font-base;
  214. color: $font-color-light;
  215. }
  216. }
  217. .money {
  218. color: #fd5b23;
  219. font-size: $font-lg;
  220. }
  221. }
  222. }
  223. </style>