account.vue 14 KB

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