<template>
	<view>
		登陆中...
	</view>
</template>

<script setup>
 
	import{ref} from "vue"
	import {login} from "@/api"
	import {onLoad} from "@dcloudio/uni-app"
 
	const fetchData=(data,e)=> {
		  login(data).then(res => {
			  console.log(res)
			  if(res.status){
				  sessionStorage.setItem("access_token",res.data.token)
				  sessionStorage.setItem("refresh_token",res.data.refresh_token)
				  if(e.objtype && e.page){
					  uni.reLaunch({
					  	url: '/pages/'+e.objtype+'/'+e.page+'?ordernum='+e.ordernum+'&price='+e.price
					  })
				  }else{
					  uni.showToast({
					    title: "缺失跳转路径",
					    icon: 'none'
					  });
				  }
			  }else{
				  uni.showToast({
				    title: res.msg,
				    icon: 'none'
				  });
			  }
		  })	
	}
	onLoad((e)=>{
		//获取url 应用编号appid  用户userid   跳转的项目类型objtype:发票invoice 工单chat  跳转页面page：列表list 详情detail, 关联的订单号: ordernum ,详情的id,发票金额price
		console.log(e)
		if(e.userid && e.appid){
			fetchData({appid:e.appid,openid:e.userid},e)
		}else{
			uni.showToast({
			  title: "缺失应用用户信息",
			  icon: 'none'
			});
		}
		
	})
	
</script>

<style>

</style>