fix: 首页推荐数据格式异常

This commit is contained in:
guozhigq
2024-07-23 23:25:06 +08:00
parent 5a9118271a
commit 7ae5373831
12 changed files with 45 additions and 459 deletions

View File

@ -34,7 +34,7 @@ class RecVideoItemAppModel {
String? title;
int? isFollowed;
RcmdOwner? owner;
RcmdReason? rcmdReason;
String? rcmdReason;
String? goto;
int? param;
String? uri;
@ -64,17 +64,11 @@ class RecVideoItemAppModel {
//duration = json['cover_right_text'];
title = json['title'];
owner = RcmdOwner.fromJson(json);
rcmdReason = json['rcmd_reason_style'] != null
? RcmdReason.fromJson(json['rcmd_reason_style'])
: null;
rcmdReason = json['bottom_rcmd_reason'] ?? json['top_rcmd_reason'];
// 由于app端api并不会直接返回与owner的关注状态
// 所以借用推荐原因是否为“已关注”、“新关注”等判别关注状态从而与web端接口等效
RegExp regex = RegExp(r'已关注|新关注');
isFollowed = rcmdReason != null &&
rcmdReason!.content != null &&
regex.hasMatch(rcmdReason!.content!)
? 1
: 0;
isFollowed = regex.hasMatch(rcmdReason ?? '') ? 1 : 0;
// 如果是就无需再显示推荐原因交由view统一处理即可
if (isFollowed == 1) {
rcmdReason = null;