quickList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  5. :class="{ current: tabCurrentIndex=== index }" @click="tabClick(index)">
  6. {{ item.text }}
  7. </view>
  8. </view>
  9. <swiper :current="tabCurrentIndex" class="swiper-box-one" duration="0" @change="changeTab">
  10. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex"
  11. @click="goToOrderDetail(item)">
  12. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  13. <!-- 空白页 -->
  14. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  15. <!-- 订单列表 -->
  16. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  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. <view>+{{ item.extract_ticket }}</view>
  27. <view v-if="item.status == 0" class="status">待发放</view>
  28. <view v-if="item.status == 1" class="status">已发放</view>
  29. </view>
  30. </view>
  31. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  32. </scroll-view>
  33. </swiper-item>
  34. </swiper>
  35. </view>
  36. </template>
  37. <script>
  38. import empty from '@/components/empty';
  39. import {
  40. getExchangeList
  41. } from '@/api/quick.js';
  42. export default {
  43. components: {
  44. empty
  45. },
  46. data() {
  47. return {
  48. loading: false, //判断是否在点击
  49. tabCurrentIndex: 0, //当前选中的第二级别我要买单选中项
  50. navList: [{
  51. state: 0,
  52. text: '待发放',
  53. loadingType: 'more',
  54. orderList: [],
  55. isnew: 1, //判断是否有新的订单
  56. page: 1, //当前页数
  57. limit: 10 //每次信息条数
  58. },
  59. {
  60. state: 1,
  61. text: '已发放',
  62. loadingType: 'more',
  63. orderList: [],
  64. isnew: 1, //判断是否有新的订单
  65. page: 1, //当前页数
  66. limit: 10 //每次信息条数
  67. }
  68. ],
  69. };
  70. },
  71. onLoad(options) {
  72. this.tabCurrentIndex = +options.state || 0;
  73. },
  74. onShow() {
  75. this.loadData();
  76. },
  77. // #ifdef APP-PLUS || H5
  78. onBackPress(e) {
  79. uni.switchTab({
  80. url: '/pages/user/user'
  81. });
  82. return true;
  83. },
  84. // #endif
  85. filters: {
  86. moneyNum(value) {
  87. return +value;
  88. }
  89. },
  90. // 页面加载完获取swiper高度
  91. onReady(res) {
  92. var obj = this;
  93. uni.getSystemInfo({
  94. success: resu => {
  95. const query = uni.createSelectorQuery();
  96. query.select('.swiper-box-one').boundingClientRect();
  97. query.exec(function(res) {
  98. console.log(res, 'ddddddddddddd');
  99. obj.height = resu.windowHeight - res[0].top + 'px';
  100. console.log('打印页面的剩余高度', obj.height);
  101. });
  102. },
  103. fail: res => {}
  104. });
  105. },
  106. methods: {
  107. //顶部tab点击
  108. tabClick(index, type) {
  109. this.tabCurrentIndex = index;
  110. },
  111. //获取订单列表
  112. loadData(source) {
  113. //这里是将订单挂载到tab列表下
  114. let index = this.tabCurrentIndex;
  115. let navItem = this.navList[index];
  116. let state = navItem.state;
  117. // if ( navItem.loaded === true) {
  118. // //tab切换只有第一次需要加载数据
  119. // return;
  120. // }
  121. if (navItem.loadingType === 'loading') {
  122. //防止重复加载
  123. return;
  124. }
  125. if (source == 'reload') {
  126. navItem.orderList = [];
  127. navItem.page = 1;
  128. navItem.limit = 10;
  129. navItem.loadingType = 'loading';
  130. }
  131. if (navItem.loadingType === 'noMore') {
  132. //防止重复加载
  133. return;
  134. }
  135. // 修改当前对象状态为加载中
  136. navItem.loadingType = 'loading';
  137. getExchangeList({
  138. status: state,
  139. page: navItem.page,
  140. limit: navItem.limit
  141. })
  142. .then(({
  143. data
  144. }) => {
  145. let arr = data.list.map(e => {
  146. return e;
  147. });
  148. navItem.orderList = navItem.orderList.concat(arr);
  149. // console.log(navItem.orderList);
  150. navItem.page++;
  151. if (navItem.limit == data.length) {
  152. //判断是否还有数据, 有改为 more, 没有改为noMore
  153. navItem.loadingType = 'more';
  154. return;
  155. } else {
  156. //判断是否还有数据, 有改为 more, 没有改为noMore
  157. navItem.loadingType = 'noMore';
  158. }
  159. uni.hideLoading();
  160. this.$set(navItem, 'loaded', true);
  161. })
  162. .catch(e => {
  163. console.log(e);
  164. });
  165. },
  166. //swiper 切换
  167. changeTab(e) {
  168. this.tabCurrentIndex = e.target.current;
  169. this.loadData();
  170. },
  171. }
  172. };
  173. </script>
  174. <style lang="scss">
  175. page,
  176. .content {
  177. background: $page-color-base;
  178. height: 100%;
  179. }
  180. .navbar {
  181. display: flex;
  182. height: 40px;
  183. padding: 0 5px;
  184. background: #fff;
  185. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  186. position: relative;
  187. z-index: 10;
  188. .nav-item {
  189. flex: 1;
  190. display: flex;
  191. justify-content: center;
  192. align-items: center;
  193. height: 100%;
  194. font-size: 15px;
  195. color: $font-color-dark;
  196. position: relative;
  197. &.current {
  198. color: $base-color;
  199. &:after {
  200. content: '';
  201. position: absolute;
  202. left: 50%;
  203. bottom: 0;
  204. transform: translateX(-50%);
  205. width: 44px;
  206. height: 0;
  207. border-bottom: 2px solid $base-color;
  208. }
  209. }
  210. }
  211. }
  212. .swiper-box-one {
  213. height: calc(100% - 40px);
  214. .tab-content {
  215. height: 100%;
  216. }
  217. .order-item {
  218. padding: 20rpx 30rpx;
  219. line-height: 1.5;
  220. .title-box {
  221. .title {
  222. font-size: $font-lg;
  223. color: $font-color-base;
  224. }
  225. .time {
  226. font-size: $font-base;
  227. color: $font-color-light;
  228. }
  229. }
  230. .money {
  231. color: #fd5b23;
  232. font-size: $font-lg;
  233. text-align: right;
  234. .status {
  235. color: $font-color-light;
  236. }
  237. }
  238. }
  239. }
  240. </style>