<template>
	<view class="content">
		<view class="bg"></view>
		<view class="cont-box">
		<!-- 	<view class="user-cont">
				<view class="user-box" v-if="user!=null" >
					<view class="left">
						<image :src="user.avatar"></image>
						<view class="user" >
							<view class="username">{{user.name}}</view>
							<view class="account" v-if="user.gender!=null" >{{user.gender==1?'男':'女'}}</view>
						</view>
					</view>
					<view class="right" >
						<image src="../../static/images/right_arrow.png"></image>
					</view>
				</view>
				<view class="company" v-if="user!=null">
					<image src="../../static/images/icon_comp.png"></image>
					<view class="name">{{user.companyName}}</view>
				</view>
			</view> -->
			<view class="menu-box">
				<view class="title-box">
					<image class="icon" src="../../static/images/office.png"></image>
					<view class="title">常用功能</view>
				</view>
				<view class="line"></view>
				<view class="menus">
					<view class="menu-item" @click="navTo('/pages/course/index?externalUserId='+externalUserId)">
						<image src="../../static/images/menu_info.png"></image>
						<view class="m-name">课程管理</view>
					</view>
					<view class="menu-item" @click="navTo('/pages/user/qwSop/sopLogsList?externalUserId='+externalUserId)">
						<image src="../../static/images/menu_info.png"></image>
						<view class="m-name">SOP记录</view>
					</view>
					<view class="menu-item"  >
						<image src="../../static/images/menu_info.png"></image>
						<view class="m-name">催课管理</view>
					</view>
					<!-- <view class="menu-item" @click="clear()">
						<image src="../../static/images/menu_info.png"></image>
						<view class="m-name">清除缓存</view>
					</view> -->
					<view class="menu-item" @click="deleteQwSopLogsByJsApi()">
						<image src="../../static/images/menu_info.png"></image>
						<view class="m-name">拉黑</view>
					</view>
					<!-- <view class="menu-item" @click="refresh()">
						<image src="../../static/images/menu_info.png"></image>
						<view class="m-name">刷新</view>
					</view> -->
				</view>
				
			</view>
			<!-- <view class="text">code:{{code}}</view>
			<view class="text">allurl:{{allUrl}}</view>
			<view class="text">url:{{url}}</view> -->
			 
		</view>
		<view class="text">CODE:{{code}}</view>
		<view class="text">外部联系人:{{externalUserId}}</view>
		<!-- <view class="text">消息:{{msg}}</view> -->
	</view>
</template>

<script>
	
	import { getConfigSignature,getQwExternalContactDetails } from '@/api/common.js'
	import { getQwSopLogsByJsApi,updateQwSopLogs,deleteQwSopLogsByJsApi} from '@/api/qwSop.js'
 
	export default {
		data() {
			return {
				isStop:false,
				msg:"",
				isConfig:false,
				logsInterval:null,
				initInterval:null,
				externalUserId:null,
				userId:null,
				wxSdk:null,
				corpId:"",
				code:"",
				url:"",
				show:false,
				sendFlag:false,
				// websocketFlag:false,
				isInit:false,//是否定位
				user:{
					gender:null,
					name:"",
					avatar:"",
					remarkMobiles:""
				},
			}
		},
		onLoad(options) {
			var that=this;
			this.url=window.location.href;
			console.log(this.url)
			this.code=options.code;
			this.corpId=options.corpId;
			uni.setStorageSync("corpId",this.corpId);
			// this.externalUserId=uni.getStorageSync("externalUserId");
			var userId=uni.getStorageSync("qwUserId");
			if(userId!=null&&userId!=undefined&&userId!=""){
				this.userId=userId;
			}
			// console.log(this.externalUserId)
			// console.log(this.userId)
			// var that=this;
			if(this.externalUserId!=null&&this.externalUserId!=undefined&&this.userId!=null&&this.userId!=undefined){
				console.log("获取外部联系人")
				this.getQwExternalContactDetails()
				that.initInterval=setInterval(function(){
					if(that.isInit){
						clearInterval(that.initInterval);
						that.getQwSopLogsByJsApi();
						setInterval(function(){
							that.getQwSopLogsByJsApi();
						},60000);
					}
				},200)
			}
			// else{
			// 	console.log("获取配置信息")
				
			// }
		
			this.wxSdk=uni.getStorageSync("wxSdk");
			var that=this;
			// uni.$on('deleteId', () => {
			// 	console.log("删除外部联系人");
			// 	that.deleteQwSopLogsByJsApi(that.nextExternalUserId)
			// })
			uni.$on('refresh', (data) => {
				//window.location.reload()
			})
			uni.$on('init', (data) => {
				that.isInit=data==1?true:false;
			})
			
			// var sendMsg=uni.getStorageSync("sendMsg");
			// if(sendMsg!=null&&sendMsg!=""){
			// 	//发送
				
			// 	//清除缓存
			// 	uni.setStorageSync("sendMsg",null);
				
			// }
			// uni.$on('sendMsg', (data) => {
			// 	//先把数据保存
			// 	//切换下一个外部联系人
			// 	var sendData=JSON.parse(data)
			// 	if(sendData.data.qwExtUserId!=null){
			// 		uni.setStorageSync("sendMsg",JSON.stringify(data));
			// 		that.openNextChat(sendData.data.qwExtUserId)
			// 	}
				
			// })
			uni.$on('reload', (data) => {
				//that.refresh();
			})
			uni.$on('sendStatus', (data) => {
				console.log("更新发送状态");
				that.sendFlag=false;
				
			})
			// uni.$on('getLogs', (data) => {
			// 	console.log("接口调用失败");
			// 	that.getQwSopLogsByJsApi()
				
			// })
			
			// uni.$on('websocket', (data) => {
			// 	 console.log("插件状态"+data);
			// 	if(data==0){
			// 		that.websocketFlag=false;
			// 		uni.showToast({
			// 			title: "插件离线",
			// 			icon: 'none',
			// 		});
			// 	}
			// 	else if(data==1){
			// 		that.websocketFlag=true;
			// 		uni.showToast({
			// 			title: "插件在线",
			// 			icon: 'none',
			// 		});
			// 	}
				
			// })
			//如果接口请求异常，重试
			this.getConfigSignature()
			// setTimeout(function(){
			// 	if(!that.isConfig){
			// 		that.getConfigSignature()
			// 	}
			// },5000);
			this.logsInterval=setInterval(function(){
				if(that.isInit&&that.externalUserId!=null){
					that.getQwSopLogsByJsApi();
				}
			},60000);
			
		},
		onShow() {
			//https://blog.csdn.net/u013361179/article/details/132336082?spm=1001.2014.3001.5501
			//https://www.cnblogs.com/goloving/p/16742077.html
			
		},
		onUnload() {
			if(this.initInterval!=null){
				clearInterval(this.initInterval);
			}
			if(this.logsInterval!=null){
				clearInterval(this.logsInterval);
			}
			
		},
		methods: {
			refresh(){
				window.location.reload();
			},
			sendTest(){
				jWeixin.invoke('sendChatMessage', {
					msgtype:"miniprogram", //消息类型，必填
					enterChat: true,
					miniprogram:
					{
						appid: "wx73f85f8d62769119", 
						title: "测试", 
						imgUrl: "https://cos.his.cdwjyyh.com/fs/20250310/de1b349b4240433fba29cf6e79135e9e.png",
						page: "/pages/index/index.html?companuUserId=123"
					}
				}, function(res) {
					console.log("小程序发送")
					console.log(res)
					uni.showToast({
						title: res,
					});
					
				})
			},
			clear(){
				//uni.setStorageSync("externalUserId",null);
				uni.setStorageSync("qwUserId",null);
				
			},
			getQwSopLogsByJsApi(){
				// if(this.isStop){
				// 	console.log("插件未响应，已暂停")
				// 	return;
				// }
				// var obj={cmd:"log",data:"getQwSopLogsByJsApi开始"};
				// uni.$emit('sendMsg',obj); 
				var data = {
					corpId:this.corpId,
					externalUserId:this.externalUserId,
					qwUserId:this.userId,
				};
				var that=this;
				try{
					getQwSopLogsByJsApi(data).then(
						res => {
							// var obj={cmd:"log",data:JSON.stringify(res)};
							// uni.$emit('sendMsg',obj); 
							if(res.data.appKey!=null&&res.data.appKey!=""){
								uni.setStorageSync("key",res.data.appKey);
							}
							else{
								uni.setStorageSync("key","");
							}
							if(res.data.sendList!=null){
								this.msg="获取待发送记录"+res.data.sendList.length;
								uni.showToast({
									title: "获取待发送记录"+res.data.sendList.length,
									icon: 'none',
								});
								console.log("获取待发送记录"+res.data.sendList.length)
							}
							else{
								
								console.log("获取待发送记录null")
							}
							console.log(res)
							//判断插件是否INIT
							if(that.isInit){
								console.log("已初始化")
								that.nextExternalUserId=res.data.nextExternalUserId;
								this.msg="外部联系人:"+res.data.nextExternalUserId;
								if(res.data.sendList!=null&&res.data.sendList.length>0){
									console.log("开始发送")
									that.sendSop(res.data.sendList,res.data.nextExternalUserId);
								}
								else if(res.data.nextExternalUserId!=null){
									console.log("切换页面")
									that.openNextChat(res.data.nextExternalUserId);
								
								}
								else{
									this.msg="外部联系人:"+res.data.nextExternalUserId;
								}
							}
							else{
								this.msg="插件未INIT";
							}
						},
						rej => {
							// var obj={cmd:"log",data:"接口获取数据失败"+JSON.stringify(rej)};
							// uni.$emit('sendMsg',obj); 
							console.log("接口获取数据失败")
						}
					);
				}
				catch(e){
				 
				}
				
			},
			openNextChat(nextExternalUserId){
				// var that=this;
				// jWeixin.invoke('openUserProfile', {
				// 		"type": 2, //1表示该userid是企业成员，2表示该userid是外部联系人
				// 		"userid": nextExternalUserId //可以是企业成员，也可以是外部联系人
				// 	}, function(res) {
				// 		console.log(res)
				// 		if(res.err_msg == "openUserProfile:ok") {
							
				// 		}
				// 		else{
				// 			uni.showToast({
				// 				title: nextExternalUserId+"不属于本人",
				// 				icon: 'none',
				// 			});
				// 			that.deleteQwSopLogsByJsApi(nextExternalUserId);
							
				// 		}
				// });
				try{
					jWeixin.openEnterpriseChat({
							// 注意：userIds和externalUserIds至少选填一个。内部群最多2000人；外部群最多500人；如果有微信联系人，最多40人
						externalUserIds: nextExternalUserId, // 参与会话的外部联系人列表，格式为userId1;userId2;…，用分号隔开。
						groupName: '',  // 会话名称。单聊时该参数传入空字符串""即可。
						chatId: "", // 若要打开已有会话，需指定此参数。如果是新建会话，chatId必须为空串
						success: function(res) {
							console.log(res);
							console.log("切换成功")
							uni.showToast({
								title: "切换成功",
								icon: 'none',
							});
							var data={cmd:"switchPage"};
							uni.$emit('sendMsg',data);
							 
						},
						fail: function(res) {
							console.log(res);
							console.log("切换失败")
							uni.showToast({
								title: "切换失败",
								icon: 'none',
							});
							var data={cmd:"switchPage"};
							uni.$emit('sendMsg',data);
						}
					});
					
				}
				catch(e){
					console.log(e);
					console.log("切换成功")
					
				}
				
			},
			async sendMsg(msgItem){
				var that=this;
				that.sendFlag=true;
				uni.showToast({
					title: "发送中请勿操作",
					icon: 'none',
				});
				if(msgItem.contentType==1){
					//await that.sleep(500);
					
					jWeixin.invoke('sendChatMessage', {
						msgtype:"text", //消息类型，必填
						enterChat: true,
						text: {
							content:msgItem.value, //文本内容
						}
					}, function(res) {
						console.log("发送成功")
						console.log(res)
						var data={cmd:"enter"};
						uni.$emit('sendMsg',data); 
						if (res.err_msg == 'sendChatMessage:ok') {
							 
						}
					})
				}
				else if(msgItem.contentType==2){
					//图片
					 //await that.sleep(2000);
					 var data={cmd:"img",data:msgItem.imgUrl};
					 uni.$emit('sendMsg',data); 
				}
				else if(msgItem.contentType==5){
					//文件
					 //await that.sleep(2000);
					 var data={cmd:"file",data:msgItem.fileUrl};
					 uni.$emit('sendMsg',data); 
					 
				}
				else if(msgItem.contentType==6){
					//视频
					 //await that.sleep(2000);
					var data={cmd:"video",data:msgItem.videoUrl};
					uni.$emit('sendMsg',data); 
				}
				else if(msgItem.contentType==7){
					//语音
					//await that.sleep(2000);
					// if(msgItem.voiceUrl!=null&&msgItem.voiceUrl!=undefined&&msgItem.voiceUrl!=""){
					// 	var data={cmd:"voice",data:msgItem.voiceUrl,time:msgItem.voiceDuration,openId:that.externalUserId};
					// 	uni.$emit('sendMsg',data); 
					// }
					// else{
					// 	that.sendFlag=true;
					//  	return;
					// }
					that.sendFlag=true;
					return;
					// if(msgItem.voiceUrl!=null&&msgItem.voiceUrl!=undefined&&msgItem.voiceUrl!=""){
					// 	var data={cmd:"voice",data:msgItem.voiceUrl,time:msgItem.voiceDuration,openId:that.externalUserId};
					// 	uni.$emit('sendMsg',data); 
					// }
					// else{
					// 	that.sendFlag=true;
					//  	return;
					// }
					// if(this.userId=="ZhangZhanYue"){
					// 	if(msgItem.voiceUrl!=null&&msgItem.voiceUrl!=undefined&&msgItem.voiceUrl!=""){
					// 		var data={cmd:"voice",data:msgItem.voiceUrl,time:msgItem.voiceDuration,openId:that.externalUserId};
					// 		uni.$emit('sendMsg',data); 
					// 	}
					// 	else{
					// 		that.sendFlag=true;
					// 	 	return;
					// 	}
					// }
					// else{
					// 	that.sendFlag=true;
					// 	return;
					// }
					
				}
				else if(msgItem.contentType==8){
					//视频号
					 //await that.sleep(2000);
					 // var video={
						//  nickname:msgItem.nickname,
						//  avatar:msgItem.avatar,
						//  coverUrl:msgItem.coverUrl,
						//  thumbUrl:msgItem.thumbUrl,
						//  desc:msgItem.desc,
						//  url:msgItem.url,
						//  extras:msgItem.extras,
					 // }
					 // var data={cmd:"videoNum",data:JSON.stringify(video),openId:that.externalUserId};
					 // uni.$emit('sendMsg',data); 
					 
					that.sendFlag=true;
					return;
				}
				else if(msgItem.contentType==3){
					//await that.sleep(500);
					jWeixin.invoke('sendChatMessage', {
						msgtype:"news", //消息类型，必填
						enterChat: true,
						news:
						{
							link: msgItem.linkUrl, //H5消息页面url 必填
							title: msgItem.linkTitle, //H5消息标题
							desc: msgItem.linkDescribe, //H5消息摘要
							imgUrl: msgItem.linkImageUrl, //H5消息封面图片URL
						}
						 
					}, function(res) {
						console.log("发送成功")
						console.log(res)
						var data={cmd:"enter"};
						uni.$emit('sendMsg',data); 
						if (res.err_msg == 'sendChatMessage:ok') {
							
							
						}
					})
				}
				else if(msgItem.contentType==4){
					//await that.sleep(500);
					
					jWeixin.invoke('sendChatMessage', {
						msgtype:"miniprogram", //消息类型，必填
						enterChat: true,
						miniprogram:
						{
							appid: msgItem.miniprogramAppid, 
							title: msgItem.miniprogramTitle, 
							imgUrl: msgItem.miniprogramPicUrl,
							page: msgItem.miniprogramPage
						}
					}, function(res) {
						console.log("发送成功")
						console.log(res)
						var data={cmd:"enter"};
						uni.$emit('sendMsg',data); 
						// if (res.err_msg == 'sendChatMessage:ok') {
							
						// }
					})
				}
				else if(msgItem.contentType==9){
					//await that.sleep(500);
				
					jWeixin.invoke('sendChatMessage', {
						msgtype:"news", //消息类型，必填
						enterChat: true,
						news:
						{
							link: msgItem.linkUrl, //H5消息页面url 必填
							title: msgItem.linkTitle, //H5消息标题
							desc: msgItem.linkDescribe, //H5消息摘要
							imgUrl: msgItem.linkImageUrl, //H5消息封面图片URL
						}
						 
					}, function(res) {
						console.log("发送成功")
						console.log(res)
						var data={cmd:"enter"};
						uni.$emit('sendMsg',data); 
						if (res.err_msg == 'sendChatMessage:ok') {
							
							
						}
					})
				}
				else if(msgItem.contentType==10){
					//清除草稿
					var data={cmd:"clear"};
					uni.$emit('sendMsg',data); 
				}
				else if(msgItem.contentType==11){
					//await that.sleep(500);
					//清除草稿
					var data={cmd:"reSend"};
					uni.$emit('sendMsg',data); 
				}
				else{
					return;
				}
				var time=150;
				while(time>0){
					console.log(time)
					if(!that.sendFlag){
						break;
					}
					else{
						time--;
						await this.sleep(200);
						
					}
				}
				//如果没有收到消息回复 
				// that.isStop=true
				
			},
			sleep(ms) {
			  return new Promise(resolve => setTimeout(resolve, ms));
			},
			async sendSop(sendList,nextExternalUserId){
				var that=this;
				console.log("开始发消息");
				for (const item of sendList) {
					console.log(item);
					var msgs=JSON.parse(item.contentJson);
					var that=this;
					if(msgs.setting.length>0){
						for(var i=0;i<msgs.setting.length;i++){
							var msgItem=msgs.setting[i]
							console.log("消息");
							console.log(msgItem);
							await that.sendMsg(msgItem)
						}
					
					
					}
					//更新消息
					that.updateQwSopLogs(item.id);
				}
				
				var data={cmd:"enterok"};
				uni.$emit('sendMsg',data);
				that.sendFlag=true;
				var time=50;
				while(time>0){
					console.log(time)
					if(!that.sendFlag){
						break;
					}
					else{
						time--;
						await this.sleep(200);
						
					}
				}
				uni.showToast({
					title: "回车发送",
					icon: 'none',
				});
				
				await that.sleep(500);
				if(nextExternalUserId!=null){
					that.openNextChat(nextExternalUserId)
				}
				else{
					// setTimeout(function(){
					// 	that.getQwSopLogsByJsApi()
					// },60000);
				}
			},
			updateQwSopLogs(id){
				console.log("更新发送状态")
				var data = {
					id:id,
					sendStatus:1,
					receivingStatus:1
				};
				var that=this;
				updateQwSopLogs(data).then(
					res => {
					},
					rej => {
						that.updateQwSopLogs2(data);
					}
				);
			},
			updateQwSopLogs2(data){
				var that=this;
				updateQwSopLogs(data).then(
					res => {
					},
					rej => {
						
					}
				);
			},
			deleteQwSopLogsByJsApi(){
				var that=this;
				uni.showModal({
					title:"提示",
					content:"确认拉黑吗?",
					showCancel:true,
					cancelText:'取消',
					confirmText:'确定',
					success:res=>{
						if(res.confirm){
							var data = {
								corpId:this.corpId,
								externalUserId:this.externalUserId,
								qwUserId:this.userId,
							};
							console.log(data)
							var that=this;
							deleteQwSopLogsByJsApi(data).then(
								res => {
									if(res.code==200){
										uni.showToast({
											title: "操作成功",
											icon: 'none',
										});
									}
									else{
										uni.showToast({
											title: res.msg,
											icon: 'none',
										});
									}
								},
								rej => {
									 
								}
							);
														
						}else{
							// 否则点击了取消  
						}
					}
				})
				
			},
			getConfigSignature(){
				var data = {
					corpId: this.corpId,
					url: this.url,
					code: this.code
				};
				if(this.userId!=null){
					data.isGetUserId=0;
				}
				else{
					data.isGetUserId=1;
				}
				var that=this;
				// var obj={cmd:"log",data:"getConfigSignature开始"};
				// uni.$emit('sendMsg',obj); 
				getConfigSignature(data).then(
					res => {
						console.log(res)
						// var obj={cmd:"log",data:JSON.stringify(res)};
						// uni.$emit('sendMsg',obj); 
						if(res.code==200){
							that.isConfig=true;
							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;
							
							if(res.config.userid!=null&&res.config.userid!=''){
								that.userId = res.config.userid;//当前员工ID
								uni.setStorageSync("qwUserId",that.userId);
								console.log("获取到USERID")
							}
							else{
								console.log("不需要获取USERID")
							}
							console.log(this.userId)
							jWeixin.config({
								beta: true,
								debug: false,
								appId: corpId,
								timestamp: timestamp,
								nonceStr: nonceStr,
								signature: configSignature,
								jsApiList: ['getCurExternalContact','sendChatMessage','openEnterpriseChat']
							});
							// const newSignature={
							// 	'timestamp':timestamp,
							// 	'nonceStr':nonceStr,
							// 	'signature':configSignature,
							// }
							// ww.register({
							//   corpId: corpId,       // 必填，当前用户企业所属企业ID
							//   jsApiList: ['openEnterpriseChat'], // 必填，需要使用的JSAPI列表
							//   newSignature                 // 必填，根据url生成企业签名的回调函数
							// })
							jWeixin.ready(() => {
								jWeixin.agentConfig({
									corpid: corpId,
									agentid: agentId,
									timestamp: timestamp,
									nonceStr: nonceStr,
									signature: agentConfigSignature,
									jsApiList: ['getCurExternalContact','sendChatMessage','openEnterpriseChat'],
									success: (res) => {
										jWeixin.invoke('getCurExternalContact', {}, async (res) => {
											if (res.err_msg === "getCurExternalContact:ok") {
												that.externalUserId = res.userId;
												//that.getQwExternalContactDetails()
												that.initInterval=setInterval(function(){
													if(that.isInit){
														clearInterval(that.initInterval);
														that.getQwSopLogsByJsApi();
													}
												},200)
												
											} else {
												// 错误处理
											}
										});
										
										// jWeixin.openEnterpriseChat({
										// 		// 注意：userIds和externalUserIds至少选填一个。内部群最多2000人；外部群最多500人；如果有微信联系人，最多40人
										// 	externalUserIds: 'wmfFKfDQAAhvgwhJr9fqkRWjvN0CzFcA', // 参与会话的外部联系人列表，格式为userId1;userId2;…，用分号隔开。
										// 	groupName: '',  // 会话名称。单聊时该参数传入空字符串""即可。
										// 	chatId: "", // 若要打开已有会话，需指定此参数。如果是新建会话，chatId必须为空串
										// 	success: function(res) {
										// 		 var chatId = res.chatId; //返回当前群聊ID，仅当使用agentConfig注入该接口权限时才返回chatId
										// 		// 回调
										// 		that.externalUserId=res.chatId;
										// 		console.log(res)
										// 		setTimeout(function(){
										// 			jWeixin.invoke('sendChatMessage', {
										// 				msgtype:"news", //消息类型，必填
										// 				enterChat: true,
										// 				text: {
										// 					content:"你好11111111111111111", //文本内容
										// 				},
										// 				news:
										// 					{
										// 						link: "https://www.baidu.com/", //H5消息页面url 必填
										// 						title: "百度一下", //H5消息标题
										// 						desc: "百度一下你就知道", //H5消息摘要
										// 						imgUrl: "https://cos.his.cdwjyyh.com/fs/20240914/efc6995ee755489b8a3e0c8413846a4e.jpg", //H5消息封面图片URL
										// 					},
										// 			}, function(res) {
																				
										// 				if (res.err_msg == 'sendChatMessage:ok') {
										// 					//发送成功
										// 					uni.showToast({
										// 						title: "回车发送",
										// 						icon: 'none',
										// 					});
										// 				}
										// 			})
										// 		},500);
												
												
												
										// 	},
										// 	fail: function(res) {
										// 		if(res.errMsg.indexOf('function not exist') > -1){
										// 			alert('版本过低请升级')
										// 		}
										// 	}
										// });
									},
									fail: (res) => {
										console.error('agentConfig fail:', res);
									},
									
									
								});
							});
							jWeixin.error((res) => {
								
								console.error('wx.error:', res);
							});
							
						}
						else{
							// uni.setStorageSync("qwUserId",null);
							console.log("获取USERID失败")
							// setTimeout(function(){
							// 	window.location.reload();
							// },5000);
							
						}
						
					},
					rej => {
						setTimeout(function(){
							window.location.reload();
						},5000);
					}
				);
			},
			navTo(url){
				console.log(url)
				uni.navigateTo({
					url
				})
			},
			getQwExternalContactDetails(){
				var that=this
				var data = {
					corpId: this.corpId,
					userId:this.userId,
					externalUserId:this.externalUserId,
				};
				getQwExternalContactDetails(data).then(res => {
					if(res.code==200){
						this.user=res.data;
						
					}else{
						
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
		background: #f6f6f6;
	}
</style>
<style scoped lang="scss">
	.content{
		position: relative;
		height: 100%;
		width: 100%;
		.bg{
			width: 100%;
			height: 400upx;
			position: absolute;
			top: 0;
			left: 0;
			z-index: 1;
			background: linear-gradient(to bottom,#82aeff, #82aeff);
			// border-radius: 0rpx 0rpx 60rpx 60rpx;
		}
		.cont-box{
			position: relative;
			z-index: 2;
			padding: 30rpx 30rpx 200rpx;
			.user-cont{
				box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
				padding: 30rpx;
				background-color: #fff;
				border-radius: 15rpx;
				.user-box{
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: flex-start;
					.left{
						flex:1;
						display: flex;
						align-items: center;
						justify-content: flex-start;
						image{
							border-radius: 50%;
							width:120rpx;
							height:120rpx;
						}
						.user{
							margin-left: 20rpx;
							width: calc(100% - 140rpx);
							display: flex;
							flex-direction: column;
							align-items: flex-start;
							justify-content: flex-start;
							.username{
								font-size: 38rpx;
								font-family: PingFang SC;
								color: #111;
								font-weight: bold;
							}
							.account{
								padding: 5rpx 20rpx;
								border-radius: 30rpx;
								background-color: #115296;
								margin-top: 20rpx;
								font-size: 24rpx;
								font-family: PingFang SC;
								color: #fff;
							}
						}
					}
					.right{
						image{
							width: 15rpx;
							height:30rpx;
						}
						
					}
					
				}
				.company{
					margin-top: 30rpx;
					display: flex;
					align-items: center;
					justify-content: flex-start;
					image{
						width:40rpx;
						height:40rpx;
					}
					.name{
						margin-left: 15rpx;
						font-size: 28rpx;
						color: #111;
					}
				}
			}
			
			.menu-box{
				box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
				width: 100%;
				margin-top: 30rpx;
				padding: 30rpx;
				background-color: #fff;
				border-radius: 15rpx;
				.title-box{
					display: flex;
					align-items: center;
					justify-content: flex-start;
					.icon{
						width: 30rpx;
						height:30rpx;
					}
					.title{
						margin-left: 10rpx;
						font-size: 28rpx;
						font-family: PingFang SC;
						color: #111;
					}
				}
				.line{
					margin-top: 15rpx;
					height: 0.5rpx;
					width: 100%;
					background-color: #efefef;
				}
				.menus{
					margin-top: 30rpx;
					display: flex;
					align-items: center;
					justify-content: flex-start;
					flex-wrap: wrap;
				}
				.menu-item{
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					width: 25%;
					margin-bottom: 20rpx;
					image{
						width:60rpx;
						height:60rpx;
					}
					.m-name{
						margin-top: 10rpx;
						font-size: 24rpx;
						font-family: PingFang SC;
						color: #111;
					}
				}
				
			}
			.menu-box1{
				width: 100%;
				margin-top: 30rpx;
				padding: 0rpx 30rpx;
				background-color: #fff;
				border-radius: 15rpx;
				.menu-item{
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: flex-start;
					line-height: 100rpx;
					.left{
						flex:1;
						display: flex;
						align-items: center;
						justify-content: flex-start;
						image{
							width: 30rpx;
							height:30rpx;
						}
						.label{
							margin-left: 10rpx;
						}
					}
					.right{
						image{
							width: 10rpx;
							height:15rpx;
						}
						
					}
				}
			}
		}
	}
	.btn-box{
		margin: 60rpx 0rpx 30rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		.sub-btn{
			// box-shadow: 0px 0px 5px 2px rgba(0,0,0,0.05);
			border: 1rpx solid #f8f8f8;
			background: #FFFFFF;
			width: 100%;
			height: 88upx;
			line-height: 88upx;
			text-align: center;
			font-size: 30upx;
			font-family: PingFang SC;
			color: #111;
		}
	}
	.text{
		width: 100%;
		font-size: 24rpx;
		 
	}
</style>
