integral.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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">{{+integralAll || 0}}</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" :style="{'height':height}">
  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" :style="{'height':height}">
  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">{{ item.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. import { getUserInfo } from '@/api/user.js';
  40. export default {
  41. components: {
  42. empty,
  43. uniLoadMore
  44. },
  45. data() {
  46. return {
  47. height: '',
  48. tabCurrentIndex: 0,
  49. navList: [
  50. {
  51. state: 1,
  52. text: '收入',
  53. loadingType: 'more',
  54. orderList: [],
  55. page: 1, //当前页数
  56. limit: 10 //每次信息条数
  57. },
  58. {
  59. state: 0,
  60. text: '支出',
  61. loadingType: 'more',
  62. orderList: [],
  63. page: 1, //当前页数
  64. limit: 10 //每次信息条数
  65. }
  66. ],
  67. list: [],
  68. // money: '',
  69. integralAll: '',//当前积分
  70. };
  71. },
  72. onLoad() {
  73. this.loadData();
  74. this.userinfo()
  75. },
  76. onReady(res) {
  77. var _this = this;
  78. uni.getSystemInfo({
  79. success: resu => {
  80. const query = uni.createSelectorQuery();
  81. query.select('.swiper-box').boundingClientRect();
  82. query.exec(function(res) {
  83. _this.height = resu.windowHeight - res[0].top + 'px';
  84. console.log('打印页面的剩余高度', _this.height);
  85. });
  86. },
  87. fail: res => {}
  88. });
  89. },
  90. methods: {
  91. //加载用户信息
  92. userinfo() {
  93. getUserInfo({}).then(({ data }) => {
  94. this.integralAll = data.integral;
  95. });
  96. },
  97. //swiper 切换
  98. changeTab(e) {
  99. this.tabCurrentIndex = e.target.current;
  100. this.loadData('tabChange');
  101. },
  102. //顶部tab点击
  103. tabClick(index) {
  104. this.tabCurrentIndex = index;
  105. },
  106. loadData(type) {
  107. let obj = this;
  108. let index = obj.tabCurrentIndex;
  109. let navItem = obj.navList[index];
  110. if (navItem.loadingType == 'loading' || navItem.loadingType == 'noMore') {
  111. return;
  112. }
  113. if (type == 'tabChange' && navItem.loaded == 'loaded') {
  114. return;
  115. }
  116. navItem.loadingType == 'loading';
  117. integral({
  118. page: navItem.page,
  119. limit: navItem.limit,
  120. pm: navItem.state
  121. }).then(res => {
  122. navItem.orderList = navItem.orderList.concat(res.data);
  123. if (navItem.limit == res.data.length) {
  124. navItem.loadingType = 'more';
  125. return;
  126. } else {
  127. navItem.loadingType = 'noMore';
  128. }
  129. uni.hideLoading();
  130. this.$set(navItem, 'loaded', true);
  131. });
  132. }
  133. }
  134. };
  135. </script>
  136. <style lang="scss">
  137. .container {
  138. width: 750rpx;
  139. background-color: #f1f1f1;
  140. .header {
  141. position: relative;
  142. image {
  143. width: 750rpx;
  144. height: 400rpx;
  145. }
  146. .money {
  147. font-size: 72rpx;
  148. font-family: PingFang SC;
  149. font-weight: 500;
  150. color: #3f7c1f;
  151. position: absolute;
  152. top: 60%;
  153. left: 50%;
  154. transform: translate(-50%, -50%);
  155. }
  156. }
  157. .navbar {
  158. display: flex;
  159. height: 100rpx;
  160. padding: 0 5rpx;
  161. background: #fff;
  162. box-shadow: 0 1rpx 5rpx rgba(0, 0, 0, 0.06);
  163. position: relative;
  164. z-index: 10;
  165. margin-top: 25rpx;
  166. .nav-item {
  167. flex: 1;
  168. display: flex;
  169. justify-content: center;
  170. align-items: center;
  171. height: 100%;
  172. font-size: 15px;
  173. color: #999999;
  174. position: relative;
  175. &.current {
  176. color: #333333;
  177. &:after {
  178. content: '';
  179. position: absolute;
  180. left: 50%;
  181. bottom: 0;
  182. transform: translateX(-50%);
  183. width: 44px;
  184. height: 0;
  185. border-bottom: 2px solid #3f7c1f;
  186. }
  187. }
  188. }
  189. }
  190. .cost {
  191. width: 750rpx;
  192. height: auto;
  193. background-color: #fff;
  194. .award {
  195. width: 100%;
  196. border-bottom: 1px solid #f0f4f8;
  197. padding: 20rpx 25rpx;
  198. display: flex;
  199. justify-content: space-between;
  200. align-items: center;
  201. .award-left {
  202. width: 60%;
  203. .text {
  204. width: 100%;
  205. font-size: 30rpx;
  206. font-family: PingFang SC;
  207. font-weight: bold;
  208. color: #666666;
  209. margin-bottom: 16rpx;
  210. }
  211. .time {
  212. font-size: 26rpx;
  213. font-family: PingFang SC;
  214. font-weight: 500;
  215. color: #aeaeae;
  216. }
  217. }
  218. .award-right {
  219. font-size: 36rpx;
  220. font-family: PingFang SC;
  221. font-weight: bold;
  222. color: #ff0000;
  223. margin-right: 30rpx;
  224. }
  225. }
  226. }
  227. }
  228. .swiper-box {
  229. // height: calc(100% - 536rpx);
  230. background-color: #fff;
  231. }
  232. </style>