/// 基础网络请求结构 /// 本来是业务层包装的一层东西,但是这个项目好像没用,用状态码代替了业务码 class BaseRespBean { int? code; T? data; // 打印的data dynamic printData; /// 后台提示 String? tip; String? action; /// 是否加密 bool? hash; /// 一般是code不为200的后端错误信息 String? msg; /// 服务器时间,一切vip时间计算以服务器时间为准 String? time; // String get avalibleMsg => TextUtil.isNotEmpty(tip) ? tip : msg; String get toast { if (tip?.isNotEmpty ?? false) return tip!; return msg ?? ''; // tip 为空时回退到 msg,避免错误信息弹不出来 } BaseRespBean(this.code, {this.data, this.msg, this.tip, this.hash = false, this.time, this.printData}); BaseRespBean.fromJson(Map? json) { json ??= {}; code = json['code']; data = json['data']; tip = json['tip']; action = json['action']; msg = json['msg']; time = json['time']; hash = json['hash']; } @override String toString() { return toJson().toString(); } Map toJson() { final Map data = {}; data['code'] = code; data['data'] = printData; data['tip'] = tip; data['action'] = action; data['msg'] = msg; data['time'] = time; data['hash'] = hash; return data; } bool get isSuccess => code == 200; }