sz.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="getList()">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  13. <view class="title-box">
  14. <view class="title">
  15. <text>{{ item.title }}</text>
  16. </view>
  17. <view class="time">
  18. <text>{{ item.add_time }}</text>
  19. </view>
  20. </view>
  21. <view class="money">
  22. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  23. </view>
  24. </view>
  25. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  26. </scroll-view>
  27. </swiper-item>
  28. </swiper>
  29. </view>
  30. </template>
  31. <script>
  32. import { spreadCommission } from '@/api/wallet.js';
  33. export default {
  34. data() {
  35. return {
  36. maxheight: '',
  37. tabCurrentIndex: 0,
  38. navList: [
  39. {
  40. state: 1,
  41. text: '收入',
  42. loadingType: 'more',
  43. orderList: [],
  44. page: 1, //当前页面
  45. limit: 10 //每次信息条数
  46. },
  47. {
  48. state: 0,
  49. text: '支出',
  50. loadingType: 'more',
  51. orderList: [],
  52. page: 1, //当前页面
  53. limit: 10 //每次信息条数
  54. }
  55. ],
  56. type: 0,//1-复投积分 2-佣金 3-分红额度 4-消费积分
  57. }
  58. },
  59. onLoad(opt) {
  60. this.type = opt.type
  61. },
  62. onShow() {
  63. this.getList()
  64. },
  65. onReady(res) {
  66. var _this = this;
  67. uni.getSystemInfo({
  68. success: resu => {
  69. const query = uni.createSelectorQuery();
  70. query.select('.swiper-box').boundingClientRect();
  71. query.exec(function(res) {
  72. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  73. console.log('打印页面的剩余高度', _this.maxheight);
  74. });
  75. },
  76. fail: res => {}
  77. });
  78. },
  79. methods:{
  80. //顶部tab点击
  81. tabClick(index) {
  82. this.tabCurrentIndex = index;
  83. },
  84. changeTab(res) {
  85. console.log(res);
  86. let that = this
  87. that.tabCurrentIndex = res.detail.current
  88. that.getList('tab')
  89. },
  90. getList(type) {
  91. let that = this
  92. let item = that.navList[that.tabCurrentIndex]
  93. let status = 0
  94. let qdata = {
  95. page: item.page,
  96. limit: item.limit,
  97. }
  98. if(type == 'tab' && item.loaded) {
  99. return
  100. }
  101. if(item.loadingType == 'noMore' || item.loadingType == 'loading') {
  102. return
  103. }
  104. item.loadingType = 'loading'
  105. if(that.type == 2 || that.type ==4) {
  106. if(that.type == 2 ) {
  107. if(item.state == 1) {
  108. status =3
  109. }else {
  110. status = 4
  111. }
  112. }else {
  113. if(item.state == 1) {
  114. status = 2
  115. }else {
  116. status =1
  117. }
  118. }
  119. }else {
  120. if(that.type == 1) {
  121. status = 7
  122. qdata.category = 'resumption'
  123. if(item.state == 1) {
  124. qdata.pm = 1
  125. }else {
  126. qdata.pm = 0
  127. }
  128. }else if(that.type == 3){
  129. status = 6
  130. qdata.category = 'pool'
  131. if(item.state == 1) {
  132. qdata.pm = 1
  133. }else {
  134. qdata.pm = 0
  135. }
  136. }else if(that.type == 8) {
  137. status = 8
  138. qdata.category = 'points'
  139. if(item.state == 1) {
  140. qdata.pm = 1
  141. }else {
  142. qdata.pm = 0
  143. }
  144. }else if(that.type == 9) {
  145. status = 9
  146. qdata.category = 'pass'
  147. if(item.state == 1) {
  148. qdata.pm = 1
  149. }else {
  150. qdata.pm = 0
  151. }
  152. }else if(that.type == 10) {
  153. status = 10
  154. qdata.category = 'integral'
  155. if(item.state == 1) {
  156. qdata.pm = 1
  157. }else {
  158. qdata.pm = 0
  159. }
  160. }
  161. }
  162. spreadCommission(qdata,status).then(({data})=> {
  163. if(data.length > 0) {
  164. let arr = []
  165. data.forEach(item => {
  166. arr = arr.concat(item.list)
  167. console.log(arr);
  168. })
  169. item.orderList = item.orderList.concat(arr);
  170. item.page++;
  171. if (item.limit == data.length) {
  172. item.loadingType = 'more';
  173. return;
  174. } else {
  175. item.loadingType = 'noMore';
  176. }
  177. // uni.hideLoading();
  178. that.$set(item, 'loaded', true);
  179. }else {
  180. item.loadingType = 'noMore'
  181. }
  182. })
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss" scoped>
  188. .navbar {
  189. display: flex;
  190. height: 40px;
  191. padding: 0 5px;
  192. background: #fff;
  193. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  194. position: relative;
  195. z-index: 10;
  196. .nav-item {
  197. flex: 1;
  198. display: flex;
  199. justify-content: center;
  200. align-items: center;
  201. height: 100%;
  202. font-size: 15px;
  203. color: $font-color-dark;
  204. position: relative;
  205. &.current {
  206. color: #000;
  207. font-weight: bold;
  208. &:after {
  209. content: '';
  210. position: absolute;
  211. left: 50%;
  212. bottom: 0;
  213. transform: translateX(-50%);
  214. width: 44px;
  215. height: 0;
  216. border-bottom: 2px solid #FF4C4C;
  217. }
  218. }
  219. }
  220. }
  221. .swiper-box {
  222. .order-item {
  223. padding: 20rpx 30rpx;
  224. line-height: 1.5;
  225. .title-box {
  226. .title {
  227. font-size: $font-lg;
  228. color: $font-color-base;
  229. }
  230. .time {
  231. font-size: $font-base;
  232. color: $font-color-light;
  233. }
  234. }
  235. .money {
  236. color: rgba(239, 58, 85, 1);
  237. font-size: $font-lg;
  238. }
  239. }
  240. }
  241. .list-scroll-content {
  242. background-color: #ffffff;
  243. height: 100%;
  244. }
  245. </style>