award.vue 8.5 KB

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