diff --git a/app.js b/app.js
index 38a23fd..8400645 100644
--- a/app.js
+++ b/app.js
@@ -191,8 +191,13 @@ App({
self.globalData.isLoggedIn = true
self.globalData.token = token
self.globalData.userInfo = user
+ self.globalData.isVip = user.isVip === 1
+ self.globalData.vipExpireAt = user.vipExpireAt || null
wx.setStorageSync('token', token)
self.emit('loginStateChange', { isLoggedIn: true })
+ if (user.isVip === 1) {
+ self.emit('vipChange', { isVip: true })
+ }
resolve(res.data)
} else {
reject(new Error(res.msg || '登录失败'))
diff --git a/pages/channel-detail/index.js b/pages/channel-detail/index.js
index f1aaa96..bac8a68 100644
--- a/pages/channel-detail/index.js
+++ b/pages/channel-detail/index.js
@@ -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)
diff --git a/pages/channel-detail/index.wxml b/pages/channel-detail/index.wxml
index ba0af09..2df7e84 100644
--- a/pages/channel-detail/index.wxml
+++ b/pages/channel-detail/index.wxml
@@ -9,10 +9,27 @@
{{domain.name}}
{{domain.tag || domain.description || ''}}
-
+
-
-
+
+
+
+
+ 👑 VIP 会员畅享
+ 🎁 永久免费频道
+
+ 有效至 {{expiredAt || '长期有效'}}
+
+
+ 续订
+
+
+
+
+
+
🎁 永久免费
-
-
-
- 有效至 {{expiredAt}}
-
-
-
+
⏰ 订阅已到期
- 已于 {{expiredAt}} 到期
+ 已于 {{expiredAt}} 到期
-
+