feat: 优化UI

This commit is contained in:
Blizzard
2026-03-05 17:04:40 +08:00
parent 0a61c4ddec
commit 7f51b2a0a8
28 changed files with 1773 additions and 964 deletions
+53 -21
View File
@@ -13,10 +13,12 @@ Page({
data: {
domain: {},
isSubscribed: false,
isExpired: false, // 订阅是否已过期
expiredAt: '', // 到期时间(格式化)
isFree: false, // 快捷字段,避免模板 domain.isFree
isExpired: false,
expiredAt: '',
isFree: false,
isVipOnly: false,
isVip: false,
canPlay: false,
domainContents: [],
isPlaying: false,
loading: true
@@ -52,7 +54,6 @@ Page({
const ch = res.data
const isFree = ch.isFree === 1
// 免费频道:不关心订阅状态和到期时间
var expiredAt = ''
var isExpired = false
var isSubscribed = false
@@ -64,13 +65,18 @@ Page({
isSubscribed = ch.hasSubscribed === 1 && !isExpired
}
// 可播放:VIP 或免费频道或已订阅
const canPlay = app.globalData.isVip || isFree || isSubscribed
self.setData({
domain: ch,
isSubscribed,
isExpired,
expiredAt,
isFree,
isVipOnly: ch.isVipOnly === 1
isVipOnly: ch.isVipOnly === 1,
isVip: app.globalData.isVip,
canPlay
})
}
}).catch(function (err) {
@@ -92,8 +98,7 @@ Page({
}
var gd = app.globalData
var isSubscribed = self.data.isSubscribed
var isFree = self.data.domain.isFree === 1
var canPlay = self.data.canPlay
var total = contents.length
contents = contents.map(function (item, idx) {
@@ -102,7 +107,7 @@ Page({
_dateDot: item.createdAt ? item.createdAt.substring(0, 10).replace(/-/g, '.') : '',
durationText: util.formatTime(item.duration || 0),
_isThisPlaying: gd.activeContent && gd.activeContent.id === item.id,
_isLocked: !isSubscribed && !isFree && idx > 0
_isLocked: !canPlay // 所有集全部锁定,没有试听
})
})
@@ -133,11 +138,12 @@ Page({
onPlayItem(e) {
const id = e.currentTarget.dataset.id
const idx = parseInt(e.currentTarget.dataset.idx)
const gd = app.globalData
if (!this.data.isSubscribed && !(this.data.domain.isFree === 1) && idx > 0) {
wx.showToast({ title: '请先订阅该频道以解锁往期内容', icon: 'none' })
// 核心权限判断:VIP || 免费频道 || 已订阅
if (!this.data.canPlay) {
// 引导到支付页
this.onSubscribe()
return
}
@@ -161,25 +167,51 @@ Page({
const id = this._domainId
const domain = this.data.domain
// 已订阅 →订阅中,无需操作
if (this.data.isSubscribed) {
wx.showToast({ title: '您已订阅该频道', icon: 'none' })
// 已可播放(VIP / 免费 / 已订阅)——正常情况下不会触发此方法
if (this.data.canPlay) {
wx.showToast({ title: '您已可收听该频道', icon: 'none' })
return
}
// 免费频道 → 直接收听
// VIP专享频道:不支持单独订阅,必须开通 VIP
if (domain.isVipOnly === 1) {
wx.navigateTo({ url: '/pages/vip/index' })
return
}
// 免费频道(理论上不会到这里,安全先)
if (domain.isFree === 1) {
wx.showToast({ title: '免费频道,直接收听!', icon: 'none' })
return
}
// VIP专享且未开通 → VIP
if (domain.isVipOnly === 1 && !app.globalData.isVip) {
wx.navigateTo({ url: '/pages/vip/index' })
return
}
// 付费频道(未订阅 / 已过期)——跳转订阅/支付
var params = 'channelId=' + id
+ '&channelName=' + encodeURIComponent(domain.name || '')
+ '&monthlyPrice=' + (domain.monthlyPrice || 0)
+ '&quarterlyPrice=' + (domain.quarterlyPrice || 0)
+ '&annualPrice=' + (domain.annualPrice || 0)
wx.navigateTo({ url: '/pages/vip/index?' + params })
},
// 付费频道(含已过期续费)→ 跳转订阅/支付页
goFirstProgram() {
var list = this.data.domainContents
if (list && list.length > 0) {
var first = list[0]
if (app.globalData.activeContent && app.globalData.activeContent.id === first.id) {
app.togglePlay()
} else {
app.playContent(first)
}
} else {
wx.showToast({ title: '暂无节目', icon: 'none' })
}
},
/** 续订:直接跳支付页,不走 canPlay 检查 */
onRenew() {
const id = this._domainId
const domain = this.data.domain
var params = 'channelId=' + id
+ '&channelName=' + encodeURIComponent(domain.name || '')
+ '&monthlyPrice=' + (domain.monthlyPrice || 0)