recharge.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="">
  3. <u-navbar
  4. title="充值"
  5. :autoBack="true"
  6. bgColor="#00A447"
  7. leftIconColor="#fff"
  8. :titleStyle="{color:'#fff'}"
  9. :safeAreaInsetTop="true"
  10. >
  11. </u-navbar>
  12. <view class="top-bg"></view>
  13. <view class="page-wrap">
  14. <view class="num-wrap">
  15. <view class="title">充值</view>
  16. <view class="inner u-flex u-row-around u-flex-wrap">
  17. <view class="num-item"
  18. :class="{active:activeIndex == index&&!usecustomize}"
  19. @click="numClick(index)"
  20. v-for="(item,index) in numItem" :key="item">
  21. ¥ {{item}}
  22. </view>
  23. </view>
  24. <view class="customize" :class="{active:usecustomize}" >
  25. <u--input
  26. prefixIcon="rmb"
  27. type="number"
  28. placeholder="自定义金额"
  29. border="surround"
  30. v-model="customizeVal"
  31. clearable
  32. ></u--input>
  33. </view>
  34. <view class="rule-wrap u-flex">
  35. <u-checkbox-group v-model="checked" @change="checkboxChange" placement="row">
  36. <u-checkbox activeColor="#00A447" name="同意" label="点击确认充值,即表示您已经同意"></u-checkbox>
  37. </u-checkbox-group>
  38. <text class="link" @click="$u.route('/credits/regulation',{regulationName:'充值协议'})">《充值协议》</text>
  39. </view>
  40. <view class="full-btn" @click="submit">充 值</view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. checked:false,
  50. checkboxVal:null,
  51. customizeVal:null,
  52. activeIndex:0,
  53. numItem:[500,10000,15000]
  54. }
  55. },
  56. onShow() {
  57. },
  58. onLoad() {
  59. },
  60. computed:{
  61. usecustomize:function(){
  62. if(this.customizeVal){
  63. return true
  64. }else{
  65. return false
  66. }
  67. }
  68. },
  69. methods: {
  70. numClick(index){
  71. this.customizeVal = '';
  72. this.activeIndex = index
  73. },
  74. submit(){
  75. // console.log('usecustomize',this.usecustomize);
  76. if(!this.checkboxVal){
  77. uni.showToast({
  78. title:'请先同意充值协议',
  79. icon:'none'
  80. })
  81. return
  82. }
  83. let num = Number(this.usecustomize?this.customizeVal:this.numItem[this.activeIndex]);
  84. console.log('num',num);
  85. if(!num){
  86. uni.showToast({
  87. title:'请正确输入金额',
  88. icon:'error'
  89. })
  90. return
  91. }
  92. return
  93. let payParams={
  94. };
  95. this.$u.api.gotoPay(payParams).then(res=>{
  96. this.payResult = res.data.payResult;
  97. console.log('res',res.data);
  98. }).catch(err=>{
  99. console.log('charge',err);
  100. })
  101. },
  102. wxPay(){
  103. uni.requestPayment({
  104. ... this.payResult,
  105. "provider": "wxpay",
  106. success(res) {
  107. uni.reLaunch({url: '/center/center'})
  108. },
  109. fail(e) {
  110. console.log('wxPayfail',e);
  111. }
  112. })
  113. },
  114. checkboxChange(e){
  115. this.checkboxVal = e[0];
  116. }
  117. }
  118. }
  119. </script>
  120. <style>
  121. page{
  122. background-color: #F5F5F5;
  123. }
  124. </style>
  125. <style lang="scss" scoped>
  126. .top-bg{
  127. width: 100%;
  128. height: 450rpx;
  129. background-color: #00A447;
  130. border-radius: 0 0 20% 20%;
  131. position: absolute;
  132. top: 0;
  133. left: 0;
  134. z-index:-1;
  135. }
  136. .num-wrap{
  137. padding: 20rpx;
  138. background-color: #fff;
  139. border-radius: 8rpx;
  140. .title{
  141. font-size: 32rpx;
  142. font-weight: 600;
  143. margin-bottom: 20rpx;
  144. }
  145. .inner{
  146. margin-bottom: 40rpx;
  147. .num-item{
  148. width: 30%;
  149. height: 260rpx;
  150. line-height: 260rpx;
  151. background-color: #EBF8F1;
  152. border: 4rpx solid #EBF8F1;
  153. text-align: center;
  154. font-size: 36rpx;
  155. font-weight: 600;
  156. color: #333333;
  157. &.active{
  158. border-color: #00A447;
  159. }
  160. }
  161. }
  162. .full-btn{
  163. background-color: #FFB600;;
  164. }
  165. }
  166. .customize{
  167. &.active{
  168. /deep/ .u-input{
  169. border-color: #00A447!important;
  170. }
  171. }
  172. // /deep/ .u-input{
  173. // background-color: #bababa;
  174. // border-color: #bababa;
  175. // input{
  176. // color: #fff!important;
  177. // height: 70rpx;
  178. // font-size: 50rpx!important;
  179. // text-align: center!important;
  180. // &::-webkit-input-placeholder{
  181. // color: red!important;
  182. // }
  183. // }
  184. // }
  185. }
  186. .rule-wrap{
  187. margin: 40rpx auto;
  188. .link{
  189. color: #00A447;
  190. }
  191. }
  192. </style>