<template>
	<view class="wrap">
		<u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
			:content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
			:showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex';

	export default {
		components: {

		},
		data() {
			return {
				isShowAlert: false,
				content: '当前登入信息验证失败，是否重新登录？',
			}
		},

		onLoad() {

		},
		// #ifndef MP
		onNavigationBarButtonTap(e) {
			const index = e.index;
			if (index === 0) {
				this.navTo('/pages/set/set');
			} else if (index === 1) {
				// #ifdef APP-PLUS
				const pages = getCurrentPages();
				const page = pages[pages.length - 1];
				const currentWebview = page.$getAppWebview();
				currentWebview.hideTitleNViewButtonRedDot({
					index
				});
				// #endif
				uni.navigateTo({
					url: '/pages/notice/notice'
				})
			}
		},
		// #endif
		computed: {
			...mapState(['hasLogin', 'userInfo']),
		},
		onShow() {
			uni.showLoading({
				title:"加载中...",
				mask:true
			})
			uni.hideLoading()
			this.$forceUpdate()//刷新data数据
			that.$api.msg('添加成功')
			that.$refs.uToast.show({
				title: '提交成功',
				type: 'success'
			})
			// 深拷贝
			let b = this.$u.deepClone(a);
			uni.setStorageSync("depotAcquisition_warehouseName",this.warehouseName)
			uni.getStorageSync("depotAcquisition_warehouseName")
			// 公司id
			compId:  uni.getStorageSync('pcUserInfo').compId,
			uni.getStorageSync("userInfo").id//用戶id
			// 调用公用方法
			 this.utils.getDistance(lat1,lng1,lat2,lng2)
			this.$api.doRequest('get', '/commonUser/api/checkSession').then(res => {
				console.log("checkSession", res)
				if (res.data.data == "INVALID") {
					this.isShowAlert = true;
				}
			})
			console.log("hasLogin", this.hasLogin)
		},
		methods: {
			// // 软键盘下一项
			// keywordConfirm(e) {
			// 	console.log(e)
			// 	var index = (e.target.id).replace('input-', '');
			// 	var value = e.detail.value;
			// 	uni.hideKeyboard(); //隐藏软键盘				
			// 	this.focus_index = Number(index)
			// 	this.$nextTick(function() {
			// 		this.focus_index = Number(index) + 1
			// 	});
			
			// 	if (index != '10' && value != '') {
			// 	this.focus_index = Number(index) + 1
			// 	}
			// },
			// confirm-type="search" type="number" :id="'input-17'" @confirm="keywordConfirm"
			// 	:focus="focus_index == 17"
			/**
			 * 统一跳转接口,拦截未登录路由
			 * navigator标签现在默认没有转场动画，所以用view
			 */
			navTo(url) {
				if (!this.hasLogin) {
					url = '/pages/public/login';
				}
				uni.navigateTo({
					url
				})
			},
			alertBtn() {
				uni.navigateTo({
					url: '/pages/public/login'
				})
			},
			cancelClick() {
				this.isShowAlert = false
			}
		}
	}
</script>
<style lang='scss' scoped>
	page {
		background: #F5F6FA;
	}

	.wrap {
		background: #fff;
		margin: 10px;
		border-radius: 10px;
		padding: 10px;
	}
</style>
