account.vue 15 KB

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