| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- <template>
- <view class="page-container">
- <!-- 顶部背景 -->
- <view class="top-bg">
- <view class="status_bar" :style="{ height: statusBarHeight }"></view>
- <view class="top-title">个人中心</view>
- </view>
- <!-- 用户卡片 -->
- <view class="user-card">
- <view class="user-info" @click="navgetTo('/pages_user/user/personInfo')">
- <image class="avatar" :src="user.avatarUrl ? user.avatarUrl : '/static/avatar.png'" mode="aspectFill"></image>
- <view class="info-content">
- <view class="name-row">
- <text class="nickname">{{ user.nickname || '立即登录' }}</text>
- <image class="arrow-right" src="/static/right_arrow_right.png" mode="aspectFit"></image>
- </view>
- <view class="welcome-text">Hi,欢迎来到小程序</view>
- </view>
- </view>
- </view>
- <!-- 菜单列表 -->
- <view class="menu-list">
- <view class="menu-item" @click="navgetTo('/pages_user/user/storeOrder')">
- <view class="left">
- <image class="icon" src="/static/manageTabIcon/training.png" mode="aspectFit"></image>
- <text class="label">我的课程</text>
- </view>
- <image class="arrow" src="/static/right_arrow_right.png" mode="aspectFit"></image>
- </view>
- <view class="menu-item" @click="navgetTo('/pages_user/user/message')">
- <view class="left">
- <image class="icon" src="/static/manageTabIcon/liveclasses.png" mode="aspectFit"></image>
- <text class="label">我的消息</text>
- </view>
- <image class="arrow" src="/static/right_arrow_right.png" mode="aspectFit"></image>
- </view>
- </view>
- <view class="menu-list mt24">
- <view class="menu-item" @click="makePhoneCall">
- <view class="left">
- <image class="icon" src="/static/service_center.png" mode="aspectFit"></image>
- <text class="label">客服中心</text>
- </view>
- <view class="right">
- <text class="phone-num">400-023-8558</text>
- <image class="arrow" src="/static/right_arrow_right.png" mode="aspectFit"></image>
- </view>
- </view>
- <view class="menu-item" @click="navgetTo('/pages_user/user/personInfo')">
- <view class="left">
- <image class="icon" src="/static/set_icon.png" mode="aspectFit"></image>
- <text class="label">设置</text>
- </view>
- <image class="arrow" src="/static/right_arrow_right.png" mode="aspectFit"></image>
- </view>
- </view>
- <!-- 退出登录 -->
- <view class="logout-btn" v-if="UserInfo" @tap="loginOUt">
- 退出登录
- </view>
- </view>
- </template>
- <script>
- import {
- getUserInfo
- } from '@/api/user'
- export default {
- data() {
- return {
- user: {
- nickname: "",
- avatarUrl: "/static/avatar.png"
- },
- statusBarHeight: uni.getStorageSync('menuInfo') ? uni.getStorageSync('menuInfo').statusBarHeight : 20,
- UserInfo: uni.getStorageSync('AppToken')
- };
- },
- onShow() {
- this.UserInfo = uni.getStorageSync('AppToken')
- if (this.UserInfo) {
- this.getUserInfo()
- }
- },
- methods: {
- getUserInfo() {
- getUserInfo().then(
- res => {
- if (res.code == 200 && res.user != null) {
- this.user = res.user;
- }
- }
- );
- },
- navgetTo(url) {
- this.utils.isLogin().then(res => {
- if (res) {
- uni.navigateTo({
- url: url
- })
- }
- })
- },
- makePhoneCall() {
- uni.makePhoneCall({
- phoneNumber: '400-023-8558'
- });
- },
- loginOUt() {
- this.utils.loginOut();
- this.UserInfo = "";
- this.user = {
- nickname: "",
- avatarUrl: "/static/avatar.png"
- };
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .page-container {
- width: 100%;
- min-height: 100vh;
- background-color: #F8F9FB;
- padding-bottom: 120rpx;
- }
- .top-bg {
- width: 100%;
- height: 380rpx;
- background: linear-gradient(180deg, #5C4BFF 0%, #7E71FF 100%);
- display: flex;
- flex-direction: column;
- .status_bar {
- width: 100%;
- }
- .top-title {
- height: 88rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 36rpx;
- font-weight: bold;
- color: #FFFFFF;
- }
- }
- .user-card {
- margin: -160rpx 30rpx 0;
- background: #FFFFFF;
- border-radius: 24rpx;
- padding: 40rpx;
- box-shadow: 0 4rpx 20rpx rgba(92, 75, 255, 0.1);
- .user-info {
- display: flex;
- align-items: center;
- .avatar {
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- margin-right: 30rpx;
- background-color: #f5f5f5;
- }
- .info-content {
- flex: 1;
- .name-row {
- display: flex;
- align-items: center;
- margin-bottom: 12rpx;
- .nickname {
- font-size: 40rpx;
- font-weight: bold;
- color: #1A1A1A;
- margin-right: 12rpx;
- }
- .arrow-right {
- width: 24rpx;
- height: 24rpx;
- }
- }
- .welcome-text {
- font-size: 26rpx;
- color: #999999;
- }
- }
- }
- }
- .menu-list {
- margin: 30rpx 30rpx 0;
- background: #FFFFFF;
- border-radius: 24rpx;
- padding: 0 30rpx;
- .menu-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 110rpx;
- border-bottom: 1rpx solid #F5F6F8;
- &:last-child {
- border-bottom: none;
- }
- .left {
- display: flex;
- align-items: center;
- .icon {
- width: 44rpx;
- height: 44rpx;
- margin-right: 20rpx;
- }
- .label {
- font-size: 30rpx;
- color: #1A1A1A;
- font-weight: 500;
- }
- }
- .right {
- display: flex;
- align-items: center;
- .phone-num {
- font-size: 28rpx;
- color: #666666;
- margin-right: 12rpx;
- }
- }
- .arrow {
- width: 24rpx;
- height: 24rpx;
- }
- }
- }
- .mt24 {
- margin-top: 24rpx;
- }
- .logout-btn {
- margin: 40rpx 30rpx;
- height: 100rpx;
- background: #FFFFFF;
- border-radius: 24rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 32rpx;
- font-weight: bold;
- color: #5C4BFF;
- }
- </style>
|