award.vue 6.3 KB

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