注册资料

This commit is contained in:
xiaoxiao
2025-05-20 14:23:03 +08:00
parent f821535e18
commit 09a6f13e1d
80 changed files with 1102 additions and 1038 deletions
+12
View File
@@ -2,6 +2,8 @@ export { hdHttp, HdResponse } from './src/main/ets/utils/request'
export { authStore, HdUser, AUTH_STORE_KEY } from './src/main/ets/utils/auth'
export { perfactAuth } from './src/main/ets/utils/PerfactAuth'
export { logger } from './src/main/ets/utils/logger'
export { getTimeText, getPercentText } from './src/main/ets/utils/base'
@@ -32,4 +34,14 @@ export { AESEncryptionDecryption } from './src/main/ets/utils/AESEncryptionDecry
export { HdGrid } from './src/main/ets/components/HdGrid'
export { PhotoActionSheet } from './src/main/ets/Views/PhotoActionSheet'
export { DatePickerDialog } from './src/main/ets/Views/DatePickerDialog'
export { OfficeSelectedSheet } from './src/main/ets/Views/OfficeSelectedSheet'
export { PositionSelectedSheet } from './src/main/ets/Views/PositionSelectedSheet'
export { SpecialitySelectedSheet } from './src/main/ets/Views/SpecialitySelectedSheet'
+1 -1
View File
@@ -6,6 +6,6 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"mypage": "file:../../features/mypage"
}
}
@@ -0,0 +1,73 @@
import { formatDate } from '../utils/DateUtils'
import { authStore } from '../utils/auth'
@CustomDialog
export struct DatePickerDialog {
@Prop selectedDateString:string = formatDate(new Date(),'YYYY-MM-DD');
controller: CustomDialogController;
// 添加回调函数属性
private dateSelected: (date: string) => void = () => {};
// 修改构造函数
constructor(controller: CustomDialogController, dateSelected: (date: string) => void) {
super();
this.controller = controller;
this.dateSelected = dateSelected;
}
// 初始化日期范围(示例为1930-至今)
private dateOptions: DatePickerOptions = {
start: new Date('1930-01-01'),
end: new Date(this.selectedDateString),
selected: new Date(authStore.getUser().birthDate?authStore.getUser().birthDate:'1930-01-01'),
}
build() {
Column() {
// 操作按钮区域
Row({space:70}) {
Button('取消')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
})
Text('请选择出生日期')
.fontSize(15)
.fontColor('#666666')
Button('确定')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
this.dateSelected(this.selectedDateString)
})
}
.height(40)
// 日期选择器主体
DatePicker(this.dateOptions)
.lunar(false) // 禁用农历显示[1](@ref)
.selectedTextStyle({
color: '#007AFF',
font: { size: 20, weight: FontWeight.Medium }
})
.onDateChange((selected:Date)=>{
this.selectedDateString = formatDate(selected,'YYYY-MM-DD');
console.info('select current date is: ' + formatDate(selected,'YYYY-MM-DD'));
})
}
.width('100%')
.height(240)
.backgroundColor(Color.White)
}
}
@@ -0,0 +1,79 @@
@Component
export struct EditUserDataItem {
private label: string = ''
private required: boolean = false
@Prop content: string = ''
private hasArrow: boolean = false
@Prop isLine:boolean = true;
build() {
Column() {
Row() {
Row() {
Text(this.label)
.fontSize(16)
.fontColor('#333333')
.margin({ left: this.isLine?15:10 })
if (this.required) {
Text('*')
.margin({ left: 0 })
.fontSize(16)
.fontColor($r('app.color.main_color'))
}
}
.layoutWeight(1)//权重自定义
.justifyContent(FlexAlign.Start)
Row({space:5}) {
if (this.label == '头像') {
Image(this.content)
.alt(this.isLine?$r('app.media.userPhoto_default'):$r('app.media.icon_touxiang_persion_ws'))
.onComplete(() => console.log('图片加载完成'))
.onError(() => console.error('图片加载失败'+this.content))
.width(40)
.height(40)
.margin({ right: this.hasArrow?0:10 })
.borderRadius(8)
} else if (this.label == '执业医师证图片或胸牌') {
Image(this.content)
.alt(this.isLine?null:$r('app.media.icon_xiongpai_ws'))
.onComplete(() => console.log('图片加载完成'))
.onError(() => console.error('图片加载失败'+this.content))
.width(60)
.height(40)
.margin({ right: this.hasArrow?0:10 })
} else {
Text(this.content)
.fontSize(14)
.fontColor('#333333')
.width('auto')
.constraintSize({
maxWidth:this.label='专长(可选一到十项)'?'50%':'70%'
})
.textOverflow({ overflow: TextOverflow.Ellipsis })
.maxLines(1)
.margin({right: this.hasArrow?0:10 })
.textAlign(TextAlign.End)
}
if (this.hasArrow) {
Image($r('sys.media.ohos_ic_public_arrow_right'))
.width(15)
.height(15)
.margin({ right: 10 })
}
}
.justifyContent(FlexAlign.End)
}
.height(50)
.alignItems(VerticalAlign.Center)
if (this.isLine) {
Divider()
.color('#F4F4F4')
.strokeWidth(1)
.height(1)
.margin({ left: 10, top: 0 })
}
}
}
}
@@ -0,0 +1,113 @@
import HashMap from '@ohos.util.HashMap';
import { promptAction } from '@kit.ArkUI'
import { BusinessError } from '@kit.BasicServicesKit';
import { RequestDefaultModel } from '../models/RequestDefaultModel'
import { hdHttp, HdResponse } from '../utils/request'
import { BasicConstant } from '../constants/BasicConstant'
interface DefaultData {
}
@CustomDialog
export struct HeroPopWindow {
@Prop heroId:string = '';
@State detailsData:object = new Object;
private years: string[] = ['2019年英雄榜','2018年英雄榜','2017年英雄榜','2016年英雄榜','2015年英雄榜'];
controller: CustomDialogController;
heroDetailsRequestUrl:string = BasicConstant.urlExpertAPI+'gethonorDetail'
hashMap: HashMap<string, string> = new HashMap();
updateHeroDetailsAction(){
this.hashMap.set('id',this.heroId);
hdHttp.httpReq<string>(this.heroDetailsRequestUrl,this.hashMap).then(async (res: HdResponse<string>) => {
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
if(json.code=='1') {
this.detailsData = json.data;
} else {
console.error('英雄榜失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
console.info(`Response fail: ${err}`);
})
}
build() {
Stack() {
//半透明黑色背景
Column().width('100%').height('100%').backgroundColor('#50000000')
//弹窗主体
Column() {
//头部图标
Image($r('app.media.heroPop_headericon'))
.width(80)
.height(80)
.margin({top:-25})
.zIndex(2)
//标题和正文范围
Column() {
Text('肝胆英雄榜')
.fontSize(20)
.fontColor('#673986')
.margin({top:20})
Grid() {
ForEach(this.years,(item:string)=>{
GridItem({style:GridItemStyle.PLAIN}) {
Text(item)
.fontSize(10)
.fontColor(Color.Black)
.backgroundColor(Color.White) // 添加背景色确保可见
.textAlign(TextAlign.Center)
.width('100%') // 确保文本容器宽度
}
.height(20)
.width('48%')
.padding(5)
.borderRadius(10)
.borderWidth(1)
.borderColor(Color.Red)
})
}
.columnsGap(10)
.rowsGap(10)
.padding(10)
.width('100%')
.height('auto')
Text('感谢有您,一路相伴。"肝胆英雄榜"是由国内最具影响力的肝胆病互联网线上服务平台-\n' +
'肝胆相照依据肝胆病医生在各自领域年度所做工作,综合评选出来的最认可的"肝胆好医生",授予证书并赠送精美感恩好礼。\n' +
'目前"肝胆英雄榜"荣誉包括:"护肝大使"护肝新量""公益之星""科普达入"、"视频之星"、"人气科室"及"宣传之星"等。')
.fontSize(12)
.fontColor('#666666')
.textAlign(TextAlign.Start)
.lineHeight(20)
.width('90%')
.margin({bottom:10})
}
.zIndex(1)
.margin({top:-10,bottom:10})
.justifyContent(FlexAlign.Center)
.backgroundColor(Color.White)
.borderRadius(16)
.height('auto')
.width('90%')
//删除按钮
Button() {
Image($r('app.media.heropop_delete'))
.width(30)
.height(30)
}
.zIndex(3)
.position({ x: '88%', y: 10 })
.onClick(() => this.controller.close())
}
.width('90%')
.backgroundImage($r('app.media.heroPop_bg'))
.backgroundImageSize(ImageSize.Cover)
.borderRadius(16)
}
}
}
@@ -0,0 +1,118 @@
import { BasicConstant } from '../constants/BasicConstant'
import { RequestDefaultModel } from '../models/RequestDefaultModel'
import { promptAction } from '@kit.ArkUI'
import HashMap from '@ohos.util.HashMap';
import { BusinessError } from '@kit.BasicServicesKit';
import { authStore } from '../utils/auth'
import { hdHttp, HdResponse } from '../utils/request'
interface DefaultData {
'officeName':string;
'officeUuid':string;
}
@CustomDialog
export struct OfficeSelectedSheet {
controller: CustomDialogController;
@State officeNameArr:Array<string> = [];
private officeArr:Array<DefaultData> = [];
@State selectedModel:DefaultData = { officeName: '', officeUuid: '' };
@State selectedIndex:number = 0;
// 添加回调函数属性
private officeSelected: (name:string , uuid:string) => void = () => {};
// 修改构造函数
constructor(controller: CustomDialogController, officeSelected: (name: string,uuid:string) => void) {
super();
this.controller = controller;
this.officeSelected = officeSelected;
}
officeRequestUrl:string = BasicConstant.urlExpert+'officeList'
hashMap: HashMap<string, string> = new HashMap();
aboutToAppear(): void {
this.uploadOffice();
}
uploadOffice() {
hdHttp.httpReq<string>(this.officeRequestUrl,this.hashMap).then(async (res: HdResponse<string>) => {
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
if(json.code=='1') {
this.officeArr = json.data as DefaultData[];
this.officeNameArr = json.data.map(item => item.officeName);
console.log('科室名称数组:', this.officeNameArr);
for (let index = 0; index < this.officeNameArr.length; index++) {
const officeObject = this.officeArr[index] as DefaultData;
const name = this.officeNameArr[index];
if (name == authStore.getUser().officeName) {
this.selectedIndex = index;
this.selectedModel = {officeName:name,officeUuid:officeObject.officeUuid}
} else {
const defaultModel = this.officeArr[0] as DefaultData;
this.selectedIndex = 0;
this.selectedModel = {officeName:defaultModel.officeName,officeUuid:defaultModel.officeUuid};
}
}
} else {
console.error('科室数据失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
console.info(`Response fail: ${err}`);
})
}
build() {
Column() {
// 操作按钮区域
Row({space:70}) {
Button('取消')
.layoutWeight(1)
// .backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
})
Text('请选择科室')
.fontSize(15)
.fontColor('#666666')
Button('确定')
.layoutWeight(1)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
this.officeSelected(this.selectedModel.officeName, this.selectedModel.officeUuid);
})
}
.height(40)
TextPicker({
range:this.officeNameArr,
selected:this.selectedIndex
})
.canLoop(false)
.selectedTextStyle({
color: '#007AFF',
font: { size: 20, weight: FontWeight.Medium }
})
.onChange((name: string | string[], index: number | number[]) => {
// 处理单列选择场景
if (typeof index === "number" && this.officeArr[index]) {
this.selectedModel = this.officeArr[index];
}
})
}
.width('100%')
.height(240)
.backgroundColor(Color.White)
}
}
@@ -0,0 +1,77 @@
import { promptAction } from '@kit.ArkUI'
@CustomDialog
export struct PerfactInputSheet {
controller:CustomDialogController;
@Prop inputTitle:string = '';
@Prop inputPlaceholder:string = ''
@State inputText:string = ''
// 添加回调函数属性
private inputCallBack: (input: string,title:string) => void = () => {};
// 修改构造函数
constructor(controller: CustomDialogController, inputCallBack: (input: string,title:string) => void) {
super();
this.controller = controller;
this.inputCallBack = inputCallBack;
}
build() {
Column() {
// 操作按钮区域
Row() {
Button('取消')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor('#EEEEEE')
.width('15%')
.fontSize(15)
.onClick(() => {
this.controller.close()
})
Text(this.inputTitle)
.width('65%')
.fontSize(15)
.fontColor('#333333')
.textAlign(TextAlign.Center)
Button('确定')
.layoutWeight(1)
.fontSize(15)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor('#EEEEEE')
.width('15%')
.onClick(() => {
if (this.inputText.length <= 0) {
promptAction.showToast({ message: '输入不能为空', duration: 1000 })
return;
}
this.controller.close()
this.inputCallBack(this.inputText, this.inputTitle);
})
}
.height(30)
Row(){
TextInput({
placeholder: this.inputPlaceholder
})
.height(50)
.fontColor(Color.Black)
.backgroundColor(Color.White)
.onChange((value: string) => {
this.inputText = value;
})
}
.backgroundColor(Color.White)
}
.width('100%')
.height(100)
.backgroundColor('#EEEEEE')
}
}
@@ -0,0 +1,145 @@
import picker from '@ohos.file.picker';
import { BusinessError } from '@ohos.base';
import photoAccessHelper from '@ohos.file.photoAccessHelper';
import common from '@ohos.app.ability.common';
import { cameraPicker, camera } from '@kit.CameraKit'
import { abilityAccessCtrl } from '@kit.AbilityKit';
@CustomDialog
export struct PhotoActionSheet {
controller: CustomDialogController;
// 添加回调函数属性
private onPhotoSelected: (uri: string) => void = () => {};
// 修改构造函数
constructor(controller: CustomDialogController, onPhotoSelected: (uri: string) => void) {
super();
this.controller = controller;
this.onPhotoSelected = onPhotoSelected;
}
async checkCameraPermission(): Promise<boolean> {
const atManager = abilityAccessCtrl.createAtManager();
const grantStatus = await atManager.checkAccessToken(
globalThis.abilityContext.applicationInfo.accessTokenId,
'ohos.permission.CAMERA'
);
return grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED;
}
build() {
Column() {
// 操作按钮区域
Column() {
Row() {
// 拍摄照片按钮
Column() {
Image($r('app.media.icon_camera'))
.width(40)
.height(40)
Text('拍摄照片')
.fontSize(15)
.margin({top:10})
.fontColor($r('app.color.main_color'))
}
.width('50%')
.height(80)
.onClick(() => {
const context = getContext() as common.UIAbilityContext;
const cameras = camera.getCameraManager(context).getSupportedCameras();
cameras.forEach(device => {
console.log('Camera type:', device.cameraPosition);
});
this.openSystemCamera();
this.animateHide();
})
.padding(20)
// 相册照片按钮
Column() {
Image($r('app.media.ixon_album'))
.width(40)
.height(40)
Text('相册照片')
.fontSize(15)
.margin({top:10})
.fontColor($r('app.color.main_color'))
}
.width('50%')
.height(80)
.onClick(() => {
this.selectPhoto();
this.animateHide()
})
.padding(20)
}
}
.backgroundColor(Color.White)
Divider()
.color('#999999')
.strokeWidth(5)
.height(5)
.margin({top:20})
// 取消按钮
Button('取消')
.width('100%')
.height(50)
.fontColor('#999999')
.backgroundColor(Color.White)
.onClick(() => this.animateHide())
}
.width('100%')
.height(150)
.backgroundColor(Color.White)
}
animateHide() {
this.controller.close();
}
// 打开相机
private async openSystemCamera() {
try {
const pickerProfile: cameraPicker.PickerProfile = {
cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK,
videoDuration: 15 // 录像时设置最大时长(秒)
};
const result = await cameraPicker.pick(
getContext(),
[cameraPicker.PickerMediaType.PHOTO], // 可替换为VIDEO
pickerProfile
);
if (result.resultCode === 0) {
console.log('Photo URI:', result.resultUri);
// 处理拍摄结果
}
} catch (error) {
console.error('Camera error:', error.code);
}
}
// 资源被选中回调,返回资源的信息,以及选中方式
private selectPhoto() {
let photoSelectOptions = new picker.PhotoSelectOptions();
photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE;
photoSelectOptions.maxSelectNumber = 1;
let photoViewPicker = new picker.PhotoViewPicker();
photoViewPicker.select(photoSelectOptions)
.then((photoSelectResult) => {
console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' +
JSON.stringify(photoSelectResult));
if (photoSelectResult.photoUris && photoSelectResult.photoUris.length > 0) {
this.onPhotoSelected(photoSelectResult.photoUris[0]);
}
})
.catch((err: BusinessError) => {
console.error('PhotoViewPicker.select failed with err: ' + err);
});
}
}
@@ -0,0 +1,121 @@
import { BasicConstant } from '../constants/BasicConstant'
import { RequestDefaultModel } from '../models/RequestDefaultModel'
import { promptAction } from '@kit.ArkUI'
import HashMap from '@ohos.util.HashMap';
import { BusinessError } from '@kit.BasicServicesKit';
import { authStore } from '../utils/auth'
import { hdHttp, HdResponse } from '../utils/request'
interface DefaultData {
'name':string;
'uuid':string;
}
@CustomDialog
export struct PositionSelectedSheet {
controller: CustomDialogController;
@State officeNameArr:Array<string> = [];
private officeArr:Array<DefaultData> = [];
@Prop selectedOffice:object = new Object;
@State selectedModel:DefaultData = { name: '', uuid: '' };
@State selectedIndex:number = 0;
// 添加回调函数属性
private officeSelected: (name:string , uuid:string) => void = () => {};
// 修改构造函数
constructor(controller: CustomDialogController, officeSelected: (name: string,uuid:string) => void) {
super();
this.controller = controller;
this.officeSelected = officeSelected;
}
officeRequestUrl:string = BasicConstant.urlExpert+'positionList'
hashMap: HashMap<string, string> = new HashMap();
aboutToAppear(): void {
this.uploadOffice();
}
uploadOffice() {
hdHttp.httpReq<string>(this.officeRequestUrl,this.hashMap).then(async (res: HdResponse<string>) => {
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
if(json.code=='1') {
this.officeArr = json.data as DefaultData[];
this.officeNameArr = json.data.map(item => item.name);
for (let index = 0; index < this.officeNameArr.length; index++) {
const object = this.officeArr[index] as DefaultData;
const nameIndex = this.officeNameArr[index];
if (nameIndex == authStore.getUser().positionName) {
this.selectedIndex = index;
this.selectedModel = {name:nameIndex,uuid:object.uuid};
break;
} else {
const defaultModel = this.officeArr[0] as DefaultData;
this.selectedIndex = 0;
this.selectedModel = {name:defaultModel.name,uuid:defaultModel.uuid};
}
}
console.log('职称名称数组:', this.officeNameArr);
} else {
console.error('职称数据失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
console.info(`Response fail: ${err}`);
})
}
build() {
Column() {
// 操作按钮区域
Row({space:70}) {
Button('取消')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
})
Text('请选择职称')
.fontSize(15)
.fontColor('#666666')
Button('确定')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
this.officeSelected(this.selectedModel.name, this.selectedModel.uuid);
})
}
.height(40)
TextPicker({
range:this.officeNameArr,
selected:this.selectedIndex
})
.canLoop(false)
.selectedTextStyle({
color: '#007AFF',
font: { size: 20, weight: FontWeight.Medium }
})
.onChange((name: string | string[], index: number | number[]) => {
// 处理单列选择场景
if (typeof index === "number" && this.officeArr[index]) {
this.selectedModel = this.officeArr[index];
}
})
}
.width('100%')
.height(240)
.backgroundColor(Color.White)
}
}
@@ -0,0 +1,68 @@
@CustomDialog
export struct SexSelectedSheet {
controller:CustomDialogController;
@State sexNameArr:Array<string> = ['男','女'];
@Prop selectedSex:number = 0;
// 添加回调函数属性
private sexSelected: (index: number) => void = () => {};
// 修改构造函数
constructor(controller: CustomDialogController, sexSelected: (index: number) => void) {
super();
this.controller = controller;
this.sexSelected = sexSelected;
}
build() {
Column() {
// 操作按钮区域
Row({space:70}) {
Button('取消')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
})
Text('请选择性别')
.fontSize(15)
.fontColor('#666666')
Button('确定')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
this.sexSelected(this.selectedSex);
})
}
.height(40)
TextPicker({
range:this.sexNameArr,
})
.canLoop(false)
.selectedTextStyle({
color: '#007AFF',
font: { size: 20, weight: FontWeight.Medium }
})
.onChange((name: string | string[], index: number | number[]) => {
// 处理单列选择场景
if (typeof index === "number") {
this.selectedSex = index;
}
})
}
.width('100%')
.height(240)
.backgroundColor(Color.White)
}
}
@@ -0,0 +1,140 @@
import HashMap from '@ohos.util.HashMap';
import { promptAction } from '@kit.ArkUI'
import { BusinessError } from '@kit.BasicServicesKit';
import { RequestDefaultModel } from '../models/RequestDefaultModel'
import { hdHttp, HdResponse } from '../utils/request'
import { BasicConstant } from '../constants/BasicConstant'
interface DefaultData {
'name':string;
'uuid':string;
}
@CustomDialog
export struct SpecialitySelectedSheet {
controller: CustomDialogController;
@State specialityArr:Array<DefaultData> = [];
@State selectedNames: Array<string> = [];
@State selectedTags: Array<string> = [];
// 添加回调函数属性
private specialitySelected: (seletedTags:string,selectedNames:string) => void = () => {};
// 修改构造函数
constructor(controller: CustomDialogController, specialitySelected: (seletedTags:string,selectedNames:string) => void) {
super();
this.controller = controller;
this.specialitySelected = specialitySelected;
}
aboutToAppear(): void {
this.uploadSpeciality();
}
uploadSpeciality() {
const officeRequestUrl:string = BasicConstant.urlExpert+'disease'
const hashMap: HashMap<string, string> = new HashMap();
hdHttp.httpReq<string>(officeRequestUrl,hashMap).then(async (res: HdResponse<string>) => {
let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel;
if(json.code=='1') {
this.specialityArr = json.data as DefaultData[];
console.log('请求专长接口成功,信息:', this.specialityArr);
} else {
console.error('请求专长接口失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
console.info(`Response fail: ${err}`);
})
}
build() {
Column() {
// 操作按钮区域
Row({space:70}) {
Button('取消')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
})
Text('请选择专长')
.fontSize(15)
.fontColor('#666666')
Button('确定')
.layoutWeight(1)
.backgroundColor(Color.Transparent)
.fontColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.width(80)
.onClick(() => {
this.controller.close()
// 拼接为逗号分隔字符串
const diseaseUuid = this.selectedTags.join(',');
const diseaseName = this.selectedNames.join(',');
console.log('当前选中标签的uuid字符串:', diseaseUuid);
console.log('当前选中标签的name字符串:', diseaseName);
this.specialitySelected(diseaseUuid,diseaseName);
})
}
.height(40)
Grid() {
ForEach(this.specialityArr, (data: DefaultData) => {
GridItem() {
// 单个标签组件
Text(data.name)
.fontSize(12)
.width('100%')
.height(30)
.textAlign(TextAlign.Center)
.backgroundColor(this.isSelected(data.uuid) ? '#b58078' : '#FFFFFF')
.onClick(() => {
this.handleTagClick(data.uuid,data.name)
})
}
.height(30)
.width('25%') // 四等分宽度
.borderWidth(1)
.borderColor(Color.Gray)
})
}
}
.width('100%')
.height(240)
.backgroundColor(Color.White)
}
// 判断是否选中
private isSelected(uuid: string): boolean {
return this.selectedTags.includes(uuid)
}
private handleTagClick(uuid: string,name:string) {
const index = this.selectedTags.indexOf(uuid);
if (index === -1) {
// 添加选中(限制最多10个)
if (this.selectedTags.length >= 10) {
promptAction.showToast({ message: '最多可选择十项!', duration: 1000 });
return;
}
this.selectedTags = [...this.selectedTags, uuid];
this.selectedNames = [...this.selectedNames,name];
} else {
// 取消选中
const newSelected = [...this.selectedTags];
newSelected.splice(index, 1);
this.selectedTags = newSelected;
const nameSelected = [...this.selectedNames];
nameSelected.splice(index, 1);
this.selectedNames = nameSelected;
}
console.log('当前选中标签:', this.selectedTags)
}
}
+18 -10
View File
@@ -1,4 +1,5 @@
import { router } from '@kit.ArkUI'
import { emitter } from '@kit.BasicServicesKit'
@Builder
function defaultBuilder(): void {
@@ -34,23 +35,30 @@ export struct HdNav {
@BuilderParam
menuBuilder: () => void = defaultBuilder
// 添加右侧点击处理
private onRightItemClick() {
emitter.emit({
eventId: 250516,
priority: emitter.EventPriority.HIGH
})
}
build() {
Row({ space: 16 }) {
Row() {
if (this.showLeftIcon) {
Image(this.leftIcon)
.size({ width: 24, height: 24 })
.margin({left:-5})
.onClick(() => router.back())
.fillColor($r('app.color.black'))
}
else {
} else {
Blank()
.width(24)
}
Row() {
if (this.title) {
Text(this.title)
.fontWeight(600)
// .fontWeight(600)
.layoutWeight(1)
.textAlign(TextAlign.Center)
.fontSize(20)
@@ -62,6 +70,7 @@ export struct HdNav {
}
}
.height(56)
.width(150)
.layoutWeight(1)
if (this.showRightIcon) {
@@ -69,14 +78,14 @@ export struct HdNav {
.size({ width: 24, height: 24 })
.objectFit(ImageFit.Contain)
.bindMenu(this.menuBuilder)
} else if (this.showRightText)
{
.onClick(()=>this.onRightItemClick())
} else if (this.showRightText) {
Text(this.rightText)
.fontSize(16)
.fontColor(this.textColor)
.margin({right:10})
}
else {
.onClick(()=>this.onRightItemClick())
// .margin({right:10})
} else {
Blank()
.width(24)
}
@@ -85,6 +94,5 @@ export struct HdNav {
.height(56 + this.topHeight)
.width('100%')
.backgroundColor(this.bgColor)
}
}
@@ -50,4 +50,6 @@ export interface ExpertData{
state:number;
realName:string;
specialy:Array<object>;
diseaseName:string;
diseaseUuid:string;
}
@@ -0,0 +1,25 @@
type DateFormat = 'YYYY-MM-DD' | 'MM/DD/YYYY' | 'DD-MMM-YYYY' | 'YYYY年MM月DD日' | 'YYYYMMDD';
export function formatDate(date: Date,pattern:DateFormat = 'YYYY-MM-DD'): string {
const padZero = (num: number): string => num.toString().padStart(2, '0');
const year = date.getFullYear();
const month = padZero(date.getMonth() + 1); // 月份修正[7,8](@ref)
const day = padZero(date.getDate());
// 模式映射逻辑(核心补全部分)
switch (pattern) {
case 'YYYY-MM-DD':
return `${year}-${month}-${day}`;
case 'MM/DD/YYYY':
return `${month}/${day}/${year}`;
case 'DD-MMM-YYYY':
const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
return `${day}-${months[date.getMonth()]}-${year}`; // 月份缩写处理[4](@ref)
case 'YYYY年MM月DD日':
return `${year}年${month}月${day}日`; // 中文格式[5](@ref)
case 'YYYYMMDD':
return `${year}${month}${day}`; // 紧凑格式
default:
throw new Error(`Unsupported format pattern: ${pattern}`);
}
}
@@ -0,0 +1,44 @@
import { preferences } from '@kit.ArkData'
import { ExpertData } from '../models/RequestDefaultModel'
export const AUTH_STORE_KEY = 'perfactAuth'
class PerfactAuth {
store: preferences.Preferences | null = null
getStore() {
if (!this.store) {
this.store = preferences.getPreferencesSync(getContext(), { name: AUTH_STORE_KEY })
}
return this.store
}
async setUser(phone:string,user: ExpertData) {
AppStorage.setOrCreate(phone, user)
await this.getStore().put(phone, JSON.stringify(user))
await this.getStore().flush()
}
async updateUser(phone:string,user: ExpertData) {
AppStorage.setOrCreate(phone, user)
await this.getStore().put(phone, JSON.stringify(user))
await this.getStore().flush()
}
async delUser(phone:string) {
AppStorage.setOrCreate(phone, {})
await this.getStore().put(phone, '{}')
await this.getStore().flush()
}
initUser() {
const json = this.getStore().getSync(AUTH_STORE_KEY, '{}') as string
AppStorage.setOrCreate(AUTH_STORE_KEY, JSON.parse(json))
}
getUser(phone:string) {
return AppStorage.get<ExpertData>(phone) || {} as ExpertData
}
}
export const perfactAuth = new PerfactAuth()
+17
View File
@@ -2,6 +2,7 @@ import { preferences } from '@kit.ArkData'
import { router } from '@kit.ArkUI'
import { Data } from '../models/LoginInfoModel'
import { ExpertData } from '../models/RequestDefaultModel'
import { BusinessError } from '@kit.BasicServicesKit'
export interface HdUser {
id: string
@@ -38,6 +39,18 @@ class AuthStore {
await this.getStore().flush()
}
async setPerfactUser(mobile:string,user:ExpertData) {
AppStorage.setOrCreate('mobile', mobile)
await this.getStore().put(mobile, JSON.stringify(user))
await this.getStore().flush((err:BusinessError)=>{
if (err) {
console.error('保存失败',err.code,err.message)
} else {
console.info('保存成功',JSON.stringify(user))
}
})
}
async delUser() {
AppStorage.setOrCreate('user', {})
await this.getStore().put(AUTH_STORE_KEY, '{}')
@@ -53,6 +66,10 @@ class AuthStore {
return AppStorage.get<Data>('user') || {} as Data
}
getPerfactUser(phone:string) {
return AppStorage.get<ExpertData>(phone) || {} as ExpertData
}
checkAuth(options: router.RouterOptions | Function) {
// if (this.getUser().token) {
// if (typeof options === 'function') {
+1 -1
View File
@@ -150,7 +150,7 @@ class HdHttp {
logger.info('Response httpReq:' + data.result);
let json:TimestampBean = JSON.parse(data.result.toString()) as TimestampBean;
let tp = json.timestamp;
datas.set("user_uuid", authStore.getUser().uuid?authStore.getUser().uuid:'');
datas.set("user_uuid", authStore.getUser().uuid?authStore.getUser().uuid:'5kO57cuAL8seXQpxgtc');
datas.set("client_type", 'A');
datas.set("version",'4.0.0' );
datas.set('timestamp',tp+'');
Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB