award.vue 7.9 KB

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