rabbit-harmony/common/src/main/ets/viewmodel/DataBean.ets

153 lines
3.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import ArrayList from "@ohos.util.ArrayList";
/**
* UserProfile 的专属转换器
*/
export const UserProfileMapper = (raw: Record<string, Object>): UserProfile => {
return {
token: (raw['token'] as string) ?? "",
temp: (raw['temp'] as boolean) ?? false,
name: (raw['name'] as string) ?? "",
user_id: (raw['user_id'] as string) ?? "",
config: ConfigMapper(raw['config'] as Record<string, Object>)
};
};
/**
* 配置转换器
*/
export const ConfigMapper = (raw: Record<string, Object>): ConfigEntity => {
return {
versionEntity: (raw['client.version.upgrade'] as VersionEntity) ?? null,
uniVersionList: (raw['client.uni.version.upgrade'] as UniVersionEntity[]) ?? [],
homeIconEntity: (raw['client.icon.uni.home'] as UniIconEntity[]) ?? [],
wgtPassword: (raw['client.wgt.password'] as string) ?? null,
isUniMpOpen: (raw['client.uni.open'] as boolean) ?? false
};
};
// 用户配置Profile
export interface UserProfile {
token: string;
temp: boolean;
name: string; // 显示的文本内容
user_id: string;
config: ConfigEntity; // 可选的图标资源
}
// 用户配置Config
export interface ConfigEntity {
versionEntity: VersionEntity | null;
uniVersionList: UniVersionEntity[];
homeIconEntity: UniIconEntity[];
wgtPassword: string | null;
isUniMpOpen: boolean | null;
}
// 用户配置App版本
export interface VersionEntity {
description: string | null;
force: boolean;
last_version_force: string | null;
title: string | null;
url: string | null;
app_size: string | null;
version: string | null;
}
// 用户配置UniMp版本
export interface UniVersionEntity {
version: string | null;
url: string | null;
last_version_force: string | null;
force: boolean;
title: string | null;
description: string | null;
unimp_id: string | null;
unimp_type: string | null;
icon: string | null;
}
// 用户配置UniMp指定路径Path
export interface UniIconEntity {
icon: string | null;
text: string | null;
url: string | null;
type: string | null;
enable: boolean;
}
// 验证码信息
export interface CaptchaProfile {
timestamp: string;
}
// 登录信息
export interface LoginProfile {
user_id: string | null;
name: string | null;
avater: string | null;
token: string | null;
}
// 用户信息(字段由/api/user 与 /api/user/account共同提供
export interface UserInfo {
alipayid: string | null;
app_id: string | null;
appleid: string | null;
avater: string | null;
balance: string | null;
client_cid: string | null;
coupon_count: string | null;
ip_area: string | null;
ip_area_name: string | null;
name: string | null;
phone: string | null;
role: string | null;
temp: boolean | true;
unionid: string | null;
user_id: string | null;
vip: number | 0;
vip_expire: string | null;
vip_expire_time: string | null;
vip_name: string | null;
weixinAppId: string | null;
weixinAppIdType: string | null;
weixinAppOpenId: string | null;
weixinOpenId: string | null;
//以下字段,目前由/api/user/account提供
vip_type: number | 0;
create_time: string | null;
bind: ArrayList<string> | null;
}
// 支付宝授权登录参数
export interface AlipayProfile {
param: string | null;
}
// UniMp小程序微信支付参数
export interface TradeData {
weixinMpOriId?: string;
outTradeNo?: string;
}
/**
* {
* "icon": "https://cdn.batiao8.com/flaunt/uni_mp/icon/other/ticket.png",
* "text": "机票",
* "url": "pages/other/tickets-app/index",
* "type": "alipay",
* "enable": true
* }
*/
// 小程序指定Page
export interface UniMpItem {
id: string;
text: string; // 显示的文本内容
icon: Resource; // 可选的图标资源
url: string; // 跳转路径
type: string; // 类型
enable: boolean; // 是否可用
}