account.vue 14 KB

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