<template>
	<view class="page">
		<view class="title flex-col">
			<!--#ifdef H5-->
			<view class="flex-row justify-center">
				<text class="title1">收益提现</text>
			</view>
			<!--#endif-->
			<text class="title2" @click="navigateTo('/pages/withdrawalRecord/withdrawalRecord')">提现记录</text>
		</view>
		<view class="flex-col justify-center" :style="{marginTop:'150rpx'}">
			<view class="flex-row justify-center">
				<text class="priceTitle">可提现金额</text>
			</view>
			<view class="flex-row justify-center marginTop">
				<text class="price">{{statistics.myEarning}}</text>
			</view>
		</view>
		<view class="flex-row justify-start ":style="{marginTop:'150rpx'}">
			<checkbox-group @change="checkboxChange">
				<checkbox :checked="checked"  color="#000000" :style="{'transform':'scale(0.7)'}"/>
				<text class="read">请阅读并同意</text>
				<text @click.stop="gotoTermOfService(8)" class="read">《娇骄儿拓客活动规则》</text>
			</checkbox-group>
		</view>


		<view  class="flex-row justify-center marginTop">
			<view class="withdrawButton" @click="apply">
				<text>立即提现</text>
			</view>
		</view>


		<!--#ifdef H5-->
		<liu-drag-button @clickBtn="back">返回</liu-drag-button>
		<!--#endif-->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				checked:false,
				statistics:{},

			}
		},
		onShow() {
			this.exStatistics()
		},
		methods: {

			// 查看储值协议
			gotoTermOfService(type){
				uni.navigateTo({
					url: '/pages/agreement/agreement?name='+'娇骄儿拓客活动规则'+'&type=' + 10,
				})
			},

			apply(){
				if (!this.checked){
					uni.showToast({
						icon: 'error',
						duration: 3000,
						title: '请同意《娇骄儿拓客活动规则》'
					});
					return
				}
				this.$api.service.apply({
					amount:null
				}).then(res=>{
					uni.showToast({
						icon: 'success',
						duration: 3000,
						title: '申请成功'
					});
				})
			},

			exStatistics(){
				this.$api.service.exStatistics().then(res=>{
					this.statistics = res.data.data
				})
			},
			navigateTo(url) {
				uni.navigateTo({
					url: url
				})
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			checkboxChange(){
				this.checked = !this.checked
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import './index.rpx.css';
</style>
