doum
13 小时以前 6e56c64e4b6b77b8acc61d34392c1fa0418ff499
mini-program/pagesA/pages/withdraw/withdraw.vue
@@ -3,14 +3,15 @@
      <view class="bg">
         <view class="bg-a">可提现余额(元)</view>
         <view class="bg-b">
            <text>1000</text>
            <text>.00</text>
            <text>{{(shop.amount || 0).toFixed(2)}}</text>
            <text></text>
         </view>
         <view class="form">
            <view class="form-a">
               <view class="form-a-label">提现至</view>
               <view class="form-a-val">
                  <text>暂无银行信息,点击添加</text>
               <view class="form-a-val" @click="jumpBank" >
                  <text v-if="!selectBank || !selectBank.id " class="text-grey">暂无银行信息,点击添加</text>
                  <text v-if="selectBank && selectBank.id  ">{{selectBank.bankInfo || ''}}</text>
                  <u-icon name="arrow-right" color="#999999" size="16"></u-icon>
               </view>
            </view>
@@ -18,22 +19,165 @@
            <view class="form-title">提现金额</view>
            <view class="form-input">
               <view class="form-input-dw">¥</view>
               <input type="text" placeholder="0" />
               <view class="form-input-tx">全部提现</view>
               <input type="text" placeholder="0" v-model="form.amount"  :focus='focus' @blur="focus=false"/>
               <view class="form-input-tx" @click="inputAll">全部提现</view>
            </view>
            <view class="form-error">输入的金额已经超过可提现金额</view>
            <view class="form-btn disable">提交申请</view>
            <view class="form-error">{{tips}}</view>
            <view class="form-btn disable" v-if="!validForm">提交申请</view>
            <view class="form-btn" v-if="validForm" @click="confirm()">提交申请</view>
         </view>
      </view>
      <u-popup :show="show" round="15" :safeAreaInsetBottom="false" mode="center">
         <view class="tc">
            <view class="tc-contemt">
               <view class="tc-contemt-title">操作提示</view>
               <view class="tc-contemt-nr">
                  您确认发起此次提现申请吗?
               </view>
            </view>
            <view class="tc-btn">
               <view class="tc-btn-item" @click="confirm() ">我再想想</view>
               <view class="tc-btn-item" style="color: #004096;" @click="applyDo">确认</view>
            </view>
         </view>
      </u-popup>
   </view>
</template>
<script>
   import { mapState } from 'vuex'
   export default {
      computed: {
         ...mapState(['navHeight', 'statusbarHeight','shopInfo', 'shopToken']),
        validForm() {
            this.tips =''
          if(! this.selectBank || !this.selectBank.id){
            this.tips ='请先选择您需要提现的银行账户信息'
             return false
          }
          this.form.bankId = this.selectBank.id
          if(!this.form.amount ||this.form.amount <=0){
            this.tips ='请输入提现金额'
            this.focus=true
             return false
          }
          if(this.form.amount >( this.shop.amount||0)){
             this.tips ='输入的金额已经超过可提现金额'
            this.focus=true
            return false
          }
           return true
         }
      },
      data() {
         return {
         return {
            show:false,
            tips:'',
            focus:false,
            valid:false,
            bankList:[],
            selectBank:[],
            form: { amount:null,bankId:null},
            shop:{},
            info:{}
         }
      },
      onLoad(options) {
         this.info={}
         this.tips=''
         this.shop  ={}
         this.bankList = []
         this.show=false
         this.focus=false
         this.selectBank={}
         this.checkShopLogin()
         this.shop = this.shopInfo || {}
         this.getBankList()
         var that =this
         uni.$on('selectBank',function(data){
            console.log('监听到事件来自 selectBank:' ,data);
            that.selectBank = data.info
         })
      },
      methods:{
         confirm(){
            this.tips = '';
            if(! this.selectBank || !this.selectBank.id){
               this.tips ='请先选择您需要提现的银行账户信息'
               return
            }
            this.form.bankId = this.selectBank.id
            if(!this.form.amount){
               this.tips ='请输入正确的提现金额'
               this.focus=true
               return
            }
            if(this.form.amount >( this.shop.amount||0)){
               this.tips ='输入的金额已经超过可提现金额'
               this.focus=true
               return
            }
            this.show = !this.show
         },
         applyDo(){
            var that =this
            this.$u.api.withdrawApply(this.form)
               .then(res => {
                  if (res.code === 200) {
                     uni.showToast({
                        title:'操作成功',
                        icon:'success'
                     })
                     uni.$emit('accountListReload',{})
                     uni.redirectTo({url:"/pagesA/pages/withdraw-success/withdraw-success?id="+res.data})
                  }
               }).catch(e=>{
                  uni.showToast({
                     title:'操作失败',
                     icon:'error'
                  })
               })
         },
         inputAll(){
            this.form.amount = this.shop.amount ||0
         },
         jumpBank(){
            if(this.selectBank  && this.selectBank.id){
               uni.navigateTo({
                  url: '/pagesA/pages/withdraw-select/withdraw-select?item='+JSON.stringify(this.selectBank)
               })
            }else{
               uni.navigateTo({
                  url: '/pagesA/pages/withdraw-select/withdraw-select'
               })
            }
         },
         async getBankList(){
            var that =this
            let res = await that.$u.api.getBankList({tokenType:1  })
            if (res.code === 200) {
               that.bankList = res.data || []
               if(that.bankList.length>0){
                  that.selectBank = that.bankList[0]
               }
            }
            
         };
         },
         async checkShopLogin(){
            var that =this
            if( this.shopInfo ==null || this.shopInfo.id==null ||  this.shopToken==null || this.shopToken==''){
               uni.navigateTo({
                  url: '/pages/login/login'
               })
            }else{
               let res = await that.$u.api.getShopInfo({tokenType:1  })
               if (res.code === 200) {
                  await that.$store.commit('setShopInfo', res.data)
                  this.shop = res.data || {}
               }
            }
         }
      }
   }
</script>
@@ -101,9 +245,12 @@
                  text {
                     font-weight: 400;
                     font-size: 28rpx;
                     color: #999999;
                     margin-right: 20rpx;
                  }
                  .text-grey {
                     color: #999999;
                  }
               }
            }
            .form-xian {