userInfo.vue 1.7 KB
<template>
	<view class="usrInfo">
		<view class="box">
			<u-cell-group :border="false">
				<u-cell
					v-for="(item, index) in userInfoList"
					:key="index"
					:icon="item.iconName"
					:title="item.title"
					isLink
					@click="goRouter(item.routerPath)"
				/>
			</u-cell-group>
		</view>
		<view class="logOut" @click="logOut">退出登录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfoList: [
					{ title: '用户信息', iconName: 'account', routerPath: '/pages_my/editUserInfo/editUserInfo' },
					{ title: '修改密码', iconName: 'lock-open', routerPath: '/pages_my/editPassword/editPassword' }
				]
			}
		},
		methods: {
			// 跳转路由
			goRouter(path){
				uni.navigateTo({
					url: path
				})
			},
			// 退出登录
			logOut(){
				let that = this
				uni.showModal({
					title: '提示',
					content: '是否退出登录',
					success: async function (res) {
						if (res.confirm) {
							that.$store.dispatch('Logout').then(res => {
								uni.$u.toast('退出成功')
								uni.navigateTo({
									url: '/pages/login/index'
								})
							})
						} else if (res.cancel) {
							uni.$u.toast('取消退出')
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.usrInfo {
	min-height: 100vh;
	background-color: #F6F7FB;
	.box{
		background-color: #fff;
		.item{
			width: 100%;
			border-bottom: 2rpx solid #eee;
			&:last-child{
				border-bottom: 0;
			}
			.avatar{
				margin: 0;
				background-color: #fff;
			}
		}
	}
	.logOut{
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color: #3D3D3D;
		font-size: 30rpx;
		background: #FFFFFF;
		margin-top: 20rpx;
	}
}
</style>