224 lines
4.4 KiB
Vue
224 lines
4.4 KiB
Vue
<template>
|
||
<view class="content">
|
||
<view class="page-bg" :style="{ position: 'absolute', top: 0, left: 0, width: '750rpx', height: bgHeight + 'px', backgroundImage: 'url(https://aliyunoss.hn12301.net/learnlaw/xfswj_dtbj.jpg)', backgroundSize: 'cover', backgroundPosition: 'top center', backgroundRepeat: 'no-repeat', zIndex: 0 }"></view>
|
||
<view class="page-body">
|
||
<view class="login-box" v-if="!isLoggedIn">
|
||
<text class="login-tip">注册后享受更多功能</text>
|
||
<button class="login-btn" @tap="goRegister">立即注册</button>
|
||
</view>
|
||
<template v-if="isLoggedIn">
|
||
<view class="user-card">
|
||
<view class="user-avatar">
|
||
<text class="avatar-text">{{ userName.charAt(0) }}</text>
|
||
</view>
|
||
<view class="user-info">
|
||
<text class="user-name">{{ userName }}</text>
|
||
<text class="user-phone">{{ maskedPhone }}</text>
|
||
</view>
|
||
</view>
|
||
<view class="menu-list">
|
||
<view class="menu-item" @tap="goAnswerRecords">
|
||
<view class="menu-icon menu-icon-record">
|
||
<text>📝</text>
|
||
</view>
|
||
<text class="menu-text">答题记录</text>
|
||
<text class="menu-arrow">›</text>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
</view>
|
||
<sw-tabbar current="profile"></sw-tabbar>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import swTabbar from '@/components/sw-tabbar/sw-tabbar.vue'
|
||
|
||
export default {
|
||
components: {
|
||
swTabbar
|
||
},
|
||
data() {
|
||
return {
|
||
isLoggedIn: false,
|
||
userName: '',
|
||
userPhone: '',
|
||
bgHeight: 0
|
||
}
|
||
},
|
||
computed: {
|
||
maskedPhone() {
|
||
const p = this.userPhone
|
||
if (!p || p.length < 7) return p
|
||
return p.slice(0, 3) + '****' + p.slice(-4)
|
||
}
|
||
},
|
||
onLoad() {
|
||
const sys = uni.getSystemInfoSync();
|
||
this.bgHeight = sys.windowHeight
|
||
},
|
||
onShow() {
|
||
this.checkLogin()
|
||
},
|
||
methods: {
|
||
checkLogin() {
|
||
const userId = uni.getStorageSync('userIdSw')
|
||
if (userId) {
|
||
this.isLoggedIn = true
|
||
this.userName = uni.getStorageSync('userNameSw') || ''
|
||
this.userPhone = uni.getStorageSync('userPhoneSw') || ''
|
||
} else {
|
||
this.isLoggedIn = false
|
||
}
|
||
},
|
||
goRegister() {
|
||
uni.navigateTo({ url: '/pages/sw-register/sw-register' })
|
||
},
|
||
goAnswerRecords() {
|
||
uni.navigateTo({ url: '/pages/sw-records/sw-records' })
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
page {
|
||
background-color: #B3E9F3;
|
||
}
|
||
|
||
.content {
|
||
position: relative;
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.page-body {
|
||
position: relative;
|
||
z-index: 1;
|
||
flex: 1;
|
||
padding: 260rpx 30rpx 140rpx;
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.login-box {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
justify-content: center;
|
||
height: 100%;
|
||
}
|
||
|
||
.login-tip {
|
||
font-size: 28rpx;
|
||
color: rgba(255,255,255,0.85);
|
||
margin-bottom: 30rpx;
|
||
}
|
||
|
||
.login-btn {
|
||
width: 400rpx;
|
||
height: 80rpx;
|
||
line-height: 80rpx;
|
||
background: linear-gradient(135deg, #FD5401, #FF7A3D);
|
||
color: #fff;
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
border: none;
|
||
border-radius: 40rpx;
|
||
box-shadow: 0 4rpx 16rpx rgba(253,84,1,0.3);
|
||
}
|
||
|
||
.user-card {
|
||
background: rgba(255,255,255,0.95);
|
||
border-radius: 20rpx;
|
||
padding: 36rpx 30rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
margin-bottom: 24rpx;
|
||
box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
|
||
}
|
||
|
||
.user-avatar {
|
||
width: 80rpx;
|
||
height: 80rpx;
|
||
border-radius: 50%;
|
||
background: linear-gradient(135deg, #FD5401, #FF7A3D);
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
margin-right: 24rpx;
|
||
}
|
||
|
||
.avatar-text {
|
||
font-size: 32rpx;
|
||
font-weight: 700;
|
||
color: #fff;
|
||
}
|
||
|
||
.user-info {
|
||
flex: 1;
|
||
min-width: 0;
|
||
}
|
||
|
||
.user-name {
|
||
font-size: 30rpx;
|
||
font-weight: 600;
|
||
color: #333;
|
||
display: block;
|
||
}
|
||
|
||
.user-phone {
|
||
font-size: 24rpx;
|
||
color: #999;
|
||
margin-top: 6rpx;
|
||
display: block;
|
||
}
|
||
|
||
.menu-list {
|
||
background: rgba(255,255,255,0.95);
|
||
border-radius: 20rpx;
|
||
overflow: hidden;
|
||
box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.06);
|
||
}
|
||
|
||
.menu-item {
|
||
display: flex;
|
||
align-items: center;
|
||
padding: 30rpx 28rpx;
|
||
border-bottom: 1rpx solid #f0f0f0;
|
||
}
|
||
|
||
.menu-item:last-child {
|
||
border-bottom: none;
|
||
}
|
||
|
||
.menu-icon {
|
||
width: 52rpx;
|
||
height: 52rpx;
|
||
border-radius: 50%;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
flex-shrink: 0;
|
||
margin-right: 20rpx;
|
||
font-size: 28rpx;
|
||
}
|
||
|
||
.menu-icon-record {
|
||
background: #f6ffed;
|
||
}
|
||
|
||
.menu-text {
|
||
flex: 1;
|
||
font-size: 28rpx;
|
||
color: #333;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.menu-arrow {
|
||
font-size: 36rpx;
|
||
color: #ccc;
|
||
flex-shrink: 0;
|
||
}
|
||
</style>
|