<template>
	<!-- 设置页面 -->
	<view class="setup">
		
		<view class="container">
			<navigator url="/pages/edit/shop/shop" class="list-cell b-b m-t"  hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">门店编辑</text>
				<image class="jiantousi" src="/static/news/jiantousi.png" mode=""></image>
			</navigator>
			<navigator url="/pages/edit/Qualifications/Qualifications" class="list-cell b-b"  hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">相关资质</text>
				<image class="jiantousi" src="/static/news/jiantousi.png" mode=""></image>
			</navigator>
			
			
			<view class="list-cell m-t">
				<text class="cell-tit">接收语音提醒</text>
				<switch :checked="ischecked" color="#fa436a" @change="switchChange" />
			</view>
			<view class="list-cell m-t b-b" @tap="cleanstore" hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">清除缓存</text>
				<image class="jiantousi" src="/static/news/jiantousi.png" mode=""></image>
			</view>
			<navigator url="/pages/tagglestore/tagglestore" class="list-cell b-b"  hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">切换门店</text>
				<image class="jiantousi" src="/static/news/jiantousi.png" mode=""></image>
			</navigator>
			<navigator url="/pages/setPassword/setPassword" class="list-cell b-b"  hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">修改密码</text>
				<image class="jiantousi" src="/static/news/jiantousi.png" mode=""></image>
			</navigator>
			<navigator url="/pages/about/about" class="list-cell b-b"  hover-class="cell-hover" :hover-stay-time="50">
				<text class="cell-tit">关于我们</text>
				<image class="jiantousi" src="/static/news/jiantousi.png" mode=""></image>
			</navigator>
			<view class="list-cell ali-c" @tap="ToUpdate">
				<text class="cell-tit">检查更新</text>
				<text class="cell-tip">当前版本 {{version}}</text>
				<image class="jiantousi" src="/static/news/jiantousi.png" mode=""></image>
			</view>
			<view class="list-cell log-out-btn" >
				<view class="button" @tap="toLogout">
					<text class="cell-tit log-out-btncolor">退出登录</text>
				</view>
				
			</view>
		</view>
		
		<yomol-upgrade   ref="yomolUpgrade" :isshowmsg="true"></yomol-upgrade>
		<!-- 升级组件 -->
		
	</view>
</template>

<script>
	import {userLogout} from "@/utils/api/api.js";
	import yomolUpgrade from '@/components/yomol-upgrade/yomol-upgrade.vue';//升级组件 
	export default {
		components:{
			yomolUpgrade,
		},
		data() {
			return {
				//ischecked:false,//声音提醒开关
				version:"1.00"
			};
		},
		onLoad() {
			this.getv();
			console.info(this.version);
		},
		computed:{
			//选中状态
			ischecked(){
				return this.$store.state.isvoice;
			}
		},
		methods:{
			getv(){
				// #ifdef APP-PLUS
				plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
					this.version = widgetInfo.version;
				})
				// #endif
				
			},
			navTo(url){
				this.$api.msg(`跳转到${url}`);
			},
			//退出登录
			toLogout(){
				uni.showModal({
				    content: '确定要退出登录么',
				    success: (e)=>{
				    	if(e.confirm){
				    		//this.logout();
							//退出登录事件处理
				    		
							
							//退出登录
							userLogout({
								
							}).then((res)=>{
								if(res.code==0){
									this.$api.msg("退出成功");
									uni.setStorageSync('token',"");
									this.$store.commit('changetoken',"");
									this.$store.commit('changeuserInfo', {});
									uni.setStorageSync('userInfo', {});
									uni.clearStorage();
									
									setTimeout(()=>{
										// uni.navigateBack();
										uni.navigateTo({
											url:"/pages/login/login",
										})
									}, 500)
								}else{
									this.$api.msg(res.msg);
								}
							})
							
							
							
				    	}
				    }
				});
			},
			//switch
			switchChange(e){
				let statusTip = e.detail.value ? '打开': '关闭';
				this.$api.msg(`已${statusTip}语音提示`);
				
				this.$store.dispatch('AudioVoice',`已${statusTip}语音提示`).then((e) => {
					console.log(e);
					
					console.info("循环消息列表2");
					//震动 调用//400ms//长震动
					uni.vibrateLong({
						success:(re)=> {
						},
						fail:(a)=> {
						}
					})
				})
				
				//console.info(e.detail.value,"e.detail.value ");
				
				this.$store.commit("changeisvoice",e.detail.value);//直接修改 双向绑定的
			},
			cleanstore(){
				//清除缓存
				uni.clearStorage();
				this.$api.msg("操作成功");

				setTimeout(()=>{
					uni.navigateTo({
						url:"/pages/login/login",
					})
				},1000)
				
			},
			//更新检测事件
			ToUpdate(){
				
				// #ifdef APP-PLUS
				//this.checkVersionClick();//自动检测更新
				this.$refs.yomolUpgrade.checkVersionClick();
				// #endif
				
				// #ifdef H5
				this.$api.msg("已是最新版本");
				// #endif
			}
		}
	}
</script>

<style lang="scss">
	@import "./setup.scss";
</style>
