account.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <template>
  2. <view class="container account clearfix">
  3. <view class="account-header">
  4. <view class="h-account">
  5. <image src="https://img.caimei365.com/group1/M00/03/8D/Cmis215XHXWAJ2l7AAGcgkqy28c765.png" mode=""></image>
  6. <view class="m-account">
  7. <view class="m-m title">
  8. <text class="m-p">可用余额</text>
  9. <text class="iconfont icon-shuoming" @click="showAccounExp"></text>
  10. </view>
  11. <view class="m-m money">
  12. <text class="m-t s">¥</text>
  13. <text class="m-t b">{{showIndexOfMoney}}</text>
  14. <text class="m-t s">{{smallMoney}}</text>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="h-calendar">
  19. <!-- 插入模式 切换年月-->
  20. <uni-calendar :selected="infoData.selected" @monthSwitch="monthSwitch" />
  21. </view>
  22. <view class="h-typeTab clearfix">
  23. <view
  24. v-for="(item, index) in navList" :key="index"
  25. class="nav-item"
  26. :class="{current: tabCurrentIndex === index}"
  27. @click="tabClick(index)"
  28. >
  29. {{item.text}}
  30. </view>
  31. </view>
  32. </view>
  33. <!-- @scrolltolower="toLower" -->
  34. <scroll-view class="h-swiper-content" scroll-y >
  35. <!-- 空白页 -->
  36. <view v-if="isEmpty" class="empty-account">
  37. <image class="empty-account-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6ADg5RAABQ9EmRCGk830.png" mode="aspectFit"></image>
  38. <text class="error-text">{{errorText}}</text>
  39. </view>
  40. <!-- 余额明细列表 -->
  41. <view v-else class="list-account">
  42. <view v-for="(item,index) in accountList" :key="index" class="list-item">
  43. <view class="list-t">
  44. <view class="t-t">{{item.addDate}}</view>
  45. <view class="t-t bold">{{item.type =='1'? '收入' : '支出'}}</view>
  46. </view>
  47. <view class="list-b">
  48. <view class="t-t bold">{{cheakType(item.balanceType)}}</view>
  49. <view class="t-t">
  50. <text class="txt">{{item.type =='1'? '+' : '-'}}</text>
  51. <text class="txt">¥{{item.amount}}</text>
  52. </view>
  53. </view>
  54. </view>
  55. <!--加载loadding-->
  56. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  57. <tui-nomore :visible="!pullUpOn" bgcolor="#F7F7F7" :text='nomoreText'></tui-nomore>
  58. <!--加载loadding-->
  59. </view>
  60. </scroll-view>
  61. <view class="showAccounExp" :class="[isShowAccounExp == true ? 'show':'hide']" @tap="hideAccounExp">
  62. <image src="https://img.caimei365.com/group1/M00/03/8D/Cmis215XHXWAZAHAAA2oDvspRRU775.png" mode=""></image>
  63. <text class="iconfont icon-close" @click="hideAccounExp"></text>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
  69. import tuiNomore from "@/components/tui-components/nomore/nomore"
  70. import uniCalendar from '@/components/uni-calendar/uni-calendar.vue'
  71. var date = new Date();
  72. export default{
  73. components: {
  74. uniCalendar,
  75. tuiLoadmore,
  76. tuiNomore
  77. },
  78. data() {
  79. return{
  80. year: date.getFullYear(), //年
  81. month: date.getMonth()+1, //月
  82. userID: '', //用户ID
  83. pageNum:1, //页数
  84. pageSize:10, //加载条数
  85. balanceType: '', //查询余额类型
  86. showIndexOfMoney:'',
  87. smallMoney:'00',
  88. ableUserMoney:58656.65, //可用余额
  89. balanceTypeText:'', //根据类型显示文字
  90. tabCurrentIndex: 0, //标签选择索引
  91. infoData: {selected: []}, //日期选择
  92. accountList: [], //余额列表
  93. isShowAccounExp:false, //控制明细说明文字显示
  94. isRefreshing:false,
  95. isNomore:false,
  96. isEmpty:false,
  97. loadding: false,
  98. pullUpOn: true,
  99. hasNextPage: false,
  100. pullFlag: true,
  101. nomoreText: '上拉显示更多',
  102. errorText:'本月没有任何余额收支记录',
  103. navList: [
  104. {state: 0,text: '全部'},
  105. {state: 1,text: '收入'},
  106. {state: 2,text: '支出'},
  107. ],
  108. isCheckObject:{
  109. 0:['','本月没有任何余额收支记录'],
  110. 1:[1, '本月没有余额收入记录!'],
  111. 2:[2, '本月没有余额支出记录!'],
  112. },
  113. }
  114. },
  115. onLoad() {
  116. this.getAccountInitData(this.tabCurrentIndex,this.year,this.month)
  117. },
  118. methods: {
  119. getAccountInitData(index,year,month){//获取余额明细数据列表
  120. Object.keys(this.isCheckObject).forEach(key => {
  121. if (+key === +index) {
  122. this.balanceType = this.isCheckObject[key][0]
  123. this.errorText = this.isCheckObject[key][1]
  124. }
  125. })
  126. this.$api.getStorage().then((resolve) =>{
  127. this.userID =resolve.userID
  128. /**
  129. * @余额明细初始化加载 仅加载第一页码
  130. * @param:type(查询余额类型:0全部,1收入,2支出)
  131. * @param:year(查询年份)
  132. * @param:month(查询月份)
  133. * @param:index(页码数)
  134. * @param:pageSize(每页条数)
  135. * @param:userId(用户ID)
  136. */
  137. let param = {year:year,month:month,userId:this.userID,index:1,pageSize:this.pageSize, type:this.balanceType,}
  138. this.$api.lodingGet('/personal/touchBalance',param,
  139. response => {
  140. this.initAbleUserMoney(response.ableUserMoney)
  141. let resData = response.page.results
  142. this.hasNextPage = response.page.hasNextPage;
  143. if(resData && resData.length > 0){
  144. this.isEmpty = false;
  145. this.accountList = [...resData];
  146. }else{
  147. this.isEmpty = true
  148. }
  149. if(this.hasNextPage){
  150. this.pullUpOn = false
  151. this.nomoreText = '上拉显示更多'
  152. }else{
  153. if(this.accountList.length < 2){
  154. this.pullUpOn = true
  155. }else{
  156. this.pullUpOn = false
  157. this.nomoreText = '已至底部'
  158. }
  159. }
  160. }
  161. )
  162. })
  163. },
  164. getOnReachBottomData(index,year,month){//上拉加载
  165. this.pageNum+=1
  166. let param = {year:year,month:month,userId:this.userID,index:this.pageNum,pageSize:this.pageSize,type:this.balanceType}
  167. this.$api.get('/personal/touchBalance',param,
  168. response => {
  169. let resData = response.page.results
  170. this.hasNextPage = response.page.hasNextPage;
  171. this.accountList = this.accountList.concat(resData)
  172. this.pullFlag = false;// 防上拉暴滑
  173. setTimeout(()=>{this.pullFlag = true;},500)
  174. if(this.hasNextPage){
  175. this.pullUpOn = false
  176. this.nomoreText = '上拉显示更多'
  177. }else{
  178. this.loadding = false
  179. this.pullUpOn = false
  180. this.nomoreText = '已至底部'
  181. }
  182. }
  183. )
  184. },
  185. initAbleUserMoney(money){//拆分金额并转千分位格式显示
  186. if(money == 0){
  187. this.showIndexOfMoney ='0';
  188. this.smallMoney=".00"
  189. }else{
  190. this.ableUserMoney = this.$api.FormatMoney(money) ;
  191. let i = this.ableUserMoney.toString().lastIndexOf('.');
  192. if(i==-1){
  193. this.showIndexOfMoney=this.$api.FormatMoney( this.ableUserMoney)
  194. this.smallMoney=".00"
  195. }else{
  196. this.smallMoney = this.ableUserMoney.toString().substring(i);
  197. this.showIndexOfMoney= this.$api.FormatMoney(this.ableUserMoney.toString().substring(0,i))
  198. }
  199. }
  200. },
  201. tabClick(index){//tab点击
  202. this.tabCurrentIndex = index;
  203. this.pageNum = 1
  204. this.accountList = []
  205. this.pullUpOn = true //隐藏
  206. this.getAccountInitData(this.tabCurrentIndex,this.year,this.month);
  207. },
  208. bindDateChange: function(e) {
  209. // console.log(e);
  210. this.date = e.target.value
  211. },
  212. monthSwitch(e) {
  213. this.year = e.year;
  214. this.month = e.month;
  215. this.getAccountInitData(this.tabCurrentIndex,this.year,this.month);
  216. },
  217. cheakType(type){
  218. let text;
  219. switch(type){
  220. case '1':
  221. text ='余额抵扣'
  222. break;
  223. case '2':
  224. text ='多收退款到余额'
  225. break;
  226. case '3':
  227. text ='申请退款'
  228. break;
  229. case '4':
  230. text ='余额充值'
  231. break;
  232. case '5':
  233. text ='余额提现'
  234. break;
  235. }
  236. return text;
  237. },
  238. showAccounExp(){
  239. this.isShowAccounExp = true
  240. },
  241. hideAccounExp(){
  242. this.isShowAccounExp = false
  243. }
  244. },
  245. onReachBottom() {
  246. if(this.hasNextPage){
  247. this.loadding = true
  248. this.pullUpOn = true
  249. this.getOnReachBottomData(this.tabCurrentIndex,this.year,this.month)
  250. }
  251. },
  252. onPullDownRefresh() {//下拉刷新
  253. this.getAccountInitData(this.tabCurrentIndex,this.year,this.month)
  254. },
  255. onShow() {
  256. // this.accountList = []
  257. }
  258. }
  259. </script>
  260. <style lang="scss">
  261. page, .container{
  262. background: #F7F7F7;
  263. height: 100%;
  264. }
  265. .account{
  266. width: 100%;
  267. height: auto;
  268. position: relative;
  269. }
  270. .account-header{
  271. width: 100%;
  272. height: auto;
  273. position: fixed;
  274. top: 0;
  275. left: 0;
  276. z-index: 998;
  277. }
  278. .h-account{
  279. width: 100%;
  280. height: 264rpx;
  281. position: relative;
  282. image{
  283. width: 750rpx;
  284. height: 264rpx;
  285. }
  286. }
  287. .h-calendar{
  288. width: 100%;
  289. height: auto;
  290. }
  291. .m-account{
  292. width: 702rpx;
  293. height: 216rpx;
  294. padding: 24rpx;
  295. position:absolute;
  296. left: 0;
  297. top: 0;
  298. .m-m{
  299. width: 702rpx;
  300. }
  301. .title{
  302. height: 74rpx;
  303. display: flex;
  304. .m-p{
  305. flex: 1;
  306. font-size: 40rpx;
  307. color: #FFFFFF;
  308. text-align: left;
  309. line-height: 74rpx;
  310. }
  311. .iconfont{
  312. flex: 1;
  313. font-size: 52rpx;
  314. color: #FFFFFF;
  315. text-align: right;
  316. line-height: 74rpx;
  317. }
  318. }
  319. .money{
  320. height: 142rpx;
  321. .m-t{
  322. font-size: 84rpx;
  323. color: #FFFFFF;
  324. text-align: left;
  325. line-height: 142rpx;
  326. &.b{
  327. font-weight: bold;
  328. }
  329. &.s{
  330. font-size: 40rpx;
  331. }
  332. }
  333. }
  334. }
  335. .h-swiper{
  336. width: 702rpx;
  337. height: 40rpx;
  338. padding: 24rpx;
  339. display: flex;
  340. .uni-input{
  341. flex: 8;
  342. font-size: $font-size-28;
  343. color: $text-color;
  344. text-align: center;
  345. line-height: 40rpx;
  346. }
  347. .iconfont{
  348. flex: 1;
  349. text-align: center;
  350. }
  351. }
  352. .h-typeTab{
  353. width: 702rpx;
  354. padding:0 24rpx;
  355. background: #fff;
  356. position: relative;
  357. z-index: 10;
  358. .nav-item{
  359. width: 33.3%;
  360. height: 40rpx;
  361. line-height:40rpx;
  362. padding: 26rpx 0 22rpx 0;
  363. font-size: $font-size-28;
  364. float: left;
  365. color: $text-color;
  366. text-align: center;
  367. position: relative;
  368. &.current{
  369. color: $color-system;
  370. }
  371. }
  372. }
  373. .h-swiper-content{
  374. width: 100%;
  375. padding:478rpx 0 0 0;
  376. height: calc(100% - 478rpx);
  377. position: relative;
  378. background: #F7F7F7;
  379. .icon-jiazai{
  380. color: #666666;
  381. font-size: 36rpx;
  382. }
  383. .loading {
  384. width: 100%;
  385. font-size: 28rpx;
  386. color: #999999;
  387. line-height: 36rpx;
  388. text-align: center;
  389. padding: 20rpx 0;
  390. &-no .line{
  391. width: 30%;
  392. margin: 0 auto;
  393. position: relative;
  394. &:before{
  395. content: "";
  396. width: 80rpx;
  397. height: 1px;
  398. background: #999999;
  399. position: absolute;
  400. left: -50rpx;
  401. top: 18rpx;
  402. }
  403. &:after{
  404. content: "";
  405. width: 80rpx;
  406. height: 1px;
  407. background: #999999;
  408. position: absolute;
  409. right: -50rpx;
  410. top: 18rpx;
  411. }
  412. }
  413. }
  414. .list-item{
  415. width: 702rpx;
  416. height: 100rpx;
  417. padding: 20rpx 24rpx;
  418. border-bottom: 1px solid #EBEBEB;
  419. background: #FFFFFF;
  420. &:last-child{
  421. border-bottom: none;
  422. }
  423. .list-t{
  424. height: 34rpx;
  425. line-height: 34rpx;
  426. font-size: $font-size-28;
  427. color: $text-color;
  428. display: flex;
  429. margin-bottom: 28rpx;
  430. .t-t{
  431. flex: 1;
  432. &:nth-child(1){
  433. text-align: left;
  434. }
  435. &:nth-child(2){
  436. text-align: right;
  437. }
  438. &.bold{
  439. font-weight: bold;
  440. }
  441. }
  442. }
  443. .list-b{
  444. height: 34rpx;
  445. line-height: 34rpx;
  446. font-size:$font-size-28;;
  447. margin-top: 24rpx;
  448. color: $text-color;
  449. display: flex;
  450. .t-t{
  451. flex: 1;
  452. &:nth-child(1){
  453. text-align: left;
  454. }
  455. &:nth-child(2){
  456. text-align: right;
  457. }
  458. .txt{
  459. color: #FF2A2A;
  460. }
  461. &.bold{
  462. font-weight: bold;
  463. }
  464. }
  465. }
  466. }
  467. }
  468. .showAccounExp{
  469. width: 100%;
  470. height: 100%;
  471. display: flex;
  472. align-items: center;
  473. justify-content: center;
  474. flex-direction: column;
  475. position: fixed;
  476. left: 0;
  477. top: 100%;
  478. display: none;
  479. background: rgba(0,0,0,.5);
  480. z-index: 999;
  481. image{
  482. width: 750rpx;
  483. height: 1052rpx;
  484. }
  485. .icon-close{
  486. position: relative;
  487. color: #FFFFFF;
  488. font-size:60rpx ;
  489. bottom: 60rpx;
  490. left: 50%;
  491. margin-left: -32rpx;
  492. }
  493. }
  494. .showAccounExp.show{
  495. top: 0;
  496. display: block;
  497. animation:rundtop 0.3s;
  498. }
  499. .showAccounExp.hide{
  500. top: 100%;
  501. display: none;
  502. animation:rundbottom 0.3s;
  503. }
  504. @keyframes rundtop{
  505. 0%{top: 100%;display: none;}
  506. 100%{top:0;display: block;}
  507. }
  508. @keyframes rundbottom{
  509. 0%{top: 0;display: block;}
  510. 100%{top:100%;display: none;}
  511. }
  512. /*空列表显示样式*/
  513. .empty-account {
  514. display: flex;
  515. align-items: center;
  516. justify-content: center;
  517. flex-direction: column;
  518. background: $bg-color;
  519. min-height: 800rpx;
  520. &-image {
  521. width: 160rpx;
  522. height: 158rpx;
  523. }
  524. .error-text{
  525. font-size: $font-size-28;
  526. color: $text-color;
  527. line-height: 88rpx;
  528. }
  529. }
  530. .swiper-box{
  531. min-height: 750rpx;
  532. }
  533. .list-scroll-content{
  534. height: 100%;
  535. }
  536. .uni-swiper-item{
  537. height: auto;
  538. }
  539. /* load-more */
  540. .uni-load-more {
  541. display: flex;
  542. flex-direction: row;
  543. height: 80upx;
  544. align-items: center;
  545. justify-content: center
  546. }
  547. .uni-load-more__text {
  548. font-size: 28upx;
  549. color: #999
  550. }
  551. .uni-load-more__img {
  552. height: 24px;
  553. width: 24px;
  554. margin-right: 10px
  555. }
  556. .uni-load-more__img>view {
  557. position: absolute
  558. }
  559. .uni-load-more__img>view view {
  560. width: 6px;
  561. height: 2px;
  562. border-top-left-radius: 1px;
  563. border-bottom-left-radius: 1px;
  564. background: #999;
  565. position: absolute;
  566. opacity: .2;
  567. transform-origin: 50%;
  568. animation: load 1.56s ease infinite
  569. }
  570. .uni-load-more__img>view view:nth-child(1) {
  571. transform: rotate(90deg);
  572. top: 2px;
  573. left: 9px
  574. }
  575. .uni-load-more__img>view view:nth-child(2) {
  576. transform: rotate(180deg);
  577. top: 11px;
  578. right: 0
  579. }
  580. .uni-load-more__img>view view:nth-child(3) {
  581. transform: rotate(270deg);
  582. bottom: 2px;
  583. left: 9px
  584. }
  585. .uni-load-more__img>view view:nth-child(4) {
  586. top: 11px;
  587. left: 0
  588. }
  589. .load1,
  590. .load2,
  591. .load3 {
  592. height: 24px;
  593. width: 24px
  594. }
  595. .load2 {
  596. transform: rotate(30deg)
  597. }
  598. .load3 {
  599. transform: rotate(60deg)
  600. }
  601. .load1 view:nth-child(1) {
  602. animation-delay: 0s
  603. }
  604. .load2 view:nth-child(1) {
  605. animation-delay: .13s
  606. }
  607. .load3 view:nth-child(1) {
  608. animation-delay: .26s
  609. }
  610. .load1 view:nth-child(2) {
  611. animation-delay: .39s
  612. }
  613. .load2 view:nth-child(2) {
  614. animation-delay: .52s
  615. }
  616. .load3 view:nth-child(2) {
  617. animation-delay: .65s
  618. }
  619. .load1 view:nth-child(3) {
  620. animation-delay: .78s
  621. }
  622. .load2 view:nth-child(3) {
  623. animation-delay: .91s
  624. }
  625. .load3 view:nth-child(3) {
  626. animation-delay: 1.04s
  627. }
  628. .load1 view:nth-child(4) {
  629. animation-delay: 1.17s
  630. }
  631. .load2 view:nth-child(4) {
  632. animation-delay: 1.3s
  633. }
  634. .load3 view:nth-child(4) {
  635. animation-delay: 1.43s
  636. }
  637. @-webkit-keyframes load {
  638. 0% {
  639. opacity: 1
  640. }
  641. 100% {
  642. opacity: .2
  643. }
  644. }
  645. </style>