award.vue 6.8 KB

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