award.vue 7.4 KB

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