ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

uni-app个人中心

2021-12-21 19:58:48  阅读:490  来源: 互联网

标签:个人 .. color app 登录 url uni margin


个人中心页面

<template>
	<view>
		<view class="u-m-t-20">
			<view class="center">
				
				<view class="u-m-t-12 u-m-l-60">
					<!-- <u-avatar :src="src" mode="circle" size="160"></u-avatar> -->
					<image :src="list.avatar" style="width: 180rpx; height: 180rpx; border-radius: 60px;"></image>
				</view>
				
				<!-- <image src=""></image> -->
				<view class="center-item">
					<!-- <view>昵称:{{list.nickName}}</view> -->
					<view>用户名:{{list.userName}}</view>
					<view>账户ID:{{list.userId}}</view>
				</view>
			</view>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="account" title="个人信息" @click="toBaseInfo"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="bag" title="订单"></u-cell-item>
				<u-cell-item icon="reload" title="修改密码" @click="changePassword"></u-cell-item>
				<u-cell-item icon="kefu-ermai" title="意见反馈"></u-cell-item>
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<!-- <u-cell-item icon="account" title="登录" @click="login"></u-cell-item> -->
				<u-cell-item icon="close" title="退出" @click="logout"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
	
</template>

<script>
	import api from "../../request/api.js"
	export default {
		data() {
			return {
				src: '../../static/phone/105.webp',
				list:[]
			}
		},
		onLoad() {
			// this.getuser()
			this.login()
			/* 判断是否token */
			/* if(!uni.getStorageSync('token')){
				this.$u.toast('请登录')
				setTimeout(()=>{
					uni.navigateTo({
						url:'../auth/login'
					})
				},3000)
			} */
		},
		onShow() {
			this.getuser()
		},
		methods: {
			
			/* 个人信息 */
			toBaseInfo(){
				uni.navigateTo({
					url:'./baseInfo'
				})
			},
			async getuser(){
				const res=await api.Getuser()
				console.log(res)
				this.list = res.user
			},
			/* 修改密码 */
			changePassword(){
				uni.navigateTo({
					url:'./changePassword'
				})
			},
			/* 登录 */
			login(){
				if(!uni.getStorageSync('token')){
					this.$u.toast('请登录')
					setTimeout(()=>{
						uni.navigateTo({
							url:'../auth/login'
						})
					},3000)
				}
			},
			
			/* 退出登录 */
			async logout(){
				uni.removeStorageSync('token')
				this.$u.toast('退出登录')
				setTimeout(()=>{
					uni.switchTab({
						url:'../index/index'
					})
				},1500)
			}
		
		}
	}
</script>

<style lang="scss" scoped>
page{
	background-color: #DCDFE6;
}
	.center{
		background-color: #FFFFFF;
		display: flex;
		
		/* image{
			height: 70px;
			width: 70px;
			margin-top: 20rpx;
			// margin: 130rpx;
		} */
		.center-item{
			margin-top:60rpx;
			margin-left: 40rpx;
		}
	}
</style>

登录页面

<template>
	<view class="wrap">
		<view class="content">
			<view class="title">欢迎登录智慧城市</view>
			<input class="u-border-bottom" type="text" v-model="username" placeholder="请输入用户名" />
			<input class="u-border-bottom" type="password" v-model="password" placeholder="请输入密码" />
			<button @tap="submit" :style="[inputStyle]" class="getCaptcha">登录</button>
			<view class="alternative">
				<view class="password">找回密码</view>
				<view class="issue" @click="register">注册</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import api from '../../request/api.js'
export default {
	data() {
		return {
			username: '',
			password: ''
		}
	},
	async onl oad() {
		
	},
	computed: {
		inputStyle() {
			let style = {};
			if(this.username && this.password) {
				style.color = "#fff";
				style.backgroundColor = this.$u.color['warning'];
			}
			return style;
		}
	},
	methods: {
		register(){
			uni.redirectTo({
				url:'./register'
			})
		},
		async submit() {
			if(!this.username || !this.password) return
			//处理登录用的参数
			const params = {
				username:this.username,
				password:this.password
			}
			//请求API,执行登录
			const res  = await api.Login(params)
			uni.setStorageSync('token',res.token)
			setTimeout(()=>{
				uni.switchTab({
					url:'../center/center'
				})
			},1500)
			
			this.$u.toast('登录成功')
			
			
			
		}
	}
};
</script>

<style lang="scss" scoped>
.u-border-bottom{
	margin-bottom: 40rpx !important;
}
.wrap {
	font-size: 28rpx;
	.content {
		width: 600rpx;
		margin: 80rpx auto 0;

		.title {
			text-align: left;
			font-size: 60rpx;
			font-weight: 500;
			margin-bottom: 100rpx;
		}
		input {
			text-align: left;
			margin-bottom: 10rpx;
			padding-bottom: 6rpx;
		}
		.tips {
			color: $u-type-info;
			margin-bottom: 60rpx;
			margin-top: 8rpx;
		}
		.getCaptcha {
			background-color: rgb(253, 243, 208);
			color: $u-tips-color;
			border: none;
			font-size: 30rpx;
			padding: 12rpx 0;
			
			&::after {
				border: none;
			}
		}
		.alternative {
			color: $u-tips-color;
			display: flex;
			justify-content: space-between;
			margin-top: 30rpx;
		}
	}
	.buttom {
		.loginType {
			display: flex;
			padding: 350rpx 150rpx 150rpx 150rpx;
			justify-content:space-between;
			
			.item {
				display: flex;
				flex-direction: column;
				align-items: center;
				color: $u-content-color;
				font-size: 28rpx;
			}
		}
		
		.hint {
			padding: 20rpx 40rpx;
			font-size: 20rpx;
			color: $u-tips-color;
			
			.link {
				color: $u-type-warning;
			}
		}
	}
}
</style>

标签:个人,..,color,app,登录,url,uni,margin
来源: https://blog.csdn.net/weixin_47350310/article/details/122071849

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有