894 lines
28 KiB
Dart
894 lines
28 KiB
Dart
import 'package:hgdj/hj_model/list_base_model.dart';
|
||
import 'package:hgdj/hj_model/mine/exchange_record_model.dart';
|
||
import 'package:hgdj/hj_model/user/user_income_info_model.dart';
|
||
import 'package:hgdj/hj_model/user/user_info_model.dart';
|
||
import 'package:hgdj/hj_model/video_model.dart';
|
||
import 'package:hgdj/hj_page/main_page/provider/msg_provider.dart';
|
||
import 'package:hgdj/tools_base/event_bus/event_bus_util.dart';
|
||
import 'package:hgdj/tools_base/event_bus/events.dart';
|
||
import 'package:hgdj/tools_base/global_store/store.dart';
|
||
import 'package:hgdj/tools_base/net/http_manager.dart';
|
||
|
||
import '../../hj_model/cartoon_media_info.dart';
|
||
import '../../hj_model/message/message_dynamic_list.dart';
|
||
import '../../hj_model/mine/credit_record_model.dart';
|
||
import '../../hj_model/mine/exchange/bill_item_model.dart';
|
||
import '../../hj_model/mine/exchange/recharge_list_model.dart';
|
||
import '../../hj_model/mine/exchange/recharge_url_model.dart';
|
||
import '../../hj_model/mine/official_list_item_model.dart';
|
||
import '../../hj_model/mine/promotion_record.dart';
|
||
import '../../hj_model/mine/task_center_data.dart';
|
||
import '../../hj_model/mine/vip_card_analytics_event.dart';
|
||
import '../../hj_model/user/wallet_model.dart';
|
||
import '../../hj_page/mine/make_money/in_come_entity.dart';
|
||
import '../../hj_page/mine/make_money/withdraw_details_model.dart';
|
||
import '../../hj_page/mine/message/un_read_msg_num_model.dart';
|
||
import '../../hj_page/mine/mine_profit/model/alipay_bank_list_model.dart';
|
||
import '../../hj_page/mine/mine_vip/coupon_model.dart';
|
||
import '../../hj_page/mine/mine_vip/pay_order_source.dart';
|
||
import '../../hj_page/mine/mine_vip/vip_support_model.dart';
|
||
import '../../hj_page/mine/welfare/widget/checkin_model.dart';
|
||
import '../../hj_page/mine/welfare/widget/sign_in_model.dart';
|
||
|
||
class MineService {
|
||
/// 设备和二维码登陆
|
||
/// [devID] 设备id
|
||
/// [qrCnt] qr二维码
|
||
/// [devType] 设备信息
|
||
/// [sysType] ios/android
|
||
/// [ver] version
|
||
/// [buildID] packageName
|
||
/// [devToken] 登录设备id验签
|
||
/// [cutInfos] 粘贴板信息
|
||
|
||
static Future<UserInfoModel?> devLogin(
|
||
devID,
|
||
qrCnt,
|
||
devType,
|
||
sysType,
|
||
ver,
|
||
buildID,
|
||
devToken, [
|
||
cutInfos = "",
|
||
]) async {
|
||
ArgumentError.checkNotNull(devID, 'devID');
|
||
ArgumentError.checkNotNull(qrCnt, 'qrCnt');
|
||
ArgumentError.checkNotNull(devType, 'devType');
|
||
ArgumentError.checkNotNull(sysType, 'sysType');
|
||
ArgumentError.checkNotNull(ver, 'ver');
|
||
ArgumentError.checkNotNull(buildID, 'buildID');
|
||
ArgumentError.checkNotNull(devToken, 'devToken');
|
||
final param = {
|
||
'devID': devID,
|
||
'qrCnt': qrCnt,
|
||
'devType': devType,
|
||
'sysType': sysType,
|
||
'ver': ver,
|
||
'buildID': buildID,
|
||
'devToken': devToken,
|
||
'cutInfos': cutInfos
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/login',
|
||
param: param,
|
||
jsonTransformation: (json) => UserInfoModel.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
static Future<bool> reduceDownloadCount() async {
|
||
return (await httpManager.fetchResponseByPOST('/mine/download/use',
|
||
param: <String, dynamic>{}))
|
||
.isSuccess;
|
||
}
|
||
|
||
/// 获取用户信息
|
||
/// uid == 0 查询自己否则查询别人
|
||
static Future<UserInfoModel?> getUserInfo([int? uid]) async {
|
||
final param = {'uid': uid};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/mine/info',
|
||
param: param,
|
||
jsonTransformation: (json) => UserInfoModel.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// 提现明细
|
||
static Future<WithdrawDetailsModel?> getWithdrawDetails(
|
||
{int pageNumber = 1, int pageSize = 10}) async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/withdraw/order',
|
||
param: {
|
||
'pageNumber': pageNumber,
|
||
'pageSize': pageSize,
|
||
},
|
||
jsonTransformation: (json) => WithdrawDetailsModel.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// 提现配置
|
||
static Future<WithdrawConfig?> withdrawConfig() async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/withdraw/cfg',
|
||
jsonTransformation: (json) => WithdrawConfig.fromJson(json),
|
||
);
|
||
|
||
//MinePublishDetailsModel
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// 提现
|
||
static Future<bool> withdraw(
|
||
String? payType,
|
||
String? act,
|
||
int? money,
|
||
String? name,
|
||
String? actName,
|
||
String? devID,
|
||
String? bankCode,
|
||
int? withdrawType,
|
||
int? productType,
|
||
) async {
|
||
final param = {
|
||
'payType': payType,
|
||
'act': act,
|
||
'money': money,
|
||
'name': name,
|
||
'actName': actName,
|
||
'devID': devID,
|
||
'bankCode': bankCode,
|
||
'withdrawType': withdrawType,
|
||
'productType': productType,
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/withdraw',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
static Future<bool> updateUserInfo(Map<String, dynamic>? map) async {
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/info',
|
||
param: map ?? {},
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
static Future<UserInfoModel?> mobileLogin(
|
||
String? mobile,
|
||
String? code,
|
||
String? devID,
|
||
String? devType,
|
||
String? sysType,
|
||
String? ver,
|
||
String? buildID,
|
||
[String? cutInfos = ""]) async {
|
||
final param = {
|
||
'mobile': mobile,
|
||
'code': code,
|
||
'devID': devID,
|
||
'devType': devType,
|
||
'sysType': sysType,
|
||
'ver': ver,
|
||
'buildID': buildID,
|
||
'cutInfos': cutInfos
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/mobileLoginOnly',
|
||
param: param,
|
||
jsonTransformation: (json) => UserInfoModel.fromJson(json['userInfo']));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// 积分兑换商品
|
||
static Future<bool> integralExchange(String id,
|
||
{String? name, String? tel, String? address}) async {
|
||
final param = <String, dynamic>{
|
||
"id": id,
|
||
"name": name,
|
||
"tel": tel,
|
||
"address": address
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager
|
||
.fetchResponseByPOST('/integral/exchangeIntegral', param: param);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//收藏类型 SP:长视频 SHORT:短视频 COVER:图文帖子 PIC:图集帖子 SEED_LINK:种子/黄油帖子
|
||
static Future<bool> postCollect(
|
||
String? objID, String? type, bool? isCollect) async {
|
||
final param = {'objID': objID, 'type': type, 'isCollect': isCollect};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/collect',
|
||
param: param,
|
||
);
|
||
eventBus.emit(
|
||
CollectStatusModel(id: objID, isCollected: isCollect, type: type));
|
||
return result.isSuccess;
|
||
}
|
||
|
||
static Future<WalletModel?> fetchWalletData() async {
|
||
final result = await httpManager.fetchResponseByGET('/mine/wallet',
|
||
param: {}, jsonTransformation: (json) => WalletModel.fromJson(json));
|
||
if (result.data is WalletModel) {
|
||
globalStore.wallet = result.data;
|
||
}
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
//关注
|
||
static Future<bool> getFollow(dynamic followUID, bool isFollow) async {
|
||
final param = {'followUID': followUID, 'isFollow': isFollow};
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/follow',
|
||
param: param,
|
||
);
|
||
eventBus.emit(CollectStatusModel(uid: followUID, isFollowed: isFollow));
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//推广记录
|
||
static Future<ListBaseModel<Promotion>?> getBindRecord(
|
||
int? pageSize, int? pageNumber) async {
|
||
final param = {'pageSize': pageSize, 'pageNumber': pageNumber};
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/userinvite/userlist',
|
||
param: param,
|
||
jsonTransformation: (json) => ListBaseModel<Promotion>.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
//playTimeType: 0 默认全部 1 视频 2 帖子
|
||
//type: hot 热度值排序;watch 最多播放;like 最多点赞(收藏);new 最新视频
|
||
//status: 0 审核中 1 已通过 2未通过
|
||
// newsType: SEED_LINK 游戏, MOVIE 视频,抖音:SP,图文:COVER
|
||
|
||
static Future<UserIncomeModel?> fetchIncomeInfo() async {
|
||
final result = await httpManager.fetchResponseByPOST('/userinvite/info',
|
||
param: {},
|
||
jsonTransformation: (json) => UserIncomeModel.fromJson(json));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// 获取用户分享列表
|
||
|
||
static Future<InviteIncomeModel?> fetchIncomeList(
|
||
{int page = 1, int size = 10}) async {
|
||
final param = <String, dynamic>{'pageSize': page, 'pageNumber': size};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/userinvite/incomelist',
|
||
param: param,
|
||
jsonTransformation: (json) => InviteIncomeModel.fromJson(json));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
static Future<ListBaseModel?> fetchLikes({
|
||
int page = 1,
|
||
int size = 10,
|
||
String? likeType,
|
||
int? uid,
|
||
}) async {
|
||
final param = <String, dynamic>{
|
||
'pageNumber': page,
|
||
'pageSize': size,
|
||
'likeType': likeType,
|
||
'uid': uid,
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/mine/like',
|
||
param: param,
|
||
jsonTransformation: (json) {
|
||
if (likeType == 'image' || likeType == 'video' || likeType == 'text') {
|
||
return ListBaseModel<CartoonMediaInfo>.fromJson(json);
|
||
}
|
||
return ListBaseModel<VideoModel>.fromJson(json);
|
||
},
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// 获取我买过电影
|
||
/// [page] 页码 默认1
|
||
/// [size] 页大小 默认20
|
||
/// [newsType] 购买类型 SP视频,COVER:图集,POST:帖
|
||
/// [uid] 查询自己不传
|
||
static Future<ListBaseModel?> fetchBuyVideo({
|
||
int page = 1,
|
||
int size = 20,
|
||
int? uid,
|
||
String? newsType,
|
||
}) async {
|
||
final param = <String, dynamic>{
|
||
'pageNumber': page,
|
||
'pageSize': size,
|
||
'newsType': newsType,
|
||
'uid': uid,
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET('/mine/buyVid',
|
||
param: param,
|
||
jsonTransformation: (json) => ListBaseModel<VideoModel>.fromJson(json));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
// 账单类型0_全部 1_金币 2_积分
|
||
static Future<ListBaseModel<BillItemModel>?> getBillData({
|
||
required int pageNumber,
|
||
required int pageSize,
|
||
int? type,
|
||
}) async {
|
||
final param = {
|
||
'pageNumber': pageNumber,
|
||
'pageSize': pageSize,
|
||
'type': type,
|
||
'year': DateTime.now().year,
|
||
'month': DateTime.now().month
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET('/mine/zhangdan',
|
||
param: param,
|
||
jsonTransformation: (json) =>
|
||
ListBaseModel<BillItemModel>.fromJson(json));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
// 充值记录
|
||
static Future<WithdrawDetailsModel?> getRechargeBill({
|
||
required int pageNumber,
|
||
required int pageSize,
|
||
}) async {
|
||
final param = {
|
||
'pageNumber': pageNumber,
|
||
'pageSize': pageSize,
|
||
};
|
||
final result = await httpManager.fetchResponseByPOST('/mine/transaction',
|
||
param: param,
|
||
jsonTransformation: (json) => WithdrawDetailsModel.fromJson(json));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
// 收益明细
|
||
static Future<ListBaseModel<IncomeModel>?> getIncomeRecord({
|
||
required int pageNumber,
|
||
required int pageSize,
|
||
}) async {
|
||
final param = {
|
||
'pageNumber': pageNumber,
|
||
'pageSize': pageSize,
|
||
};
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/mine/iIncomes',
|
||
param: param,
|
||
jsonTransformation: (json) => ListBaseModel<IncomeModel>.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
//收藏的影视 video / img
|
||
static Future<ListBaseModel<T>?> fetchCollectList<T>(
|
||
String type, {
|
||
int page = 1,
|
||
int size = 20,
|
||
int? uid,
|
||
}) async {
|
||
final param = {
|
||
"type": type,
|
||
'pageNumber': page,
|
||
'pageSize': size,
|
||
'uid': uid ?? globalStore.meInfo?.uid,
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/mine/collect/infoList',
|
||
param: param,
|
||
jsonTransformation: (json) => ListBaseModel<T>.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
///获取充值金额列表
|
||
static Future<RechargeListModel?> getChatRechargeTypes(int? type) async {
|
||
final param = {'type': type};
|
||
final result = await httpManager.fetchResponseByGET('/mine/currencys',
|
||
param: param,
|
||
jsonTransformation: (json) => RechargeListModel.fromJson(json));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// 金币/VIP 充值下单
|
||
///[finalPayStatus]: 预售业务,true 付尾款, false 付预定款;null 非预售业务;
|
||
///[goldExtraID] 金币加赠券只有充值金币用到
|
||
/// [rechargeType] 支付渠道
|
||
/// [orderTrack] 下单来源/实验/会话等可选埋点字段(见 /mine/topay)
|
||
static Future<RechargeUrlModel?> chargeGoldCoin(
|
||
String? rechargeType, {
|
||
String? productId,
|
||
bool? isVip,
|
||
String? goldExtraID,
|
||
bool? finalPayStatus,
|
||
PayOrderTrackInfo? orderTrack,
|
||
// 兼容旧调用:仅 VIP 时回传实验信息;优先用 orderTrack
|
||
String? experimentId,
|
||
String? variant,
|
||
}) async {
|
||
ArgumentError.checkNotNull(rechargeType, 'rechargeType');
|
||
final track = orderTrack;
|
||
// DISABLED / 无实验时上游不填;空字符串也不传,避免参数错误
|
||
final expId = track?.experimentId ?? experimentId;
|
||
final expVariant = track?.experimentVariant ?? variant;
|
||
final param = <String, dynamic>{
|
||
'rechargeType': rechargeType,
|
||
'productID': productId,
|
||
'buyType': isVip == true ? 4 : 1,
|
||
'cId': goldExtraID?.isNotEmpty == true ? goldExtraID : null,
|
||
'uid': globalStore.meInfo?.uid,
|
||
'goldExtraID': goldExtraID,
|
||
'finalPayStatus': finalPayStatus,
|
||
// 下单来源埋点(非必填)
|
||
'sourcePage': track?.sourcePage?.value,
|
||
'sourceRef': track?.sourceRef,
|
||
'videoId': track?.videoId,
|
||
'activityId': track?.activityId,
|
||
'sessionId': track?.sessionId,
|
||
// 短剧付费墙来源:服务端用这三个字段算「当前剧充值金币 / 当前剧开通会员卡」的收入归因
|
||
'mediaId': track?.mediaId,
|
||
'contentId': track?.contentId,
|
||
'checkoutContextId': track?.checkoutContextId,
|
||
'experimentId': (expId != null && expId.isNotEmpty) ? expId : null,
|
||
'experimentVariant':
|
||
(expVariant != null && expVariant.isNotEmpty) ? expVariant : null,
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/topay',
|
||
param: param,
|
||
jsonTransformation: (json) => RechargeUrlModel.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
///意见反馈
|
||
static Future<bool> feedback(
|
||
String content, {
|
||
String? location,
|
||
String? device,
|
||
String? carrier,
|
||
String? contact,
|
||
List<String>? img,
|
||
String? fType,
|
||
}) async {
|
||
final param = {
|
||
'desc': content,
|
||
"region": location,
|
||
"devInfo": device,
|
||
"ISP": carrier,
|
||
'images': img,
|
||
'cateInfo': fType,
|
||
'contact': contact
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/feedback',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//积分兑换记录
|
||
static Future<List<CreditRecordModel>> getCreditRecords(
|
||
{int pageNumber = 1, int pageSize = 20}) async {
|
||
final param = {'pageNumber': pageNumber, 'pageSize': pageSize};
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/integral/record/list',
|
||
param: param,
|
||
);
|
||
final List<CreditRecordModel> list = [];
|
||
if (result.isSuccess) {
|
||
List? values = result.data as List?;
|
||
list.addAll(
|
||
values?.map((e) => CreditRecordModel.fromJson(e)).toList() ?? []);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
///获取所有会员卡信息列表
|
||
static Future<VipSupportModel?> getVipProduct({int? status}) async {
|
||
final param = <String, dynamic>{'status': status};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/vip/product',
|
||
param: param,
|
||
jsonTransformation: (json) => VipSupportModel.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// VIP 卡片统计事件批量上报
|
||
static Future<bool> reportAnalyticsEvents(
|
||
List<VipCardAnalyticsEvent> events) async {
|
||
if (events.isEmpty) return true;
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/analytics/events',
|
||
param: <String, dynamic>{
|
||
'events': events.map((e) => e.toJson()).toList(),
|
||
},
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//积分兑换列表
|
||
static Future<List<IntegralExchangeModel>> fetchExchangeList() async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/integral/list',
|
||
param: {},
|
||
);
|
||
final List<IntegralExchangeModel> list = [];
|
||
if (result.isSuccess) {
|
||
List? values = result.data as List?;
|
||
list.addAll(
|
||
values?.map((e) => IntegralExchangeModel.fromJson(e)).toList() ?? []);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//获取官方社群
|
||
static Future<List<OfficialListItemModel>?> getOfficialLists() async {
|
||
final param = {
|
||
'type': 2,
|
||
};
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/official/list',
|
||
param: param,
|
||
);
|
||
final List<OfficialListItemModel> list = [];
|
||
if (result.isSuccess) {
|
||
List? values = result.data as List?;
|
||
list.addAll(
|
||
values?.map((e) => OfficialListItemModel.fromJson(e)).toList() ?? []);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//领取积分
|
||
static Future<bool> receiveIntegral(String? taskId, int? type) async {
|
||
final param = {'taskId': taskId, 'type': type};
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/task/receive',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//兑换码兑换
|
||
static Future<bool> postExchangeCode(String code) async {
|
||
final param = {'code': code};
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/code/exchange',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//绑定邀请码
|
||
static Future<bool> getProxyBind(String promotionCode) async {
|
||
final param = {'promotionCode': promotionCode};
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/proxy/bind',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//发送验证码 type, 1绑定手机号,2 找回账号;
|
||
static Future<bool> postCaptchaCode(String phone, int type) async {
|
||
final param = {
|
||
'type': type,
|
||
'mobile': "+86$phone",
|
||
};
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/notification/captcha',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//绑定手机
|
||
static Future<bool> bindPhone(String phone, String code,
|
||
{String? devID,
|
||
String? smsId,
|
||
String? sysType,
|
||
String? ver,
|
||
String? devType,
|
||
String? applicationID}) async {
|
||
final param = {
|
||
'mobile': "+86$phone",
|
||
'code': code,
|
||
'devID': devID,
|
||
'smsId': smsId,
|
||
'sysType': sysType,
|
||
'ver': ver,
|
||
'devType': devType,
|
||
'applicationID': applicationID
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/mobileBind',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//动态、收益列表
|
||
static Future<ListBaseModel<MessageDynamicList>?> getDynamicList(
|
||
{int pageNumber = 1, int pageSize = 20, int? msgType}) async {
|
||
final param = {
|
||
'pageNumber': pageNumber,
|
||
'pageSize': pageSize,
|
||
'msgType': msgType,
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET('/msg/dynamic/list',
|
||
param: param,
|
||
jsonTransformation: (json) =>
|
||
ListBaseModel<MessageDynamicList>.fromJson(json));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
//未读消息列表
|
||
static Future<UnReadMsgNumModel?> getUnreadNum() async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/msg/dynamic/noRedNum',
|
||
param: {},
|
||
jsonTransformation: (json) => UnReadMsgNumModel.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
/// 黑料社获取用户优惠券
|
||
static Future<List<CouponModel>> fetchUserCoupons(int type,
|
||
{int page = 1, int size = 0}) async {
|
||
final param = <String, dynamic>{
|
||
'type': type,
|
||
'pageNumber': page,
|
||
'pageSize': size,
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET('/coupon/list',
|
||
param: param,
|
||
jsonTransformation: (json) =>
|
||
(json['list'] as List?)
|
||
?.map((e) => CouponModel.fromJson(e))
|
||
.toList() ??
|
||
[]);
|
||
//返回类型非空,给不了 null:失败时这里抛,由调用方 try/catch 兜底(改可空要连调用方一起改)
|
||
return result.data;
|
||
}
|
||
|
||
static Future<bool> bankCardDelete({String? id}) async {
|
||
final param = <String, dynamic>{'id': id};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByDELETE(
|
||
'/mine/txnact/del',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
static Future<ApBankListModel?> getBankCards() async {
|
||
final result = await httpManager.fetchResponseByGET('/mine/txnact/yh/get',
|
||
param: {},
|
||
jsonTransformation: (json) => ApBankListModel.fromJson(json));
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
static Future<bool> addBankCard(
|
||
String? act,
|
||
String? actName,
|
||
String? bankCode,
|
||
String? cardType,
|
||
) async {
|
||
final param = <String, dynamic>{
|
||
'act': act,
|
||
'actName': actName,
|
||
'bankCode': bankCode,
|
||
'cardType': cardType
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/txnact/yh/add',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//获取兑换码记录
|
||
static Future<ExchangeRecordList?> getExchangeRecord(
|
||
int pageNumber, int pageSize) async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/code/userRecord',
|
||
param: {
|
||
'pageNumber': pageNumber,
|
||
'pageSize': pageSize,
|
||
},
|
||
jsonTransformation: (json) => ExchangeRecordList.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
//获取消息小红点
|
||
static Future<NewMessageTip?> checkMessageTip() async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/ping/checkMessageTip',
|
||
param: {},
|
||
jsonTransformation: (json) => NewMessageTip.fromJson(json),
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
//获取消息小红点
|
||
static Future<String?> certificateQR() async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/mine/certificate/qr',
|
||
param: {},
|
||
jsonTransformation: (json) {
|
||
return json['content'] ?? '';
|
||
},
|
||
);
|
||
return result.isSuccess ? result.data : null;
|
||
}
|
||
|
||
static Future<List<String>> getPortrait() async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/mine/portrait',
|
||
);
|
||
final List<String> list = [];
|
||
if (result.isSuccess) {
|
||
List? values = result.data['data'] as List?;
|
||
list.addAll(values?.map((e) => e as String).toList() ?? []);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//绑定邀请码
|
||
static Future<bool> exchangeInviteCode(String code) async {
|
||
final param = {'promotionCode': code};
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/mine/inviteBind',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
|
||
//type: hot 热度值排序;watch 最多播放;like 最多点赞(收藏);new 最新视频
|
||
//status: 0 审核中 1 已通过 2未通过
|
||
|
||
static Future<ListBaseModel<VideoModel>> fetchPublishes({
|
||
int page = 1,
|
||
int size = 10,
|
||
int status = 0,
|
||
String? newsType,
|
||
int? uid,
|
||
}) async {
|
||
final param = <String, dynamic>{
|
||
'pageNumber': page,
|
||
'pageSize': size,
|
||
'status': status,
|
||
'uid': uid,
|
||
'newsType': newsType
|
||
};
|
||
param.removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET('/mine/publish',
|
||
param: param,
|
||
jsonTransformation: (json) => ListBaseModel<VideoModel>.fromJson(json));
|
||
//返回类型非空,给不了 null:失败时这里抛,由调用方 try/catch 兜底(改可空要连调用方一起改)
|
||
return result.data;
|
||
}
|
||
|
||
static Future<String> deletePublishes({
|
||
List<String>? ids,
|
||
}) async {
|
||
final param = <String, dynamic>{'ids': ids};
|
||
final result = await httpManager.fetchResponseByPOST('/mine/publish/delete',
|
||
param: param);
|
||
if (result.isSuccess) {
|
||
return '';
|
||
}
|
||
return result.tip ?? result.msg ?? '';
|
||
}
|
||
|
||
//获取优惠券
|
||
static Future<List<AICouponModel>?> backPack(
|
||
int page, {
|
||
int? limit = 10, //每页条数
|
||
int? status = 2, //物品状态 1-已使用 2-未使用 3-过期
|
||
int? type = 3, //1-楼风解锁折扣卷 2-会员折扣卷 3-AI换脸折扣券
|
||
}) async {
|
||
final param = <String, dynamic>{
|
||
'page': page,
|
||
'limit': limit,
|
||
'status': status,
|
||
'type': type,
|
||
}..removeWhere((k, v) => v == null);
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/backpack',
|
||
param: param,
|
||
jsonTransformation: (json) => CouponModel.fromJson(json),
|
||
);
|
||
final List<AICouponModel> list = [];
|
||
if (result.isSuccess) {
|
||
List? values = result.data as List?;
|
||
list.addAll(values?.map((e) => AICouponModel.fromJson(e)).toList() ?? []);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
// 签到
|
||
static Future<CheckinDoResp?> postDayMark() async {
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/checkin/click',
|
||
param: {},
|
||
);
|
||
if (!result.isSuccess || result.data == null) return null;
|
||
return CheckinDoResp.fromJson(result.data);
|
||
}
|
||
|
||
// 会员补领签到奖励
|
||
static Future<CheckinDoResp?> claimCheckinVip() async {
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/checkin/claim_vip',
|
||
param: {},
|
||
);
|
||
if (!result.isSuccess || result.data == null) return null;
|
||
return CheckinDoResp.fromJson(result.data!);
|
||
}
|
||
|
||
//签到额外奖励
|
||
static Future<List<ExtraSignRewardItem>?> getExtraDayMark() async {
|
||
final result = await httpManager.fetchResponseByGET(
|
||
'/task/sign-extra-prizes',
|
||
param: {},
|
||
);
|
||
|
||
final List<ExtraSignRewardItem> list = [];
|
||
if (result.isSuccess) {
|
||
List? values = result.data as List?;
|
||
list.addAll(
|
||
values?.map((e) => ExtraSignRewardItem.fromJson(e)).toList() ?? []);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
//获取签到列表
|
||
static Future<CheckinPrizeResp?> getSignList() async {
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/checkin/prize',
|
||
param: {},
|
||
);
|
||
if (!result.isSuccess || result.data == null) return null;
|
||
return CheckinPrizeResp.fromJson(result.data);
|
||
}
|
||
|
||
// 补签
|
||
static Future<bool> postReSign(String id) async {
|
||
final param = {'id': id};
|
||
final result = await httpManager.fetchResponseByPOST(
|
||
'/task/resign',
|
||
param: param,
|
||
);
|
||
return result.isSuccess;
|
||
}
|
||
}
|