| <template> | 
|     <view class="tx"> | 
|         <view class="tx-content"> | 
|             <view class="tx-content-title">可提现余额(元)</view> | 
|             <view class="tx-content-price"> | 
|                 <text>{{((userInfo.amount|| 0)/100).toFixed(2)}}</text> | 
|                 <view class="tx-content-price-btn" @click="jump">余额明细</view> | 
|             </view> | 
|             <view class="content"> | 
|                 <view class="content-head"> | 
|                     <text>提现到账</text> | 
|                     <text>微信零钱</text> | 
|                 </view> | 
|                 <view class="content-title">真实姓名</view> | 
|                 <view class="content-input" style="margin-bottom: 40rpx;">  | 
|                     <input style="font-weight: 500;" type="text" v-model="name"  @input="changeName" placeholder="微信实名认证姓名" />  | 
|                 </view> | 
|                 <view class="content-title">提现金额</view> | 
|                 <view class="content-input"> | 
|                     <view class="content-input-icon"> | 
|                         <image src="/static/icon/ic_money@2x.png" mode="widthFix"></image> | 
|                     </view> | 
|                     <input type="digit" v-model="amount" @input="changeAmount" placeholder="请输入提现金额" /> | 
|                     <view class="content-input-btn" @click="inputAll">全部提现</view>  | 
|                 </view> | 
|                 <view class="content-tips">{{tips}}</view> | 
|                 <view class="content-button" @click="submit">2小时到账,确认提现</view> | 
|             </view> | 
|         </view> | 
|     </view> | 
| </template> | 
|   | 
| <script> | 
|     import { mapState } from 'vuex' | 
|     export default { | 
|         computed: { | 
|             ...mapState(['userInfo' ]) | 
|         }, | 
|         data() { | 
|             return { | 
|                 tips:'',// | 
|                 wxTips:'', | 
|                 canTransfer:false, | 
|                 changing1:false, | 
|                 amount: null, | 
|                 name:'' | 
|             }; | 
|         }, | 
|         onLoad(){ | 
|             this.name = this.userInfo.name | 
|             var that =this | 
|             that.canTransfer = false | 
|             if (wx.canIUse('requestMerchantTransfer')) { | 
|                 //that.tips='您的微信版本支持该功能' | 
|                 that.canTransfer = true | 
|             }else{ | 
|                 that.tips='您的微信版本过低,请更新至最新版本使用该功能' | 
|                 uni.showToast({ | 
|                     title:'您的微信版本过低,请更新至最新版本使用该功能。' | 
|                 }) | 
|             } | 
|             /* wx.ready(function () { | 
|               wx.checkJsApi({ | 
|                 jsApiList: ['requestMerchantTransfer'], | 
|                 success: function (res) { | 
|                   if (res.checkResult['requestMerchantTransfer']) { | 
|                         that.canTransfer = true | 
|                   } else { | 
|                       that.tips='您的微信版本过低,请更新至最新版本使用该功能' | 
|                       uni.showToast({ | 
|                           title:'您的微信版本过低,请更新至最新版本使用该功能。' | 
|                       }) | 
|                   } | 
|                 } | 
|               }); | 
|             }); */ | 
|         }, | 
|         methods: { | 
|             jump() { | 
|                 uni.navigateTo({ | 
|                     url: '/pages/balance-details/balance-details' | 
|                 }) | 
|             },  | 
|             inputAll(){ | 
|                 this.amount = ((this.userInfo.amount|| 0)/100).toFixed(2) | 
|             }, | 
|             changeAmount(){ | 
|                 this.tips='' | 
|             }, | 
|             wxMerchantTransfer(param){     | 
|                 wx.requestMerchantTransfer({ | 
|                     mchId: param.mchId, | 
|                     appId: param.appId, | 
|                     package: param.packageInfo, | 
|                     success: (res) => { | 
|                       // res.err_msg将在页面展示成功后返回应用时返回ok,并不代表付款成功 | 
|                       console.log(res) | 
|                       uni.navigateTo({ | 
|                           url: '/pages/withdrawal-successful/withdrawal-successful' | 
|                       }) | 
|                     }, | 
|                     fail: (res) => { | 
|                       console.log("22222222222222",res) | 
|                       uni.showToast({ | 
|                           title:'对不起,提现失败。'+res.err_msg | 
|                       }) | 
|                     }, | 
|                   }); | 
|                 /* WeixinJSBridge.invoke('requestMerchantTransfer',param, | 
|                   function (res) { | 
|                     if (res.err_msg === 'requestMerchantTransfer:ok') { | 
|                       // res.err_msg将在页面展示成功后返回应用时返回success,并不代表付款成功 | 
|                       uni.navigateTo({ | 
|                           url: '/pages/withdrawal-successful/withdrawal-successful' | 
|                       }) | 
|                     }else{  | 
|                         uni.showToast({ | 
|                             title:'对不起,提现失败。'+res.err_msg | 
|                         }) | 
|                     } | 
|                   } | 
|                 );     */                   | 
|             }, | 
|             submit() { | 
|                   if(!this.canTransfer){ | 
|                       uni.showToast({ | 
|                           title:'您的微信版本过低,请更新至最新版本使用该功能。' | 
|                       }) | 
|                       return; | 
|                   } | 
|                   if(this.changing1){ | 
|                         return | 
|                   } | 
|                   this.changing1 = true | 
|                   if(this.amount == null || this.amount<=0){ | 
|                       this.tips = '提交金额必须大于0,至少提现0.1元' | 
|                       this.changing1 = false | 
|                       return | 
|                   } | 
|                   if(this.amount *100 > this.userInfo.amount){ | 
|                       this.tips = '输入的金额已经超过可提现金额' | 
|                       this.changing1 = false | 
|                       return | 
|                   } | 
|                   this.changing1 = true | 
|                   var that = this | 
|                   var param ={amount:this.amount,name:this.name } | 
|                   that.$u.api.applyWithdrawal(param) | 
|                   .then(res =>{ | 
|                         if(res.code ===200){ | 
|                             that.wxMerchantTransfer(res.data); | 
|                             // uni.navigateTo({ | 
|                             //     url: '/pages/withdrawal-successful/withdrawal-successful' | 
|                             // }) | 
|                         }  | 
|                    }).finally(() => { | 
|                         that.changing1 = false | 
|                         that.tips='' | 
|                         that.amount =null | 
|                     }) | 
|             }, | 
|              | 
|         } | 
|     } | 
| </script> | 
|   | 
| <style lang="scss"> | 
|     page { | 
|         background-color: $uni-bg-color-grey; | 
|     } | 
| </style> | 
|   | 
| <style lang="scss" scoped> | 
|     .tx { | 
|         width: 100%; | 
|         .tx-content { | 
|             width: 100%; | 
|             height: 240rpx; | 
|             padding: 30rpx 40rpx; | 
|             box-sizing: border-box; | 
|             background: #5BBE38; | 
|             .content { | 
|                 width: 100%; | 
|                 padding: 60rpx 40rpx; | 
|                 box-sizing: border-box; | 
|                 background: #FFFFFF; | 
|                 box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(0,0,0,0.08); | 
|                 border-radius: 20rpx; | 
|                 .content-head { | 
|                     width: 100%; | 
|                     display: flex; | 
|                     align-items: center; | 
|                     justify-content: space-between; | 
|                     border-bottom: 1rpx solid #E5E5E5; | 
|                     padding-bottom: 32rpx; | 
|                     box-sizing: border-box; | 
|                     margin-bottom: 30rpx; | 
|                     text { | 
|                         &:nth-child(1) { | 
|                             font-weight: 400; | 
|                             font-size: 30rpx; | 
|                             color: #666666; | 
|                         } | 
|                         &:nth-child(2) { | 
|                             font-weight: 400; | 
|                             font-size: 30rpx; | 
|                             color: #222222; | 
|                         } | 
|                     } | 
|                 } | 
|                 .content-title { | 
|                     font-weight: 500; | 
|                     font-size: 34rpx; | 
|                     color: #111111; | 
|                 } | 
|                 .content-input { | 
|                     width: 100%; | 
|                     height: 116rpx; | 
|                     display: flex; | 
|                     align-items: center; | 
|                     border-bottom: 1rpx solid #E5E5E5; | 
|                     .content-input-icon { | 
|                         width: 24rpx; | 
|                         height: 56rpx; | 
|                         flex-shrink: 0; | 
|                         display: flex; | 
|                         align-items: center; | 
|                         justify-content: center; | 
|                         image { | 
|                             width: 100%; | 
|                             height: 100%; | 
|                         } | 
|                     } | 
|                     input { | 
|                         flex: 1; | 
|                         margin: 0 10px; | 
|                         font-weight: 500; | 
|                         font-size: 40rpx; | 
|                         color: #222222; | 
|                     } | 
|                     .content-input-btn { | 
|                         font-weight: 400; | 
|                         font-size: 30rpx; | 
|                         color: #5BBE38; | 
|                     } | 
|                 } | 
|                 .content-tips { | 
|                     font-weight: 400; | 
|                     font-size: 26rpx; | 
|                     color: #FF0000; | 
|                     margin-top: 30rpx; | 
|                 } | 
|                 .content-button { | 
|                     width: 100%; | 
|                     height: 88rpx; | 
|                     line-height: 88rpx; | 
|                     text-align: center; | 
|                     background: #5BBE38; | 
|                     box-shadow: 0rpx 8rpx 12rpx 0rpx rgba(91,190,56,0.16); | 
|                     border-radius: 44rpx; | 
|                     font-weight: 500; | 
|                     font-size: 32rpx; | 
|                     color: #FFFFFF; | 
|                     margin-top: 80rpx; | 
|                     box-sizing: border-box; | 
|                 } | 
|             } | 
|             .tx-content-title { | 
|                 font-weight: 400; | 
|                 font-size: 26rpx; | 
|                 color: #FFFFFF; | 
|                 margin-bottom: 14rpx; | 
|             } | 
|             .tx-content-price { | 
|                 width: 100%; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: space-between; | 
|                 margin-bottom: 32rpx; | 
|                 text { | 
|                     font-weight: 600; | 
|                     font-size: 48rpx; | 
|                     color: #FFFFFF; | 
|                 } | 
|                 .tx-content-price-btn { | 
|                     width: 164rpx; | 
|                     height: 60rpx; | 
|                     line-height: 60rpx; | 
|                     text-align: center; | 
|                     border-radius: 30rpx; | 
|                     font-weight: 400; | 
|                     font-size: 26rpx; | 
|                     color: #FFFFFF; | 
|                     border: 2rpx solid #FFFFFF; | 
|                 } | 
|             } | 
|         } | 
|     } | 
| </style> |