award.vue 7.5 KB

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