award.vue 7.8 KB

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