account.vue 15 KB

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