1.2.0部分代码

This commit is contained in:
xiaoxiao
2025-09-09 13:27:34 +08:00
parent e89a5f15ce
commit 3013b441a6
80 changed files with 4824 additions and 105 deletions
+15 -1
View File
@@ -2,4 +2,18 @@ export { SchoolhouseComp } from './src/main/ets/components/SchoolhouseComp';
export { KeepStudyComp } from './src/main/ets/components/KeepStudyComp';
export { CoursewareComp } from './src/main/ets/components/CoursewareComp';
export { CoursewareComp } from './src/main/ets/components/CoursewareComp';
export { PayComp } from './src/main/ets/components/PayComp'
export { NewsComp } from './src/main/ets/components/NewsComp'
export { newsUtil } from './src/main/ets/utils/NewsUtil'
export { newsRollNewRequest,newsRequestOfData } from './src/main/ets/models/NewsModel'
export { NewsListComp } from './src/main/ets/components/NewsListComp'
export { SendFollowComp } from './src/main/ets/components/SendFollowComp'
export { FlowerDetailsComp } from './src/main/ets/components/FlowerDetailsComp'
@@ -242,6 +242,9 @@ export struct CoursewareComp {
ForEach(this.data, (item: KeJianModel) => {
ListItem() {
KeJianItemComp({item:item})
.onClick(()=>{
router.pushUrl({url:"pages/WebView/KeJianDetailsWebPage",params:{"model":item}})
})
}
})
}
@@ -0,0 +1,232 @@
import { BasicConstant, ChangeUtil, EmptyViewComp, hdHttp, HdLoadingDialog, HdNav, HdResponse } from '@itcast/basic';
import { PullToRefreshLayout, RefreshController } from 'refreshlib';
import { HashMap } from '@kit.ArkTS';
import { promptAction } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
@Component
export struct FlowerDetailsComp {
public controller:RefreshController = new RefreshController();
scroller = new Scroller();
@State pageNumber:number = 1;
@State totalPageNumer:number = 1;
@State flowerList:flowerListData[] = []
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
@State allFlower:string = '0'
@State allTotalNum:string = '0.00'
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
aboutToAppear(): void {
this.getFlowetListData()
}
getFlowetListData() {
const hashMap: HashMap<string, string> = new HashMap();
hashMap.set('page',this.pageNumber.toString());
this.dialog.open()
hdHttp.httpReq<string>(BasicConstant.getFlowerList,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:flowerRequest = JSON.parse(res+'') as flowerRequest;
if(json.code == 200) {
if(this.pageNumber==1) {
this.flowerList=[]
if(json.data!=null) {
this.flowerList = json.data.flower_data.list;
}
} else if(this.pageNumber>1) {
this.flowerList.push(...json.data.flower_data.list)
}
this.totalPageNumer = json.data.flower_data.pages
if (ChangeUtil.stringIsUndefinedAndNull(json.data.total_num.toString())) {
this.allFlower = '0'
} else {
this.allFlower = json.data.total_num.toString()
}
this.allTotalNum = ChangeUtil.formatPrice(json.data.total_amount.toString())
} else {
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
build() {
Column() {
HdNav({title:'我的鲜花',showRightIcon:false,showRightText:false})
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.getFlowetListData();
setTimeout(() => {
this.controller.refreshSuccess()
}, 1000)
},
onCanPullRefresh:()=>{
if (!this.scroller.currentOffset()) {
/*处理无数据,为空的情况*/
return true
}
//如果列表到顶,返回true,表示可以下拉,返回false,表示无法下拉
return this.scroller.currentOffset().yOffset <= 0
},
onLoad:()=>{
this.pageNumber++;
this.getFlowetListData();
setTimeout(() => {
this.controller.loadSuccess()
}, 1000)
},
onCanPullLoad: () => {
if (this.pageNumber >= this.totalPageNumer) {
return false;
} else {
return true;
}
}
}).width('100%').layoutWeight(1).clip(true)
}
}
.height('100%')
.width('100%')
.backgroundColor('#f1f1f1')
}
@Builder
contentView() {
List({scroller:this.scroller}) {
ListItemGroup({header:this.headerView()}) {
ForEach(this.flowerList,(item:flowerListData)=>{
ListItem() {
Row() {
Text(item.patient_name)
.fontColor(Color.Gray)
.width(130)
Blank()
.layoutWeight(1)
Text(item.create_date.substring(0,10))
.fontColor(Color.Gray)
.width(180)
Blank()
.layoutWeight(1)
Text(item.num.toString())
.textAlign(TextAlign.Center)
.fontColor(Color.Gray)
.width(40)
}
.padding(10)
.width('100%')
.height(50)
.backgroundColor(Color.White)
}
})
}
}
.width('100%')
.height('100%')
}
@Builder
headerView() {
Column() {
Row() {
Row() {
Image($r('app.media.flower_expertFlower_icon'))
.size({ width: 20, height: 20 })
Text(this.allFlower)
.fontColor($r('app.color.main_color'))
.margin({ left: 10 })
}
Row() {
Image($r('app.media.flower_accountJinbi_icon'))
.size({ width: 20, height: 20 })
Text(this.allTotalNum)
.fontColor($r('app.color.main_color'))
.margin({ left: 10 })
}
.margin({ left: 50 })
}
.padding(10)
.width('100%')
.height(45)
.backgroundColor(Color.White)
Row(){
Text('姓名')
.fontColor(Color.White)
Blank()
.layoutWeight(1)
Text('时间')
.fontColor(Color.White)
Blank()
.layoutWeight(1)
Text('数量')
.fontColor(Color.White)
}
.padding(10)
.width('100%')
.height(45)
.backgroundColor($r('app.color.main_color'))
}
.width('100%')
.height(90)
}
}
export interface flowerRequest {
'code':number
'message':string
'data':flowerData
}
export interface flowerData {
'flower_data':flower_data,
'total_num':number
'total_amount':number
}
export interface flower_data {
'isFirstPage':number
'isLastPage':number
'pageNum':number
'pages':number
'pageSize':number
'total':number
'list':flowerListData[]
}
export interface flowerListData {
'patiet_photo':string
'expert_photo':string
'expert_name':string
'patient_name':string
'patient_uuid':string
'expert_uuid':string
'num':number
'create_date':string
'trade_no':string
'order_status':string
'amount':number
'message':string
'id':string
}
@@ -79,6 +79,6 @@ export struct KeepStudyComp {
}
.width('100%')
.height('100%')
.backgroundColor('#F1F3F5')
.backgroundColor('#f1f1f1')
}
}
@@ -0,0 +1,19 @@
@Component
export struct MainPage {
@State message: string = 'Hello World';
build() {
Row() {
Column() {
Text(this.message)
.fontSize($r('app.float.page_text_font_size'))
.fontWeight(FontWeight.Bold)
.onClick(() => {
this.message = 'Welcome';
})
}
.width('100%')
}
.height('100%')
}
}
@@ -0,0 +1,85 @@
import { AppUtil, HdNav } from "@itcast/basic"
import { NewsSwiperView } from "../views/NewsSwiperView"
import { router } from "@kit.ArkUI"
@Component
export struct NewsComp {
build() {
Column() {
HdNav({title:'肝胆新闻',showRightIcon:false,showRightText:false})
NewsSwiperView().height(AppUtil.getDisplayWindowWidth().vp / 16 * 9)
Row(){
Image($r('app.media.news_new_icon'))
.width(50)
.height(50)
.margin({left:10})
.objectFit(ImageFit.Fill)
Column(){
Text('肝胆新闻')
.fontSize(16)
Text('新鲜资讯,一触即达')
.fontSize(14)
.margin({top:5})
.fontColor($r('app.color.common_gray_02'))
}
.alignItems(HorizontalAlign.Start)
.margin({left:10,right:10})
.layoutWeight(1)
Image($r('app.media.arrow_right'))
.width(12)
.height(15)
.margin({right:10})
}
.width('95%')
.height(90)
.borderRadius(3)
.backgroundColor(Color.White)
.margin({left:10,top:10,right:10})
.onClick(()=>{
router.pushUrl({
url:'pages/News/GandanNewsListPage',
})
})
Row(){
Image($r('app.media.news_meeting_icon'))
.width(50)
.height(50)
.margin({left:10})
.objectFit(ImageFit.Fill)
Column(){
Text('肝胆会议')
.fontSize(16)
Text('了解会议信息的最佳入口')
.fontSize(14)
.margin({top:5})
.fontColor($r('app.color.common_gray_02'))
}
.alignItems(HorizontalAlign.Start)
.margin({left:10,right:10})
.layoutWeight(1)
.onClick(()=>{
router.pushUrl({
url:'pages/Meeting/MeetingPage',
params:{"isLeft":"需要"}
})
})
Image($r('app.media.arrow_right'))
.width(12)
.height(15)
.margin({right:10})
}
.width('95%')
.height(90)
.borderRadius(3)
.backgroundColor(Color.White)
.margin({left:10,top:10,right:10})
}
.backgroundColor('#f1f1f1')
.width('100%')
.height('100%')
}
}
@@ -0,0 +1,188 @@
import { AppUtil, BasicConstant,
EmptyViewComp,
hdHttp, HdLoadingDialog, HdNav, HdResponse, logger } from "@itcast/basic"
import { NewsSwiperView } from "../views/NewsSwiperView"
import { promptAction, router } from "@kit.ArkUI"
import { HashMap } from "@kit.ArkTS";
import {
newsListRequest,
newsRequestOfData, newsRollNewRequest, newsTagRequest, newsTagsRequestData } from "../models/NewsModel";
import { BusinessError } from "@kit.BasicServicesKit";
import { PullToRefreshLayout, RefreshController } from "refreshlib";
import { NewsItemView } from "../views/NewsItemView";
@Component
export struct NewsListComp {
@State tagsList:newsTagsRequestData[] = []
@State newsList:newsRequestOfData[] = []
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
public controller:RefreshController = new RefreshController();
scroller = new Scroller();
@State pageNumber:number = 1;
@State totalPageNumer:number = 1;
@State selectedTagId:string = '';
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
aboutToAppear(): void {
this.getHeaderTags()
this.getNewsListData(true)
}
getHeaderTags() {
const entity = {} as Record<string,string>
this.dialog.open()
hdHttp.post<string>(BasicConstant.newsTagList, entity).then(async (res: HdResponse<string>) => {
logger.info('Response newsTagList'+res);
let json:newsTagRequest = JSON.parse(res+'') as newsTagRequest;
this.dialog.close();
this.tagsList = json.data
}).catch((err: BusinessError) => {
this.dialog.close();
})
}
getNewsListData(isDefault:boolean) {
const hashMap: HashMap<string, string> = new HashMap();
this.dialog.open()
hashMap.clear();
hashMap.set('page',this.pageNumber.toString())
if (!isDefault)
hashMap.set('newstagid', this.selectedTagId)//点击标签的ID
hdHttp.httpReq<string>(isDefault?BasicConstant.defaultNewsListNew:BasicConstant.newsListNew,hashMap).then(async (res: HdResponse<string>) => {
logger.info('Response newsListNew/defaultNewsListNew'+res);
this.dialog.close();
let json:newsListRequest = JSON.parse(res+'') as newsListRequest;
if(json.code == '1') {
if(this.pageNumber==1) {
this.newsList = []
if(json.data!=null) {
this.newsList = json.data;
}
} else if(this.pageNumber>1) {
this.newsList.push(...json.data)
}
this.totalPageNumer =json.totalPage;
if (this.newsList.length > 0) {
this.isEmptyViewVisible = false;
} else {
this.isEmptyViewVisible = true;
}
} else {
promptAction.showToast({ message: json.message, duration: 1000 })
}
this.isEmptyViewVisible = !this.newsList || this.newsList.length === 0
}).catch((err: BusinessError) => {
this.dialog.close();
})
}
build() {
Column() {
HdNav({ title: '肝胆新闻',showRightIcon: true,rightIcon:$r('app.media.selected_hospital_ws') ,showRightText:false,
rightItemAction:()=>{
router.pushUrl({
url:'pages/SearchPage/VideoSearchPage',
params:{'pageName':'视频'}
})
}})
//标签
if (this.tagsList && this.tagsList.length > 0) {
Scroll() {
Row() {
ForEach(this.tagsList, (tag:newsTagsRequestData) => {
Text(tag.NAME)
.padding({ left: 12, right: 12, top: 6, bottom: 6 })
.margin({ left: 6, right: 6, top: 10, bottom: 10 })
.fontSize(16)
.fontColor(this.selectedTagId == tag.ID?$r('app.color.main_color'):Color.Black)
.borderRadius(16)
.onClick(() => {
if (this.selectedTagId !== tag.ID) {
this.selectedTagId = tag.ID
this.pageNumber = 1
this.getNewsListData(false)
}
})
})
}
}
.scrollable(ScrollDirection.Horizontal)
.width('100%')
.height(48)
.scrollBar(BarState.Off)
.backgroundColor('#ffffff')
}
//轮播
NewsSwiperView().height(AppUtil.getDisplayWindowWidth().vp / 16 * 9)
//列表
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.getNewsListData(this.selectedTagId==='');//标签点击的第一个为true,后面是false
setTimeout(() => {
this.controller.refreshSuccess()
}, 1000)
},
onCanPullRefresh:()=>{
if (!this.scroller.currentOffset()) {
/*处理无数据,为空的情况*/
return true
}
//如果列表到顶,返回true,表示可以下拉,返回false,表示无法下拉
return this.scroller.currentOffset().yOffset <= 0
},
onLoad:()=>{
this.pageNumber++;
this.getNewsListData(this.selectedTagId==='');//标签点击的第一个为true,后面是false
setTimeout(() => {
this.controller.loadSuccess()
}, 1000)
},
onCanPullLoad: () => {
if (this.pageNumber >= this.totalPageNumer) {
return false;
} else {
return true;
}
}
}).width('100%').layoutWeight(1).clip(true)
}
}
.backgroundColor('#f1f1f1')
.width('100%')
.height('100%')
}
@Builder
contentView(){
List({ scroller: this.scroller }) {
ForEach(this.newsList, (item: newsRequestOfData, index) => {
ListItem() {
NewsItemView({item:item})
}
})
}
.width('100%')
.height('100%')
.edgeEffect(EdgeEffect.None)
}
}
@@ -0,0 +1,323 @@
import { BasicConstant, ChangeUtil,
DefaultHintProWindows,
hdHttp, HdLoadingDialog, HdNav, HdResponse,
OnWXResp,
WXApi,
WXEventHandler} from "@itcast/basic";
import { promptAction, router } from "@kit.ArkUI";
import { BusinessError, emitter } from "@kit.BasicServicesKit";
import { HashMap } from "@kit.ArkTS";
import * as wxopensdk from '@tencent/wechat_open_sdk';
import { common } from "@kit.AbilityKit";
@Component
export struct PayComp {
@State params:Record<string,string | Record<string,string> | FileOrderData> = router.getParams() as Record<string,string | Record<string,string> | FileOrderData>
@State payType:number = 0//0没有选择支付;1;选择余额支付;2:选择微信支付
@State balanceEnough: boolean = false
@State balanceMoney: string = ''
@State name:string = ''
@State hintMessage:string = ''
@State pwd:string = ''
@State kejianData:FileOrderData = {} as FileOrderData
@State songhuaData:Record<string,string | Record<string,string>> = {}
private wxApi = WXApi
private wxEventHandler = WXEventHandler
private onWXResp: OnWXResp = (resp) => {
console.info('wxResp:'+JSON.stringify(resp ?? {}, null, 2))
if (resp.errCode == 0) {
this.notificationRequest()
} else if (resp.errCode == -2) {
this.hintMessage = '支付取消'
this.alertView.open()
}
}
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
alertView:CustomDialogController = new CustomDialogController({
builder:DefaultHintProWindows({
title:'提示',
message:this.hintMessage,
cancleTitle: '',
confirmTitleColor: '#666666',
selectedButton: (index:number)=>{
this.alertView.close();
if (this.hintMessage == '支付成功' || '您已经成功送给肝胆相照送出心意') {
let innerEvent: emitter.InnerEvent = {
eventId: BasicConstant.notification_kejian_pay_success
};
let eventData: emitter.EventData = {
data:{"status":'success'}
};
emitter.emit(innerEvent, eventData);
router.back()
}
}
}),
alignment: DialogAlignment.Center,
cornerRadius:24,
backgroundColor: ('rgba(0,0,0,0.5)'),
})
inputAlertView:CustomDialogController = new CustomDialogController({
builder:DefaultHintProWindows({
title:'提示',
message:'',
cancleTitleColor: '#333333',
confirmTitleColor: $r('app.color.main_color'),
selectedButtonAndContent:(index:number,content:string)=>{
if (index == 0) {
this.inputAlertView.close()
} else {
if (!ChangeUtil.stringIsUndefinedAndNull(content)) {
this.pwd = content
this.inputAlertView.close()
this.payOrderRequest()
}
}
}
}),
alignment: DialogAlignment.Center,
cornerRadius:24,
backgroundColor: ('rgba(0,0,0,0.5)'),
})
aboutToDisappear(): void {
this.wxEventHandler.unregisterOnWXRespCallback(this.onWXResp)
}
aboutToAppear(): void {
if (this.params.page == '送花') {
this.name = '肝胆相照'
this.songhuaData = this.params.data as Record<string,string | Record<string,string>>
} else if (this.params.page == '课件详情') {
this.kejianData = this.params.data as FileOrderData
this.name = this.kejianData.provider_name
}
this.getAccountData()
this.wxEventHandler.registerOnWXRespCallback(this.onWXResp)
}
build() {
Column() {
HdNav({title:'在线支付',showRightIcon:false,showRightText:false})
Column() {
Row() {
Row() {
Text(this.params.page == '课件详情'?`下载${this.name}医生的`:`给${this.name}`)
.fontSize(16)
Text(this.params.page == '课件详情'?'课件':'送心意')
.borderRadius(8)
.fontColor(Color.White)
.margin({ left: 20 })
.size({ width: 50, height: 30 })
.textAlign(TextAlign.Center)
.backgroundColor($r('app.color.main_color'))
}
.layoutWeight(1)
Text(this.params.page == '课件详情'?ChangeUtil.formatPrice(this.kejianData.amount).toString():ChangeUtil.formatPrice(String(this.songhuaData.amount)).toString()+' 元')
.fontColor(Color.Red)
.width('40%')
.textAlign(TextAlign.End)
}
.padding(10)
.width('100%')
.backgroundColor(Color.White)
Text('请通过以下方式支付')
.width('100%')
.padding(10)
Row() {
Row() {
Image($r('app.media.pay_account_icon'))
.size({ width: 35, height: 35 })
Text('余额支付')
.fontSize(16)
.margin({ left: 10 })
Text(` ¥ ${ChangeUtil.formatPrice(this.balanceMoney)}`)
.fontSize(16)
}
.layoutWeight(1)
Row() {
if (!this.balanceEnough) {
Text('余额不足')
.fontSize(16)
.fontColor(Color.Red)
.margin({ right: 20 })
}
Image(this.payType == 1 ? $r('app.media.patiemts_list_selected') : $r('app.media.huise_kongquan'))
.width(15)
.height(15)
.enabled(this.balanceEnough)// 余额不足时禁用
}
.width('40%')
.justifyContent(FlexAlign.End)
.onClick(() => {
if (this.balanceEnough) {
this.payType = 1
}
})
}
.width('100%')
.padding(10)
.backgroundColor(Color.White)
Text('选择付款方式')
.width('100%')
.padding(10)
Row() {
Image($r('app.media.pay_wx_icon'))
.size({ width: 35, height: 35 })
Text('微信支付')
.fontSize(16)
.margin({ left: 10 })
.layoutWeight(1)
Image(this.payType == 2 ? $r('app.media.patiemts_list_selected') : $r('app.media.huise_kongquan'))
.width(15)
.height(15)
}
.width('100%')
.padding(10)
.backgroundColor(Color.White)
.onClick(() => {
this.payType = 2
})
}
.width('100%')
.layoutWeight(1)
Button('立即支付')
.width('90%')
.height(40)
.fontColor(Color.White)
.backgroundColor($r('app.color.main_color'))
.margin({left:20,bottom:50,right:20})
.onClick(() => {
if (this.payType == 0) {
this.hintMessage = '请选择支付方式'
this.alertView.open()
return
} else if (this.payType == 1) {
this.inputAlertView.open()
return
}
this.payOrderRequest()
})
}
.backgroundColor('#f4f4f4')
.width('100%')
.height('100%')
}
getAccountData() {
const hashMap: HashMap<string, string> = new HashMap()
this.dialog.open()
hashMap.clear()
hdHttp.httpReq<string>(BasicConstant.getBalance,hashMap).then(async (res: HdResponse<string>) => {
console.info('Response getBalance'+res)
this.dialog.close()
let json:Record<string,string> = JSON.parse(res+'') as Record<string,string>;
if(json.code == '200') {
this.balanceMoney = json.data
let amount = this.params.page == '课件详情'?ChangeUtil.formatPrice(this.kejianData.amount):ChangeUtil.formatPrice(String(this.songhuaData.amount))
if (ChangeUtil.formatPrice(this.balanceMoney)> amount) {
this.balanceEnough = true
}
} else {
promptAction.showToast({ message: String(json.message), duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close()
console.error(`Response fails: ${err}`);
})
}
payOrderRequest() {
const hashMap: HashMap<string, string> = new HashMap()
this.dialog.open()
let trade_no = this.params.page == '课件详情'?this.kejianData.trade_no:String(this.songhuaData.trade_no)
hashMap.clear()
hashMap.set('channel', this.payType == 1?'balance':'wx')
hashMap.set('trade_no',trade_no)
hashMap.set('pwd',this.pwd)
hdHttp.httpReq<string>(this.params.page == '课件详情'?BasicConstant.payGanDanFileOrder:BasicConstant.payXinYiOrder,hashMap).then(async (res: HdResponse<string>) => {
console.info('Response payGanDanFileOrder'+res)
this.dialog.close()
let json:Record<string,string | Record<string,string>> = JSON.parse(res+'') as Record<string,string | Record<string,string>>;
if(json.code == '200') {
if (json.data != undefined) {
let req = new wxopensdk.PayReq
req.partnerId = json.data['partnerid']
req.appId = json.data['appid']
req.packageValue = json.data['package_str']
req.prepayId = json.data['prepayid']
req.nonceStr = json.data['noncestr']
req.timeStamp = json.data['timestamp']
req.sign = json.data['sign']
req.extData = 'extData'
let finished = await this.wxApi.sendReq(getContext(this) as common.UIAbilityContext, req)
console.info("send request finished: ", finished)
} else {
if (this.payType == 1) {
this.hintMessage = this.params.page == '课件详情'?'支付成功':'您已经成功送给肝胆相照送出心意'
this.alertView.open()
}
}
} else {
promptAction.showToast({ message: String(json.message), duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close()
console.error(`Response fails: ${err}`);
})
}
notificationRequest() {
const hashMap: HashMap<string, string> = new HashMap()
let trade_no = this.params.page == '课件详情'?this.kejianData.trade_no:String(this.songhuaData.trade_no)
this.dialog.open()
hashMap.clear()
hashMap.set('trade_no',trade_no)
hdHttp.httpReq<string>(BasicConstant.getOrderStatus,hashMap).then(async (res: HdResponse<string>) => {
console.info('Response getOrderStatus'+res)
this.dialog.close()
let json:Record<string,string | Record<string,string>> = JSON.parse(res+'') as Record<string,string | Record<string,string>>;
if(json.code == '200') {
if (this.payType == 2) {
let tradeState = json.data['tradeState'] as string
if (tradeState == 'SUCCESS') {
this.hintMessage = this.params.page == '课件详情'?'支付成功':'您已经成功送给肝胆相照送出心意'
this.alertView.open()
}
}
} else {
promptAction.showToast({ message: String(json.message), duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close()
console.error(`Response fails: ${err}`);
})
}
}
interface FileOrderData {
trade_no:string
order_id:string
amount:string
account:string
provider_name:string
}
@@ -258,7 +258,6 @@ export struct SchoolhouseComp {
ForEach(this.data, (item: PatientTBean, index) => {
ListItem() {
ItemCompTeach({item:item})
.onClick(()=>{this.pushDetailsView(item)})
}
})
}
@@ -266,25 +265,4 @@ export struct SchoolhouseComp {
.height('100%')
.edgeEffect(EdgeEffect.None)
}
private pushDetailsView(item: PatientTBean) {
const entity = {
"news_article_uuid":item.uuid,
"user_uuid": authStore.getUser().uuid,
"type":'2'
} as Record<string,string>
this.dialog.open()
hdHttp.post<string>(BasicConstant.read, entity).then(async (res: HdResponse<string>) => {
this.dialog.close();
console.info('Response delConditionRecord'+res);
let json:Record<string,string | Record<string,string> | Array<Record<string,string>>> = JSON.parse(res+'') as Record<string,string | Record<string,string> | Array<Record<string,string>>>;
if(json.code == '1') {
router.pushUrl({url:"pages/WebView/EducationDetailsWebPage",params:{"model":item}})
}
}).catch((err: BusinessError) => {
this.dialog.close();
console.error(`Response fails: ${err}`);
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
})
}
}
@@ -0,0 +1,343 @@
import { BasicConstant, ChangeUtil,
DefaultHintProWindows,
hdHttp, HdLoadingDialog, HdNav, HdResponse } from "@itcast/basic";
import { PullToRefreshLayout, RefreshController } from "refreshlib";
import { HashMap } from "@kit.ArkTS";
import { xinyiListData, xinyiRequest } from "../models/XinYiModel";
import { promptAction, router } from "@kit.ArkUI";
import { BusinessError, emitter } from "@kit.BasicServicesKit";
@Component
export struct SendFollowComp {
public controller:RefreshController = new RefreshController();
scroller = new Scroller();
@State pageNumber:number = 1;
@State totalPageNumer:number = 1;
@State xinyiList:xinyiListData[] = []
@State xinyiPrice:string = ''
@State sendPrice:string = ''
@State selectedAmount:number = 5
@State message:string = '祝肝胆相照平台越来越好!'
moneyOptions:number[] = [1,2,5,10,50]
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
alertView:CustomDialogController = new CustomDialogController({
builder:DefaultHintProWindows({
title:'提示',
message:'您确定是否送出',
cancleTitle:'否',
confirmTitle:'是',
cancleTitleColor: '#666666',
confirmTitleColor: $r('app.color.main_color'),
selectedButton: (index:number)=>{
this.alertView.close();
if (index == 1) {
this.createXinYiOrder()
}
}
}),
alignment: DialogAlignment.Center,
cornerRadius:24,
backgroundColor: ('rgba(0,0,0,0.5)'),
})
private refreshDataCallback = (eventData?: emitter.EventData): void => {
if (Object(eventData?.data)['status'] == 'success') {
this.pageNumber = 1;
this.getXinYiListData()
}
};
aboutToAppear(): void {
this.getXinyiPriceData()
this.getXinYiListData()
let innerEvent: emitter.InnerEvent = {
eventId: BasicConstant.notification_kejian_pay_success
}
emitter.on(innerEvent, this.refreshDataCallback)
}
aboutToDisappear(): void {
emitter.off(BasicConstant.notification_kejian_pay_success, this.refreshDataCallback)
}
getXinYiListData() {
const hashMap: HashMap<string, string> = new HashMap();
hashMap.set('page',this.pageNumber.toString());
this.dialog.open()
hdHttp.httpReq<string>(BasicConstant.allXinyiList,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:xinyiRequest = JSON.parse(res+'') as xinyiRequest;
if(json.code == '200') {
if(this.pageNumber==1) {
this.xinyiList=[]
if(json.data!=null) {
this.xinyiList = json.data.list;
}
} else if(this.pageNumber>1) {
this.xinyiList.push(...json.data.list)
}
this.totalPageNumer = json.data.total;
} else {
promptAction.showToast({ message: json.message, duration: 1000 })
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
getXinyiPriceData() {
const hashMap: HashMap<string, string> = new HashMap();
this.dialog.open()
hdHttp.httpReq<string>(BasicConstant.xinyiPrice,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:Record<string , string> = JSON.parse(res+'') as Record<string , string>;
if(json.code == '200') {
this.xinyiPrice = String(json.data)
this.sendPrice = ChangeUtil.formatPrice2(this.xinyiPrice,'5')
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
createXinYiOrder() {
const hashMap: HashMap<string, string> = new HashMap();
this.dialog.open()
hashMap.set('message',ChangeUtil.stringIsUndefinedAndNull(this.message)?'祝肝胆相照平台越来越好!':this.message)
hashMap.set('amount',this.selectedAmount.toString())
hdHttp.httpReq<string>(BasicConstant.createXinYiOrder,hashMap).then(async (res: HdResponse<string>) => {
this.dialog.close();
let json:Record<string , string | Record<string,string>> = JSON.parse(res+'') as Record<string , string | Record<string,string>>
if(json.code == '200') {
router.pushUrl({
url:"pages/Pay/PayPage",
params:{"data":json.data,"page":"送花"}
})
} else {
promptAction.showToast({message:'服务器异常',duration:1000})
}
}).catch((err: BusinessError) => {
this.dialog.close();
this.controller.refreshError();
console.info(`Response fails: ${err}`);
})
}
build() {
Row() {
Column() {
HdNav({title:'表达暖暖心意',showRightIcon:false,showRightText:false})
PullToRefreshLayout({
scroller:this.scroller,
viewKey:"ListPage",
controller:this.controller,
contentView:()=>{
this.contentView()
},
onRefresh:()=>{
this.pageNumber = 1;
setTimeout(() => {
this.controller.refreshSuccess()
}, 1000)
},
onCanPullRefresh:()=>{
if (!this.scroller.currentOffset()) {
/*处理无数据,为空的情况*/
return true
}
//如果列表到顶,返回true,表示可以下拉,返回false,表示无法下拉
return this.scroller.currentOffset().yOffset <= 0
},
onLoad:()=>{
this.pageNumber++;
this.getXinYiListData();
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() {
Column() {
List({scroller:this.scroller}) {
ListItemGroup({header:this.headerView()}) {
ForEach(this.xinyiList, (item: xinyiListData, index: number) => {
ListItem() {
Column() {
Row() {
Image(BasicConstant.urlImage + item.user_photo)
.alt($r('app.media.userPhoto_default'))
.width(50)
.height(50)
.borderRadius(5)
Column() {
Text(ChangeUtil.stringIsUndefinedAndNull(item.user_name) ? '账号已注销' : item.user_name)
.fontColor($r('app.color.main_color'))
.fontSize(16)
Text(item.message)
.fontSize(14)
.fontColor(Color.Grey)
}
.width('60%')
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Start)
.margin({left:10})
Text(item.create_date.length > 10 ? item.create_date.substring(0,10) : item.create_date)
.fontSize(12)
.textAlign(TextAlign.End)
.margin({top:10})
}
.width('100%')
Blank()
.height(1)
.width('100%')
.margin({top:10})
.backgroundColor('rgb(227,227,227)')
}
.width('100%')
.padding(10)
}
}, (item: xinyiListData) => item.create_date + item.user_name)
}
}
.width('100%')
.layoutWeight(1)
}
}
@Builder
headerView() {
Column() {
Blank()
.backgroundColor('rgb(227,228,229)')
.width('100%')
.height(10)
Image($r('app.media.patientLogo'))
.size({width:40,height:40})
.margin({top:10})
Text('肝胆相照')
.fontSize(16)
.margin({top:10})
.fontColor($r('app.color.main_color'))
Text('您的心意将用于肝胆相照平台的持续发展,有了您的支持,肝胆相照会越来越好,同时将给大家带来更多、更好的服务。')
.fontSize(11)
.fontColor('rgb(102,102,102)')
.margin({ left: 8, right: 8, top: 10 })
Blank()
.backgroundColor('rgb(227,227,227)')
.width('100%')
.height(1)
.margin({top:10})
Image($r("app.media.send_header_follow_icon"))
.size({width:75,height:75})
.margin({top:25})
Text(`¥ ${this.sendPrice}元`)
.fontSize(14)
.textAlign(TextAlign.Center)
.fontColor(Color.Red)
.margin({ top: 20 })
// 金额选项
Row() {
ForEach(this.moneyOptions, (money:number) => {
Text(`${money}`)
.backgroundColor(this.selectedAmount === money ? $r('app.color.main_color') : Color.White)
.fontColor(this.selectedAmount === money ? Color.White : $r('app.color.main_color'))
.fontSize(16)
.border({ width: 1, color: $r('app.color.main_color') })
.width(30)
.height(30)
.borderRadius(15)
.textAlign(TextAlign.Center)
.margin({ left: 10, right: 10, top: 12 })
.onClick(() => {
this.selectedAmount = money
this.sendPrice = ChangeUtil.formatPrice2(this.xinyiPrice,String(money))
})
})
}
.justifyContent(FlexAlign.Center)
.width('100%')
}
.width('100%')
// 留言输入
TextInput({ text: this.message, placeholder: '请输入您的祝福' })
.onChange((val:string) => this.message = val)
.margin({ left: 10, right: 10, top: 15 })
.height(55)
.borderRadius(8)
.fontSize(12)
.maxLength(100)
.backgroundColor('rgb(227,227,227)')
.onChange((value:string)=>{
this.message = value
})
// 送出按钮
Text('送出')
.fontSize(16)
.backgroundColor($r('app.color.main_color'))
.fontColor(Color.White)
.margin({ top: 10 })
.height(40)
.textAlign(TextAlign.Center)
.width('100%')
.onClick(() => {
this.alertView.open()
})
Blank()
.width('100%')
.height(10)
.backgroundColor('rgb(227,228,229)')
// 心意墙标题
Row() {
Image($r('app.media.send_follow_list_icon'))
.size({width:25,height:25})
Text('肝胆相照的心意墙')
.fontSize(18)
.fontColor($r('app.color.main_color'))
.margin({ left: 10 })
}
.width('100%')
.padding(10)
Blank()
.backgroundColor('rgb(227,228,229)')
.width('100%')
.height(1)
}
}
@@ -0,0 +1,49 @@
export interface newsRollNewRequest {
"code":string
"data":newsRequestOfData[]
"message":string
}
export interface newsRequestOfData {
"path":string
"title":string
"imgs":string
"imgpath":string
"author":string
"headImg":string
"name":string
"uuid":string
"projectName":string
"content":string
"projectType":string
"createDateStr":string
"createDate":string
"create_date":string
"contentText":string
"endDate":string
"summary":string
"readnum":string
"agreenum":string
"public_name":string
"HEAD_IMG":string
"TITLE":string
"editType":string
}
export interface newsTagRequest {
'code':string
'data':newsTagsRequestData[]
}
export interface newsTagsRequestData {
"NAME":string
"ID":string
}
export interface newsListRequest {
'code':string
'data':newsRequestOfData[]
'message':string
'totalPage':number
}
@@ -0,0 +1,17 @@
export interface xinyiRequest {
'code':string
'message':string
'data':xinyiRequestOfData
}
export interface xinyiRequestOfData {
'total':number
'list':xinyiListData[]
}
export interface xinyiListData {
'user_photo':string
'user_name':string
'message':string
'create_date':string
}
@@ -0,0 +1,33 @@
import { BasicConstant,authStore } from '@itcast/basic'
import HashMap from '@ohos.util.HashMap';
import { hdHttp, HdResponse} from '@itcast/basic/Index'
import { BusinessError } from '@kit.BasicServicesKit'
import { newsRequestOfData } from '../models/NewsModel';
import { router } from '@kit.ArkUI';
class NewsUtil {
hashMap: HashMap<string, string> = new HashMap();
readNews(uuid:string,model:newsRequestOfData) {
hdHttp.post<string>(BasicConstant.read, {
user_uuid: authStore.getUser().uuid,
news_article_uuid:uuid,
type: '1',
} as readExtraData).then(async (res: HdResponse<string>) => {
console.info('Response delConditionRecord'+res);
let json:Record<string,string | Record<string,string> | Array<Record<string,string>>> = JSON.parse(res+'') as Record<string,string | Record<string,string> | Array<Record<string,string>>>;
if(json.code == '1') {
router.pushUrl({url:"pages/WebView/NewsDetailsWebPage",params:{"model":model}})
}
}).catch((err: BusinessError) => {
console.error(`Response fails: ${err}`);
})
}
}
interface readExtraData{
user_uuid:string,
news_article_uuid:string,
type:string,
}
export const newsUtil = new NewsUtil()
@@ -1,5 +1,7 @@
import { BasicConstant, TimestampUtil } from '@itcast/basic';
import { authStore, BasicConstant, hdHttp, HdLoadingDialog, HdResponse, TimestampUtil } from '@itcast/basic';
import { PatientTBean } from '@itcast/basic/src/main/ets/models/TeachModel';
import { promptAction, router } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
@Preview
@@ -7,9 +9,12 @@ import { PatientTBean } from '@itcast/basic/src/main/ets/models/TeachModel';
export struct ItemCompTeach {
@Prop item:PatientTBean;
aboutToAppear(): void {
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
}
build() {
Column() {
Row() {
@@ -58,11 +63,32 @@ export struct ItemCompTeach {
.width('100%')
.padding(10)
.onClick(() => {
this.pushDetailsView(this.item)
})
Text().backgroundColor($r('app.color.efefef')).width('100%').height(1)
}
.backgroundColor(Color.White)
}
private pushDetailsView(item: PatientTBean) {
const entity = {
"news_article_uuid":item.uuid,
"user_uuid": authStore.getUser().uuid,
"type":'2'
} as Record<string,string>
this.dialog.open()
hdHttp.post<string>(BasicConstant.read, entity).then(async (res: HdResponse<string>) => {
this.dialog.close();
console.info('Response delConditionRecord'+res);
let json:Record<string,string | Record<string,string> | Array<Record<string,string>>> = JSON.parse(res+'') as Record<string,string | Record<string,string> | Array<Record<string,string>>>;
if(json.code == '1') {
router.pushUrl({url:"pages/WebView/EducationDetailsWebPage",params:{"model":item,"isAgree":json.isAgree}})
}
}).catch((err: BusinessError) => {
this.dialog.close();
console.error(`Response fails: ${err}`);
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
})
}
}
@@ -55,7 +55,7 @@ export struct KeJianItemComp {
.margin({ left: 2 })
.fontSize(13)
.fontColor(Color.Red)
Text(this.formatPrice(this.item.price))
Text(ChangeUtil.formatPrice(this.item.price))
.fontColor(Color.Red)
.fontSize(16)
}
@@ -79,14 +79,14 @@ export struct KeJianItemComp {
.margin({ left: 2 })
.fontSize(13)
.fontColor(Color.Red)
Text(this.formatPrice2(this.item.price, this.item.discount))
Text(ChangeUtil.formatPrice2(this.item.price, this.item.discount))
.fontColor(Color.Red)
.fontSize(16)
Text('原价')
.margin({ left: 10 })
.fontSize(12)
.fontColor('#999999')
Text('¥'+this.formatPrice(this.item.price))
Text('¥'+ChangeUtil.formatPrice(this.item.price))
.fontSize(12)
.fontColor('#999999')
.decoration({ type: TextDecorationType.LineThrough })
@@ -113,18 +113,6 @@ export struct KeJianItemComp {
.backgroundColor(Color.White)
}
private formatPrice(priceStr: string): string {
let priceInFen = parseFloat(priceStr);
let priceInYuan = priceInFen / 100;
return `${priceInYuan.toFixed(2)}`;
}
private formatPrice2(priceStr: string,discount: string): string {
let priceInFen = parseFloat(priceStr);
let priceInYuan = priceInFen / 100 * parseFloat(discount);
return `${priceInYuan.toFixed(2)}`;
}
private contentShow(name:string,hospital:string):string {
let newname:string = ''
let newhospital:string = ''
@@ -0,0 +1,67 @@
import { authStore, BasicConstant,
ChangeUtil,
hdHttp, HdLoadingDialog, HdResponse, TimestampUtil } from '@itcast/basic';
import { newsRequestOfData } from '../models/NewsModel';
import { newsUtil } from '../utils/NewsUtil';
@Preview
@Component
export struct NewsItemView {
@Prop item:newsRequestOfData;
build() {
Column() {
Row() {
Image(ChangeUtil.stringIsUndefinedAndNull(this.item.headImg)?BasicConstant.urlHtml+this.item.imgs:BasicConstant.urlHtml+this.item.headImg).width(114).height(76).alt($r('app.media.home_scroll_default1'))
.alt($r('app.media.home_top_scroll_default'))
Column() {
Text(ChangeUtil.stringIsUndefinedAndNull(this.item.title)?this.item.projectName:this.item.title).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.createDate) ? Visibility.Visible : Visibility.None)
Text(this.item.createDate.length > 10 ? this.item.createDate.substring(5, 10) : this.item.createDate)
.fontColor($r('app.color.common_gray_03'))
.fontSize(12)
.visibility(!TimestampUtil.isToday(this.item.createDate) ? Visibility.Visible : Visibility.None)
}.width(80).align(Alignment.Start)
Row() {
Image($r('app.media.read_commient')).width(10).height(10)
Text(Number(this.item.readnum) > 100000 ? Number(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(Number(this.item.agreenum) > 100000 ? Number(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(() => {
newsUtil.readNews(this.item.uuid,this.item)
})
Text().backgroundColor($r('app.color.efefef')).width('100%').height(1)
}
.backgroundColor(Color.White)
}
}
@@ -0,0 +1,79 @@
import { AppUtil, BasicConstant,hdHttp, HdResponse ,logger} from '@itcast/basic/Index'
import { BusinessError } from '@kit.BasicServicesKit';
import { HdLoadingDialog } from '@itcast/basic'
import HashMap from '@ohos.util.HashMap';
import { newsRequestOfData, newsRollNewRequest } from '../models/NewsModel';
import { newsUtil } from '../utils/NewsUtil';
@Component
export struct NewsSwiperView {
@State list: newsRequestOfData[] = []
dialog: CustomDialogController = new CustomDialogController({
builder: HdLoadingDialog({ message: '加载中...' }),
customStyle: true,
alignment: DialogAlignment.Center
})
aboutToAppear(): void {
this.initData()
}
initData() {
const hashMap: HashMap<string, string> = new HashMap();
this.dialog.open()
hashMap.clear();
hdHttp.httpReq<string>(BasicConstant.newsRollNew,hashMap).then(async (res: HdResponse<string>) => {
logger.info('Response newsRollNew'+res);
let json:newsRollNewRequest = JSON.parse(res+'') as newsRollNewRequest;
this.dialog.close();
this.list = json.data
}).catch((err: BusinessError) => {
this.dialog.close();
})
}
build() {
Column() { // 使用堆叠布局实现按钮覆盖
Swiper() {
ForEach(this.list, (item: newsRequestOfData) => {
Stack({alignContent:Alignment.Bottom}) {
Image(BasicConstant.urlHtml + item.headImg)
.objectFit(ImageFit.Fill)// 图片填充模式
.width('100%')
.height(AppUtil.getDisplayWindowWidth().vp / 16 * 9)
Text(item.title)
.maxLines(1)
.height(30)
.fontColor('#F6F6F6')
.textAlign(TextAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.backgroundColor('#88000000')
.width('100%')
.padding({right:100,left:5})
.margin({ bottom: 0 })
}.onClick(()=>{
newsUtil.readNews(item.uuid,item)
})
}, (item: newsRequestOfData) => JSON.stringify(item))
}
.indicator(
Indicator.dot()
.right(0)
.itemWidth(4)
.itemHeight(4)
.selectedItemWidth(4)
.selectedItemHeight(4)
.color($r('app.color.common_gray_02'))
.selectedColor('#3cc9c0')
)
.loop(true)
.autoPlay(true)
.interval(3000)
.onChange((index: number) => {
})
}
.width('100%')
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB