mygx.vue 8.5 KB

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