<template>
	<view class="contentindex">
		<view class="box-header">
			<view class="images">
				<image src="https://cdn.bjtdba.com/vod/image/2022-08-09/20220809134301741.gif" mode="widthFix"></image>
			</view>
			<view class="texts">
				正在加载…
			</view>
		</view>
	</view>
</template>


<script>
	import {
		selectMerchant
	} from '@/commit/api.js'
	import {
		encryptDes,
		decryptDes
	} from '@/encryption/index.js' // 引用路径根据自己的文件结构而定
	import
	Base64
	from 'base-64'
	export default {
		data() {
			return {

			}
		},
		onLoad() {
			
			console.log('进来了')
			
			let authorization = uni.getStorageSync('authorization')
			let userinfo = uni.getStorageSync('userinfo')
			let uid = userinfo.uid
			// 用户状态判断
			if (authorization) {
				selectMerchant({
					uid: uid
				}).then(data => {
					if (data.data.status == 200) {
						let selectmerchant = data.data.data
						uni.setStorageSync('selectmerchant', selectmerchant)
						if (authorization && uid) {
							if (selectmerchant.merId >= 0 && selectmerchant.status == -1) {
								uni.redirectTo({
									url: "/openmerchant/guide/index" //有或者没有商户 没有金额支付and激活码支付
								});
								return
							} else if (selectmerchant.merId > 0 && (selectmerchant.status == 1 || selectmerchant.status == 5)) {
								uni.switchTab({
									url: '/pages/cashier/index' //已开通商户
								});
								return
							} else if (selectmerchant.merId >= 0 && (selectmerchant.status == 3 || selectmerchant.status == 4)) {
								uni.redirectTo({
									url: '/openmerchant/shopentry/process?mer_id=' + selectmerchant.merId //已开通商户未填写资料
								});
								return
							} else if (selectmerchant.merId > 0 && selectmerchant.status == 0) {
								uni.redirectTo({
									url: '/openmerchant/shopentry/processaudit?submitCode=' + 3 //已开通商户待审核
								});
								return
							} else if (selectmerchant.merId > 0 && selectmerchant.status == 2) {
								uni.redirectTo({
									url: '/openmerchant/shopentry/processaudit?submitCode=' + 2 //已开通商户审核拒绝
								});
								return
							}

						} else {
							uni.redirectTo({
								url: "/pages/user/login/index"
							});
						}
					}
				}, fail => {
					uni.showToast({
						title: fail,
						icon: "none"
					})
				}).catch(err => {
					console.log(err)
				})
			} else {
				uni.redirectTo({
					url: "/pages/user/login/index"
				});
			}
		},
		methods: {}
	}
</script>

<style lang="scss" scoped>
	.contentindex {
		width: 100%;
		height: 100%;
		background: transparent;
		position: fixed;
		margin: auto;
		left: 0;
		right: 0;
		top: 0;
		bottom: 0;
		display: flex;
		justify-content: center;
		align-items: center;

		.box-header {
			text-align: center;
			line-height: 100rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			align-items: center;

			.images {
				width: 128rpx;
				height: 128rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.texts {
				width: 150rpx;
				height: 42rpx;
				font-size: 30rpx;
				line-height: 42rpx;
				color: #333333;
				margin-top: 61rpx;
			}
		}
	}
</style>
