<template> <block> <view class="content"> <view class="cashInfo"> <view class="cTitle">提现金额</view> <view class="cPrice" style="font-size: 24rpx;"> <view> 可提现金额 <text class="cWeight">{{ info.money }}</text> 元 </view> <view @tap="cashAll">全部提现</view> </view> </view> <view class="cInput"> <view>¥</view> <input type="number" @input="cashinput" placeholder="请输入提现金额" placeholder-class="placeClass" :value="cashmoney" /> </view> <!-- <view class="cItem"> <view class="cTip"> <view>税收(6%):</view> <view>*平台代缴纳</view> </view> <view class="cNum">¥{{lessMoney}}</view> </view> <view class="cItem"> <view class="cTip"> <view>实际到账:</view> </view> <view class="cNum">¥{{realMoney}}</view> </view> --> <view class="cItem"> <view class="cTip"> <view>到账银行卡:</view> </view> <picker v-if="banklist.length" mode="selector" @change="bindBankConfirm" range-key="showtitle" :value="bankindex" :range="banklist"> <view class="cNum fweigh">{{ bankTitle ? bankTitle : '请选择提现银行卡' }}</view> </picker> <view class="cNum fweigh" v-else @tap="toPage" data-url="/pages/Withdrawal/addbank" :data-type="type"> {{ bankTitle ? bankTitle : '请先添加银行卡' }}</view> <image v-if="banklist.length" src="https://ymyun-oss.oss-cn-hangzhou.aliyuncs.com/yidu_tc/public/upload/12/8/3c95e397fd285160c474c52ed2e3e4d1.png" mode="widthFix" class="leftArrow"></image> </view> </view> <view class="btn" @tap="confirm">立即提现</view> </block> </template> <script> var app = getApp(); // a = app.requirejs('core'); var loading = false; export default { data() { return { info: { money: '' }, cashmoney: '', banklist: [], bankindex: 0, bankTitle: '', name: '', lessMoney:0, realMoney:0 }; }, onLoad: function(e) {}, onShow() { this.getinfo(); this.getbank(); }, onPullDownRefresh: function() {}, onReachBottom: function() {}, methods: { async confirm() { var that = this; if (!this.cashmoney) { uni.showToast({ title: '请先填写提现金额', icon: 'none' }); return false; } if (!this.bankTitle) { uni.showToast({ title: '请先选择银行卡', icon: 'none' }); return false; } let result = await this.$api.request('/withdraw/add', 'POST', {money:that.cashmoney,bid:that.banklist[that.bankindex].id}); console.log(result) if (result) { this.$api.msg('添加成功'); uni.redirectTo({ url:'/pages/wallet/index' }) } }, bindBankConfirm(e) { console.log(e); this.bankindex = e.detail.value, this.bankTitle = this.banklist[e.detail.value].showtitle }, async getbank() { var that = this; let res = await this.$api.request('/bank/index', 'GET', { page: 1, pagesize: 20 }); console.log(res) if (res) { if (res.length > 0) { res.map(function(item) { return item.showtitle = item.bank + '(' + item.card.substr(item.card.length - 4) + ')' }) this.banklist = this.banklist.concat(res); this.page++; } else { this.loaded = true this.$api.msg('没有更多数据'); } } }, toPage(e) { app.globalData.toPage(e); }, cashAll() { this.cashmoney = this.info.money }, cashinput(e) { this.cashmoney = e.detail.value }, async getinfo() { let data = await this.$api.request('/wallet/index'); console.log(data) this.info = data; }, } }; </script> <style> page { background: #f4f5f9; } .content { padding: 36rpx 44rpx 0; background: #fff; } .cashInfo { display: flex; align-items: center; padding-bottom: 60rpx; justify-content: space-between; } .cTitle { font-size: 28rpx; font-weight: 700; } .cPrice { display: flex; align-items: center; } .cPrice>view:nth-child(2) { color: #253f8e; margin-left: 30rpx; } .cWeight { font-weight: 700; font-size: 30rpx; } .cInput { display: flex; align-items: center; padding-bottom: 30rpx; border-bottom: 1px solid #e4e5ee; } .cInput>view { font-size: 54rpx; color: #011b33; font-weight: 700; } .cInput>input { font-size: 54rpx; color: #011b33; font-weight: 700; } .placeClass { font-size: 35rpx; font-weight: 500; padding-left: 40rpx; } .cItem { padding: 30rpx 0; border-bottom: 1px solid #e4e5ee; display: flex; align-items: center; position: relative; } .cItem:last-child { border-bottom: none; } .cTip>view:nth-child(1) { font-size: 28rpx; } .cTip>view:nth-child(2) { margin-top: 8rpx; color: #ff4c34; font-size: 22rpx; } .cNum { margin-left: 40rpx; font-size: 36rpx; } .fweigh { font-size: 28rpx; font-weight: 700; } .leftArrow { position: absolute; right: 0; width: 14rpx; } .btn { width: 614rpx; height: 88rpx; display: flex; align-items: center; justify-content: center; background: linear-gradient(to right, #F8A52B, #F8C657); color: #fff; font-size: 30rpx; border-radius: 40rpx; margin: 72rpx auto; } picker { flex: 1; } view { font-size: 24rpx; } </style>