| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461 |
- <template>
- <scroll-view class="page" scroll-y>
- <!-- 当前会员状态卡片 -->
- <view class="status-card">
- <view class="status-badge" :class="isFree ? 'badge-free' : 'badge-family'">
- <text class="badge-icon">{{ isFree ? '○' : '●' }}</text>
- <text class="badge-text">{{ currentLevelName }}</text>
- </view>
- <view class="status-body" v-if="membership && membership.levelCode !== 'FREE'">
- <view class="expiry-row">
- <text class="expiry-label">到期时间</text>
- <text class="expiry-value">{{ formatDate(membership.endDate) }}</text>
- </view>
- <view class="days-remaining" v-if="membership.isActive">
- <text class="days-num">{{ membership.daysRemaining || 0 }}</text>
- <text class="days-unit">天剩余</text>
- </view>
- <view class="expired-msg" v-else>
- <text class="expired-text">会员已过期,续费恢复权益</text>
- </view>
- </view>
- <view class="status-body" v-else>
- <text class="free-hint">当前为免费版,开通家庭会员解锁全部特权</text>
- </view>
- </view>
- <!-- 家庭会员开通卡片 -->
- <view class="upgrade-card" v-if="isFree">
- <view class="upgrade-header">
- <text class="upgrade-title">家庭会员</text>
- <text class="upgrade-subtitle">FAMILY</text>
- </view>
- <view class="upgrade-price">
- <text class="price-symbol">¥</text>
- <text class="price-amount">365</text>
- <text class="price-unit">/年</text>
- </view>
- <view class="feature-list">
- <view class="feature-item" v-for="(feature, idx) in features" :key="idx">
- <text class="feature-check">✓</text>
- <text class="feature-text">{{ feature }}</text>
- </view>
- </view>
- <button class="btn-upgrade" @click="handleUpgrade">立即开通</button>
- </view>
- <!-- 续费卡片 -->
- <view class="upgrade-card" v-else>
- <view class="upgrade-header">
- <text class="upgrade-title">续费会员</text>
- <text class="upgrade-subtitle">保持权益不中断</text>
- </view>
- <view class="upgrade-price">
- <text class="price-symbol">¥</text>
- <text class="price-amount">365</text>
- <text class="price-unit">/年</text>
- </view>
- <button class="btn-upgrade btn-renew" @click="handleRenew">立即续费</button>
- </view>
- <!-- 权益对比表 -->
- <view class="compare-section">
- <text class="section-title">权益对比</text>
- <view class="compare-table">
- <view class="compare-row header-row">
- <text class="compare-cell cell-feature">权益项</text>
- <text class="compare-cell cell-free">免费</text>
- <text class="compare-cell cell-family active">家庭会员</text>
- </view>
- <view class="compare-row" v-for="(item, idx) in compareData" :key="idx">
- <text class="compare-cell cell-feature">{{ item.name }}</text>
- <text class="compare-cell cell-free">{{ item.free }}</text>
- <text class="compare-cell cell-family active">{{ item.family }}</text>
- </view>
- </view>
- </view>
- <!-- 升级记录 -->
- <view class="records-section" v-if="records.length > 0">
- <text class="section-title">升级记录</text>
- <view class="record-item" v-for="record in records" :key="record.id">
- <view class="record-left">
- <text class="record-level">{{ record.levelName }}</text>
- <text class="record-time">{{ formatDate(record.createdAt) }}</text>
- </view>
- <text class="record-amount">¥{{ record.amount || '0.00' }}</text>
- </view>
- </view>
- </scroll-view>
- </template>
- <script>
- import { getMyMembership, getMembershipLevels, getUpgradeRecords, upgradeMember, createOrder } from '../../utils/api.js'
- export default {
- data() {
- return {
- membership: null,
- levels: [],
- records: [],
- features: ['折扣购物', '家庭管理', '推荐佣金', '专属活动', '任务特权', '成长报告'],
- isFree: true,
- currentLevelName: '免费用户',
- compareData: [
- { name: '商品折扣', free: '普通价格', family: '会员专享价' },
- { name: '家庭管理', free: '基础功能', family: '全部功能' },
- { name: '推荐佣金', free: '不可参与', family: '最高15%' },
- { name: '专属活动', free: '部分参与', family: '全部参与' },
- { name: '成长报告', free: '月度', family: '每周+深度' },
- { name: '任务配额', free: '每日5个', family: '不限量' }
- ]
- }
- },
- onLoad() {
- this.loadData()
- },
- methods: {
- async loadData() {
- try {
- const membershipRes = await getMyMembership()
- this.membership = membershipRes.data
- if (this.membership && this.membership.levelCode && this.membership.levelCode !== 'FREE') {
- this.isFree = false
- this.currentLevelName = this.membership.levelName || '家庭会员'
- } else {
- this.isFree = true
- this.currentLevelName = '免费用户'
- }
- } catch (e) {
- console.error('加载会员信息失败', e)
- }
- try {
- const levelsRes = await getMembershipLevels()
- this.levels = levelsRes.data || []
- } catch (e) {
- console.error('加载会员等级失败', e)
- }
- try {
- const recordsRes = await getUpgradeRecords()
- if (recordsRes.data && recordsRes.data.records) {
- this.records = recordsRes.data.records
- }
- } catch (e) {
- console.error('加载升级记录失败', e)
- }
- },
- handleUpgrade() {
- uni.showModal({
- title: '确认开通',
- content: '确认开通家庭会员(¥365/年)?',
- success: async (res) => {
- if (!res.confirm) return
- try {
- await upgradeMember('FAMILY')
- uni.showToast({ title: '开通成功', icon: 'success' })
- this.loadData()
- } catch (e) {
- uni.showToast({ title: e.message || '开通失败', icon: 'none' })
- }
- }
- })
- },
- handleRenew() {
- uni.showModal({
- title: '确认续费',
- content: '确认续费家庭会员(¥365/年)?',
- success: async (res) => {
- if (!res.confirm) return
- try {
- await upgradeMember('FAMILY')
- uni.showToast({ title: '续费成功', icon: 'success' })
- this.loadData()
- } catch (e) {
- uni.showToast({ title: e.message || '续费失败', icon: 'none' })
- }
- }
- })
- },
- formatDate(date) {
- if (!date) return ''
- var d = new Date(date)
- return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0')
- }
- }
- }
- </script>
- <style scoped>
- .page {
- min-height: 100vh;
- background: #FFF7ED;
- padding: 30rpx;
- box-sizing: border-box;
- }
- /* ===== 状态卡片 ===== */
- .status-card {
- background: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
- border-radius: 20rpx;
- padding: 40rpx;
- margin-bottom: 30rpx;
- }
- .status-badge {
- display: inline-flex;
- align-items: center;
- padding: 10rpx 24rpx;
- border-radius: 9999rpx;
- font-size: 24rpx;
- }
- .badge-free {
- background: rgba(255,255,255,0.2);
- color: #fff;
- }
- .badge-family {
- background: rgba(255,255,255,0.3);
- color: #fff;
- }
- .badge-icon {
- font-size: 20rpx;
- margin-right: 8rpx;
- }
- .badge-text {
- font-weight: 600;
- }
- .status-body {
- margin-top: 24rpx;
- }
- .expiry-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .expiry-label {
- font-size: 26rpx;
- color: rgba(255,255,255,0.8);
- }
- .expiry-value {
- font-size: 28rpx;
- color: #fff;
- font-weight: 500;
- }
- .days-remaining {
- display: flex;
- align-items: baseline;
- justify-content: center;
- margin-top: 20rpx;
- }
- .days-num {
- font-size: 56rpx;
- font-weight: bold;
- color: #FEF3C7;
- }
- .days-unit {
- font-size: 26rpx;
- color: rgba(255,255,255,0.7);
- margin-left: 8rpx;
- }
- .expired-msg {
- text-align: center;
- margin-top: 16rpx;
- }
- .expired-text {
- font-size: 26rpx;
- color: #FEF3C7;
- }
- .free-hint {
- font-size: 26rpx;
- color: rgba(255,255,255,0.85);
- text-align: center;
- display: block;
- }
- /* ===== 升级/续费卡片 ===== */
- .upgrade-card {
- background: #FFFFFF;
- border-radius: 20rpx;
- padding: 40rpx;
- margin-bottom: 30rpx;
- box-shadow: 0 4rpx 24rpx rgba(249, 115, 22, 0.08);
- }
- .upgrade-header {
- text-align: center;
- margin-bottom: 20rpx;
- }
- .upgrade-title {
- font-size: 36rpx;
- font-weight: bold;
- color: #1E293B;
- display: block;
- }
- .upgrade-subtitle {
- font-size: 24rpx;
- color: #94A3B8;
- margin-top: 6rpx;
- display: block;
- }
- .upgrade-price {
- text-align: center;
- margin: 24rpx 0;
- }
- .price-symbol {
- font-size: 28rpx;
- color: #F97316;
- vertical-align: top;
- }
- .price-amount {
- font-size: 64rpx;
- font-weight: bold;
- color: #F97316;
- line-height: 1;
- }
- .price-unit {
- font-size: 26rpx;
- color: #94A3B8;
- margin-left: 6rpx;
- }
- .feature-list {
- margin: 24rpx 0;
- }
- .feature-item {
- display: flex;
- align-items: center;
- padding: 12rpx 0;
- }
- .feature-check {
- width: 40rpx;
- height: 40rpx;
- line-height: 40rpx;
- text-align: center;
- background: #F97316;
- color: #fff;
- border-radius: 50%;
- font-size: 22rpx;
- margin-right: 16rpx;
- flex-shrink: 0;
- }
- .feature-text {
- font-size: 28rpx;
- color: #1E293B;
- }
- .btn-upgrade {
- width: 100%;
- height: 88rpx;
- line-height: 88rpx;
- background: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
- color: #fff;
- font-size: 32rpx;
- font-weight: 600;
- border-radius: 44rpx;
- margin-top: 20rpx;
- border: none;
- }
- .btn-upgrade::after {
- border: none;
- }
- .btn-upgrade:active {
- opacity: 0.9;
- }
- .btn-renew {
- background: linear-gradient(135deg, #0EA5E9 0%, #0284C7 100%);
- }
- /* ===== 权益对比 ===== */
- .compare-section {
- background: #FFFFFF;
- border-radius: 20rpx;
- padding: 30rpx;
- margin-bottom: 30rpx;
- box-shadow: 0 4rpx 24rpx rgba(249, 115, 22, 0.08);
- }
- .section-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #1E293B;
- display: block;
- margin-bottom: 24rpx;
- }
- .compare-table {
- border-radius: 16rpx;
- overflow: hidden;
- border: 1rpx solid #FED7AA;
- }
- .compare-row {
- display: flex;
- border-bottom: 1rpx solid #FED7AA;
- }
- .compare-row:last-child {
- border-bottom: none;
- }
- .header-row {
- background: #FFF7ED;
- }
- .compare-cell {
- flex: 1;
- padding: 20rpx 16rpx;
- font-size: 26rpx;
- text-align: center;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .cell-feature {
- flex: 1.5;
- color: #1E293B;
- font-weight: 500;
- justify-content: flex-start;
- }
- .cell-free {
- color: #94A3B8;
- }
- .cell-family.active {
- color: #F97316;
- font-weight: 600;
- }
- .header-row .compare-cell {
- font-size: 24rpx;
- font-weight: 600;
- color: #64748B;
- }
- .header-row .cell-family.active {
- color: #F97316;
- }
- /* ===== 升级记录 ===== */
- .records-section {
- background: #FFFFFF;
- border-radius: 20rpx;
- padding: 30rpx;
- margin-bottom: 30rpx;
- box-shadow: 0 4rpx 24rpx rgba(249, 115, 22, 0.08);
- }
- .record-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx 0;
- border-bottom: 1rpx solid #FED7AA;
- }
- .record-item:last-child {
- border-bottom: none;
- }
- .record-left {
- flex: 1;
- }
- .record-level {
- font-size: 28rpx;
- color: #1E293B;
- display: block;
- }
- .record-time {
- font-size: 22rpx;
- color: #94A3B8;
- margin-top: 4rpx;
- display: block;
- }
- .record-amount {
- font-size: 30rpx;
- font-weight: bold;
- color: #F97316;
- }
- </style>
|