profile.vue 2.66 KB
<template>
	<view>
		<headerComp :title="titleStr"></headerComp>
		<view class="prefix-elem"></view>
		<view class="profile-item" @tap="switchConnect">
			<span class="texts">切换服务器地址</span>
			<img class="arrows" :src="rArrow" alt=""/>
		</view>
		<!-- <view class="profile-item">
			<span class="texts">修改密码</span>
			<img class="arrows" :src="rArrow" alt=""/>
		</view> -->
		<view class="logout">
			<button type="primary" class="primary logout-btn" @tap="logoutHandle">退出登录</button>
		</view>
	</view>
</template>

<script>
	import headerComp from '../../components/header'
	import backArrow from '../../static/header/backArrow.png'
	import rArrow from "../../static/analysis/rArrow.png"

	export default {
		onLoad(option) {
			console.log(option)
		},
		components: {
			headerComp
		},
		data() {
			return {
				titleStr: '我的',
				backArrow: backArrow,
				rArrow: rArrow
			}
		},
		methods: {
			switchConnect() {
				let that = this;
				that.$message.confirm('<div class="dialog-content" style="color: #333; font-size: 17px;text-align: center;">确认切换该服务器地址?</div>', function(res, body) {
				}, [{
					className: 'dialog-btn',
					label: '取消',
					callback: function(res, $body) {
						return true;
					}
				}, {
					className: 'dialog-btn',
					label: '确定',
					callback: function(res, $body) {
						that.clearCache(true);
						model.switchConnectType() // 调用swift 无参
					}
				}], '提示');
			},
			logoutHandle() {
				this.clearCache();
				uni.reLaunch({
				    url: '../login/login',
				});
			},
			clearCache(isAllClear) {
				Object.keys(window.localStorage).forEach(item => {
					if(isAllClear) {
						uni.removeStorage({
							key: item,
							success: function (res) {
							}
						});
					} else {
						if(item!='user'&&item!='pwd'&&item!='statusBarH'){
							uni.removeStorage({
								key: item,
								success: function (res) {
								}
							});
						}
					}
					
				})
			}
		},
	}
</script>

<style>
	.prefix-elem {
		height: 25.36upx;
	}
	.profile-item {
		background: #FFFFFF;
		position: relative;
	}
	.texts {
		display: block;
		height: 90.57upx;
		line-height: 90.57upx;
		margin-left: 23.55upx;
		font-size: 28.98upx;
		color: #333;
		border-bottom: 1.81upx solid rgba(151, 151, 151, .2);
		box-sizing: border-box;
	}
	.profile-item:last-of-type .texts {
		border-bottom: none;
	}
	.arrows {
		width: 14.49upx;
		height: 25.36upx;
		position: absolute;
		right: 23.55upx;
		top: 32.6upx;
	}
	.logout {
		margin-top: 255.43upx;
		padding: 0 41.66upx;
	}
	.logout-btn {
		background-color: transparent;
		border: 1px solid #0069FF;
		color: #0069FF;
		border-radius: 41.66upx;
	}
</style>