<template>
	<view class="warp">
		<view class="flex flex-direction align-center justify-center">
			<view v-for="(item,index) in list" :key="index"
				class="btn flex align-center justify-center text-lg text-bold" :class="menutype==item.type?'active':''"
				@tap="chooseTap(item.type)">{{item.name}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						name: "小微",
						type: 0
					},
					{
						name: "个体工商户",
						type: 1
					},
					{
						name: "企业",
						type: 2
					}
				],
				menutype: -1,
				type: 0,
				id: ""
			}
		},
		onLoad(options) {
			this.type = options.type ? options.type : 1
			this.id = options.sid ? options.sid : ""
			if (this.id) {
				this.post66d2930b149ad()
			}
		},
		methods: {
			post66d2930b149ad(url) {
				this.$api.post(global.apiUrls.post66d2930b149ad, {
					id: this.id,
				}).then(res => {
					if (res.data.code == 1) {
						let status = res.data.data.status
						console.log(status)
						//-1 未认证，0=审核中 1=通过 2=驳回
						if (status == 0) {
							// this.$message.info('您申请的类目正在审核中')
							uni.navigateTo({
								url: '/pages/user/login/examine/jinindexdaili'
							})
						} else if (status == -1) {
							uni.reLaunch({
								url: "/pages/user/login/auth/dailijijian?merType=" + 2 + '&id=' + this.id
							})
						} else if (status == 1) {
							uni.navigateTo({
								url: "/pages/user/login/auth/dailijijian?merType=" + type + '&id=' + this
									.id
							})
						} else if (status == 2) {
							uni.navigateTo({
								url: '/pages/user/login/examine/jinindexdaili?type=' + 'success' +
									'&reason=' + res.data.data.reason + '&model=' + res.data.data.data
									.type + '&id=' + this.id
							})
						}
					} else {
						uni.navigateTo({
							url: url
						})
					}
				})
			},
			chooseTap(type) {
				this.menutype = type
				uni.navigateTo({
					url: "/pages/dl/auth/jinjian?merType=" + type
				})
				// if(this.type==2){
				// 	uni.navigateTo({
				// 		url:"/pages/user/login/auth/jinjian?merType=" + type
				// 	})
				// }else{
				// 	uni.navigateTo({
				// 		url:"/pages/user/login/auth/dailijijian?merType=" + type + '&id=' + this.id
				// 	})
				// }

			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #fff;
	}

	.btn {
		width: 686rpx;
		padding: 32rpx 0;
		margin: 80rpx 0 0 0;
		border: 1rpx solid #eee;
		border-radius: 16rpx;
	}

	.active {
		border: 1rpx solid #42AB4F;
		color: #42AB4F;
	}
</style>
