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
+25 -12
View File
@@ -10,6 +10,7 @@ const api = require('../../utils/api')
Page({
data: {
isVip: false,
vipPriceText: '',
categories: [],
activeFilter: '',
filteredDomains: [],
@@ -22,6 +23,7 @@ Page({
onShow() {
this._loadChannels()
this._loadVipPrice()
this._onSubChange = () => this._loadChannels()
this._onVipChange = () => this._loadChannels()
app.on('subscriptionChange', this._onSubChange)
@@ -69,6 +71,9 @@ Page({
var filtered = channels.map(function (ch) {
var isFree = ch.isFree === 1
var isVipOnly = ch.isVipOnly === 1
var isSubscribed = ch.hasSubscribed === 1
// VIP 用户可播放所有频道
var canPlay = gd.isVip || isFree || isSubscribed
// 最低价(分→元)
var lowestPrice = null
if (!isFree && !isVipOnly) {
@@ -83,10 +88,11 @@ Page({
}
}
return Object.assign({}, ch, {
_isSubscribed: ch.hasSubscribed === 1,
_isSubscribed: isSubscribed,
_isFree: isFree,
_isVipOnly: isVipOnly,
_lowestPrice: lowestPrice
_lowestPrice: lowestPrice,
_canPlay: canPlay
})
})
@@ -102,6 +108,19 @@ Page({
})
},
_loadVipPrice() {
var self = this
api.getVipConfig().then(function (res) {
if (res.code === 200 && res.data) {
var cfg = res.data
var p = cfg.discountedPrice > 0 ? cfg.discountedPrice : cfg.price
self.setData({ vipPriceText: (p / 100).toFixed(2) + '元' })
}
}).catch(function () {
self.setData({ vipPriceText: '' })
})
},
/**
* 切换分类筛选
*/
@@ -129,25 +148,19 @@ Page({
}
if (!channel) return
// 已订阅 → 直接进详情
if (channel._isSubscribed) {
// 规则1canPlayVIP || isFree || hasSubscribed)→ 进频道详情
if (channel._canPlay) {
wx.navigateTo({ url: '/pages/channel-detail/index?id=' + id })
return
}
// 免费 → 直接进详情收听
if (channel._isFree) {
wx.navigateTo({ url: '/pages/channel-detail/index?id=' + id })
return
}
// VIP专享 → 引导 VIP 页
// 规则2:VIP专享 → 只能开通VIP,不可订阅
if (channel._isVipOnly) {
wx.navigateTo({ url: '/pages/vip/index' })
return
}
// 付费订阅 → 跳转 VIP/订阅页(channel 模式)
// 付费频道未订阅 → 跳转订阅页
var params = 'channelId=' + id
+ '&channelName=' + encodeURIComponent(channel.name || '')
+ '&monthlyPrice=' + (channel.monthlyPrice || 0)