| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- <template>
- <scroll-view class="container" scroll-y>
- <!-- 当前会员状态 -->
- <view class="membership-card">
- <view class="card-header">
- <view class="card-header-left">
- <text class="card-title">我的会员</text>
- <text class="card-subtitle">Membership</text>
- </view>
- <text class="card-level-badge" :class="currentLevel.levelCode === 'FAMILY' ? 'badge-family' : 'badge-free'">
- {{ currentLevel.levelName || '免费用户' }}
- </text>
- </view>
- <view class="card-body" v-if="membership">
- <view class="expiry-info">
- <text class="label">到期时间</text>
- <text class="value">{{ formatDate(membership.endDate) }}</text>
- </view>
- <view class="days-info" v-if="membership.isActive">
- <text class="remaining">{{ membership.daysRemaining }}天</text>
- <text class="tip">剩余天数</text>
- </view>
- <view class="expired-tip" v-else>
- <text class="tip">会员已过期,请续费</text>
- </view>
- </view>
- <view class="card-body" v-else>
- <text class="free-tip">您当前为免费版,升级享受更多服务</text>
- </view>
- <button class="btn-upgrade" @click="goToUpgrade">
- {{ currentLevel.levelCode === 'FAMILY' ? '续费升级' : '立即升级' }}
- </button>
- </view>
- <!-- 会员权益亮点 -->
- <view class="highlights-section">
- <text class="section-title">会员特权</text>
- <view class="highlights-grid">
- <view class="highlight-item" v-for="(item, idx) in highlights" :key="idx">
- <view class="highlight-icon" :style="'background:' + item.bg">
- <text class="highlight-emoji">{{ item.icon }}</text>
- </view>
- <text class="highlight-name">{{ item.name }}</text>
- <text class="highlight-desc">{{ item.desc }}</text>
- </view>
- </view>
- </view>
- <!-- 开通CTA -->
- <view class="cta-section" v-if="!membership || !membership.isActive">
- <text class="cta-title">开通家庭会员,享受全部特权</text>
- <text class="cta-price">¥365/年</text>
- <button class="cta-btn" @click="goToUpgrade">立即开通</button>
- </view>
- <!-- 会员权益 -->
- <view class="benefits-section">
- <text class="section-title">会员等级</text>
- <view class="benefits-grid">
- <view class="benefit-item" v-for="level in levels" :key="level.levelCode">
- <view class="benefit-header">
- <text class="level-name">{{ level.levelName }}</text>
- <text class="level-price" v-if="level.priceMonthly > 0">¥{{ level.priceMonthly }}/月</text>
- <text class="level-price free" v-else>免费</text>
- </view>
- <view class="benefit-features">
- <text class="feature-tag" v-for="(feature, idx) in parseFeatures(level.features)" :key="idx">
- {{ feature }}
- </text>
- </view>
- </view>
- </view>
- </view>
- <!-- 老师咨询授权 -->
- <view class="auth-section">
- <text class="section-title">老师咨询授权</text>
- <view class="auth-item" v-for="auth in authorizations" :key="auth.id">
- <view class="auth-info">
- <text class="teacher-name">{{ auth.teacherName }}</text>
- <text class="auth-status" :class="auth.status">{{ auth.statusText }}</text>
- </view>
- <view class="auth-actions">
- <button class="btn-revoke" v-if="auth.status === 'active'" @click="revokeAuth(auth.id)">撤销</button>
- </view>
- </view>
- <view class="no-auth" v-if="authorizations.length === 0">
- <text class="tip">暂无老师授权</text>
- <text class="desc">联系老师获取授权后,可查看孩子任务执行情况</text>
- </view>
- </view>
- </scroll-view>
- </template>
- <script>
- import { getMembershipLevels, getMyMembership, getAuthorizations } from '../../utils/api.js'
- export default {
- data() {
- return {
- levels: [],
- membership: null,
- currentLevel: {},
- authorizations: [],
- highlights: [
- { icon: '🛒', name: '折扣购物', desc: '商品会员专享价', bg: '#FEF3C7' },
- { icon: '👨👩👧👦', name: '家庭管理', desc: '多成员统一管理', bg: '#DBEAFE' },
- { icon: '💰', name: '推荐佣金', desc: '分享赚取佣金', bg: '#D1FAE5' },
- { icon: '🎪', name: '专属活动', desc: '会员优先参与', bg: '#FCE7F3' }
- ]
- }
- },
- onShow() {
- this.loadData()
- },
- methods: {
- async loadData() {
- try {
- // 获取会员等级
- const levelsRes = await getMembershipLevels()
- this.levels = levelsRes.data || []
-
- // 获取我的会员信息
- const membershipRes = await getMyMembership()
- this.membership = membershipRes.data
-
- // 确定当前等级
- if (this.membership && this.membership.levelCode) {
- this.currentLevel = this.levels.find(function(l) { return l.levelCode === this.membership.levelCode }.bind(this)) || {}
- } else {
- this.currentLevel = this.levels.find(function(l) { return l.levelCode === 'FREE' }) || {}
- }
-
- // 获取授权列表
- const authRes = await getAuthorizations()
- const authData = authRes.data || []
- this.authorizations = authData.map(function(a) {
- return Object.assign({}, a, {
- statusText: a.status === 'active' ? '已授权' : '已撤销'
- })
- })
- } catch (e) {
- console.error('加载数据失败', e)
- }
- },
- formatDate(date) {
- if (!date) return ''
- const d = new Date(date)
- return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0')
- },
- parseFeatures(features) {
- if (!features) return []
- try {
- return JSON.parse(features)
- } catch (e) {
- return []
- }
- },
- goToUpgrade() {
- uni.navigateTo({
- url: '/pages/membership/upgrade'
- })
- },
- revokeAuth(authId) {
- uni.showModal({
- title: '撤销授权',
- content: '确定要撤销该老师的查看权限吗?',
- success: function(res) {
- if (res.confirm) {
- uni.showToast({ title: '已撤销', icon: 'success' })
- this.loadData()
- }
- }.bind(this)
- })
- }
- }
- }
- </script>
- <style scoped>
- .container {
- padding: 30rpx;
- }
- .membership-card {
- background: linear-gradient(135deg, #5B9BD5 0%, #3A7CC4 100%);
- border-radius: 20rpx;
- padding: 40rpx;
- margin-bottom: 30rpx;
- }
- .card-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .card-header-left {
- display: flex;
- flex-direction: column;
- }
- .card-title {
- font-size: 32rpx;
- color: #fff;
- font-weight: bold;
- }
- .card-subtitle {
- font-size: 20rpx;
- color: rgba(255,255,255,0.6);
- margin-top: 4rpx;
- }
- .card-level-badge {
- font-size: 22rpx;
- padding: 8rpx 20rpx;
- border-radius: 9999rpx;
- font-weight: 600;
- }
- .badge-free {
- background: rgba(255,255,255,0.2);
- color: #fff;
- }
- .badge-family {
- background: #FEF3C7;
- color: #D97706;
- }
- .card-body {
- margin-top: 30rpx;
- }
- .expiry-info {
- display: flex;
- justify-content: space-between;
- }
- .expiry-info .label {
- font-size: 26rpx;
- color: rgba(255,255,255,0.8);
- }
- .expiry-info .value {
- font-size: 26rpx;
- color: #fff;
- }
- .days-info {
- text-align: center;
- margin-top: 20rpx;
- }
- .remaining {
- font-size: 48rpx;
- font-weight: bold;
- color: #FFD700;
- }
- .days-info .tip {
- font-size: 24rpx;
- color: rgba(255,255,255,0.7);
- display: block;
- }
- .expired-tip {
- text-align: center;
- margin-top: 20rpx;
- }
- .expired-tip .tip {
- color: #FFD700;
- font-size: 26rpx;
- }
- .free-tip {
- font-size: 26rpx;
- color: rgba(255,255,255,0.8);
- text-align: center;
- }
- .btn-upgrade {
- margin-top: 30rpx;
- background: #FFD700;
- color: #333;
- border-radius: 40rpx;
- font-size: 28rpx;
- }
- .benefits-section {
- background: #fff;
- border-radius: 20rpx;
- padding: 30rpx;
- margin-bottom: 30rpx;
- }
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #333;
- display: block;
- margin-bottom: 20rpx;
- }
- .benefits-grid {
- display: flex;
- flex-direction: column;
- gap: 20rpx;
- }
- .benefit-item {
- border: 1rpx solid #eee;
- border-radius: 10rpx;
- padding: 20rpx;
- }
- .benefit-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .level-name {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- }
- .level-price {
- font-size: 26rpx;
- color: #5B9BD5;
- }
- .level-price.free {
- color: #52C41A;
- }
- .benefit-features {
- display: flex;
- flex-wrap: wrap;
- gap: 10rpx;
- margin-top: 15rpx;
- }
- .feature-tag {
- font-size: 22rpx;
- padding: 6rpx 16rpx;
- background: #f5f5f5;
- border-radius: 20rpx;
- color: #666;
- }
- .auth-section {
- background: #fff;
- border-radius: 20rpx;
- padding: 30rpx;
- }
- .auth-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #f0f0f0;
- }
- .auth-item:last-child {
- border-bottom: none;
- }
- .auth-info {
- flex: 1;
- }
- .teacher-name {
- font-size: 28rpx;
- color: #333;
- display: block;
- }
- .auth-status {
- font-size: 24rpx;
- color: #999;
- margin-top: 8rpx;
- }
- .auth-status.active {
- color: #52C41A;
- }
- .btn-revoke {
- font-size: 24rpx;
- padding: 10rpx 20rpx;
- background: #FF4D4F;
- color: #fff;
- border-radius: 10rpx;
- }
- .no-auth {
- text-align: center;
- padding: 40rpx;
- }
- .no-auth .tip {
- font-size: 28rpx;
- color: #999;
- display: block;
- }
- .no-auth .desc {
- font-size: 24rpx;
- color: #ccc;
- margin-top: 10rpx;
- display: block;
- }
- /* ===== 权益亮点 ===== */
- .highlights-section {
- background: #fff;
- border-radius: 20rpx;
- padding: 30rpx;
- margin-bottom: 30rpx;
- }
- .highlights-grid {
- display: flex;
- flex-wrap: wrap;
- gap: 20rpx;
- }
- .highlight-item {
- width: calc(50% - 10rpx);
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 24rpx 16rpx;
- background: #FFF7ED;
- border-radius: 16rpx;
- box-sizing: border-box;
- }
- .highlight-icon {
- width: 72rpx;
- height: 72rpx;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-bottom: 12rpx;
- }
- .highlight-emoji {
- font-size: 36rpx;
- }
- .highlight-name {
- font-size: 28rpx;
- font-weight: 600;
- color: #1E293B;
- margin-bottom: 4rpx;
- }
- .highlight-desc {
- font-size: 22rpx;
- color: #94A3B8;
- }
- /* ===== CTA开通 ===== */
- .cta-section {
- background: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
- border-radius: 20rpx;
- padding: 40rpx;
- text-align: center;
- margin-bottom: 30rpx;
- }
- .cta-title {
- font-size: 30rpx;
- color: #fff;
- font-weight: 600;
- display: block;
- }
- .cta-price {
- font-size: 44rpx;
- color: #FEF3C7;
- font-weight: bold;
- margin: 16rpx 0 24rpx;
- display: block;
- }
- .cta-btn {
- width: 280rpx;
- height: 72rpx;
- line-height: 72rpx;
- background: #fff;
- color: #F97316;
- font-size: 28rpx;
- font-weight: 600;
- border-radius: 36rpx;
- border: none;
- }
- .cta-btn::after {
- border: none;
- }
- </style>
|