个人中心页面
<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>