<template>
	<view>

		<navbar :title="$t('pageTitle.selectIdentity')" :leftClick="!$route.query.back"
			@leftClick="$utils.navigateBack" />

		<view class="container">
			
			<view class="title">{{ $t('components.selectIdentity') }}</view>
			<view class="button-group">
				<!--供应商-->
				<view class="identity-button" @click="selectIdentity(0)">
					<view class="identity-text"> {{ $t('other.iAmBuyer') }}</view>
					<view class="identity-icon">
						<img src="../../static/image/index/5.png" style="width: 100%; height: 100%;">
					</view>
				</view>
				<!--采购-->
				<view class="identity-button" @click="selectIdentity(1)">
					<view class="identity-text"> {{ $t('other.iAmSupplier') }}</view>
					<view class="identity-icon">
						<img src="../../static/image/index/6.png" style="width: 100%; height: 100%;">
					</view>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	import {
		mapGetters
	} from 'vuex'

	export default {
		computed: {
			...mapGetters(['userShop', "userInfo"]),
		},
		methods: {
			selectIdentity(identity) {
				// if (userInfo)
				if (identity == 0 && this.$store.state.buy) {
					this.$store.commit('setShop', false)
					uni.reLaunch({
						url: '/pages/index/index'
					})
				} else if (identity == 1 && this.$store.state.shopData) {
					this.$store.commit('setShop', true)
					uni.reLaunch({
						url: '/pages/index/index'
					})
				} else {
					uni.navigateTo({
						url: `/pages_order/auth/registerShop?identity=${identity}`
					})
				}
			},
		}
	}
</script>

<style scoped lang="scss">
	* {
		box-sizing: border-box;
	}

	.container {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		//height: 100vh;
		background-color: #f5f5f5;

		.title {
			font-size: 40rpx;
			color: #333;
			margin: 80rpx 0;
		}

		.button-group {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;

			width: 100vw;
			//padding: 0 20px;

			.identity-button {
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 80%;
				margin-bottom: 40rpx;
				padding: 40rpx 50rpx;
				background-color: #2d2f59;
				border-radius: 20rpx;
				color: white;

				.identity-text {
					font-size: 40rpx;
				}

				.identity-icon {
					width: 130rpx;
					height: 130rpx;
				}
			}
		}
	}
</style>