<template>
	<view class="content">

	</view>
</template>

<script>
	import {getToken,getUserInfo} from "@/utils/auth";
    const keepAlivePlugin = uni.requireNativePlugin('Ba-KeepAlive')
	export default {
		data() {
			return {
				keepLive: {
					channelId: 'Ba-KeepAlive',
					channelName: "Ba-KeepAlive",
					title: "汽修小助手正在运行",
					content: "汽修小助手正在运行",
					dataResult: "",
					type: undefined
				}
			}
		},
		onLoad() {
		// #ifdef APP
			//保活技术
			this.register()
		// #endif
      if(getToken()){
        //跳转首页
        //判断是否是仓管，仓管需要跳单独的首页
        let userInfo = getUserInfo()
        if(userInfo.roleCodes.includes('repair_warehouse')){
          //仓管
          uni.navigateTo({
            url: '/pages-warehouse/home/home'
          })
        }else{
          uni.navigateTo({
            url: '/pages-home/home/home'
          })
        }
      }else{
        uni.navigateTo({
          url: '/pages/login/login'
        })
		}
		},
		methods: {
			register() { //注册
				console.log(keepAlivePlugin, 'keepAlive');
				keepAlivePlugin.register({
						channelId: this.keepLive.channelId,
						channelName: this.keepLive.channelName,
						title: this.keepLive.title,
						content: this.keepLive.content,
					},
					(res) => {
						console.log('保活注册', res);
					});
			},
		}
	}
</script>

<style>

</style>
