integral.vue 5.6 KB

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