balance.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. {extend name="public/container"}
  2. {block name="title"}我的账户{/block}
  3. {extend name="public/container"}
  4. {block name="head"}
  5. <style>
  6. .loading-line{background-color: #fff;}
  7. </style>
  8. {/block}
  9. {block name="content"}
  10. <body style="background:#f5f5f5;">
  11. <div id="user-balance" class="user-balance">
  12. <section>
  13. <header ref="head" @touchmove.prevent="">
  14. <div class="count-wrapper">
  15. <p>当前余额(元)</p>
  16. <span class="count-txt">{$userInfo.now_money}</span>
  17. <div class="text-bar"></div>
  18. </div>
  19. <div class="link-list">
  20. <ul>
  21. <li class="border-1px">
  22. <a href="javascript:void(0);" @click="showRechargeCard = true">
  23. <i class="icon icon-money"></i>立即充值
  24. </a>
  25. </li>
  26. <li>
  27. <a href="{:url('index/index')}">
  28. <i class="icon icon-mall"></i>进入商城
  29. </a>
  30. </li>
  31. </ul>
  32. </div>
  33. </header>
  34. <div class="list-info">
  35. <div class="link-list" ref="nav" @touchmove.prevent="">
  36. <ul>
  37. <li class="border-1px"><i class="icon"></i>余额明细</li>
  38. </ul>
  39. </div>
  40. <div class="info-list" ref="bsDom">
  41. <div style="-webkit-overflow-scrolling : touch; position: relative;">
  42. <ul>
  43. <li class="border-1px flex" v-for="item in group.list" v-cloak="">
  44. <div class="txt-content">
  45. <p v-text="item.mark"></p>
  46. <span v-text="item.add_time"></span>
  47. </div>
  48. <div class="count" :class="{increase:item.pm == 1}">{{item.pm == 1 ? '+' : '-'}}{{item.number}}</div>
  49. </li>
  50. </ul>
  51. <p class="loading-line" v-show="loading == true"><i></i><span>正在加载中</span><i></i></p>
  52. <p class="loading-line" v-show="loading == false && group.loaded == false" v-cloak=""><i></i><span>加载更多</span><i></i></p>
  53. <p class="loading-line" v-show="loading == false && group.loaded == true" v-cloak=""><i></i><span>没有更多了</span><i></i></p>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="model-bg" @touchmove.prevent @click="showRechargeCard = false" :class="{on:showRechargeCard == true}"></div>
  58. <div class="card-model" :class="{up:showRechargeCard == true}">
  59. <div id="selects-wrapper" class="selects-info" style="max-height: 4.96rem;">
  60. <div class="payplay-wrapper">
  61. <div class="info-wrapper">
  62. <div class="tit">输入充值金额</div>
  63. <div class="money">
  64. <span>¥</span>
  65. <input v-model="rechargePrice" type="number" placeholder="0.00"/>
  66. </div>
  67. <div class="tips">充值提示:单次充值金额不能低于<span>{{minRecharge}}元</span></div>
  68. <button class="pay-btn" @click="toRecharge">点击进行微信支付</button>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="model-close" @click="showRechargeCard = false"></div>
  73. </div>
  74. </section>
  75. </div>
  76. <script>
  77. (function(){
  78. var minRecharge = '<?=$userMinRecharge?>';
  79. requirejs(['vue','helper','better-scroll','store'],function(Vue,$h,BScroll,storeApi){
  80. var wxApi = mapleWx($jssdk());
  81. new Vue({
  82. el:'#user-balance',
  83. data:{
  84. showRechargeCard:false,
  85. minRecharge:minRecharge,
  86. rechargePrice:'',
  87. group:{
  88. first:0,
  89. limit:20,
  90. list:[],
  91. loaded:false
  92. },
  93. loading: false,
  94. scroll:null,
  95. },
  96. watch:{
  97. showRechargeCard:function(){
  98. this.rechargePrice = '';
  99. }
  100. },
  101. methods:{
  102. getList:function(){
  103. if(this.loading) return;
  104. var that = this,type = 'group',group = that.group;
  105. if(group.loaded) return ;
  106. this.loading = true;
  107. storeApi.getUserBalanceList({
  108. first:group.first,
  109. limit:group.limit
  110. },function(res){
  111. var list = res.data.data,groupLength = group.list.length;
  112. that.scroll.stop();
  113. group.loaded = list.length < group.limit;
  114. group.first += list.length;
  115. group.list = group.list.concat(list);
  116. that.$set(that,type,group);
  117. that.loading = false;
  118. that.$nextTick(function(){
  119. if(list.length || !groupLength) that.scroll.refresh();
  120. if(!groupLength) setTimeout(function(){that.scroll.scrollTo(0,0,300);},0);
  121. that.scroll.finishPullUp();
  122. });
  123. },function(){that.loading = false});
  124. },
  125. toRecharge:function(){
  126. if(rechargePrice == '') return ;
  127. var rechargePrice = parseFloat(this.rechargePrice);
  128. if(rechargePrice != this.rechargePrice || rechargePrice <= 0)
  129. return $h.pushMsgOnce('请输入正确的充值金额');
  130. if(rechargePrice < minRecharge)
  131. return $h.pushMsgOnce('充值金额不能低于'+parseFloat(minRecharge));
  132. this.showRechargeCard = false;
  133. this.rechargePrice = '';
  134. storeApi.userWechatRecharge(rechargePrice,function(res){
  135. wxApi.chooseWXPay(res.data.data,function(){
  136. that.showRechargeCard = false;
  137. $h.pushMsgOnce('成功充值'+rechargePrice);
  138. });
  139. });
  140. },
  141. bScrollInit:function () {
  142. var that = this;
  143. this.$refs.bsDom.style.height = (
  144. document.documentElement.clientHeight -
  145. this.$refs.head.offsetHeight -
  146. this.$refs.nav.offsetHeight - 6.5
  147. )+'px';
  148. this.$refs.bsDom.style.overflow = 'hidden';
  149. this.scroll = new BScroll(this.$refs.bsDom,{observeDOM:false,useTransition:false,click:true,probeType:1,cancelable:false,deceleration:0.005,snapThreshold:0.01});
  150. this.scroll.on('pullingUp',function(){
  151. that.loading == false && that.getList();
  152. })
  153. }
  154. },
  155. mounted:function(){
  156. this.bScrollInit();
  157. this.getList();
  158. }
  159. })
  160. });
  161. })();
  162. </script>
  163. {/block}