award.vue 7.6 KB

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