<template>
	<view class="cashout-page">
	  <view class="profit-box">
	    <image src="../../../static/profit.png" class="profit-bg"></image>
	    <view class="profit-info">
	      <view>当前可提现积分<text class="s-word">（积分比例为1:1）</text></view>
	      <view class="fz70">{{userInfo.brokeragePrice || 0}}</view>
	    </view>
	  </view>
	  <view class="tips">注：提现需在每月20-26日进行，其他时间不可提现</view>
	  <view class="handle-box">
	    <view class="tit">提现金额</view>
	    <view class="inp-box acea-row row-between row-middle">
	      <text class="fz50">￥</text>
	      <input type="text" v-model="cashNum" placeholder="最低提现100积分" />
	      <view class="colO" @click="allCash">全部提现</view>
	    </view>
	  </view>
	  <view class="submit-btn" @click="cashClick">提现</view>
	</view>

</template>

<script>
	import { getUserInfo, cash } from '@/api/user.js'
	import cookie from '@/utils/store/cookie'
	export default {
		data() {
			return {
				cashNum: '',
				userInfo: {},
			}
		},
		mounted() {
			getUserInfo().then((res)=>{
				this.userInfo = res.data
			})
		},
		methods: {
			allCash(){
				this.cashNum = this.userInfo.brokeragePrice
			},
			cashClick(){
				if(this.userInfo.userBank){
					if(this.cashNum == '' || Number(this.cashNum) <= 100 || Number(this.cashNum) > this.userInfo.brokeragePrice){
						return this.alertMessage('请输入正确的积分')
					}
					cash({
						extractType: 'bank',
						money: this.cashNum
					}).then((res)=>{
						uni.showToast({
							title: '申请提现成功',
						})
						setTimeout(()=>{
							uni.navigateBack({
								delta: 1,
							})
						},1500)
					})
				} else{
					uni.showModal({
						title: '提示！',
						content: '您还未绑定银行卡，点击确定按钮立即绑定。',
						success: (res)=> {
							if(res.confirm){
								this.$yrouter.push({
									path: '/pages/user/bindCard/index'
								})
							}
						}
					})
				}
			},
			alertMessage(msg){
				uni.showToast({
					title: msg,
					icon: 'none'
				})
			}
		}
	}
</script>

<style>
/* pages/user/cashOut/index.wxss */
.cashout-page{
  width: 100%;
  min-height: 100vh;
  padding: 40rpx;
  background: #F8F8F8;
}
.profit-box{
  width: 100%;
  height: 256rpx;
  position: relative;
  margin-top: 20rpx;
}
.profit-box image{
	width: 100%;
	height: 256rpx;
  position: absolute;
  top: 0;
}
.profit-info{
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  z-index: 3;
  padding: 48rpx 94rpx 0 36rpx;
  color: #fff;
  font-weight: 500;
}
.s-word{
  font-size: 22rpx;
}
.fz70{
  font-size: 70rpx;
  font-weight: 500;
  line-height: 98rpx;
}
.tips{
  font-size: 20rpx;
  color:#FF3434;
  margin: 62rpx 0 20rpx;
  font-weight: 600;
}
.handle-box{
  background: #fff;
  border-radius: 18rpx;
  font-size: 28rpx;
}
.handle-box .tit{
  width: 100%;
  height: 98rpx;
  line-height: 98rpx;
  text-indent: 2em;
  border-bottom: 2rpx solid #F5F5F5;
  font-size: 28rpx;
}
.inp-box{
  width: 100%;
  padding: 0 32rpx;
  height: 108rpx;
}
.inp-box input{
  margin-left: -100rpx;
}
.fz50{
  font-size: 50rpx;
}
.colO{
  color: #F68514;
}
.submit-btn{
  width: 440rpx;
  height: 88rpx;
  background: #F7C37A;
  border-radius: 44rpx;
  text-align: center;
  line-height: 88rpx;
  font-size: 42rpx;
  color: #FFFFFF;
  margin: 110rpx auto 0;
}
</style>
