You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
1.9 KiB
97 lines
1.9 KiB
<template>
|
|
<view class="container">
|
|
<view style="padding-left: 16px;color: rgba(0,0,0,0.5);font-size: 12px;margin-bottom: -10px;margin-top: 16px;">
|
|
账号信息</view>
|
|
<uni-card padding="0">
|
|
<uni-list :border="false">
|
|
<uni-list-item title="账号" :rightText="userInfo.userName"></uni-list-item>
|
|
<uni-list-item title="昵称" :rightText="userInfo.nickName"></uni-list-item>
|
|
<uni-list-item title="手机号" :rightText="userInfo.phonenumber"></uni-list-item>
|
|
</uni-list>
|
|
</uni-card>
|
|
|
|
<button class="submit" type="warn" @click="logout" :loading="submiting">退出登录</button>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import helper from '../../common/helper'
|
|
export default {
|
|
data() {
|
|
return {
|
|
userInfo: {},
|
|
submiting: false,
|
|
|
|
}
|
|
},
|
|
onLoad() {
|
|
console.log(1)
|
|
uni.getStorage({
|
|
key: 'tempUserInfo',
|
|
success: (resp) => {
|
|
console.log(resp)
|
|
this.userInfo = resp.data.user;
|
|
},
|
|
fail: (err) => {
|
|
console.log(err)
|
|
}
|
|
})
|
|
},
|
|
onShow() {},
|
|
methods: {
|
|
|
|
logout() {
|
|
const toLogin = (token) => {
|
|
uni.request({
|
|
url: `${helper.serverUrl}/user/logout`,
|
|
method: 'POST',
|
|
header: {
|
|
Authorization: `Bearer ${token}`
|
|
},
|
|
success() {
|
|
uni.reLaunch({
|
|
url: '/pages/login/login'
|
|
})
|
|
},
|
|
fail() {
|
|
uni.reLaunch({
|
|
url: '/pages/login/login'
|
|
})
|
|
}
|
|
})
|
|
}
|
|
uni.showModal({
|
|
content: '是否退出当前用户?',
|
|
title: '提示',
|
|
success(res) {
|
|
if (res.confirm) {
|
|
uni.getStorage({
|
|
key: 'token',
|
|
success(resp) {
|
|
uni.removeStorage({
|
|
key: 'token'
|
|
})
|
|
toLogin(resp.data);
|
|
},
|
|
fail() {
|
|
toLogin();
|
|
}
|
|
})
|
|
} else if (res.cancel) {}
|
|
}
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.container>>>.uni-list::after {
|
|
height: 0;
|
|
}
|
|
|
|
.submit {
|
|
border-radius: 47px;
|
|
width: 375rpx;
|
|
}
|
|
</style> |