integral.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="container">
  3. <!-- 头部 -->
  4. <view class="header">
  5. <image src="../../static/img/img38.png" mode="scaleToFill"></image>
  6. <view class="money">3852</view>
  7. </view>
  8. <!-- 收入和支出 -->
  9. <view class="navbar">
  10. <view class="nav-item" v-for="(item, index) in navList" :key="index" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  11. </view>
  12. <swiper class="swiper-box" :current="tabCurrentIndex" duration="300" @change="changeTab">
  13. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  14. <!-- 空白页 -->
  15. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  16. <!-- 推广奖励 -->
  17. <scroll-view class="scorll" scroll-y="true">
  18. <view class="cost">
  19. <view class="award" v-for="item in tabItem.orderList">
  20. <view class="award-left">
  21. <view class="text clamp">{{ item.mark }}</view>
  22. <view class="time">{{ item.add_time }}</view>
  23. </view>
  24. <view class="award-right">{{ pm == 1 ? '-' : '+' }}{{ item.number }}</view>
  25. </view>
  26. </view>
  27. </scroll-view>
  28. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  29. </swiper-item>
  30. </swiper>
  31. </view>
  32. </template>
  33. <script>
  34. // 组件
  35. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  36. import empty from '@/components/empty';
  37. //接口
  38. import { integral } from '@/api/wallet.js';
  39. export default {
  40. components: {
  41. empty,
  42. uniLoadMore
  43. },
  44. data() {
  45. return {
  46. height: '',
  47. tabCurrentIndex: 0,
  48. navList: [
  49. {
  50. state: 1,
  51. text: '收入',
  52. loadingType: 'more',
  53. orderList: [],
  54. page: 1, //当前页数
  55. limit: 10 //每次信息条数
  56. },
  57. {
  58. state: 0,
  59. text: '支出',
  60. loadingType: 'more',
  61. orderList: [],
  62. page: 1, //当前页数
  63. limit: 10 //每次信息条数
  64. }
  65. ],
  66. list: [],
  67. money: ''
  68. };
  69. },
  70. onLoad() {
  71. this.loadData();
  72. },
  73. methods: {
  74. //swiper 切换
  75. changeTab(e) {
  76. this.tabCurrentIndex = e.target.current;
  77. this.loadData('tabChange');
  78. },
  79. //顶部tab点击
  80. tabClick(index) {
  81. this.tabCurrentIndex = index;
  82. },
  83. loadData(type) {
  84. let obj = this;
  85. let index = obj.tabCurrentIndex;
  86. let navItem = obj.navList[index];
  87. if (navItem.loadingType == 'loading' || navItem.loadingType == 'noMore') {
  88. return;
  89. }
  90. if (type == 'tabChange' && navItem.loaded == 'loaded') {
  91. return;
  92. }
  93. navItem.loadingType == 'loading';
  94. integral({
  95. page: navItem.page,
  96. limit: navItem.limit,
  97. pm: navItem.state
  98. }).then(res => {
  99. navItem.orderList = navItem.orderList.concat(res.data);
  100. if (navItem.limit == res.data.length) {
  101. navItem.loadingType = 'more';
  102. return;
  103. } else {
  104. navItem.loadingType = 'noMore';
  105. }
  106. uni.hideLoading();
  107. this.$set(navItem, 'loaded', true);
  108. });
  109. }
  110. }
  111. };
  112. </script>
  113. <style lang="scss">
  114. .container {
  115. width: 750rpx;
  116. height: 1334rpx;
  117. background-color: #f1f1f1;
  118. .header {
  119. position: relative;
  120. image {
  121. width: 750rpx;
  122. height: 400rpx;
  123. }
  124. .money {
  125. font-size: 72rpx;
  126. font-family: PingFang SC;
  127. font-weight: 500;
  128. color: #3f7c1f;
  129. position: absolute;
  130. top: 50%;
  131. left: 50%;
  132. transform: translate(-50%, -50%);
  133. }
  134. }
  135. .navbar {
  136. display: flex;
  137. height: 100rpx;
  138. padding: 0 5rpx;
  139. background: #fff;
  140. box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.06);
  141. position: relative;
  142. z-index: 10;
  143. margin-top: 25rpx;
  144. .nav-item {
  145. flex: 1;
  146. display: flex;
  147. justify-content: center;
  148. align-items: center;
  149. height: 100%;
  150. font-size: 15px;
  151. color: #999999;
  152. position: relative;
  153. &.current {
  154. color: #333333;
  155. &:after {
  156. content: '';
  157. position: absolute;
  158. left: 50%;
  159. bottom: 0;
  160. transform: translateX(-50%);
  161. width: 44px;
  162. height: 0;
  163. border-bottom: 2px solid #3f7c1f;
  164. }
  165. }
  166. }
  167. }
  168. .cost {
  169. width: 750rpx;
  170. height: auto;
  171. background-color: #fff;
  172. .award {
  173. width: 100%;
  174. border-bottom: 1px solid #f0f4f8;
  175. padding: 20rpx 25rpx;
  176. display: flex;
  177. justify-content: space-between;
  178. align-items: center;
  179. .award-left {
  180. width: 60%;
  181. .text {
  182. width: 100%;
  183. font-size: 30rpx;
  184. font-family: PingFang SC;
  185. font-weight: bold;
  186. color: #666666;
  187. margin-bottom: 16rpx;
  188. }
  189. .time {
  190. font-size: 26rpx;
  191. font-family: PingFang SC;
  192. font-weight: 500;
  193. color: #aeaeae;
  194. }
  195. }
  196. .award-right {
  197. font-size: 36rpx;
  198. font-family: PingFang SC;
  199. font-weight: bold;
  200. color: #ff0000;
  201. margin-right: 30rpx;
  202. }
  203. }
  204. }
  205. }
  206. .swiper-box {
  207. height: calc(100% - 536rpx);
  208. background-color: #ffffff;
  209. }
  210. // .tab-content {
  211. // height: calc(100% - 260px);
  212. // }
  213. </style>