account.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  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 "@/api/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. },
  274. onShow() {
  275. // this.accountList = []
  276. }
  277. }
  278. </script>
  279. <style lang="scss">
  280. page, .container{
  281. background: #FFFFFF;
  282. height: 100%;
  283. }
  284. .account{
  285. width: 100%;
  286. height: auto;
  287. position: relative;
  288. }
  289. .account-header{
  290. width: 100%;
  291. height: auto;
  292. position: fixed;
  293. top: 0;
  294. left: 0;
  295. z-index: 998;
  296. }
  297. .h-account{
  298. width: 100%;
  299. height: 258rpx;
  300. position: relative;
  301. background-size: cover;
  302. }
  303. .h-calendar{
  304. width: 100%;
  305. height: auto;
  306. }
  307. .m-account{
  308. width: 100%;
  309. height: 258rpx;
  310. padding:50rpx 24rpx;
  311. box-sizing: border-box;
  312. position: relative;
  313. .icon-tishi{
  314. position: absolute;
  315. right: 30rpx;
  316. top: 20rpx;
  317. font-size: 44rpx;
  318. color: #FFFFFF;
  319. text-align: right;
  320. line-height: 74rpx;
  321. }
  322. .m-m{
  323. width: 100%;
  324. }
  325. .title{
  326. height: 48rpx;
  327. text-align: center;
  328. .m-p{
  329. width: 100%;
  330. font-size: 28rpx;
  331. color: #FFFFFF;
  332. line-height: 40rpx;
  333. }
  334. }
  335. .money{
  336. height: 90rpx;
  337. text-align: center;
  338. .m-t{
  339. font-size:58rpx;
  340. color: #FFFFFF;
  341. line-height: 90rpx;
  342. &.b{
  343. font-weight: bold;
  344. }
  345. &.s{
  346. font-size: 40rpx;
  347. }
  348. }
  349. }
  350. }
  351. .h-swiper{
  352. width: 702rpx;
  353. height: 40rpx;
  354. padding: 24rpx;
  355. display: flex;
  356. .uni-input{
  357. flex: 8;
  358. font-size: $font-size-28;
  359. color: $text-color;
  360. text-align: center;
  361. line-height: 40rpx;
  362. }
  363. .iconfont{
  364. flex: 1;
  365. text-align: center;
  366. }
  367. }
  368. .h-typeTab{
  369. width: 702rpx;
  370. padding:0 24rpx;
  371. background: #fff;
  372. position: relative;
  373. z-index: 10;
  374. .nav-item{
  375. width: 33.3%;
  376. height: 40rpx;
  377. line-height:40rpx;
  378. padding: 26rpx 0 22rpx 0;
  379. font-size: $font-size-28;
  380. float: left;
  381. color: $text-color;
  382. text-align: center;
  383. position: relative;
  384. .line{
  385. width: 70rpx;
  386. height: 4rpx;
  387. background-color: #FFFFFF;
  388. position: absolute;
  389. bottom: 10rpx;
  390. left: 50%;
  391. margin-left: -35rpx;
  392. }
  393. &.current{
  394. color: $color-system;
  395. .line{
  396. background-color: $color-system;
  397. }
  398. }
  399. }
  400. }
  401. .h-swiper-content{
  402. width: 100%;
  403. height: calc(100% - 478rpx);
  404. position: relative;
  405. background: #FFFFFF;
  406. box-sizing: border-box;
  407. .list-account{
  408. width: 100%;
  409. height: auto;
  410. box-sizing: border-box;
  411. padding: 0 24rpx;
  412. background: #FFFFFF;
  413. }
  414. .icon-jiazai{
  415. color: #666666;
  416. font-size: 36rpx;
  417. }
  418. .loading {
  419. width: 100%;
  420. font-size: 28rpx;
  421. color: #999999;
  422. line-height: 36rpx;
  423. text-align: center;
  424. padding: 20rpx 0;
  425. &-no .line{
  426. width: 30%;
  427. margin: 0 auto;
  428. position: relative;
  429. &:before{
  430. content: "";
  431. width: 80rpx;
  432. height: 1px;
  433. background: #999999;
  434. position: absolute;
  435. left: -50rpx;
  436. top: 18rpx;
  437. }
  438. &:after{
  439. content: "";
  440. width: 80rpx;
  441. height: 1px;
  442. background: #999999;
  443. position: absolute;
  444. right: -50rpx;
  445. top: 18rpx;
  446. }
  447. }
  448. }
  449. .list-item{
  450. width: 100%;
  451. height: 140rpx;
  452. padding: 20rpx 0;
  453. border-bottom: 1px solid #EBEBEB;
  454. box-sizing: border-box;
  455. background: #FFFFFF;
  456. &:last-child{
  457. border-bottom: none;
  458. }
  459. .list-t{
  460. height: 54rpx;
  461. line-height: 54rpx;
  462. font-size: $font-size-32;
  463. color: #333333;
  464. display: flex;
  465. .t-t{
  466. flex: 1;
  467. &:nth-child(1){
  468. text-align: left;
  469. }
  470. &:nth-child(2){
  471. text-align: right;
  472. }
  473. &.bold{
  474. font-weight: bold;
  475. }
  476. }
  477. }
  478. .list-b{
  479. height: 46rpx;
  480. line-height: 46rpx;
  481. font-size:$font-size-28;;
  482. color: $text-color;
  483. display: flex;
  484. .t-t{
  485. flex: 1;
  486. color: #9aa5b5;
  487. &:nth-child(1){
  488. text-align: left;
  489. }
  490. &:nth-child(2){
  491. text-align: right;
  492. }
  493. .txt{
  494. color: #FF2A2A;
  495. }
  496. &.bold{
  497. font-weight: bold;
  498. }
  499. }
  500. }
  501. }
  502. }
  503. .showAccounExp{
  504. width: 100%;
  505. height: 100%;
  506. display: flex;
  507. align-items: center;
  508. justify-content: center;
  509. flex-direction: column;
  510. position: fixed;
  511. left: 0;
  512. top: 100%;
  513. opacity: 0;
  514. background: rgba(0,0,0,.5);
  515. z-index: 999;
  516. image{
  517. width: 750rpx;
  518. height: 1052rpx;
  519. }
  520. .icon-close{
  521. position: absolute;
  522. color: #FFFFFF;
  523. font-size:60rpx ;
  524. bottom: 15%;
  525. left: 50%;
  526. margin-left: -32rpx;
  527. }
  528. }
  529. .showAccounExp.show{
  530. top: 0;
  531. opacity: 1;
  532. animation:rundtop 0.3s;
  533. }
  534. .showAccounExp.hide{
  535. top: 100%;
  536. opacity: 0;
  537. animation:rundbottom 0.3s;
  538. }
  539. @keyframes rundtop{
  540. 0%{top: 100%;opacity: 0;}
  541. 100%{top:0;opacity: 1;}
  542. }
  543. @keyframes rundbottom{
  544. 0%{top: 0;opacity: 1;}
  545. 100%{top:100%;opacity: 0;}
  546. }
  547. /*空列表显示样式*/
  548. .empty-account {
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. flex-direction: column;
  553. background: $bg-color;
  554. min-height: 800rpx;
  555. &-image {
  556. width: 160rpx;
  557. height: 158rpx;
  558. }
  559. .error-text{
  560. font-size: $font-size-28;
  561. color: $text-color;
  562. line-height: 88rpx;
  563. }
  564. }
  565. .swiper-box{
  566. min-height: 750rpx;
  567. }
  568. .list-scroll-content{
  569. height: 100%;
  570. }
  571. .uni-swiper-item{
  572. height: auto;
  573. }
  574. /* load-more */
  575. .uni-load-more {
  576. display: flex;
  577. flex-direction: row;
  578. height: 80upx;
  579. align-items: center;
  580. justify-content: center
  581. }
  582. .uni-load-more__text {
  583. font-size: 28upx;
  584. color: #999
  585. }
  586. .uni-load-more__img {
  587. height: 24px;
  588. width: 24px;
  589. margin-right: 10px
  590. }
  591. .uni-load-more__img>view {
  592. position: absolute
  593. }
  594. .uni-load-more__img>view view {
  595. width: 6px;
  596. height: 2px;
  597. border-top-left-radius: 1px;
  598. border-bottom-left-radius: 1px;
  599. background: #999;
  600. position: absolute;
  601. opacity: .2;
  602. transform-origin: 50%;
  603. animation: load 1.56s ease infinite
  604. }
  605. .uni-load-more__img>view view:nth-child(1) {
  606. transform: rotate(90deg);
  607. top: 2px;
  608. left: 9px
  609. }
  610. .uni-load-more__img>view view:nth-child(2) {
  611. transform: rotate(180deg);
  612. top: 11px;
  613. right: 0
  614. }
  615. .uni-load-more__img>view view:nth-child(3) {
  616. transform: rotate(270deg);
  617. bottom: 2px;
  618. left: 9px
  619. }
  620. .uni-load-more__img>view view:nth-child(4) {
  621. top: 11px;
  622. left: 0
  623. }
  624. .load1,
  625. .load2,
  626. .load3 {
  627. height: 24px;
  628. width: 24px
  629. }
  630. .load2 {
  631. transform: rotate(30deg)
  632. }
  633. .load3 {
  634. transform: rotate(60deg)
  635. }
  636. .load1 view:nth-child(1) {
  637. animation-delay: 0s
  638. }
  639. .load2 view:nth-child(1) {
  640. animation-delay: .13s
  641. }
  642. .load3 view:nth-child(1) {
  643. animation-delay: .26s
  644. }
  645. .load1 view:nth-child(2) {
  646. animation-delay: .39s
  647. }
  648. .load2 view:nth-child(2) {
  649. animation-delay: .52s
  650. }
  651. .load3 view:nth-child(2) {
  652. animation-delay: .65s
  653. }
  654. .load1 view:nth-child(3) {
  655. animation-delay: .78s
  656. }
  657. .load2 view:nth-child(3) {
  658. animation-delay: .91s
  659. }
  660. .load3 view:nth-child(3) {
  661. animation-delay: 1.04s
  662. }
  663. .load1 view:nth-child(4) {
  664. animation-delay: 1.17s
  665. }
  666. .load2 view:nth-child(4) {
  667. animation-delay: 1.3s
  668. }
  669. .load3 view:nth-child(4) {
  670. animation-delay: 1.43s
  671. }
  672. @-webkit-keyframes load {
  673. 0% {
  674. opacity: 1
  675. }
  676. 100% {
  677. opacity: .2
  678. }
  679. }
  680. </style>