You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
3.1 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<script setup>
/**
* name
* usersa0ChunLuyu
* date2022-04-19 14:58:23
*/
import {
ref
} from 'vue'
import config from '@/config.js'
import {
getToken,
delToken
} from '@/tool/member.js'
import {
getUserInfoAction
} from '@/api/index.js'
const login_ref = ref(null)
const quit_show = ref(false)
const user_info = ref(false)
const loginRef = (e) => {
login_ref.value = e
}
const quitDo = () => {
quit_show.value = false
delToken()
user_info.value = false
login_ref.value.getUserInfo()
}
const quitClick = () => {
quit_show.value = true
}
import {
onShow
} from '@dcloudio/uni-app'
onShow(() => {
getUserInfo()
})
const toUserSetInfo = () => {
uni.navigateTo({
url: '/pages/user/set_info/set_info'
})
}
const getUserInfo = () => {
if (getToken()) {
getUserInfoAction((info) => {
user_info.value = info
}, false)
}
}
const $img = (mark) => {
return uni.$img(mark)
}
</script>
<template>
<u-modal v-model="quit_show" confirm-color="#529051" :show-cancel-button="true" @confirm="quitDo"
content="是否退出当前账号?"></u-modal>
<Login :ref="loginRef"></Login>
<view class="user_top_wrapper">
<view v-if="user_info" class="user_info_wrapper" @click="toUserSetInfo()">
<view class="user_info_avatar_wrapper">
<u-image :src="user_info.info.avatar" width="140rpx" height="140rpx"></u-image>
</view>
<view class="user_info_nickname_wrapper">
<view v-if="user_info.info.nickname">{{ user_info.info.nickname }}</view>
<view v-else>点击设置昵称</view>
</view>
</view>
<view v-else class="user_info_wrapper">
<view class="user_info_avatar_wrapper">
<u-image :src="$img('upload/user/avatar/default.png')" width="140rpx" height="140rpx"></u-image>
</view>
<view class="user_info_nickname_wrapper">
点击登录
</view>
</view>
<view class="user_top_bottom_bg_wrapper"></view>
</view>
<view>
<view v-if="user_info" @click="toUserSetInfo()" class="primary_button_wrapper set_info_wrapper">
设置信息
</view>
</view>
<view>
<view v-if="user_info" @click="quitClick()" class="primary_button_wrapper quit_wrapper">
退
</view>
</view>
</template>
<style>
page {
background: #ffffff;
}
</style>
<style scoped>
.set_info_wrapper {
margin: 200rpx auto 0;
}
.quit_wrapper {
margin: 50rpx auto 0;
}
.user_info_avatar_wrapper {
width: 140rpx;
height: 140rpx;
border-radius: 6rpx;
background: #ffffff;
margin: 30rpx auto 0;
border-radius: 6rpx;
overflow: hidden;
box-shadow: 0 0 50rpx #00000060;
}
.user_info_nickname_wrapper {
font-size: 28rpx;
font-weight: bold;
margin-top: 20rpx;
}
.user_info_wrapper {
text-align: center;
}
.user_top_bottom_bg_wrapper {
position: absolute;
width: 750rpx;
height: 100rpx;
background: #ffffff;
border-radius: 50%;
bottom: 0;
transform: translateY(50%);
box-shadow: 0 0 50rpx #00000060;
}
.user_top_wrapper {
height: 300rpx;
overflow: hidden;
position: relative;
background: #67b163;
}
</style>