云信发送消息相关

This commit is contained in:
XiuYun CHEN
2025-07-18 17:26:48 +08:00
parent f7408f7cbc
commit cbf50189cc
55 changed files with 4298 additions and 200 deletions
@@ -84,6 +84,75 @@ class VideoTools {
})
}
getVideoDetails(video_uuid:string)
{
this.hashMap.clear();
this.hashMap.set('video_uuid', video_uuid)
hdHttp.httpReq<string>(BasicConstant.videoDetail,this.hashMap).then(async (res: HdResponse<string>) => {
logger.info('Response videoDetail'+res);
let json:VideoDetailModel = JSON.parse(res+'') as VideoDetailModel;
if(json.video.polyv_uuid==null||json.video.polyv_uuid==undefined)
{
if(json.video.content!=null)
{
let content=json.video.content
let split = content.split("\"vid\" : ");
if (split.length<2){
split = content.split("'vid' : ");
if (split.length>1){
let split1 = split[1].split("'");
this.goPLVMediaPlayerOnlyVideoPage(split1[1],video_uuid)
}else {
promptAction.showToast({ message: '视频信息错误' })
this.goPLVMediaPlayerOnlyVideoPage('',video_uuid)
}
}else if(split.length>1){
let split1 = split[1].split("\"");
this.goPLVMediaPlayerOnlyVideoPage(split1[1],video_uuid)
}
}
else
{
promptAction.showToast({ message: '视频信息错误' })
this.goPLVMediaPlayerOnlyVideoPage('',video_uuid)
}
}
else
{
this.goPLVMediaPlayerOnlyVideoPage(json.video.polyv_uuid,video_uuid)
}
}).catch((err: BusinessError) => {
this.goPLVMediaPlayerOnlyVideoPage('',video_uuid)
})
}
async goPLVMediaPlayerOnlyVideoPage(vid:string,video_uuid:string)
{
const mediaResourcesResult = await runCatching(PLVMockMediaResourceData.getInstance().setupMediaResourcesFromLocal(vid,mockViewerParam))
if (mediaResourcesResult.success === false) {
promptAction.showToast({
message: `'视频数据初始化失败': ${mediaResourcesResult.error}`,
duration: seconds(3).toMillis()
})
return
}
const mediaResource = mediaResourcesResult.data[0]
router.pushUrl({
url:'pages/VideoPage/PLVMediaPlayerOnlyVideoPage',
params: {
video_uuid:video_uuid,
param:new PLVMediaPlayerSingleVideoPageParam(mediaResource)
}
})
}
}
export const videoTools = new VideoTools()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

+1 -1
View File
@@ -13,6 +13,6 @@
"@nimsdk/base": "10.9.10",
"@nimkit/common": "file:../../common",
"@nimkit/localconversationkit_ui": "file:../../localconversationkit_ui",
"refreshlib": "file:../../RefreshLib"
}
}
@@ -2,7 +2,8 @@
import { ConsulList } from '../model/ConsulModel'
import { router } from '@kit.ArkUI'
import { BasicConstant, ChatParam, preferenceStore } from '@itcast/basic';
import { ChatKitClient } from '@nimkit/chatkit';
import { ChatKitClient, LocalConversationRepo } from '@nimkit/chatkit';
import { HMRouterMgr } from '@hadss/hmrouter';
@Preview
@@ -11,10 +12,11 @@ export struct ItemCompPublic {
@Prop item:ConsulList;
@State isHistory:boolean = false;//是否是我已回答
@State status:string=''
@State unreadCount:number=0
aboutToAppear(): void {
this.getUnread()
}
pathStack: NavPathStack = new NavPathStack()
// pathStack: NavPathStack = new NavPathStack()
build() {
Column() {
@@ -26,13 +28,16 @@ export struct ItemCompPublic {
Text(this.item.createDate ?
this.item.createDate.length > 16 ? this.item.createDate.substring(1, 16) : this.item.createDate : '')
.fontSize(15).fontColor($r('app.color.top_title')).padding({ left: 5 })
Text('')
.width(11)
.height(11)
Text(this.unreadCount>100?'...':this.unreadCount+'')
.width(18)
.height(18)
.fontSize(11)
.textAlign(TextAlign.Center)
.fontColor(Color.White)
.backgroundColor('#ffff3e3e')
.borderRadius(20)
.margin({ top: -20 })
.visibility(this.isHistory ? Visibility.Visible : Visibility.None)
.visibility(this.unreadCount>0&&this.item.state!=3 ? Visibility.Visible : Visibility.None)
}
@@ -56,10 +61,13 @@ export struct ItemCompPublic {
.borderRadius(17)
.textAlign(TextAlign.Center)
.onClick(() => {
router.pushUrl({
url: 'pages/Netease/ConsultationDetailPage',
params: { uuid: this.item.uuid, isHistory: this.isHistory + '' }
});
HMRouterMgr.push({ pageUrl: 'ConsultationDetailPage' , param: {
uuid: this.item.uuid, isHistory: this.isHistory+''
} })
// router.pushUrl({
// url: 'pages/Netease/ConsultationDetailPage',
// params: { uuid: this.item.uuid, isHistory: this.isHistory + '' ,patientUuid:this.item.patientUuid}
// });
})
Text(this.item.diseaseName.includes("甲、乙、丙、丁") ? '肝炎' : this.item.diseaseName)
.fontSize(11)
@@ -83,22 +91,31 @@ export struct ItemCompPublic {
{
preferenceStore.setItemString('gdxz_consult_uuid', this.item.uuid)
preferenceStore.setItemString('gdxz_sessionType', BasicConstant.consult)
this.pathStack.pushPath({
name: "ChatP2PPage",
param: {
conversationId: ChatKitClient.nim.conversationIdUtil.p2pConversationId(this.item.patientUuid.toString()
.toLowerCase()),
name: this.item.realName,
chat_state:this.item.state+''
} as ChatParam
})
HMRouterMgr.push({ pageUrl: 'ChatP2PPage' , param: {
conversationId: ChatKitClient.nim.conversationIdUtil.p2pConversationId(this.item.patientUuid.toString()
.toLowerCase()),
name: this.item.realName,
chat_state:this.item.state+''
} as ChatParam})
// this.pathStack.pushPath({
// name: "ChatP2PPage",
// param: {
// conversationId: ChatKitClient.nim.conversationIdUtil.p2pConversationId(this.item.patientUuid.toString()
// .toLowerCase()),
// name: this.item.realName,
// chat_state:this.item.state+''
// } as ChatParam
// })
}
else
{
router.pushUrl({
url: 'pages/Netease/ConsultationDetailPage',
params: { uuid: this.item.uuid,isHistory:this.isHistory+''}
});
HMRouterMgr.push({ pageUrl: 'ConsultationDetailPage' , param: {
uuid: this.item.uuid, isHistory: this.isHistory+''
} })
// router.pushUrl({
// url: 'pages/Netease/ConsultationDetailPage',
// params: { uuid: this.item.uuid,isHistory:this.isHistory+''}
// });
}
@@ -108,5 +125,11 @@ export struct ItemCompPublic {
}
getUnread()
{
this.unreadCount = LocalConversationRepo.getTotalUnreadCount() ?? 0
}
}
@@ -0,0 +1,122 @@
import { HMRouterMgr } from '@hadss/hmrouter';
import { BasicConstant, TimestampUtil } from '@itcast/basic';
import { PerfactInputSheet } from '@itcast/basic/src/main/ets/Views/PerfactInputSheet';
import { LengthMetrics, router } from '@kit.ArkUI'
import { ChatKitClient } from '@nimkit/chatkit';
import { customAttachment } from '@nimkit/chatkit_ui/src/main/ets/view/MessageComponentBuilder';
import { StringIsEmpty } from '@nimkit/common';
import { PatientTBean } from '../model/TeachModel';
@Preview
@Component
export struct ItemCompTeach {
@Prop item:PatientTBean;
aboutToAppear(): void {
this.initDialog()
}
private dialog!:CustomDialogController;
@State inputPlaceholder:string=''
initDialog() {
this.dialog = new CustomDialogController({
builder:PerfactInputSheet({
controller:this.dialog,
inputTitle:'是否确定发送此患教科普',
inputPlaceholder:this.inputPlaceholder,
style:'2',
okText:'发送',
okColor:$r('app.color.top_title'),
inputCallBack:(input: string,title:string)=>{
let img=StringIsEmpty(this.item.imgPath)?"http://doc.igandan.com/app/html/img/2016/20160714132557.png":BasicConstant.urlHtml+this.item.imgPath
const jsonData:customAttachment = {
gdxz_title: this.item.topic,
gdxz_url:BasicConstant.urlHtml+this.item.path,
gdxz_content:this.item.summary,
gdxz_id: this.item.uuid,
gdxz_img:img ,
gdxz_type: BasicConstant.Teach,
gdxz_ext_data: ''
}
HMRouterMgr.pop({param:JSON.stringify(jsonData)})
}
}),
keyboardAvoidDistance: LengthMetrics.vp(0), // 设置弹窗底部与键盘顶部间距(单位:vp)
alignment: DialogAlignment.Center,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
})
}
build() {
Column()
{ Row()
{
Image(BasicConstant.urlHtml+this.item.imgPath).width(114).height(76).alt($r('app.media.home_scroll_default1'))
Column()
{
Text(this.item.topic).fontColor($r('app.color.common_gray_01')).fontSize(16) .textOverflow({ overflow: TextOverflow.Ellipsis }).height(40)
.ellipsisMode(EllipsisMode.END).maxLines(2) .textAlign(TextAlign.Start).align(Alignment.TopStart)
.width('100%')
Row()
{
Row() {
Text('今日')
.borderRadius(30)
.fontColor(Color.White)
.backgroundColor('#f24d57')
.fontSize(11)
.padding({ left: 5, right: 5,top:2,bottom:2 })
.visibility(TimestampUtil.isToday(this.item.modifyDate) ? Visibility.Visible : Visibility.None)
Text(this.item.modifyDate.length > 10 ? this.item.modifyDate.substring(5, 10) : this.item.modifyDate)
.fontColor($r('app.color.common_gray_03'))
.fontSize(12)
.visibility(!TimestampUtil.isToday(this.item.modifyDate) ? Visibility.Visible : Visibility.None)
}.width(80).align(Alignment.Start)
Row() {
Image($r('app.media.read_commient')).width(10).height(10)
Text(this.item.readnum > 100000 ? this.item.readnum * 1.000 / 10000.00 + '万' : this.item.readnum + '')
.fontColor($r('app.color.common_gray_03')).padding({left:3})
.fontSize(12)
}.width(80).align(Alignment.Start)
Row() {
Image($r('app.media.argee_commient')).width(10).height(10)
Text(this.item.agreenum > 100000 ? this.item.agreenum * 1.000 / 10000.00 + '万' : this.item.agreenum + '')
.fontColor($r('app.color.common_gray_03')).padding({left:3})
.fontSize(12)
}.width(80).align(Alignment.Start)
}
.margin({top:10})
.width('100%')
}.padding({left:10})
.layoutWeight(1)
}.alignSelf(ItemAlign.Start)
.width('100%')
.padding(10)
.onClick(() => {
this.inputPlaceholder=this.item.topic
this.dialog.open()
})
Text().backgroundColor($r('app.color.efefef')).width('100%').height(1)
}
}
}
@@ -0,0 +1,114 @@
import { HMRouterMgr } from '@hadss/hmrouter';
import { BasicConstant, TimestampUtil } from '@itcast/basic';
import { PerfactInputSheet } from '@itcast/basic/src/main/ets/Views/PerfactInputSheet';
import { LengthMetrics, router } from '@kit.ArkUI'
import { ChatKitClient } from '@nimkit/chatkit';
import { customAttachment } from '@nimkit/chatkit_ui/src/main/ets/view/MessageComponentBuilder';
import { StringIsEmpty } from '@nimkit/common';
import { PatientVBean } from '../model/TeachVideoModel';
@Preview
@Component
export struct ItemCompTeachVideo {
@Prop item:PatientVBean;
aboutToAppear(): void {
this.initDialog()
}
private dialog!:CustomDialogController;
@State inputPlaceholder:string=''
initDialog() {
this.dialog = new CustomDialogController({
builder:PerfactInputSheet({
controller:this.dialog,
inputTitle:'是否确定发送此患教科普',
inputPlaceholder:this.inputPlaceholder,
style:'2',
okText:'发送',
okColor:$r('app.color.top_title'),
inputCallBack:(input: string,title:string)=>{
let img=StringIsEmpty(this.item.imgpath)?"http://doc.igandan.com/app/html/img/2016/20160714132557.png":BasicConstant.urlHtml+this.item.imgpath
const jsonData:customAttachment = {
gdxz_title: this.item.name,
gdxz_url:BasicConstant.urlHtml+this.item.path,
gdxz_content:'肝胆相照®肝胆病在线公共服务平台',
gdxz_id: this.item.uuid,
gdxz_img:img,
gdxz_type: BasicConstant.VideoTeach,
gdxz_ext_data: ''
}
HMRouterMgr.pop({param:JSON.stringify(jsonData)})
}
}),
keyboardAvoidDistance: LengthMetrics.vp(0), // 设置弹窗底部与键盘顶部间距(单位:vp)
alignment: DialogAlignment.Center,
customStyle: true,
autoCancel: false,
backgroundColor: ('rgba(0,0,0,0.5)'),
height: '100%'
})
}
build() {
Column()
{ Row()
{
Image(BasicConstant.urlHtml+this.item.imgpath).width(114).height(76).alt($r('app.media.home_scroll_default1')).borderRadius(4)
Column()
{
Text(this.item.name).fontColor($r('app.color.common_gray_01')).fontSize(16) .textOverflow({ overflow: TextOverflow.Ellipsis }).height(40)
.ellipsisMode(EllipsisMode.END).maxLines(2) .textAlign(TextAlign.Start).align(Alignment.TopStart)
.width('100%')
Text(this.item.public_name)
.fontColor($r('app.color.common_gray_03'))
.fontSize(14)
.width('100%').textAlign(TextAlign.Start)
Row()
{
Row() {
Text(this.item.create_date.split(" ")[0])
.fontColor($r('app.color.common_gray_03'))
.fontSize(12)
}.width(100).align(Alignment.Start)
Row() {
Image($r('app.media.read_commient')).width(10).height(10)
Text(this.item.readnum > 100000 ? this.item.readnum * 1.000 / 10000.00 + '万' : this.item.readnum + '')
.fontColor($r('app.color.common_gray_03')).padding({left:3})
.fontSize(12)
}.width(80).align(Alignment.Start)
}
.margin({top:10})
.width('100%')
}.padding({left:10})
.layoutWeight(1)
}.alignSelf(ItemAlign.Start)
.width('100%')
.padding(10)
.onClick(() => {
this.inputPlaceholder=this.item.name
this.dialog.open()
})
Text().backgroundColor($r('app.color.efefef')).width('100%').height(1)
}
}
}
@@ -9,7 +9,7 @@ import HashMap from '@ohos.util.HashMap';
@Component
export struct ListCompPublic {
pathStack: NavPathStack = new NavPathStack()
// pathStack: NavPathStack = new NavPathStack()
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
@Prop
@Watch('onUpdate')
@@ -207,7 +207,7 @@ export struct ListCompPublic {
{
ForEach(this.list, (item: ConsulList) => {
ListItem() {
ItemCompPublic({ item,isHistory:this.isHistory,pathStack: this.pathStack })
ItemCompPublic({ item,isHistory:this.isHistory })
}
@@ -0,0 +1,14 @@
import { PatientsData } from '@itcast/basic';
export class Groups {
/**
* 处理后的数据分组标题
*/
title: string = '';
/**
* RegionData数组
*/
regionDataList: Array<PatientsData> = [];
}
@@ -0,0 +1,31 @@
export interface TeachModel {
code:string;
data:PatientTBean[];
message:string;
totalPage:number
}
export interface PatientTBean{
expertName:string;
imgPath:string;
topic:string;
publisherUuid:string;
recommendedUuid:string;
isOriginal:string;
isThrough:string;
filePath:number;
uuid:string;
agreenum:number;
readnum:number;
submitDate:string;
modifyDate:string;
summary:string;
type:string;
path:string;
tags:string;
content:string;
}
@@ -0,0 +1,31 @@
export interface TeachVideoModel {
code:string;
data:TeachVideo;
message:string;
}
export interface TeachVideo {
totalPage:number,
list:PatientVBean[];
}
export interface PatientVBean{
type_uuid:string;
imgpath:string;
public_name:string;
sort:string;
uuid:string;
readnum:number;
create_date:string;
name:string;
status:string;
path:string;
tags:string;
note:string;
video_type_name:string;
}
@@ -0,0 +1,20 @@
export interface patientVideoTypeModel {
code:string;
data:VideoTypeBean[];
message:string;
}
export interface VideoTypeBean{
uuid:string;
sort:number;
status:number;
note:string;
name:string;
}
@@ -1,25 +1,36 @@
import { authStore, BaseBean, BasicConstant, hdHttp, HdLoadingDialog, HdNav, HdResponse,
import { authStore, BaseBean, BasicConstant,
ChatParam,
hdHttp, HdLoadingDialog, HdNav, HdResponse,
PhotoGrids,
preferenceStore,
ViewImageInfo} from '@itcast/basic'
import { HashMap } from '@kit.ArkTS';
import { ConsultDetail, ConsultPhoto } from '../model/ConsulModel';
import { BusinessError } from '@kit.BasicServicesKit';
import { promptAction, router } from '@kit.ArkUI';
import { PerfactInputSheet } from '@itcast/basic/src/main/ets/Views/PerfactInputSheet';
import { ChatKitClient } from '@nimkit/chatkit';
import { customAttachment } from '@nimkit/chatkit_ui/src/main/ets/view/MessageComponentBuilder';
import { HMRouter, HMRouterMgr } from '@hadss/hmrouter';
@HMRouter({
pageUrl: 'ConsultationDetailPage'
})
@Component
export struct ConsultationDetailComp {
@State patientName: string='' ;
hashMap: HashMap<string, string> = new HashMap();
@State params:Record<string, string> = router.getParams() as Record<string, string>;
// @State params:Record<string, string> = router.getParams() as Record<string, string>;
@State params:Record<string, string>= HMRouterMgr.getCurrentParam() as Record<string, string>;
@State state: number=1 ;
@State createDate: string='' ;
@State content: string='' ;
@State diseaseName: string='' ;
@State imgList:ConsultPhoto[]=[]
@State chat_state:string=''
// pathStack: NavPathStack = new NavPathStack()
@State patientUuid:string=''
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
@@ -51,6 +62,7 @@ export struct ConsultationDetailComp {
}
aboutToAppear() {
this.initDialog()
this.initData()
}
@@ -71,7 +83,7 @@ export struct ConsultationDetailComp {
this.content=json.data.detail.content
this.diseaseName=json.data.detail.diseaseName
this.imgList = [...json.data.imgList]
this.patientUuid=json.data.detail.patientUuid
}).catch((err: BusinessError) => {
this.dialog.close()
@@ -113,6 +125,39 @@ export struct ConsultationDetailComp {
{
promptAction.showToast({ message: '抢答成功' })
this.addBonusPoints()
preferenceStore.setItemString('gdxz_consult_uuid',this.params.uuid)
preferenceStore.setItemString('gdxz_sessionType', BasicConstant.consult)
const jsonData:customAttachment = {
gdxz_title: this.content,
gdxz_url: '',
gdxz_content: '',
gdxz_id: this.params.uuid,
gdxz_img: '',
gdxz_type: BasicConstant.CouTeach,
gdxz_ext_data: ''
}
HMRouterMgr.push({ pageUrl: 'ChatP2PPage' , param: {
conversationId: ChatKitClient.nim.conversationIdUtil.p2pConversationId(this.patientUuid
.toLowerCase()),
name: this.patientName,
chat_state:'',
hasMessage:'true',
messageType:BasicConstant.CouTeach,
rawAttach:JSON.stringify(jsonData)
} as ChatParam})
// this.pathStack.pushPath({
// name: "ChatP2PPage",
// param: {
// conversationId: ChatKitClient.nim.conversationIdUtil.p2pConversationId(this.params.patientUuid
// .toLowerCase()),
// name: this.patientName,
// chat_state:'',
// hasMessage:'true',
// gdxz_sessionType:BasicConstant.consult,
// rawAttach:JSON.stringify(jsonData)
// } as ChatParam
// })
}
else
{
@@ -125,6 +170,7 @@ export struct ConsultationDetailComp {
})
}
addBonusPoints() {
const hashMap: HashMap<string, string> = new HashMap();
@@ -142,7 +188,9 @@ export struct ConsultationDetailComp {
build() {
Column() {
HdNav({ title: '咨询详情', showRightIcon: false, showLeftIcon: true})
HdNav({ title: '咨询详情', showRightIcon: false, showLeftIcon: true,isLeftAction:true,leftItemAction: () => {
HMRouterMgr.pop()
}})
Text(this.state==0?$r('app.string.cancellation'):this.patientName).fontSize(19).fontColor($r('app.color.top_title')).width('100%') .padding(10)
Row()
{
@@ -180,7 +228,7 @@ export struct ConsultationDetailComp {
.fontColor($r('app.color.main_color'))
.onClick(() => {
this.countConsult()
})
.visibility(this.params.isHistory=='false'?Visibility.Visible:Visibility.None)
@@ -191,12 +239,7 @@ export struct ConsultationDetailComp {
.width('100%')
.width('100%')
.onClick(() => {
// router.pushUrl({
// url: 'pages/Netease/ConsultationDetailPage',
// params: { uuid: this.item.uuid}
// });
})
}
@@ -9,7 +9,7 @@ import { V2NIMFriendAddApplication } from '@nimsdk/base';
@ComponentV2
export struct MessageComp {
@Param pathStack: NavPathStack = new NavPathStack()
// @Param pathStack: NavPathStack = new NavPathStack()
@Param onUreadMessageChange?: (unreadCount?: number) => void = undefined
loadUnreadApplication = async () => {
@@ -70,7 +70,7 @@ export struct MessageComp {
// })
}})
LocalConversationPage({
pathStack: this.pathStack,
onUreadMessageChange: this.onUreadMessageChange,
})
@@ -0,0 +1,440 @@
import { authStore, BasicConstant, hdHttp, HdLoadingDialog,HdNav, HdResponse, patientDbManager,
PatientListModel,
PatientsData} from '@itcast/basic'
import { Groups } from '../model/Groups';
import { display } from '@kit.ArkUI';
import { StringIsEmpty } from '@nimkit/common';
import I18n from '@ohos.i18n';
import Intl from '@ohos.intl';
let collator = new Intl.Collator(I18n.System.getSystemLocale(), {
usage: 'sort',
collation: 'pinyin',
caseFirst: 'lower'
})
@Component
export struct PatientListComp {
private scroller: Scroller = new Scroller()
@State regionInfo: Array<PatientsData> = [];
@State regionDataGroupsList: Array<Groups> = [];
private indexList: Array<string> = []
private normalIndexValue: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '#']
private indexUtil = I18n.getInstance(I18n.System.getSystemLocale());
@State alphabetSelected: number = 0
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
aboutToAppear() {
this. PatientsData()
this.loadPatients()
}
PatientsData()
{
this.dialog.open()
hdHttp.post<string>(BasicConstant.urlExpert + 'patientListByGBK', {
expertUuid: authStore.getUser().uuid
} as updateExtraData).then(async (res: HdResponse<string>) => {
try {
let json: PatientListModel = JSON.parse(res + '') as PatientListModel;
console.log('服务器返回的患者数据:', json);
if(json.data!=null)
{
this.collationData(json.data);
}
} catch (parseError) {
console.error('解析服务器响应失败:', parseError);
}
})
}
async loadPatients() {
try {
await patientDbManager.patientsToFMDB();
} catch (error) {
console.error('加载患者数据失败:', error);
}
}
@Builder
itemHead(text: string) {
ListItem() {
Row() {
Text(text)
.fontSize($r('sys.float.ohos_id_text_size_sub_title3'))
.fontWeight(FontWeight.Medium)
.fontFamily($r('sys.string.ohos_id_text_font_family_medium'))
.fontColor($r('sys.color.ohos_id_color_text_secondary'))
}
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Start)
.backgroundColor($r('sys.color.ohos_id_color_panel_bg'))
// .enabled(this.selectState)
.height(40)
.width('100%')
.padding({ left: 15,})
}
}
build() {
Column() {
HdNav({ title: '患者消息', showRightIcon: true, showLeftIcon: true,showRightText:false,rightIcon:$r('app.media.selected_hospital_ws')})
Stack({ alignContent: Alignment.TopEnd }) {
Column() {
List({ scroller: this.scroller, space: 0, initialIndex: 0 }) {
ListItem() {
Column()
{
Row() {
Image($r('app.media.new_patient'))
.width(50)
.height(50)
.margin({ left:10 })
Row()
{
Text('新的患者')
.fontSize(16)
.fontColor($r('app.color.common_gray_01'))
.textAlign(TextAlign.Start)
.padding({left:10,right:10})
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.ellipsisMode(EllipsisMode.END)
Text('(待审核'+'人)')
.fontSize(16)
.fontColor(Color.Red)
.layoutWeight(1)
.textAlign(TextAlign.Start)
.padding({left:5})
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.ellipsisMode(EllipsisMode.END)
}.layoutWeight(1)
.align(Alignment.Start)
Column()
{
Image($r('app.media.arrow_right'))
.width(7)
.height(13)
.margin({ left:10 })
.alignSelf(ItemAlign.End)
}.align(Alignment.End).padding({right:30})
}
.alignItems(VerticalAlign.Center)
.padding({ top:10,bottom:10})
.width('100%')
Text().height(0.5).backgroundColor($r('sys.color.ohos_id_color_list_separator')).width('100%')
}
}
.width('100%')
.align(Alignment.Start)
.onClick(() => {
})
ListItem() {
Row() {
Image($r('app.media.patientgroup'))
.width(50)
.height(50)
.margin({ left:10 })
Row()
{
Text('患者分组')
.fontSize(16)
.fontColor($r('app.color.common_gray_01'))
.textAlign(TextAlign.Start)
.padding({left:10,right:10})
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.ellipsisMode(EllipsisMode.END)
Text('(随访'+'人)')
.fontSize(16)
.fontColor(Color.Red)
.layoutWeight(1)
.textAlign(TextAlign.Start)
.padding({left:5})
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.ellipsisMode(EllipsisMode.END)
}.layoutWeight(1)
.align(Alignment.Start)
Column()
{
Image($r('app.media.arrow_right'))
.width(7)
.height(13)
.margin({ left:10 })
.alignSelf(ItemAlign.End)
}.align(Alignment.End).padding({right:30})
}
.alignItems(VerticalAlign.Center)
.padding({ top:10,bottom:10})
.width('100%')
}
.width('100%')
.align(Alignment.Start)
.onClick(() => {
})
ForEach(this.regionDataGroupsList, (regionDataGroups: Groups, index) => {
ListItemGroup({ header: this.itemHead(regionDataGroups.title) }) {
ListItem() {
List() {
ForEach(regionDataGroups.regionDataList, (regionData: PatientsData, index?: number) => {
ListItem() {
Row() {
Image(BasicConstant.urlHtml+regionData.photo)
.alt($r('app.media.userPhoto_default'))
.width(50)
.height(50)
.margin({ left:10 })
.borderRadius(8)
Column()
{
Text(regionData.realName)
.fontSize(16)
.fontColor($r('app.color.common_gray_01'))
.width('100%')
.textAlign(TextAlign.Start)
.padding({left:10,right:10})
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.ellipsisMode(EllipsisMode.END)
Text(regionData.diagnosis?regionData.diagnosis.includes("甲、乙、丙、丁") ? '肝炎' :regionData.diagnosis:'')
.fontSize(12)
.borderColor($r('app.color.top_title'))
.fontColor($r('app.color.top_title'))
.padding({left:8,right:8,top:3,bottom:3})
.borderRadius(17)
.borderWidth(1)
.textAlign(TextAlign.Center)
.margin({top:5,left:10})
.visibility(regionData.diagnosis?Visibility.Visible:Visibility.None)
.alignSelf(ItemAlign.Start)
}.layoutWeight(1)
.align(Alignment.Start)
Column()
{
Image($r('app.media.edit_patitent'))
.width(24)
.height(24)
.margin({ left:10 })
.alignSelf(ItemAlign.End)
Text(regionData.join_date ?"随访于"+ regionData.join_date.split(" ")[0] :'')
.fontSize(12)
.fontColor($r('app.color.666666'))
.margin({top:5})
.textAlign(TextAlign.Center)
.visibility(regionData.join_date?Visibility.Visible:Visibility.None)
}.align(Alignment.End).padding({right:30})
}
.alignItems(VerticalAlign.Center)
.padding({ top:10,bottom:10})
.width('100%')
}
.width('100%')
.align(Alignment.Start)
.onClick(() => {
// // 暂不选择需要退出
// if (regionData.name === this.noSelect) {
// this.selectedRegion = '';
// // 页面返回
// return;
// }
// this.selectedRegion = regionData.name;
// this.selectState = false;
// if (this.pageLevel < 4) {
// this.pageLevel++;
// }
// let regionData1 = this.getData('data2');
// if (this.pageLevel > 1) {
// regionData1 = this.getData('data3');
// }
// if (regionData1.regionInfos.length === 0) {
// return;
// }
// if (this.pageLevel < 4) {
// this.collationData(regionData1, false);
// }
})
})
}
.divider({
strokeWidth: 0.5,
color: $r('sys.color.ohos_id_color_list_separator'),
startMargin: 0,
endMargin: 0
})
.width('100%')
}
.width('100%')
}
.width('100%')
.align(Alignment.Center)
})
}
.sticky(StickyStyle.None)
.onScrollIndex((start: number, end: number) => {
let target = this.indexList[start]
let indexList = this.normalIndexValue;
let index = this.searchIndex(indexList, target)
this.alphabetSelected = index === -1 ? this.onSlideList(indexList, target) - 1 : index;
})
.layoutWeight(1)
.width('100%')
.scrollBar(BarState.Off)
// Text().height(56).width('100%')
}
.width('100%')
.height('100%')
Column() {
AlphabetIndexer({
arrayValue: this.normalIndexValue,
selected: 0
})
.usingPopup(true)
.selected(this.alphabetSelected)
.onSelect((index: number) => {
if (index === 0) {
this.scroller.scrollToIndex(0);
return;
}
let pos = 0
let useValue = this.normalIndexValue
let currentWord = useValue[index] // 在右侧索引上的位置
if (currentWord === '·') { // 在右侧索引上的位置 刚号是点,则需要找右侧索引上一个字母
let beforeWord = useValue[index - 1]; // 这个是右侧索引点的上一个字母
let afterWord = useValue[index + 1];
pos = this.onClickPointIndex(this.indexList, beforeWord, afterWord)
} else {
pos = this.searchIndex(this.indexList, currentWord)
}
if (pos === -1) {
return;
}
this.scroller.scrollToIndex(pos);
})
.id('id_hwid_region_choose_alphabetIndexer')
.onAreaChange((oldValue: Area, newValue: Area) => {
// 获取屏幕对象
let displayObj: display.Display = display.getDefaultDisplaySync();
// 获取屏幕高度
let displayHeight: number = displayObj.height / displayObj.densityPixels;
})
.itemSize('20')
.font({ size: '20vp' })
.selectedFont({
size: '20vp', style: FontStyle.Normal,
weight: FontWeight.Bolder
})
}
.height('100%')
.backgroundColor(Color.Transparent)
}
.layoutWeight(1)
}.width('100%')
.height('100%')
// .backgroundColor($r('app.color.white'))
}
private collationData(regionRequestData: PatientsData[]) {
this.regionInfo = regionRequestData.map((regionData: PatientsData) => {
if(StringIsEmpty(regionData.nickname))
{
regionData.nickname = regionData.realName ;
}
return regionData;
}).sort((a, b) => collator.compare(a.nickname, b.nickname));
this.indexList = [];
this.regionDataGroupsList = [];
this.regionInfo.forEach((value: PatientsData) => {
let index = this.indexUtil.getIndex(value.nickname);
if (this.indexList.indexOf(index) === -1) {
let regionDataGroups: Groups = new Groups();
if(this.normalIndexValue.includes(index))
{
regionDataGroups.title = index;
}
else
{
regionDataGroups.title = '#';
}
this.indexList.push(index);
regionDataGroups.regionDataList.push(value);
this.regionDataGroupsList.push(regionDataGroups);
} else {
this.regionDataGroupsList[this.indexList.indexOf(index)].regionDataList.push(value);
}
})
this.regionDataGroupsList.sort((a, b) => {
return this.normalIndexValue.indexOf(a.title) - this.normalIndexValue.indexOf(b.title);
});
this.dialog.close()
}
private searchIndex(indexList: string[], target: string): number {
return indexList.indexOf(target);
}
private onSlideList(indexList: string[], target: string): number {
for (let i = 1; i < indexList.length; i++) {
if (indexList[i] > target && indexList[i] !== '·') {
return i;
}
}
return 0;
}
private onClickPointIndex(indexList: string[], beforeWord: string, afterWord: string): number {
for (let i = 1; i < indexList.length; i++) {
if (indexList[i] > beforeWord && indexList[i] < afterWord) {
return i;
}
}
return 0;
}
}
interface updateExtraData {
expertUuid: string
}
@@ -7,14 +7,14 @@ export struct QuictDoctorComp {
@Watch('onChangeIndex')
activeIndex: number = 0
@State type: number=0
pathStack: NavPathStack = new NavPathStack()
// pathStack: NavPathStack = new NavPathStack()
onChangeIndex() {
}
build() {
Column() {
TabBarTopComp({activeIndex:this.activeIndex,type:this.type,pathStack: this.pathStack});
TabBarTopComp({activeIndex:this.activeIndex,type:this.type});
@@ -0,0 +1,228 @@
import { BasicConstant, EmptyViewComp, hdHttp, HdLoadingDialog, HdNav, HdResponse, HdSearchNav } from '@itcast/basic'
import { HMRouter, HMRouterMgr } from '@hadss/hmrouter'
import { PullToRefreshLayout, RefreshController } from 'refreshlib'
import { HashMap } from '@kit.ArkTS';
import { BusinessError } from '@kit.BasicServicesKit';
import { PatientTBean, TeachModel } from '../model/TeachModel';
import { promptAction } from '@kit.ArkUI';
import { ItemCompTeach } from '../components/ItemCompTeach';
import { PatientVBean, TeachVideoModel } from '../model/TeachVideoModel';
import { ItemCompTeachVideo } from '../components/ItemCompTeachVideo';
@HMRouter({ pageUrl: 'SearchComp' })
@Component
export struct SearchComp {
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
@State params:Record<string, string>= HMRouterMgr.getCurrentParam() as Record<string, string>;
@State pageNumber:number = 1;
@State totalPageNumer:number = 1;
@State data:PatientTBean[]=[];
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
@State datav:PatientVBean[]=[];
@State empty:string='暂无数据'
aboutToAppear() {
this.getApplyList();
}
getApplyList() {
this.dialog.open()
if(this.params.type=='tuwen')
{
this.empty='暂无患教学堂'
const hashMap: HashMap<string, string> = new HashMap();
hashMap.set('page',this.pageNumber.toString());
hashMap.set("topic", this.inputText);
hdHttp.httpReq<string>(BasicConstant.polularScienceArticleListInexpertNew,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:TeachModel = JSON.parse(res+'') as TeachModel;
if(json.code == '1') {
if(this.pageNumber==1)
{
this.data=[]
if(json.data!=null)
{
this.data = json.data;
}
}
else if(this.pageNumber>1)
{
this.data.push(...json.data)
}
this.totalPageNumer =json.totalPage;
if (this.data.length > 0) {
this.isEmptyViewVisible = false;
} else {
this.isEmptyViewVisible = true;
}
} else {
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
else if(this.params.type=='video')
{
this.empty='暂无科普视频'
const hashMap: HashMap<string, string> = new HashMap();
hashMap.set('page',this.pageNumber.toString());
hashMap.set("sort", this.params.sort);
hashMap.set("name", this.inputText);
if(this.params.typeUuid!='')
{
hashMap.set("typeUuid", this.params.typeUuid);
}
hdHttp.httpReq<string>(BasicConstant.patientVideoByName,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:TeachVideoModel = JSON.parse(res+'') as TeachVideoModel;
if(json.code == '1') {
if(this.pageNumber==1)
{
this.datav=[]
if(json.data!=null)
{
this.datav = json.data.list;
}
}
else if(this.pageNumber>1)
{
this.datav.push(...json.data.list)
}
this.totalPageNumer =json.data.totalPage;
} else {
promptAction.showToast({ message: json.message, duration: 1000 })
}
if (this.datav.length > 0) {
this.isEmptyViewVisible = false;
} else {
this.isEmptyViewVisible = true;
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
}
public controller:RefreshController = new RefreshController();
scroller = new Scroller();
@State inputText:string=''
onRefresh()
{
this.pageNumber = 1;
this.getApplyList();
}
build() {
Column(){
HdSearchNav({showRightText:true,rightText:'搜索',rightTextColor:Color.White,isFocus:true,placeholder:'输入搜索内容',rightItemAction:(value: string)=>{
this.inputText = value;
this.onRefresh();
},isLeftAction:true,
leftItemAction:()=>{
HMRouterMgr.pop()
}})
Text().height(5).width('100%').backgroundColor($r('app.color.home_gray'))
if (this.isEmptyViewVisible){
EmptyViewComp({promptText:this.empty,isVisibility:this.isEmptyViewVisible}).layoutWeight(1)
}
else
{
PullToRefreshLayout({
scroller:this.scroller,
viewKey:"ListPage",
controller:this.controller,
contentView:()=>{
this.contentView()
},
onRefresh:()=>{
this.pageNumber = 1;
this.getApplyList();
setTimeout(() => {
this.controller.refreshSuccess()
}, 1000)
},
onCanPullRefresh:()=>{
if (!this.scroller.currentOffset()) {
/*处理无数据,为空的情况*/
return true
}
//如果列表到顶,返回true,表示可以下拉,返回false,表示无法下拉
return this.scroller.currentOffset().yOffset <= 0
},
onLoad:()=>{
this.pageNumber++;
this.getApplyList();
setTimeout(() => {
this.controller.loadSuccess()
}, 1000)
},
onCanPullLoad: () => {
if (this.pageNumber >= this.totalPageNumer) {
return false;
} else {
return true;
}
}
}).width('100%').layoutWeight(1).clip(true)
}
}
.width('100%')
.height('100%')
}
@Builder
contentView(){
List({ scroller: this.scroller }) {
if(this.params.type=='tuwen')
{
ForEach(this.data, (item: PatientTBean, index) => {
ListItem() {
ItemCompTeach({item:item})
}
})
}
else if(this.params.type=='video')
{
ForEach(this.datav, (item: PatientVBean, index) => {
ListItem() {
ItemCompTeachVideo({item:item})
}
})
}
}
.width('100%')
.height('100%')
.edgeEffect(EdgeEffect.None)
}
}
@@ -2,10 +2,11 @@ import { TabBarCompModel } from '../model/TabBarCompModel'
import { TabBarItems } from '../components/TabBarItems'
import { BasicConstant } from '@itcast/basic'
import { MessageComp } from '../view/MessageComp'
import { PatientListComp } from './PatientListComp'
@Component
export struct TabBarComp {
pathStack: NavPathStack = new NavPathStack()
// pathStack: NavPathStack = new NavPathStack()
@StorageProp('bottomHeight')
bottomHeight: number = 0
@Link
@@ -33,8 +34,9 @@ export struct TabBarComp {
}) {
ForEach(TabBarItems, (item: TabBarCompModel, index: number) => {
TabContent() {
if (index === 0) MessageComp({ pathStack: this.pathStack })
// else if (index === 1) VideoGandan()
// if (index === 0) MessageComp({ pathStack: this.pathStack })
if (index === 0) MessageComp()
else if (index === 1) PatientListComp()
// else if (index === 2) MyHomePage()
}
@@ -6,7 +6,7 @@ import { ManyForOneComp } from '../view/ManyForOneComp'
@Component
export struct TabBarConsultationComp {
pathStack: NavPathStack = new NavPathStack()
// pathStack: NavPathStack = new NavPathStack()
@StorageProp('bottomHeight')
bottomHeight: number = 0
@Link activeIndex: number
@@ -42,7 +42,7 @@ export struct TabBarConsultationComp {
TabContent() {
if (index === 0)
{
QuictDoctorComp({pathStack: this.pathStack})
QuictDoctorComp()
}
else if(index === 1)
{
@@ -5,7 +5,7 @@ import { ListCompMany } from '../components/ListCompMany'
@Component
export struct TabBarTopComp {
pathStack: NavPathStack = new NavPathStack()
// pathStack: NavPathStack = new NavPathStack()
@StorageProp('bottomHeight')
bottomHeight: number = 0
@Link activeIndex: number
@@ -46,7 +46,7 @@ export struct TabBarTopComp {
TabContent() {
if (this.type==0)
{
ListCompPublic({isHistory:this.isHistory,pathStack: this.pathStack})
ListCompPublic({isHistory:this.isHistory})
}
else if(this.type==1)
@@ -0,0 +1,212 @@
import { BasicConstant, EmptyViewComp, hdHttp, HdLoadingDialog, HdNav, HdResponse, HdSearchNav } from '@itcast/basic'
import { HMRouter, HMRouterMgr, HMRouterPathCallback, HMRouterPathInfo } from '@hadss/hmrouter'
import { PullToRefreshLayout, RefreshController } from 'refreshlib'
import { HashMap } from '@kit.ArkTS';
import { BusinessError } from '@kit.BasicServicesKit';
import { PatientTBean, TeachModel } from '../model/TeachModel';
import { promptAction } from '@kit.ArkUI';
import { ItemCompTeach } from '../components/ItemCompTeach';
import { StringIsEmpty } from '@nimkit/common';
@HMRouter({ pageUrl: 'TuwenCompPage' })
@Component
export struct TuwenComp {
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
@State pageNumber:number = 1;
@State totalPageNumer:number = 1;
@State data:PatientTBean[]=[];
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
aboutToAppear() {
this.getApplyList();
}
getApplyList() {
const hashMap: HashMap<string, string> = new HashMap();
hashMap.set('page',this.pageNumber.toString());
hashMap.set("type", this.sort);
hashMap.set("keywords", this.inputText);
this.dialog.open()
hdHttp.httpReq<string>(BasicConstant.polularScienceArticleListByKeywordsNew,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:TeachModel = JSON.parse(res+'') as TeachModel;
if(json.code == '1') {
if(this.pageNumber==1)
{
this.data=[]
if(json.data!=null)
{
this.data = json.data;
}
}
else if(this.pageNumber>1)
{
this.data.push(...json.data)
}
this.totalPageNumer =json.totalPage;
if (this.data.length > 0) {
this.isEmptyViewVisible = false;
} else {
this.isEmptyViewVisible = true;
}
} else {
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
public controller:RefreshController = new RefreshController();
scroller = new Scroller();
@State Sorts:string='最新'
@State Imgs:ResourceStr=$r('app.media.cb_new')
@State inputText:string=''
@State
@Watch('onRefresh')
sort:string='1'
onRefresh()
{
this.pageNumber = 1;
this.getApplyList();
}
build() {
Column(){
HdNav({ title: '患教学堂', showRightIcon: false, showLeftIcon: true , isLeftAction:true,leftItemAction:()=>{
HMRouterMgr.pop()
}})
Row() {
Row() {
Image($r('app.media.search_no')).width(15).height(15).margin({ right:5 })
Text('搜索').fontSize(14).fontColor($r('app.color.common_gray_03')).textAlign(TextAlign.Start)
}
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
.onClick(()=>{
const pathInfo1: HMRouterPathInfo = {
pageUrl: 'SearchComp',
param:{type:'tuwen'}
};
const callback: HMRouterPathCallback = {
onResult: (popInfo: PopInfo) => {
const result = popInfo.result as string;
if(!StringIsEmpty(result))
{
HMRouterMgr.pop({param:result})
}
// this.sendHelloMessage(result,BasicConstant.Teach);
}
};
HMRouterMgr.push(pathInfo1,callback)
// HMRouterMgr.push({ pageUrl: 'SearchComp' })
})
Text('|').fontColor($r('app.color.tab_text_nor'))
.fontSize(13)
Row() {
Text(this.Sorts).fontSize(14).fontColor($r('app.color.common_gray_03')).textAlign(TextAlign.Start)
.margin({ left:5 })
Image(this.Imgs).width(15).height(15)
}
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
.onClick(()=>{
if(this.Sorts=='最新')
{
this.sort='2'
this.Sorts='最热'
this.Imgs=$r('app.media.cb_hot')
}
else
{
this.sort='1'
this.Sorts='最新'
this.Imgs=$r('app.media.cb_new')
}
})
}.width('100%').height(45)
Text().height(5).width('100%').backgroundColor($r('app.color.home_gray'))
if (this.isEmptyViewVisible){
EmptyViewComp({promptText:'暂无数据',isVisibility:this.isEmptyViewVisible}).layoutWeight(1)
}
else
{
PullToRefreshLayout({
scroller:this.scroller,
viewKey:"ListPage",
controller:this.controller,
contentView:()=>{
this.contentView()
},
onRefresh:()=>{
this.pageNumber = 1;
this.getApplyList();
setTimeout(() => {
this.controller.refreshSuccess()
}, 1000)
},
onCanPullRefresh:()=>{
if (!this.scroller.currentOffset()) {
/*处理无数据,为空的情况*/
return true
}
//如果列表到顶,返回true,表示可以下拉,返回false,表示无法下拉
return this.scroller.currentOffset().yOffset <= 0
},
onLoad:()=>{
this.pageNumber++;
this.getApplyList();
setTimeout(() => {
this.controller.loadSuccess()
}, 1000)
},
onCanPullLoad: () => {
if (this.pageNumber >= this.totalPageNumer) {
return false;
} else {
return true;
}
}
}).width('100%').layoutWeight(1).clip(true)
}
}
.width('100%')
.height('100%')
}
@Builder
contentView(){
List({ scroller: this.scroller }) {
ForEach(this.data, (item: PatientTBean, index) => {
ListItem() {
ItemCompTeach({item:item})
}
})
}
.width('100%')
.height('100%')
.edgeEffect(EdgeEffect.None)
}
}
@@ -0,0 +1,322 @@
import { BasicConstant,
ChangeUtil,
EmptyViewComp, hdHttp, HdLoadingDialog, HdNav, HdResponse, HdSearchNav } from '@itcast/basic'
import { HMRouter, HMRouterMgr, HMRouterPathCallback, HMRouterPathInfo } from '@hadss/hmrouter'
import { PullToRefreshLayout, RefreshController } from 'refreshlib'
import { HashMap } from '@kit.ArkTS';
import { BusinessError } from '@kit.BasicServicesKit';
import { promptAction } from '@kit.ArkUI';
import { StringIsEmpty } from '@nimkit/common';
import { patientVideoTypeModel, VideoTypeBean } from '../model/patientVideoTypeModel';
import { PatientVBean, TeachVideoModel } from '../model/TeachVideoModel';
import { ItemCompTeachVideo } from '../components/ItemCompTeachVideo';
@HMRouter({ pageUrl: 'VideoTeach' })
@Component
export struct VideoTeachComp {
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
@State pageNumber:number = 1;
@State totalPageNumer:number = 1;
@State data:PatientVBean[]=[];
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
@State beanType:VideoTypeBean[]=[];
aboutToAppear() {
this.patientVideoType()
this.getApplyList();
}
getApplyList() {
const hashMap: HashMap<string, string> = new HashMap();
hashMap.set('page',this.pageNumber.toString());
hashMap.set("sort", this.sort);
hashMap.set("name", '');
if(this.typeUuid!='')
{
hashMap.set("typeUuid", this.typeUuid);
}
this.dialog.open()
hdHttp.httpReq<string>(BasicConstant.patientVideoByName,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:TeachVideoModel = JSON.parse(res+'') as TeachVideoModel;
if(json.code == '1') {
if(this.pageNumber==1)
{
this.data=[]
if(json.data!=null)
{
this.data = json.data.list;
}
}
else if(this.pageNumber>1)
{
this.data.push(...json.data.list)
}
this.totalPageNumer =json.data.totalPage;
} else {
promptAction.showToast({ message: json.message, duration: 1000 })
}
if (this.data.length > 0) {
this.isEmptyViewVisible = false;
} else {
this.isEmptyViewVisible = true;
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
patientVideoType() {
const hashMap: HashMap<string, string> = new HashMap();
this.dialog.open()
hdHttp.httpReq<string>(BasicConstant.patientVideoType,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:patientVideoTypeModel = JSON.parse(res+'') as patientVideoTypeModel;
this.beanType=[]
if(json.data!=null)
{
this.beanType = json.data;
for (let j = 0;j<this.beanType.length;j++){
let title:string = this.beanType[j].name
let s:string;
let digit:boolean = ChangeUtil.isFirstDigit(title.charAt(0));//判断首位是否是数字
let asciiAlpha :boolean= ChangeUtil.isLetter(title.charAt(0));//字母
if(digit||asciiAlpha){
let substring:string = '';
if (title.length>=4){
substring = title.substring(0, 4);//取出来前4位
}else if(title.length>=3){
substring = title.substring(0, 3);//取出来前3位
}else if (title.length>=2){
substring = title.substring(0, 2);//取出来前2位
}
if (substring.includes("-")){//含有-
let split: string[] = substring.split("-");
if (split.length>1){
s = split[split.length - 1] + title.substring(4, title.length);
}else {
s = title.substring(4, title.length);
}
this.beanType[j].name=s;
}
}
if('乙肝'==this.beanType[j].name)
{
this.typeUuid=this.beanType[j].uuid
}
}
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
public controller:RefreshController = new RefreshController();
scroller = new Scroller();
@State Sorts:string='最新'
@State Imgs:ResourceStr=$r('app.media.cb_new')
@State notselectImg: ResourceStr = $r('app.media.triangle_normal');
@State selectImg: ResourceStr = $r('app.media.triangle_green_theme');
@State typePosition:number=-1
@State
@Watch('onRefresh')
sort:string='2'
@State
@Watch('onRefresh')
typeUuid:string=''
@State typelistStatus:boolean=false;
onRefresh()
{
this.pageNumber = 1;
this.getApplyList();
}
build() {
Column(){
HdNav({ title: '视频科普', showLeftIcon: true , isLeftAction:true,leftItemAction:()=>{
HMRouterMgr.pop()
}, showRightIcon: true,rightIcon:$r('app.media.selected_hospital_ws'),rightItemAction:()=> {
const pathInfo1: HMRouterPathInfo = {
pageUrl: 'SearchComp',
param:{type:'video',sort:this.sort,typeUuid:this.typeUuid}
};
const callback: HMRouterPathCallback = {
onResult: (popInfo: PopInfo) => {
const result = popInfo.result as string;
if(!StringIsEmpty(result))
{
HMRouterMgr.pop({param:result})
}
}
};
HMRouterMgr.push(pathInfo1,callback)
}})
Row() {
Row() {
Text(this.typePosition==-1?'乙肝':this.beanType[this.typePosition].name).fontSize(14)
.fontColor(this.typePosition==-1?$r('app.color.common_gray_03'):$r('app.color.top_title')).textAlign(TextAlign.Start)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
Image(this.typePosition==-1?this.notselectImg:this.selectImg).width(15).height(15).margin({ right:5 })
}
.padding({left:30,right:30})
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
.onClick(()=>{
this.typelistStatus=!this.typelistStatus
})
Text('|').fontColor($r('app.color.tab_text_nor'))
.fontSize(13)
Row() {
Text(this.Sorts).fontSize(14).fontColor($r('app.color.common_gray_03')).textAlign(TextAlign.Start)
.margin({ left:5 })
Image(this.Imgs).width(15).height(15)
}
.layoutWeight(1)
.justifyContent(FlexAlign.Center)
.onClick(()=>{
if(this.Sorts=='最新')
{
this.sort='1'
this.Sorts='最热'
this.Imgs=$r('app.media.cb_hot')
}
else
{
this.sort='2'
this.Sorts='最新'
this.Imgs=$r('app.media.cb_new')
}
})
}.width('100%').height(45)
Text().height(5).width('100%').backgroundColor($r('app.color.home_gray'))
Stack({ }) {
if (this.isEmptyViewVisible){
EmptyViewComp({promptText:'暂无视频科普',isVisibility:this.isEmptyViewVisible}).width('100%')
}
else
{
PullToRefreshLayout({
scroller:this.scroller,
viewKey:"ListPage",
controller:this.controller,
contentView:()=>{
this.contentView()
},
onRefresh:()=>{
this.pageNumber = 1;
this.getApplyList();
setTimeout(() => {
this.controller.refreshSuccess()
}, 1000)
},
onCanPullRefresh:()=>{
if (!this.scroller.currentOffset()) {
/*处理无数据,为空的情况*/
return true
}
//如果列表到顶,返回true,表示可以下拉,返回false,表示无法下拉
return this.scroller.currentOffset().yOffset <= 0
},
onLoad:()=>{
this.pageNumber++;
this.getApplyList();
setTimeout(() => {
this.controller.loadSuccess()
}, 1000)
},
onCanPullLoad: () => {
if (this.pageNumber >= this.totalPageNumer) {
return false;
} else {
return true;
}
}
}).width('100%') .height('100%').clip(true)
}
List() {
ForEach(this.beanType, (item: VideoTypeBean,index:number) => {
ListItem() {
Column() {
Text(item.name).fontColor(this.typePosition==index?$r('app.color.top_title'):$r('app.color.tab_text_nor'))
.fontSize(14).height(40)
.padding({left:10})
.width('100%')
.alignSelf(ItemAlign.Start)
}
.width('100%')
.justifyContent(FlexAlign.Start)
.onClick(()=>{
this.typePosition=index
this.typeUuid=item.uuid
this.typelistStatus=false
})
}
}, (item: VideoTypeBean) => JSON.stringify(item))
} .width('100%')
.height('100%')
.visibility(this.typelistStatus?Visibility.Visible:Visibility.None)
.backgroundColor(Color.White)
}
.layoutWeight(1)
}
.width('100%')
.height('100%')
}
@Builder
contentView(){
List({ scroller: this.scroller }) {
ForEach(this.data, (item: PatientVBean, index) => {
ListItem() {
ItemCompTeachVideo({item:item})
}
})
}
.width('100%')
.height('100%')
.edgeEffect(EdgeEffect.None)
}
}