jf.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="content-money">
  5. <view class="status_bar"><!-- 这里是状态栏 --></view>
  6. <view class="body-title">
  7. <view class="goback-box" @click="toBack"><image class="goback" src="../../static/icon/fanhui.png" mode=""></image></view>
  8. <view class="header">我的贡献值</view>
  9. </view>
  10. <view class="content-bg"><image src="../../static/img/tg-bg.png" mode=""></image></view>
  11. <view class="money-box">
  12. <view class="money">{{ userInfo.contribute | getMoneyStyle }}</view>
  13. <view>贡献值</view>
  14. </view>
  15. <view class="moneybtn-box">
  16. <view class="money-btn" style="text-decoration: underline;"></view>
  17. <view class="money-btn" ></view>
  18. </view>
  19. </view>
  20. </view>
  21. <swiper :current="tabCurrentIndex" :style="{ height: maxheight }" class="swiper-box" duration="300" @change="changeTab" disable-touch>
  22. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  23. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  24. <!-- 空白页 -->
  25. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  26. <!-- 订单列表 -->
  27. <view class="order-item flex" v-for="(item, index) in tabItem.orderList" :key="index">
  28. <view class="title-box">
  29. <view class="title">
  30. <text>{{ item.title }}</text>
  31. </view>
  32. <view class="time">
  33. <text>{{ item.add_time }}</text>
  34. </view>
  35. </view>
  36. <view class="money">
  37. <text>{{ (item.pm == 0 ? '-' : '+') + item.number }}</text>
  38. </view>
  39. </view>
  40. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  41. </scroll-view>
  42. </swiper-item>
  43. </swiper>
  44. </view>
  45. </template>
  46. <script>
  47. import { spreadCommission, userBalance, yue, integral } from '@/api/wallet.js';
  48. import { mapState, mapMutations } from 'vuex';
  49. import { getMoneyStyle } from '@/utils/rocessor.js';
  50. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  51. import empty from '@/components/empty';
  52. import { getUserInfo } from '@/api/user.js';
  53. export default {
  54. filters: {
  55. getMoneyStyle
  56. },
  57. computed: {
  58. ...mapState('user', ['userInfo'])
  59. },
  60. components: {
  61. empty,
  62. uniLoadMore
  63. },
  64. onReady(res) {
  65. var _this = this;
  66. uni.getSystemInfo({
  67. success: resu => {
  68. const query = uni.createSelectorQuery();
  69. query.select('.swiper-box').boundingClientRect();
  70. query.exec(function(res) {
  71. _this.maxheight = resu.windowHeight - res[0].top + 'px';
  72. console.log('打印页面的剩余高度', _this.maxheight);
  73. });
  74. },
  75. fail: res => {}
  76. });
  77. },
  78. data() {
  79. return {
  80. // 头部图高度
  81. maxheight: '',
  82. tabCurrentIndex: 0,
  83. sr: '',
  84. zc: '',
  85. navList: [
  86. {
  87. state: 1,
  88. text: '收入',
  89. loadingType: 'more',
  90. orderList: [],
  91. page: 1, //当前页面
  92. limit: 10 //每次信息条数
  93. },
  94. {
  95. state: 0,
  96. text: '支出',
  97. loadingType: 'more',
  98. orderList: [],
  99. page: 1, //当前页面
  100. limit: 10 //每次信息条数
  101. }
  102. ],
  103. money: ''
  104. };
  105. },
  106. onLoad(options) {},
  107. onShow() {
  108. this.getUserInfo();
  109. this.loadData();
  110. //获取用户余额
  111. // userBalance({}).then(({ data }) => {
  112. // this.money = data.commissionCount;
  113. // });
  114. },
  115. methods: {
  116. ...mapMutations('user', ['setUserInfo']),
  117. navto(e) {
  118. uni.navigateTo({
  119. url: e
  120. });
  121. },
  122. getUserInfo() {
  123. getUserInfo({}).then(({ data }) => {
  124. this.setUserInfo(data);
  125. });
  126. },
  127. async loadData(source) {
  128. const obj = this;
  129. //这里时将订单挂载到tab列表下
  130. let index = this.tabCurrentIndex;
  131. let navItem = this.navList[index];
  132. let state = navItem.state ;
  133. if (source === 'tabChange' && navItem.loaded === true) {
  134. //tab切换只有第一次需要加载数据
  135. return;
  136. }
  137. if (navItem.loadingType === 'loading') {
  138. //防止重复加载
  139. return;
  140. }
  141. //修改当前对象状态为加载中
  142. navItem.loadingType = 'loading';
  143. spreadCommission(
  144. {
  145. page: navItem.page,
  146. limit: navItem.limit,
  147. category: 'contribute'
  148. },5
  149. )
  150. .then(({ data }) => {
  151. if (data.length > 0) {
  152. let arr = []
  153. data.forEach(item => {
  154. arr = arr.concat(item.list)
  155. console.log(arr);
  156. })
  157. navItem.orderList = navItem.orderList.concat(arr);
  158. // navItem.orderList = navItem.orderList.concat(data);
  159. // console.log(navItem.orderList);
  160. // navItem.page++;
  161. }
  162. //判断是否还有数据, 有改为more, 没有改为noMore
  163. if (navItem.limit == data.length) {
  164. navItem.loadingType = 'more';
  165. } else {
  166. navItem.loadingType = 'noMore';
  167. }
  168. uni.hideLoading();
  169. this.$set(navItem, 'loaded', true);
  170. })
  171. .catch(e => {
  172. console.log(e);
  173. });
  174. },
  175. //swiper 切换
  176. changeTab(e) {
  177. this.tabCurrentIndex = e.target.current;
  178. this.loadData('tabChange');
  179. },
  180. //顶部tab点击
  181. tabClick(index) {
  182. this.tabCurrentIndex = index;
  183. },
  184. toBack() {
  185. uni.navigateBack();
  186. }
  187. }
  188. };
  189. </script>
  190. <style lang="scss">
  191. page {
  192. background: #f2f5f4;
  193. height: 100%;
  194. }
  195. .status_bar {
  196. height: var(--status-bar-height);
  197. width: 100%;
  198. }
  199. .content-money {
  200. position: relative;
  201. height: 480rpx;
  202. .content-bg {
  203. position: absolute;
  204. top: 0;
  205. left: 0;
  206. right: 0;
  207. width: 750rpx;
  208. height: 480rpx;
  209. image {
  210. width: 100%;
  211. height: 100%;
  212. }
  213. }
  214. .body-title {
  215. height: 80rpx;
  216. text-align: center;
  217. font-size: 35rpx;
  218. position: relative;
  219. .header {
  220. position: absolute;
  221. left: 0;
  222. top: 0;
  223. width: 100%;
  224. font-size: 36rpx;
  225. font-family: PingFang SC;
  226. font-weight: bold;
  227. color: $base-color;
  228. height: 80rpx;
  229. font-size: 36rpx;
  230. font-weight: 700;
  231. z-index: 9;
  232. display: flex;
  233. justify-content: center;
  234. align-items: center;
  235. }
  236. .goback-box {
  237. position: absolute;
  238. left: 18rpx;
  239. top: 0;
  240. height: 80rpx;
  241. display: flex;
  242. align-items: center;
  243. }
  244. .goback {
  245. z-index: 100;
  246. width: 34rpx;
  247. height: 34rpx;
  248. }
  249. }
  250. }
  251. .money-box {
  252. position: relative;
  253. z-index: 2;
  254. padding-top: 100rpx;
  255. color: $base-color;
  256. text-align: center;
  257. .money {
  258. font-size: 72rpx;
  259. font-family: PingFang SC;
  260. font-weight: bold;
  261. color: $base-color;
  262. }
  263. .text {
  264. font-size: 30rpx;
  265. }
  266. }
  267. .moneybtn-box {
  268. display: flex;
  269. justify-content: space-between;
  270. position: relative;
  271. z-index: 2;
  272. color: #ffffff;
  273. padding: 20rpx 50rpx;
  274. font-size: 30rpx;
  275. font-family: PingFang SC;
  276. font-weight: bold;
  277. color: #ffffff;
  278. }
  279. .navbar {
  280. margin-top: 25rpx;
  281. display: flex;
  282. height: 40px;
  283. padding: 0 5px;
  284. background: #fff;
  285. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  286. position: relative;
  287. z-index: 10;
  288. .nav-item {
  289. flex: 1;
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. height: 100%;
  294. font-size: 15px;
  295. color: $font-color-dark;
  296. position: relative;
  297. &.current {
  298. color: #000;
  299. font-weight: bold;
  300. &:after {
  301. content: '';
  302. position: absolute;
  303. left: 50%;
  304. bottom: 0;
  305. transform: translateX(-50%);
  306. width: 44px;
  307. height: 0;
  308. border-bottom: 2px solid rgba(154, 94, 25, 1);
  309. }
  310. }
  311. }
  312. }
  313. //列表
  314. .swiper-box {
  315. .order-item {
  316. padding: 20rpx 30rpx;
  317. line-height: 1.5;
  318. .title-box {
  319. .title {
  320. font-size: $font-lg;
  321. color: $font-color-base;
  322. }
  323. .time {
  324. font-size: $font-base;
  325. color: $font-color-light;
  326. }
  327. }
  328. .money {
  329. color: rgba(239, 58, 85, 1);
  330. font-size: $font-lg;
  331. }
  332. }
  333. }
  334. .info-box {
  335. width: 670rpx;
  336. height: 186rpx;
  337. background: #ffffff;
  338. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  339. border-radius: 20rpx;
  340. margin: -100rpx auto 0;
  341. position: relative;
  342. z-index: 2;
  343. .info-item {
  344. width: 50%;
  345. display: flex;
  346. flex-direction: column;
  347. align-items: center;
  348. line-height: 1;
  349. .info-font {
  350. font-size: 30rpx;
  351. font-family: PingFang SC;
  352. font-weight: bold;
  353. color: #999999;
  354. }
  355. .info-num {
  356. margin-top: 30rpx;
  357. font-size: 30rpx;
  358. font-family: PingFang SC;
  359. font-weight: bold;
  360. color: #181818;
  361. }
  362. }
  363. .shu {
  364. width: 2rpx;
  365. height: 74rpx;
  366. background: #dcdfe6;
  367. }
  368. }
  369. .list-scroll-content {
  370. background-color: #ffffff;
  371. height: 100%;
  372. }
  373. .content {
  374. height: 100%;
  375. .empty-content {
  376. background-color: #ffffff;
  377. }
  378. }
  379. .btm-wrap {
  380. height: 140rpx;
  381. width: 750rpx;
  382. position: fixed;
  383. bottom: 0;
  384. left: 0;
  385. background-color: #fff;
  386. .btn {
  387. width: 674rpx;
  388. height: 88rpx;
  389. line-height: 88rpx;
  390. margin: auto;
  391. background: linear-gradient(-22deg, #9a5e19, #9a5e19);
  392. border-radius: 44rpx;
  393. text-align: center;
  394. font-size: 36rpx;
  395. font-family: PingFang SC;
  396. font-weight: 500;
  397. color: #ffffff;
  398. }
  399. }
  400. </style>