<template>
	<view class="content">
		<view class="row-box">
			<view class="title">转出金额</view>
			<view class="row">
				<text class="tit">￥</text>
				<input class="input" type="number" v-model="money" placeholder="请输入充值金额" placeholder-class="placeholder" />
			</view>
		</view>
		<button class="add-btn up" :class="{ 'active-bg': payLoding }" @click="!payLoding ? confirm() : ''">转出</button>
	</view>
</template>

<script>
import { getMoneyStyle } from '@/utils/rocessor.js';
// #ifdef APP-PLUS
import { rechargeRoutine } from '@/api/wallet.js';
// #endif
// #ifdef H5
import { rechargeWechat } from '@/api/wallet.js';
// #endif
// #ifdef MP
import { rechargeRoutine } from '@/api/wallet.js';
// #endif
import { mapState } from 'vuex';
export default {
	filters: {
		getMoneyStyle
	},
	data() {
		return {
			type: 'weixin',
			money: '', //充值金额
			payLoding: false //是否加载中
		};
	},
	onLoad(options) {},
	computed: {
		// #ifdef H5
		...mapState(['weichatObj'])
		// #endif
	},
	methods: {
		// 跳转
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		// 切换选中对象
		tabRadio(e) {
			this.type = e;
			console.log(this.type,'this.type')
		},
		// 提交
		confirm() {
			let obj = this;
			obj.payLoding = true;
			console.log(obj.money);
			if ( obj.money == '') {
				this.$api.msg('金额不能为空');
				obj.payLoding = false;
				return
			}
			// #ifdef APP-PLUS
			rechargeRoutine({
				price: this.money,
				from: this.type,
				type: 1,
			}).then(e => {
				this.$api.msg('转入余额成功');
			})
			.catch(e => {
				obj.payLoding = false;
			});
			// #endif
			
			// #ifdef H5
			rechargeWechat({ 
				price: this.money,
				from: this.type,
				type: 1,
			}).then(e => {
				this.$api.msg('转入余额成功');
			})
			.catch(e => {
				obj.payLoding = false;
			});
			// #endif
			
			// #ifdef MP
			rechargeRoutine({
				price: this.money,
				from: this.type,
				type: 1,
			}).then(e => {
				this.$api.msg('转入余额成功');
			})
			.catch(e => {
				obj.payLoding = false;
			});
			// #endif
		}
	}
};
</script>

<style lang="scss">
page {
	height: 100%;
}

.add-btn {
	&.modified {
		color: $base-color;
	}
	&.up {
		background:$base-color;
		color: #fff;
	}
	display: flex;
	align-items: center;
	justify-content: center;
	width: 560rpx;
	height: 80rpx;
	margin: 0 auto;
	margin-top: 60rpx;
	font-size: $font-lg;
	border-radius: 40rpx;
}
.row-box {
	border-top: 1px solid #EEEEEE;
	padding: 20rpx 30rpx;
	background: #fff;
	.title {
		font-size: $font-base + 2rpx;
		color: $font-color-dark;
	}
	.row {
		display: flex;
		align-items: center;
		position: relative;
		height: 80rpx;
		.tit {
			flex-shrink: 0;
			width: 40rpx;
			font-size: 30rpx;
			color: $font-color-dark;
		}
		.input {
			flex: 1;
			font-size: 30rpx;
			color: $font-color-dark;
		}
		.iconlocation {
			font-size: 36rpx;
			color: $font-color-light;
		}

		.buttom {
			color: $font-color;
			font-size: $font-base;
		}
	}
}
.list {
	padding:0 30rpx;
	margin-top: 20rpx;
	background-color: #ffffff;
	.box {
		display: flex;
		align-items: center;
		width: 100%;
		height: 100rpx;
		border-bottom: 1px solid $border-color-light;
	}
	.box1{
		display: flex;
		align-items: center;
		width: 100%;
		height: 100rpx;
	}
	.icon {
		font-size: 48rpx;
		padding-right: 20rpx;
	}
	.iconweixin1 {
		color: #18bf16;
	}
	.iconzhifubao {
		color: #08aaec;
	}
	.title-box {
		flex-grow: 1;
		text-align: left;
		.title {
			font-size: $font-base + 2rpx;
			color: #333333;
		}
		/* .node {
			font-size: $font-base;
			color: #333333;
		} */
	}
	image {
		width: 25rpx;
		height: 25rpx;
	}
}
/deep/ .uni-radio-input {
	width: 45rpx;
	height: 45rpx;
}
.active-bg {
	background-color: $color-gray !important;
}
</style>
