<style>
	page {
		background: #f5f5f5
	}

	.user-line {
		padding: 0 15px;
		height: 70px;
		background: #fff;
		border-top: 1px #f5f5f5 solid;
		display: flex;
		align-items: center
	}

	.ul-left {
		color: #585858;
		font-size: 14px
	}

	.ul-right {
		width: 60%;
		margin-left: auto;
		display: flex;
		align-items: center;
		justify-content: flex-end
	}

	.ulr-name {
		color: #9b9b9b;
		font-size: 13px
	}

	.ulr-img {
		width: 50px;
		height: 50px
	}

	.ulr-img image {
		width: 100%;
		height: 100%;
		border-radius: 100%
	}

	.ulr-jiantou {
		width: 16px;
		height: 16px;
		margin-left: 10px
	}

	.ulr-jiantou image {
		width: 100%;
		height: 100%
	}
</style>
<template>
	<view id="box">
		<view class="user-line" style="margin-top: 10px;" @tap="tapOpen" data-url="/pages/user/userinfo/password">
			<view class="ul-left"><text>修改密码</text></view>
			<view class="ul-right">
				<view class="ulr-name">
					<text></text>
				</view>
				<view class="ulr-jiantou">
					<image src="/static/img/ic_next.png"></image>
				</view>
			</view>
		</view>
		
		<view class="user-line" style="margin-top: 10px;" @tap="tapOpen" data-url="/pages/user/userinfo/cancellation">
			<view class="ul-left"><text>注销账号</text></view>
			<view class="ul-right">
				<view class="ulr-name">
					<text></text>
				</view>
				<view class="ulr-jiantou">
					<image src="/static/img/ic_next.png"></image>
				</view>
			</view>
		</view>
		
		<view class="user-line" style="margin-top: 10px;" @tap="onUpdate">
			<view class="ul-left"><text>检查更新</text></view>
			<view class="ul-right">
				<view class="ulr-name">
					<text>{{version}}</text>
				</view>
				<view class="ulr-jiantou">
					<image src="/static/img/ic_next.png"></image>
				</view>
			</view>
		</view>
		
		<view class="user-line"  @tap="tapOpen" data-url="/pages/operation/user">
			<view class="ul-left"><text>用户协议</text></view>
			<view class="ul-right">
				<view class="ulr-name">
					<text></text>
				</view>
				<view class="ulr-jiantou">
					<image src="/static/img/ic_next.png"></image>
				</view>
			</view>
		</view>
		
		
		<view class="user-line" @tap="tapOpen" data-url="/pages/operation/agreement">
			<view class="ul-left"><text>隐私条款</text></view>
			<view class="ul-right">
				<view class="ulr-name">
					<text></text>
				</view>
				<view class="ulr-jiantou">
					<image src="/static/img/ic_next.png"></image>
				</view>
			</view>
		</view>
		
		<view class="user-line" style="margin-top: 10px;" @tap="outClick()">
			<view class="ul-left"><text>退出登陆</text></view>
			<view class="ul-right" >
				<view class="ulr-name">
					<text></text>
				</view>
				<view class="ulr-jiantou">
					<image src="/static/img/ic_next.png"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import global from "../../../config/global.js";
	export default {
		computed: mapState(['user']),
		data() {
			return {
				version:""
			}
		},
		onLoad() {
			this.version = global.version;
		},
		methods: {
			...mapMutations(['loginOut','sysInit','setSys']),
			/**
			 * 打开文件
			 * @param {Object} ev
			 */
			tapOpen: function(ev) {
				console.log(ev)
				let url = ev.currentTarget.dataset.url
				uni.navigateTo({
					url: url
				});
			},
			outClick:function(){
				this.utils.showModal("确认要退出吗",()=>{
					this.loginOut();
					uni.showToast({ title: '退出成功',mask: true,icon: 'none'});
					uni.reLaunch({ url:"/pages/login/index" });
				});
			},
			
			/**
			 * 基本逻辑
			 */
			onUpdate:function(){
				this
					.request
					.post("sysInit")
					.then(res => {
						if (res.code == 200) {
							this.setSys(res.data);
							if(plus != null){
								plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
									console.log(wgtinfo);
									this.version = wgtinfo.version;
									if(wgtinfo.versionCode < res.data.app_code){
										uni.showModal({
											title:"新版本",
											content:res.data.app_update,
											success:()=> {
												console.log(this.$device.platform);
												if(this.$device.platform == 'ios') {
													var urlStr = encodeURI(res.data.ios_url);
													plus.runtime.openURL(urlStr);
												}
												
												if(this.$device.platform != 'ios') {
													var urlStr = encodeURI(res.data.android_url);
													plus.runtime.openURL(urlStr);
												}
												
											}
										})
									} else {
										this.utils.Tip("无新版本");
									}
								})
							}
						}
					});
			},
			
		},
	}
</script>
