74 lines
2.4 KiB
Dart
74 lines
2.4 KiB
Dart
import '../../hj_model/video_model.dart';
|
||
|
||
/// 付费引导弹窗配置(场景 VIP_CONTENT_UPDATE:VIP 内容上新顶部推送横幅)
|
||
/// 只解析前端用得到的字段;title/segment/style/cover/durationSeconds/videoIds 暂未使用
|
||
class GuidePushModel {
|
||
bool? show; // false = 本次不展示(已展示过 / 无可用配置 / 无符合条件内容)
|
||
String? configId;
|
||
String? contentVersion; // 内容版本,上报回执时原样带回;也是本地去重的依据
|
||
String? description; // 横幅标题文案
|
||
String? productId;
|
||
GuidePushAction? action; // 按钮跳转配置
|
||
List<GuidePushVideo> videos = []; // 最新 VIP 内容,最多 4 条
|
||
|
||
GuidePushModel.fromJson(Map<String, dynamic>? json) {
|
||
json ??= {};
|
||
show = json['show'];
|
||
configId = json['configId'];
|
||
contentVersion = json['contentVersion'];
|
||
description = json['description'];
|
||
productId = json['productId'];
|
||
if (json['action'] is Map) {
|
||
action = GuidePushAction.fromJson(json['action']);
|
||
}
|
||
if (json['videos'] is List) {
|
||
videos = (json['videos'] as List).map((e) => GuidePushVideo.fromJson(e)).toList();
|
||
}
|
||
}
|
||
}
|
||
|
||
/// 弹窗按钮动作:type=VIP_PRODUCT 时 value 为会员商品 id
|
||
class GuidePushAction {
|
||
String? type;
|
||
String? value;
|
||
|
||
GuidePushAction.fromJson(Map<String, dynamic>? json) {
|
||
json ??= {};
|
||
type = json['type'];
|
||
value = json['value'];
|
||
}
|
||
}
|
||
|
||
class GuidePushVideo {
|
||
String? id;
|
||
String? title;
|
||
String? cover;
|
||
String? coverThumb; // 缩略图,列表展示优先用它
|
||
int? playTime; // 时长(秒)
|
||
int? playCount; // 播放量
|
||
|
||
GuidePushVideo.fromJson(Map<String, dynamic>? json) {
|
||
json ??= {};
|
||
id = json['id'];
|
||
title = json['title'];
|
||
cover = json['cover'];
|
||
coverThumb = json['coverThumb'];
|
||
playTime = json['playTime'];
|
||
playCount = json['playCount'];
|
||
}
|
||
|
||
/// 列表用封面:缩略图为空时回落大图
|
||
String get showCover => coverThumb?.isNotEmpty == true ? coverThumb! : cover ?? '';
|
||
|
||
/// 转成 VideoModel,复用项目现成的视频 cell。
|
||
/// freeArea=true 是为了让 cell 不画右上角 VIP 角标(见 VideoSimpleCell._buildLevelIcon),
|
||
/// ⚠️ 因此这个对象只能喂给 cell 渲染,不能传给播放页——那边会当成免费区、放过付费拦截
|
||
VideoModel toVideoModel() => VideoModel()
|
||
..id = id
|
||
..title = title
|
||
..cover = showCover
|
||
..playTime = playTime
|
||
..playCount = playCount
|
||
..freeArea = true;
|
||
}
|