<template>
	<view class="center">
		<view class="" v-if="accountType == '2'">
			{{dataInfo.companyName}}
		</view>
		<view class="flex account">
			<view class="account_info">
				可用余额
				<view class="money">
					{{dataInfo.accountBalance?dataInfo.accountBalance:0}}元
				</view>
			</view>
			<view class="account_info">
				已冻结
				<view class="money">
					{{dataInfo.frozenAmount?dataInfo.frozenAmount:0}}元
				</view>
			</view>
		</view>
		<u-button type="primary" text="提现" @click="withdrawal"></u-button>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataInfo: {},
				accountType: '', //accountType  1个人 2企业
				id:"",//如果是企业  公司id

			}
		},
		onLoad(options) {
			if (options.id) { //我的企业进来的
				this.accountType = '2'
				this.id = options.id
				console.log(this.dataInfo)
			} else {  //个人账户
				this.accountType = '1'
			}
		},
		onShow() {
			
				this.getList()
			

		},
		onNavigationBarButtonTap(e) {
			uni.$u.route('/pages/mine/myAccount/bill?type=' + this.accountType)
		},
		methods: {
			getList() {
				if(this.accountType == '1'){
					this.$request.baseRequest('get', '/cargoOwnerInfo/selectAccount', {
						commonId: uni.getStorageSync("userInfo").id
					}).then(res => {
						this.dataInfo = res.data
					})
				}else if(this.accountType == '2'){
					this.$request.baseRequest('get', '/cargoOwnerInfo/selectAccountBalance', {
						id:this.id,
						flag:this.accountType
					}).then(res => {
						this.dataInfo = res.data
					})
				}
			},
			withdrawal() {
				if(this.accountType == '1'){
					uni.$u.route("/pages/mine/myAccount/withdrawal?id=" + this.dataInfo.id +"&flag=" + this.accountType)
				}else if(this.accountType == '2'){
					uni.$u.route("/pages/mine/myAccount/withdrawal?id=" + this.id +"&flag=" + this.accountType)
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.center {
		padding: 20rpx;

		.account {
			margin-top: 30rpx;

			.account_info {
				width: 50%;
				text-align: center;
			}

			.money {
				margin: 40rpx;
			}
		}


	}
</style>
