feat: 样式调整
This commit is contained in:
+65
-2
@@ -148,10 +148,13 @@ Page({
|
||||
|
||||
const list = res.data.list || []
|
||||
const freeChannels = list.map(function (ch) {
|
||||
var cover = ch.cover || '📻'
|
||||
return {
|
||||
id: ch.id,
|
||||
name: ch.name || '未命名',
|
||||
cover: ch.cover || '📻',
|
||||
cover: cover,
|
||||
_isDefaultCover: cover === '📻',
|
||||
_initial: (ch.name || '频').substring(0, 1),
|
||||
bgColor: self._genColor(ch.id),
|
||||
isFree: ch.isFree,
|
||||
isVipOnly: ch.isVipOnly
|
||||
@@ -172,8 +175,8 @@ Page({
|
||||
_mapChannel(channel, gd) {
|
||||
const programs = channel.programs || []
|
||||
const latest = programs.length > 0 ? programs[0] : null
|
||||
// cover 直接是 emoji 字符串
|
||||
const cover = channel.cover || '📻'
|
||||
const isDefaultCover = cover === '📻'
|
||||
const todayContent = latest ? Object.assign({}, latest, {
|
||||
durationText: util.formatTime(latest.duration || 0)
|
||||
}) : null
|
||||
@@ -188,6 +191,8 @@ Page({
|
||||
isFree: channel.isFree,
|
||||
isVipOnly: channel.isVipOnly,
|
||||
cover: cover,
|
||||
_isDefaultCover: isDefaultCover,
|
||||
_initial: (channel.name || '频').substring(0, 1),
|
||||
bgColor: this._genColor(channel.id),
|
||||
_todayContent: todayContent,
|
||||
_isThisPlaying: isThisPlaying
|
||||
@@ -292,4 +297,62 @@ Page({
|
||||
|
||||
// ===================== 工具方法 =====================
|
||||
// _computeGreeting 已提至模块级,可在 data 初始化时直接调用
|
||||
|
||||
// ===================== 左滑操作 =====================
|
||||
|
||||
onSwipeStart(e) {
|
||||
this._touchStartX = e.touches[0].clientX
|
||||
this._touchStartY = e.touches[0].clientY
|
||||
this._swiping = false
|
||||
},
|
||||
|
||||
onSwipeMove(e) {
|
||||
var dx = e.touches[0].clientX - this._touchStartX
|
||||
var dy = e.touches[0].clientY - this._touchStartY
|
||||
// 水平滑动距离大于垂直才算滑动
|
||||
if (Math.abs(dx) < Math.abs(dy)) return
|
||||
this._swiping = true
|
||||
var idx = e.currentTarget.dataset.idx
|
||||
var x = Math.max(-180, Math.min(0, dx))
|
||||
var key = 'subscribedData[' + idx + ']._swipeX'
|
||||
this.setData({ [key]: x })
|
||||
},
|
||||
|
||||
onSwipeEnd(e) {
|
||||
if (!this._swiping) return
|
||||
var idx = e.currentTarget.dataset.idx
|
||||
var cur = this.data.subscribedData[idx]._swipeX || 0
|
||||
var key = 'subscribedData[' + idx + ']._swipeX'
|
||||
// 超过 90rpx 则展开操作区,否则回弹
|
||||
this.setData({ [key]: cur < -90 ? -180 : 0 })
|
||||
},
|
||||
|
||||
onUnsubscribe(e) {
|
||||
var id = e.currentTarget.dataset.id
|
||||
var name = e.currentTarget.dataset.name || ''
|
||||
wx.showModal({
|
||||
title: '取消订阅',
|
||||
content: '确定取消订阅「' + name + '」频道吗?',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
app.unsubscribeFromDomain(id)
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// ===================== 分享钩子 =====================
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '全声汇 - 听见世界的声音',
|
||||
path: '/pages/index/index'
|
||||
}
|
||||
},
|
||||
|
||||
onShareTimeline() {
|
||||
return {
|
||||
title: '全声汇 - 听见世界的声音',
|
||||
query: ''
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user