| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- <template>
- <view class="container">
- <!-- 当前会员状态 -->
- <view class="membership-card">
- <view class="card-header">
- <text class="card-title">我的会员</text>
- <text class="card-status" :class="currentLevel.levelCode">{{ 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">立即升级</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>
- </view>
- </template>
- <script>
- import { getMembershipLevels, getMyMembership, getAuthorizations } from '../../utils/api.js'
- export default {
- data() {
- return {
- levels: [],
- membership: null,
- currentLevel: {},
- authorizations: []
- }
- },
- 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(l => l.levelCode === this.membership.levelCode) || {}
- } else {
- this.currentLevel = this.levels.find(l => l.levelCode === 'FREE') || {}
- }
-
- // 获取授权列表
- const authRes = await getAuthorizations()
- this.authorizations = (authRes.data || []).map(a => ({
- ...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 {
- return []
- }
- },
- goToUpgrade() {
- uni.navigateTo({
- url: '/pages/membership/upgrade'
- })
- },
- revokeAuth(authId) {
- uni.showModal({
- title: '撤销授权',
- content: '确定要撤销该老师的查看权限吗?',
- success: (res) => {
- if (res.confirm) {
- // TODO: 调用撤销API
- uni.showToast({ title: '已撤销', icon: 'success' })
- this.loadData()
- }
- }
- })
- }
- }
- }
- </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-title {
- font-size: 32rpx;
- color: #fff;
- font-weight: bold;
- }
- .card-status {
- font-size: 24rpx;
- padding: 8rpx 20rpx;
- border-radius: 20rpx;
- background: rgba(255,255,255,0.2);
- color: #fff;
- }
- .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;
- }
- </style>
|