account-bean.vue 14 KB

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