<template>
	<view class="content">
		 <view class="loadding" v-if="loadding==true">
		 	<image src="https://fbylive.obs.cn-southwest-2.myhuaweicloud.com/fs/20250416/1744811256845.png"></image>
		 	<text class="text">壹道正气</text>
		 </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loading: null,
				outUserId: null,
				qwUserId: null,
				currentPath: null,
				baseUrl:uni.getStorageSync('requestPath')
				
			};
		},
		onShow() {
			// this.getUserId();
			this.navigatHandler();
		},
		methods: {
			navigatHandler() {
				if (!this.utils.isLogin()) {
					// #ifdef H5
					uni.reLaunch({
						url: '/pages/auth/login',
					})
					// #endif
					// #ifdef MP-WEIXIN
					uni.reLaunch({
						url: '/pages/auth/wxlogin',
					})
					// #endif
				} else {
					// #ifdef H5
					uni.reLaunch({
						url: '/pages/index/index',
					})
					// #endif
					// #ifdef MP-WEIXIN
					console.log('现在')
					uni.reLaunch({
						url: '/pages/enterprise/enterprise',
					})
					// #endif
					
				}
			},
			getUserId() {
				const urlParams = new URLSearchParams(window.location.search);
				const currentUrl = window.location.href.split('#')[0];
				const companyId = urlParams.get('companyId');
				const code = urlParams.get('code');
				var data={
					companyId: companyId,
					url: currentUrl,
					code: code
				}
				getConfigSignature(data).then(
					res => {
						uni.hideLoading()
						if(res.code==200){
							const agentConfigSignature = res.config.agentConfigSignature;
							const configSignature = res.config.configSignature;
							const corpId = res.config.corpId;
							const nonceStr = res.config.nonceStr;
							const timestamp = res.config.timestamp;
							const agentId = res.config.agentId;
							this.qwUserId = res.config.userid;
							wx.config({
								beta: true,
								debug: false,
								appId: corpId,
								timestamp: timestamp,
								nonceStr: nonceStr,
								signature: configSignature,
								jsApiList: ['getCurExternalContact']
							});
							wx.ready(() => {
								wx.agentConfig({
									corpid: corpId,
									agentid: agentId,
									timestamp: timestamp,
									nonceStr: nonceStr,
									signature: agentConfigSignature,
									jsApiList: ['getCurExternalContact'],
									success: (res) => {
										wx.invoke('getCurExternalContact', {}, async (res) => {
											if (res.err_msg === "getCurExternalContact:ok") {
												this.outUserId = res.userId;
												uni.showToast({
													title: res.userId,
													icon: 'none'
												})
											} else {
												// 错误处理
											}
										});
									},
									fail: (res) => {
										console.error('agentConfig fail:', res);
									}
								});
							});
							wx.error((res) => {
								console.error('wx.error:', res);
							});
						}
						else{
							uni.showToast({
								title: res.msg,
								icon: 'none'
							})
						}
						
					},
					rej => {}
				);
				 
			}
		}
 
	};
 
</script>
<style lang="scss">
	page{
		background-color: #fff;
	}
	.content {
		background-color: #fff;
		height: 100%;
		width: 100%;
		position: relative;
	}
	.loadding{
		background-color: #fff;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 9999;
		image{
			border-radius: 50%;
			animation: load linear 1s infinite;
			width: 120rpx;
			height:120rpx;
		}
		.text{
			font-size: 28rpx;
			margin-top: 20rpx;
		}
	}
</style>
