Files
llpreheat/pages/hj-profile/hj-profile.vue
T

239 lines
4.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<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/xfhj_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="goMyPrizes">
<view class="menu-icon menu-icon-prize">
<text>🎁</text>
</view>
<text class="menu-text">我的奖品</text>
<text class="menu-arrow">›</text>
</view>
<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>
<hj-tabbar current="profile"></hj-tabbar>
</view>
</template>
<script>
import hjTabbar from '@/components/hj-tabbar/hj-tabbar.vue'
export default {
components: {
hjTabbar
},
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('userIdHj')
if (userId) {
this.isLoggedIn = true
this.userName = uni.getStorageSync('userNameHj') || ''
this.userPhone = uni.getStorageSync('userPhoneHj') || ''
} else {
this.isLoggedIn = false
}
},
goRegister() {
uni.navigateTo({ url: '/pages/hj-register/hj-register' })
},
goMyPrizes() {
const phone = uni.getStorageSync('userPhoneHj') || ''
window.location.href = 'https://goldnar.hntgov.net/cardholder/index.html#/?phone=' + phone
},
goAnswerRecords() {
uni.navigateTo({ url: '/pages/hj-records/hj-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: 350rpx 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-prize {
background: #fff7e6;
}
.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>