first commit

This commit is contained in:
Blizzard
2026-03-05 09:08:21 +08:00
commit 0a61c4ddec
2189 changed files with 38610 additions and 0 deletions
+99
View File
@@ -0,0 +1,99 @@
/**
* 个人中心 — 用户信息 + 订阅管理 + 菜单
* 从后端获取已订阅频道列表
*/
const app = getApp()
const api = require('../../utils/api')
Page({
data: {
isVip: false,
userInfo: null,
subscribedData: [],
menuItems: [
{ id: 'vip', label: '会员中心', icon: '👑', desc: '未开通', highlight: true },
{ id: 'help', label: '帮助与反馈', icon: '❓', desc: '', highlight: false },
{ id: 'about', label: '关于我们', icon: '📄', desc: 'v1.0.0', highlight: false }
]
},
onShow() {
this._refresh()
this._onSubChange = () => this._refresh()
this._onVipChange = () => this._refresh()
app.on('subscriptionChange', this._onSubChange)
app.on('vipChange', this._onVipChange)
},
onHide() {
if (this._onSubChange) app.off('subscriptionChange', this._onSubChange)
if (this._onVipChange) app.off('vipChange', this._onVipChange)
},
_refresh() {
const self = this
const gd = app.globalData
this.setData({
isVip: gd.isVip,
userInfo: gd.userInfo
})
// 从后端获取已订阅频道
api.getSubscriptionList({ current: 1, pageSize: 50 }).then(function (res) {
if (res.code === 200 && res.data) {
var subList = res.data.list || res.data || []
// 适配封面 URL
subList = subList.map(function (ch) {
return Object.assign({}, ch, {
_coverUrl: (ch.cover && ch.cover.url) || ch.coverUrl || ''
})
})
self.setData({ subscribedData: subList })
}
}).catch(function (err) {
console.error('[Profile] 加载订阅失败:', err)
})
// 更新菜单VIP状态
var menuItems = this.data.menuItems.slice()
menuItems[0].desc = gd.isVip ? '已开通' : '未开通'
menuItems[0].highlight = !gd.isVip
this.setData({ menuItems: menuItems })
},
onUnsubscribe(e) {
const id = e.currentTarget.dataset.id
const name = e.currentTarget.dataset.name
const self = this
wx.showModal({
title: '提示',
content: '确定要取消订阅【' + name + '】吗?',
success(res) {
if (res.confirm) {
app.unsubscribeFromDomain(id).then(function () {
self._refresh()
})
}
}
})
},
onMenuTap(e) {
const id = e.currentTarget.dataset.id
if (id === 'vip') {
wx.navigateTo({ url: '/pages/vip/index' })
} else if (id === 'help') {
wx.showToast({ title: '帮助中心开发中', icon: 'none' })
} else if (id === 'about') {
wx.showToast({ title: '早安电台 v1.0.0', icon: 'none' })
}
},
goDiscover() {
wx.switchTab({ url: '/pages/discover/index' })
}
})
+6
View File
@@ -0,0 +1,6 @@
{
"usingComponents": {
"global-player": "/components/global-player/index"
},
"navigationBarTitleText": "我的"
}
+85
View File
@@ -0,0 +1,85 @@
<!-- 个人中心 —— 用户信息 + 订阅管理 + 菜单 -->
<view class="profile-page">
<!-- 橙色头部背景 -->
<view class="header-bg">
<view class="user-info">
<!-- 头像 -->
<view class="avatar-wrap">
<image wx:if="{{userInfo && userInfo.avatarId}}" src="{{userInfo.avatar.url || ''}}" class="avatar-img" mode="aspectFill" />
<text wx:else class="avatar-emoji">😊</text>
</view>
<text class="user-name">
{{userInfo.nickName || userInfo.name || '微信用户'}}
<text wx:if="{{isVip}}" class="vip-crown">👑</text>
</text>
<text class="user-desc">
{{isVip ? '全频道会员' : '免费用户 · 开通会员畅听全频道'}}
</text>
</view>
</view>
<!-- 订阅管理卡片(上移覆盖) -->
<view class="sub-card-wrap">
<view class="card sub-card">
<!-- 空状态 -->
<view wx:if="{{subscribedData.length === 0}}" class="sub-empty">
<text class="sub-empty-text">暂未订阅任何频道</text>
<button class="btn-ghost" bindtap="goDiscover">去广场添加</button>
</view>
<!-- 订阅列表 -->
<view wx:else>
<view
wx:for="{{subscribedData}}"
wx:key="id"
class="sub-item"
>
<view class="sub-item-left">
<view class="sub-icon" style="background: {{item.bgColor || '#F0F0F0'}};">
<image wx:if="{{item._coverUrl}}" src="{{item._coverUrl}}" class="sub-cover-img" mode="aspectFill" />
<text wx:else class="sub-emoji">{{item.icon || '📻'}}</text>
</view>
<view class="sub-info">
<text class="sub-name">{{item.name}}</text>
<text class="sub-tag {{item.isFree === 1 ? 'free' : ''}}">
{{item.isFree === 1 ? '免费' : '已订阅'}}
</text>
</view>
</view>
<view class="sub-del tap-active" bindtap="onUnsubscribe" data-id="{{item.id}}" data-name="{{item.name}}">
<text class="del-icon">🗑</text>
</view>
</view>
</view>
</view>
</view>
<!-- 菜单列表 -->
<view class="menu-card-wrap">
<view class="card menu-card">
<view
wx:for="{{menuItems}}"
wx:key="id"
class="menu-item tap-active"
bindtap="onMenuTap"
data-id="{{item.id}}"
>
<view class="menu-item-left">
<view class="menu-icon-wrap {{item.highlight ? 'highlight' : ''}}">
<text class="menu-emoji">{{item.icon}}</text>
</view>
<text class="menu-label">{{item.label}}</text>
</view>
<view class="menu-item-right">
<text class="menu-desc {{item.highlight ? 'highlight' : ''}}">{{item.desc}}</text>
<text class="menu-arrow"></text>
</view>
</view>
</view>
</view>
<view style="height: 200rpx;"></view>
<global-player />
</view>
+223
View File
@@ -0,0 +1,223 @@
/* 个人中心样式 */
.profile-page {
min-height: 100vh;
background: var(--color-bg-page);
}
/* 橙色头部 */
.header-bg {
background: #F38600;
border-radius: 0 0 48rpx 48rpx;
padding-bottom: 200rpx;
}
.user-info {
display: flex;
flex-direction: column;
align-items: center;
padding: 32rpx 40rpx;
}
.avatar-wrap {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
border: 6rpx solid rgba(255, 255, 255, 0.3);
background: linear-gradient(135deg, #FFB366, #FFE0B2);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20rpx;
overflow: hidden;
}
.avatar-emoji {
font-size: 64rpx;
}
.avatar-img {
width: 100%;
height: 100%;
border-radius: 50%;
}
.user-name {
font-size: 32rpx;
font-weight: 700;
color: #FFF;
letter-spacing: 2rpx;
}
.vip-crown {
font-size: 28rpx;
margin-left: 8rpx;
}
.user-desc {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.9);
margin-top: 8rpx;
font-weight: 500;
text-align: center;
}
/* 订阅卡片 */
.sub-card-wrap {
padding: 0 32rpx;
margin-top: -140rpx;
position: relative;
z-index: 10;
}
.sub-card {
padding: 32rpx;
}
/* 空状态 */
.sub-empty {
text-align: center;
padding: 40rpx 0;
}
.sub-empty-text {
display: block;
font-size: 26rpx;
color: #999;
margin-bottom: 24rpx;
}
/* 订阅列表项 */
.sub-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20rpx;
border-radius: 32rpx;
background: #FEFEFE;
border: 1rpx solid rgba(0,0,0,0.04);
box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.02);
margin-bottom: 16rpx;
}
.sub-item-left {
display: flex;
align-items: center;
flex: 1;
overflow: hidden;
}
.sub-icon {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.1);
}
.sub-emoji {
font-size: 36rpx;
}
.sub-cover-img {
width: 100%;
height: 100%;
border-radius: 50%;
}
.sub-info {
margin-left: 24rpx;
overflow: hidden;
}
.sub-name {
display: block;
font-size: 28rpx;
font-weight: 700;
color: #333;
}
.sub-tag {
display: inline-block;
margin-top: 8rpx;
padding: 4rpx 12rpx;
border-radius: 6rpx;
font-size: 20rpx;
font-weight: 700;
}
.sub-tag.free {
background: rgba(45, 90, 39, 0.1);
color: #2D5A27;
}
.sub-del {
width: 56rpx;
height: 56rpx;
border-radius: 50%;
background: #F5F5F5;
border: 1rpx solid #EEE;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.del-icon {
font-size: 24rpx;
}
.sub-notice {
display: block;
font-size: 20rpx;
color: rgba(255, 157, 66, 0.7);
text-align: center;
margin-top: 12rpx;
font-weight: 500;
}
/* 菜单卡片 */
.menu-card-wrap {
padding: 24rpx 32rpx 0;
}
.menu-card {
padding: 8rpx 0;
}
.menu-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28rpx 32rpx;
border-bottom: 1rpx solid rgba(0,0,0,0.03);
}
.menu-item:last-child {
border-bottom: none;
}
.menu-item-left {
display: flex;
align-items: center;
}
.menu-icon-wrap {
width: 52rpx;
height: 52rpx;
border-radius: 50%;
background: #F5F5F5;
display: flex;
align-items: center;
justify-content: center;
margin-right: 20rpx;
}
.menu-icon-wrap.highlight {
background: rgba(251, 191, 36, 0.1);
}
.menu-emoji {
font-size: 24rpx;
}
.menu-label {
font-size: 28rpx;
font-weight: 700;
color: #333;
letter-spacing: 2rpx;
}
.menu-item-right {
display: flex;
align-items: center;
gap: 12rpx;
}
.menu-desc {
font-size: 22rpx;
color: #999;
font-weight: 500;
}
.menu-desc.highlight {
color: #D97706;
}
.menu-arrow {
font-size: 28rpx;
color: #CCC;
}