初始化

This commit is contained in:
谢宇宁
2026-09-15 15:44:13 +07:00
commit a23ba685e9
1065 changed files with 101122 additions and 0 deletions
@@ -0,0 +1,47 @@
/// 推广收益概览
class UserIncomeModel {
String? totalAmount; // 可提现收益
String? totalIncomeAmount; // 累计收益总额
String? totalPayUserCount; // 累计付费用户
String? totalInviteUserCount; // 累计推广用户
String? todayInviteUserCount; // 今日推广用户
String? monthInviteUserCount; // 当月推广用户
String? monthIncomeAmount; // 当月推广收益金币
String? todayIncomeAmount; // 今日推广收益金币
UserIncomeModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
totalAmount = json['totalAmount'];
totalIncomeAmount = json['totalIncomeAmount'];
totalPayUserCount = json['totalPayUserCount'];
totalInviteUserCount = json['totalInviteUserCount'];
todayInviteUserCount = json['todayInviteUserCount'];
monthInviteUserCount = json['monthInviteUserCount'];
monthIncomeAmount = json['monthIncomeAmount'];
todayIncomeAmount = json['todayIncomeAmount'];
}
}
/// 推广收益列表(分页)
class InviteIncomeModel {
bool? hasNext;
List<InviteItem>? items;
InviteIncomeModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
hasNext = json['hasNext'];
items = (json['list'] as List?)?.map((e) => InviteItem.fromJson(e)).toList();
}
}
/// 单条推广记录
class InviteItem {
String? userName; // 被邀请人昵称
int? incomeAmount; // 该用户带来的收益金币
InviteItem.fromJson(Map<String, dynamic>? json) {
json ??= {};
userName = json['userName'];
incomeAmount = json['incomeAmount'];
}
}
+139
View File
@@ -0,0 +1,139 @@
import 'package:hgdj/assets_tool/images.dart';
/// 用户信息
class UserInfoModel {
// —— 基础资料 ——
int? uid; // 用户ID
String? name; // 昵称
String? portrait; // 头像
String? gender; // 性别
String? summary; // 个性签名
String? mobile; // 手机号
int? urrPortraitStatus; // 头像审核状态
// —— 账号 / 登录 ——
String? token; // 登录 token
String? devID; // 设备 ID
String? createdAt; // 注册时间
String? districtCode; // 渠道码
// —— 社交统计 ——
int? fans; // 粉丝数
int? likeCount; // 获赞数
bool? isFollow; // 是否已关注
// —— 会员 / VIP ——
bool? isVip; // 是否会员
int? vipLevel; // 会员等级 1-影片会员 2-ACG会员 3-超级会员(一卡通)
String? vipName; // 会员名称
String? vipExpireDate; // 会员到期时间
bool? isUpgrade; // 是否可升级
// —— 推广 / 邀请 ——
String? promoteURL; // 推广链接
String? promotionCode; // 我的邀请码
String? inviterCode; // 邀请人邀请码
// —— 金币 / 观影券 / 权益 ——
bool allGoldVideoFree = false; // 是否全场金币视频免费
String? goldVideoFreeExpire; // 金币视频免费权益到期时间
List<MyCoupon>? goldVideoCoupon; // 观影券列表
String? broadcastExpire; // 直播观看权益有效期
String? dramaExpire; // 短剧卡到期时间,晚于当前时间就是有短剧权益
int? payVidDiscount; // 付费视频折扣
// —— 创作 / 等级 ——
int? vidUploadCount; // 视频上传数
int? coverUploadCount; // 封面上传数
int? level; // 当前等级
// —— 状态 / 权限 ——
int? adverAbTestShowType; // 广告AB -1-首次进app免广告 0-全部展示 其他N-注册后N分钟内免广告(分层后固定不变)
// ============ 计算属性 ============
/// 观影券总数量
int get couponCount =>
(goldVideoCoupon ?? []).fold(0, (sum, e) => sum + (e.count ?? 0));
/// 可解锁该金币视频的观影券面额:券面额需 >= 视频金币,都不够就退回第一张
int? couponGold(int? originCoins) {
final coupons = goldVideoCoupon ?? [];
for (final coupon in coupons) {
if ((coupon.gold ?? 0) >= (originCoins ?? 0)) return coupon.gold ?? 0;
}
return coupons.isEmpty ? null : coupons.first.gold;
}
/// 作品总数(视频上传 + 封面上传)
int get totalWorkCount => (vidUploadCount ?? 0) + (coverUploadCount ?? 0);
/// 会员等级对应的角标图片;等级 1~4,0 级(含推广会员)无角标
String get vipImageName {
final level = vipLevel ?? 0;
if (level < 1) return "";
return "vip_${level.clamp(1, 4)}.webp".mineImgPath;
}
/// 是否充值会员
bool get isRechargeVIP => (isVip ?? false) && (vipLevel ?? 0) > 0;
// ============ 序列化 ============
UserInfoModel.fromJson(Map<String, dynamic>? map) {
map ??= {};
uid = map['uid'];
name = map['name'];
portrait = map['portrait'];
gender = map['gender'];
summary = map['summary'];
mobile = map['mobile'];
urrPortraitStatus = map['urrPortraitStatus'];
token = map['token'];
devID = map['devID'];
createdAt = map['createdAt'];
districtCode = map['districtCode'];
fans = map['fans'];
likeCount = map['likeCount'];
isFollow = map['isFollow'];
isVip = map['isVip'];
vipLevel = map['vipLevel'];
vipName = map['vipName'];
vipExpireDate = map['vipExpireDate'];
isUpgrade = map['isUpgrade'];
promoteURL = map['promoteURL'];
promotionCode = map['promotionCode'];
inviterCode = map['inviterCode'];
allGoldVideoFree = map['allGoldVideoFree'] ?? false;
goldVideoFreeExpire = map['goldVideoFreeExpire'];
goldVideoCoupon = (map['goldVideoCoupon'] as List?)
?.map((o) => MyCoupon.fromJson(o))
.toList();
broadcastExpire = map['broadcastExpire'];
dramaExpire = map['dramaExpire'];
payVidDiscount = map['payVidDiscount'];
vidUploadCount = map['vidUploadCount'];
coverUploadCount = map['coverUploadCount'];
level = map['level'];
adverAbTestShowType = map['adverAbTestShowType'];
}
}
/// 观影券
class MyCoupon {
int? gold; // 券面额(金币)
int? count; // 数量
MyCoupon.fromJson(Map<String, dynamic>? map) {
map ??= {};
gold = map['gold'];
count = map['count'];
}
}
+35
View File
@@ -0,0 +1,35 @@
/// 钱包信息,来自 /mine/wallet
class WalletModel {
// ===== 收益 =====
int? income; //收益金币的整数部分
double? incomePot; //收益金币的零头,和 income 一起算总收益
num? vidIncome; //视频收益
// ===== 余额 =====
int? amount; //充值金币余额,购买后会被写回
int? integral; //积分
// ===== 剩余次数 =====
int? downloadCount; //视频下载次数
int? aiUndressFreeTimes; //AI 脱衣免费次数
int? todayAiFreeTimes; //今日 AI 免费次数
//字段顺序与上方声明一致,便于比对
WalletModel.fromJson(Map<String, dynamic>? json) {
json ??= {};
income = json['income'];
//后端可能下发 double / int / 数字字符串,统一按字符串解析。
//解析不了、或拿到 NaN/Infinity 都留 null 当没零头——balance 的 `~/` 吃到它们会抛 UnsupportedError
final pot = double.tryParse('${json['incomePot'] ?? 0}');
incomePot = pot != null && pot.isFinite ? pot : null;
vidIncome = json['vidIncome'];
amount = json['amount'];
integral = json['integral'];
downloadCount = json['downloadCount'];
aiUndressFreeTimes = json['aiUndressFreeTimes'];
todayAiFreeTimes = json['todayAiFreeTimes'];
}
//收益总额:先放大 100 倍算再取整,避免 double 直接相加的精度误差
int get balance => ((income ?? 0) * 100.0 + (incomePot ?? 0) * 100) ~/ 100;
}