award.vue 7.0 KB

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