MrShi
2025-08-21 d98b610bd0793dd5d29f623400a1d0a81bb55334
small-program/pages/withdrawal/withdrawal.vue
@@ -11,13 +11,17 @@
               <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="number" v-model="amount" @input="changeAmount" placeholder="请输入提现金额" />
               <view class="content-input-btn" @click="inputAll">全部提现</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>
@@ -35,23 +39,95 @@
      data() {
         return {
            tips:'',//
            wxTips:'',
            canTransfer:false,
            changing1:false,
            amount: null
            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
              }
@@ -68,13 +144,14 @@
              }
              this.changing1 = true
              var that = this
              var param ={amount:this.amount }
              var param ={amount:this.amount,name:this.name }
              that.$u.api.applyWithdrawal(param)
              .then(res =>{
                  if(res.code ===200){
                     uni.navigateTo({
                        url: '/pages/withdrawal-successful/withdrawal-successful'
                     })
                     that.wxMerchantTransfer(res.data);
                     // uni.navigateTo({
                     //    url: '/pages/withdrawal-successful/withdrawal-successful'
                     // })
                  } 
               }).finally(() => {
                  that.changing1 = false