<script>
import config from './config';
import store from '@/store';
import { getToken, getuserId, removeuserId } from '@/utils/auth';
// #ifdef APP-PLUS
import permision from '@/js_sdk/wa-permission/permission.js';
// #endif

export default {
	onLaunch: function() {
		// removeuserId();
		// console.log(getuserId())
		// //有userid才执行,就是说第一次没登录前，本地没有userid就不会执行
		// if (getuserId()) {
		// 	console.log('shauxin');
		// 	this.$store.dispatch('websocketInit', `${getuserId()}`);
		// }

		//隐藏tabber
		uni.hideTabBar();
		this.initApp();
	},
	onShow: function() {
		// console.log('shauxin2');
		uni.hideTabBar();
		// #ifdef APP-PLUS
		let that = this;
		that.requestAndroidPermission('android.permission.READ_CALENDAR'); // 读取日历
		that.requestAndroidPermission('android.permission.WRITE_CALENDAR'); // 写入日历
		// #endif
	},
	methods: {
		// 初始化应用
		initApp() {
			// 初始化应用配置
			this.initConfig();
			// 检查用户登录状态
		},
		initConfig() {
			this.globalData.config = config;
		},

		// 网址的代码 copy
		async requestAndroidPermission(permisionID) {
			let result = await permision.requestAndroidPermission(permisionID);
			let strStatus;
			if (result == 1) {
				strStatus = '已获得授权';
			} else if (result == 0) {
				strStatus = '未获得授权';
			} else {
				strStatus = '被永久拒绝权限';
			}
			// 测试代码
			// uni.showModal({
			// 	content: permisionID + strStatus,
			// 	showCancel: false
			// });
		}
	}
};
</script>

<style lang="scss">
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
@import '@/uni_modules/uview-ui/index.scss';
@import '@/static/scss/index.scss';

//黑体
@font-face {
	font-family: 'Source_Han_Sans_SC_Normal_Normal';
	src: url('/static/fontSize/Source_Han_Sans_SC_Normal_Normal.otf');
}

html,
body {
	font-family: 'Source_Han_Sans_SC_Normal_Normal';
}

page {
	background-color: #f6f7fb;
}
</style>
