account.vue 15 KB

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