// 注册 Vant 组件
Vue.use(vant.NavBar);
Vue.use(vant.Icon);
Vue.use(vant.Toast);

var app = new Vue({
	el: "#app",
	data: {},

	methods: {
		/**
		 * 返回上一页
		 */
		goBack: function () {
			history.go(-1);
		},

		/**
		 * 跳转到数据同步页面
		 */
		goToSync: function () {
			var _self = this;

			// 显示加载提示
			vant.Toast.loading({
				message: '加载中...',
				forbidClick: true,
				duration: 500
			});

			// 延迟跳转，显示加载动画
			setTimeout(function () {
				window.location.href = './DataSync.html';
			}, 500);
		},

		/**
		 * 跳转到离线盘点页面
		 */
		goToInventory: function () {
			var _self = this;

			// 显示加载提示
			vant.Toast.loading({
				message: '加载中...',
				forbidClick: true,
				duration: 500
			});

			// 延迟跳转，显示加载动画
			setTimeout(function () {
				window.location.href = './AssetInventorySelect.html';
			}, 500);
		},

		/**
		 * 初始化
		 */
		init: function () {
			var _self = this;
			console.log('功能菜单页面初始化完成');
		}
	},

	created: function () {
		console.log('Menu Vue实例创建完成');
	},

	mounted: function () {
		var _self = this;
		if (!plugin.urlApi.getApiUrl()) {
			const ip = Common.getRootPath();
			localStorage.setItem("ipServer", ip);
			console.log(ip)
		} else {
			localStorage.setItem("ipServer", plugin.urlApi.getApiUrl());
		}
		_self.init();
		console.log('Menu页面加载完成');
	}
});
