1.2.0部分代码
This commit is contained in:
@@ -4,7 +4,7 @@ import { window } from '@kit.ArkUI';
|
||||
import notificationManager from '@ohos.notificationManager';
|
||||
import { PLVMediaPlayerStartUp } from '../startup/PLVMediaPlayerStartUp';
|
||||
import contextConstant from '@ohos.app.ability.contextConstant';
|
||||
import { patientDbManager } from '@itcast/basic';
|
||||
import { patientDbManager, WXApi, WXEventHandler } from '@itcast/basic';
|
||||
import { HMRouterMgr } from '@hadss/hmrouter'
|
||||
import { BusinessError } from '@kit.BasicServicesKit'
|
||||
|
||||
@@ -16,6 +16,8 @@ export default class EntryAbility extends UIAbility {
|
||||
this.checkNotificationStatus(); // 首次检查
|
||||
// 初始化患者数据库
|
||||
this.initPatientDatabase();
|
||||
//微信
|
||||
this.handleWeChatCallIfNeed(want)
|
||||
|
||||
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
|
||||
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
|
||||
@@ -89,4 +91,12 @@ export default class EntryAbility extends UIAbility {
|
||||
// 错误处理,例如保持当前状态或设置为默认值
|
||||
}
|
||||
}
|
||||
|
||||
onNewWant(want: Want, _launchParam: AbilityConstant.LaunchParam): void {
|
||||
this.handleWeChatCallIfNeed(want)
|
||||
}
|
||||
|
||||
private handleWeChatCallIfNeed(want: Want) {
|
||||
WXApi.handleWant(want, WXEventHandler)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { HdNav } from '@itcast/basic'
|
||||
import { router } from '@kit.ArkUI'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct AllDownloadPage {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HdNav({title:'我的下载',showRightIcon:false,showRightText:false})
|
||||
|
||||
Column() {
|
||||
Row(){
|
||||
Text('课件文档')
|
||||
.fontSize(16)
|
||||
.layoutWeight(1)
|
||||
Image($r('app.media.arrow_right'))
|
||||
.width(7)
|
||||
.height(10)
|
||||
.margin({right:10})
|
||||
}
|
||||
.width('100%')
|
||||
.height('calc(100% - 1vp)')
|
||||
}
|
||||
.width('100%')
|
||||
.height(50)
|
||||
.padding(10)
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(()=>{
|
||||
router.pushUrl({url:'pages/Download/KeJianDownloadPage'})
|
||||
})
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
.backgroundColor('#f1f1f1')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
import { DefaultHintProWindows, HdNav } from '@itcast/basic'
|
||||
import { FileManager } from '@itcast/basic'
|
||||
import { FileInfo } from '@itcast/basic'
|
||||
import { common } from '@kit.AbilityKit'
|
||||
import { promptAction } from '@kit.ArkUI'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct KeJianDownloadPage {
|
||||
@State fileList: FileInfo[] = []
|
||||
private fileManager: FileManager | null = null
|
||||
@State selected:number = 0
|
||||
|
||||
alertView:CustomDialogController = new CustomDialogController({
|
||||
builder:DefaultHintProWindows({
|
||||
title:'提示',
|
||||
message:'确定删除该课件?',
|
||||
cancleTitleColor: '#666666',
|
||||
confirmTitleColor: $r('app.color.main_color'),
|
||||
selectedButton: (index:number)=>{
|
||||
this.alertView.close();
|
||||
if (index == 1) {
|
||||
this.deleteFile(this.fileList[this.selected].fileId)
|
||||
}
|
||||
}
|
||||
}),
|
||||
alignment: DialogAlignment.Center,
|
||||
cornerRadius:24,
|
||||
backgroundColor: ('rgba(0,0,0,0.5)'),
|
||||
})
|
||||
|
||||
aboutToAppear() {
|
||||
this.initFileManager()
|
||||
this.loadDownloadedFiles()
|
||||
}
|
||||
|
||||
private initFileManager() {
|
||||
try {
|
||||
const context = getContext(this) as common.UIAbilityContext
|
||||
this.fileManager = new FileManager(context)
|
||||
} catch (error) {
|
||||
console.error('初始化文件管理器失败:', error)
|
||||
promptAction.showToast({ message: '初始化失败', duration: 2000 })
|
||||
}
|
||||
}
|
||||
|
||||
private async loadDownloadedFiles() {
|
||||
try {
|
||||
if (this.fileManager) {
|
||||
this.fileList = await this.fileManager.getDownloadedFiles()
|
||||
console.info(`加载了 ${this.fileList.length} 个已下载文件`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载文件列表失败:', error)
|
||||
promptAction.showToast({ message: '加载失败', duration: 2000 })
|
||||
}
|
||||
}
|
||||
|
||||
private async previewFile(fileId: string) {
|
||||
try {
|
||||
if (this.fileManager) {
|
||||
await this.fileManager.previewFile(fileId)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('预览文件失败:', error)
|
||||
promptAction.showToast({ message: '预览失败', duration: 2000 })
|
||||
}
|
||||
}
|
||||
|
||||
private async deleteFile(fileId: string) {
|
||||
try {
|
||||
if (this.fileManager) {
|
||||
const success = await this.fileManager.deleteFile(fileId)
|
||||
if (success) {
|
||||
this.fileList = this.fileList.filter(file => file.fileId !== fileId)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('删除文件失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HdNav({title:'课件文档',showRightIcon:false,showRightText:false})
|
||||
|
||||
if (this.fileList.length === 0) {
|
||||
Column() {
|
||||
Text('暂无下载课件')
|
||||
.fontSize(16)
|
||||
.fontColor('#999999')
|
||||
.margin({ top: 10 })
|
||||
}
|
||||
.width('100%')
|
||||
.height(200)
|
||||
.justifyContent(FlexAlign.Center)
|
||||
} else {
|
||||
List() {
|
||||
ForEach(this.fileList, (file: FileInfo, index: number) => {
|
||||
ListItem() {
|
||||
Row() {
|
||||
Text(file.fileName)
|
||||
.fontSize(16)
|
||||
.fontColor('#333333')
|
||||
.fontWeight(FontWeight.Medium)
|
||||
.maxLines(1)
|
||||
.textOverflow({ overflow: TextOverflow.Ellipsis })
|
||||
.layoutWeight(1)
|
||||
}
|
||||
.height(50)
|
||||
.width('100%')
|
||||
.padding(10)
|
||||
.backgroundColor(Color.White)
|
||||
.onClick(() => {
|
||||
this.previewFile(file.fileId)
|
||||
})
|
||||
}
|
||||
.swipeAction({
|
||||
end: {
|
||||
builder: () => { this.itemEnd(index) },
|
||||
}
|
||||
})
|
||||
}, (file: FileInfo) => file.fileId)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
.backgroundColor('#f1f1f1')
|
||||
}
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
.backgroundColor('#F5F5F5')
|
||||
}
|
||||
|
||||
@Builder
|
||||
itemEnd(index: number) {
|
||||
Text('删除')
|
||||
.fontSize(14)
|
||||
.fontColor(Color.White)
|
||||
.backgroundColor(Color.Red)
|
||||
.textAlign(TextAlign.Center)
|
||||
.size({width:60,height:50})
|
||||
.borderRadius(4)
|
||||
.onClick(() => {
|
||||
this.selected = index
|
||||
this.alertView.open()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { FlowerDetailsComp } from 'study'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct FlowerDetailsPage {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
FlowerDetailsComp()
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import { NimRepository } from '../../entryability/NimRepository'
|
||||
import { AppConfig } from '../../constants/AppConfig'
|
||||
import { PerfactInputSheet } from '@itcast/basic/src/main/ets/Views/PerfactInputSheet'
|
||||
import { LengthMetrics, router } from '@kit.ArkUI'
|
||||
import { TimestampUtil } from '@itcast/basic'
|
||||
import { TimestampUtil, WXApi } from '@itcast/basic'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@@ -65,6 +65,7 @@ struct LoginPage {
|
||||
this.dialog.open()
|
||||
}
|
||||
|
||||
console.info('是否安装微信:',WXApi.isWXAppInstalled())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { VideoPage } from 'home'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct MeetingPage {
|
||||
|
||||
build() {
|
||||
Column(){
|
||||
VideoPage()
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ struct SettingPage {
|
||||
getVersion() {
|
||||
bundleManager.getBundleInfoForSelf(
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA
|
||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA | bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_SIGNATURE_INFO
|
||||
)
|
||||
.then((res) => {
|
||||
this.version = 'V' + res.versionName
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { NewsListComp } from 'study'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct GandanNewsListPage {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
NewsListComp()
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { NewsComp } from 'study'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct GandanNewsPages {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
NewsComp()
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { PayComp } from 'study';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct PayPage {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
PayComp()
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { SendFollowComp } from 'study'
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct SendFollowPage {
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
SendFollowComp()
|
||||
}
|
||||
.height('100%')
|
||||
.width('100%')
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
import webview from '@ohos.web.webview';
|
||||
import { BasicConstant, HdNav, preferenceStore } from '@itcast/basic';
|
||||
import { authStore, BasicConstant, hdHttp, HdLoadingDialog, HdNav, HdResponse, preferenceStore } from '@itcast/basic';
|
||||
import router from '@ohos.router';
|
||||
import { image } from '@kit.ImageKit';
|
||||
import { photoAccessHelper } from '@kit.MediaLibraryKit';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
import { fileIo, fileUri } from '@kit.CoreFileKit';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { PatientTBean } from '@itcast/basic/src/main/ets/models/TeachModel';
|
||||
|
||||
@@ -13,6 +10,10 @@ import { PatientTBean } from '@itcast/basic/src/main/ets/models/TeachModel';
|
||||
struct EducationDetailsWebPage {
|
||||
private controller: webview.WebviewController = new webview.WebviewController();
|
||||
@State params:RouteParams = router.getParams() as RouteParams;
|
||||
@State isDianZan:boolean = String(this.params.isAgree)=='1'?true:false
|
||||
@State isShouCang:boolean = false
|
||||
@State agreenum:string = this.params.model.agreenum.toString()
|
||||
@State readnum:string = this.params.model.readnum.toString()
|
||||
|
||||
// 修改为移动端User-Agent,解决链接中有视频的问题
|
||||
private customUserAgent: string = 'Mozilla/5.0 (Linux; Android 10; HarmonyOS) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 gdxz-expert';
|
||||
@@ -22,6 +23,16 @@ struct EducationDetailsWebPage {
|
||||
@State url: string = BasicConstant.urlHtml+this.params.model.path;
|
||||
@State title: string = '患教详情';
|
||||
|
||||
dialog: CustomDialogController = new CustomDialogController({
|
||||
builder: HdLoadingDialog({ message: '加载中...' }),
|
||||
customStyle: true,
|
||||
alignment: DialogAlignment.Center
|
||||
})
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.getKepuDetailsData()
|
||||
}
|
||||
|
||||
onBackPress(): boolean | void {
|
||||
if (this.controller.accessStep(-1)) {
|
||||
this.controller.backward();
|
||||
@@ -64,24 +75,173 @@ struct EducationDetailsWebPage {
|
||||
|
||||
})
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
.height('calc(100% - 80vp)')
|
||||
.height('calc(100% - 156vp)')
|
||||
.clip(true)
|
||||
|
||||
Row(){
|
||||
Row(){
|
||||
Image('')
|
||||
Image($r('app.media.eye_main_color'))
|
||||
.size({width:20,height:20})
|
||||
.objectFit(ImageFit.Contain)
|
||||
Text(this.readnum)
|
||||
.margin({left:10})
|
||||
.fontSize(15)
|
||||
.fontColor(Color.Gray)
|
||||
}
|
||||
.margin({left:15,top:12})
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.width(80)
|
||||
.margin({top:12})
|
||||
.layoutWeight(1)
|
||||
Row(){
|
||||
Image(this.isDianZan?$r('app.media.yi_dian_zan'):$r('app.media.wei_dian_zan'))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.size({width:20,height:20})
|
||||
Text(this.agreenum)
|
||||
.margin({left:10})
|
||||
.fontSize(15)
|
||||
.fontColor(Color.Gray)
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.width(80)
|
||||
.margin({top:12})
|
||||
.layoutWeight(1)
|
||||
.onClick(()=>{
|
||||
this.setAgreeData(this.isDianZan?"0":"1")
|
||||
})
|
||||
Row(){
|
||||
Image(this.isShouCang?$r('app.media.yi_shou_cang'):$r('app.media.wei_shou_cang'))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.size({width:20,height:20})
|
||||
Text('收藏')
|
||||
.margin({left:10})
|
||||
.fontSize(15)
|
||||
.fontColor(Color.Gray)
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.width(80)
|
||||
.margin({top:12})
|
||||
.layoutWeight(1)
|
||||
.onClick(()=>{
|
||||
this.setCollectionData(this.isShouCang?"0":"1")
|
||||
})
|
||||
Row(){
|
||||
Image($r('app.media.fenxiang'))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.size({width:20,height:20})
|
||||
Text('分享')
|
||||
.margin({left:10})
|
||||
.fontSize(15)
|
||||
.fontColor(Color.Gray)
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.width(80)
|
||||
.margin({top:12})
|
||||
.layoutWeight(1)
|
||||
.onClick(()=>{
|
||||
promptAction.showToast({ message:'敬请期待', duration: 1000 })
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.alignItems(VerticalAlign.Top)
|
||||
.backgroundColor(Color.White)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
|
||||
getKepuDetailsData() {
|
||||
const entity = {
|
||||
"uuid":this.params.model.uuid,
|
||||
"user_uuid": authStore.getUser().uuid
|
||||
} as Record<string,string>
|
||||
this.dialog.open()
|
||||
hdHttp.post<string>(BasicConstant.getKePuCollection, 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') {
|
||||
let isCollection = json.isCollection
|
||||
if (isCollection == '1') {
|
||||
this.isShouCang = true
|
||||
} else {
|
||||
this.isShouCang = false
|
||||
}
|
||||
this.readnum = String(json.readnum)
|
||||
this.agreenum = String(json.agreenum)
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close();
|
||||
console.error(`Response fails: ${err}`);
|
||||
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
|
||||
})
|
||||
}
|
||||
|
||||
setCollectionData(type:string) {//0取消收藏;1收藏
|
||||
const entity = {
|
||||
"other_uuid":this.params.model.uuid,
|
||||
"user_uuid": authStore.getUser().uuid,
|
||||
"title":this.params.model.topic,
|
||||
"path":this.params.model.path,
|
||||
"imgpath":this.params.model.imgPath,
|
||||
"readnum":this.readnum,
|
||||
"type":"2"
|
||||
} as Record<string,string>
|
||||
this.dialog.open()
|
||||
hdHttp.post<string>(type=='0'?BasicConstant.discollection:BasicConstant.collection, 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') {
|
||||
if (type == '0') {
|
||||
this.isShouCang = false
|
||||
promptAction.showToast({ message: '取消收藏成功', duration: 1000 })
|
||||
} else {
|
||||
this.isShouCang = true
|
||||
promptAction.showToast({ message: '收藏成功', duration: 1000 })
|
||||
}
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close();
|
||||
console.error(`Response fails: ${err}`);
|
||||
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
|
||||
})
|
||||
}
|
||||
|
||||
setAgreeData(type:string) {//0取消点赞;1点赞
|
||||
const entity = {
|
||||
"news_article_uuid":this.params.model.uuid,
|
||||
"user_uuid": authStore.getUser().uuid,
|
||||
"type":"2"
|
||||
} as Record<string,string>
|
||||
this.dialog.open()
|
||||
hdHttp.post<string>(type=='0'?BasicConstant.disagree:BasicConstant.agree, 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') {
|
||||
if (type == '0') {
|
||||
this.agreenum = String(Number(this.agreenum)-1)
|
||||
this.isDianZan = false
|
||||
promptAction.showToast({ message: '取消点赞成功', duration: 1000 })
|
||||
} else {
|
||||
this.agreenum = String(Number(this.agreenum)+1)
|
||||
this.isDianZan = true
|
||||
promptAction.showToast({ message: '点赞成功', duration: 1000 })
|
||||
}
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close();
|
||||
console.error(`Response fails: ${err}`);
|
||||
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface RouteParams {
|
||||
model:PatientTBean
|
||||
isAgree:string
|
||||
}
|
||||
@@ -0,0 +1,553 @@
|
||||
import webview from '@ohos.web.webview';
|
||||
import {
|
||||
authStore, BasicConstant,
|
||||
ChangeUtil,
|
||||
DefaultHintProWindows,
|
||||
FileManager,
|
||||
FileInfo,
|
||||
hdHttp, HdLoadingDialog, HdNav, HdResponse, preferenceStore,
|
||||
WXApi,
|
||||
AESEncryptionDecryption} from '@itcast/basic';
|
||||
import router from '@ohos.router';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
import { BusinessError, emitter } from '@kit.BasicServicesKit';
|
||||
import { KeJianModel } from 'study/src/main/ets/models/KeJianModel';
|
||||
import { HashMap } from '@kit.ArkTS';
|
||||
import * as wxopensdk from '@tencent/wechat_open_sdk';
|
||||
import { common, Want } from '@kit.AbilityKit';
|
||||
import { http } from '@kit.NetworkKit';
|
||||
import { fileIo } from '@kit.CoreFileKit';
|
||||
import request from '@ohos.request';
|
||||
|
||||
export enum OrderStatus {
|
||||
status_default = 0,/**不能点击 */
|
||||
status_pay = 1,/**付费下载 */
|
||||
status_free = 2,/**免费下载 */
|
||||
status_download = 3,/**重新下载 */
|
||||
status_check = 4,/**查看课件 */
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct KeJianDetailsWebPage {
|
||||
private controller: webview.WebviewController = new webview.WebviewController();
|
||||
@State params:RouteParams = router.getParams() as RouteParams;
|
||||
|
||||
// 修改为移动端User-Agent,解决链接中有视频的问题
|
||||
private customUserAgent: string = 'Mozilla/5.0 (Linux; Android 10; HarmonyOS) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 gdxz-expert';
|
||||
private hcp_token:string = preferenceStore.getItemString(BasicConstant.EXPERT_HCP_TOKEN)
|
||||
|
||||
private wxApi = WXApi
|
||||
@State btnStatus: number = OrderStatus.status_default
|
||||
@State contentWidth: number = 0;
|
||||
@State contentHeight: number = 0;
|
||||
@State url: string = BasicConstant.urlHtml+this.params.model.preview_path;
|
||||
@State title: string = '课件详情';
|
||||
@State downloadImage: ResourceStr = ''
|
||||
@State isShowDownloadImage: boolean = false
|
||||
@State downloadState: string = ''
|
||||
@State collectionIcon: ResourceStr = $r('app.media.wei_shou_cang')
|
||||
@State kejianDetailsData : RequestData = {} as RequestData
|
||||
@State hintMessage:string = ''
|
||||
@State downType:string = ''
|
||||
@State down_order_id:string = ''
|
||||
@State isUseFreeRecord:boolean = false
|
||||
@State isUserWelfareNum:boolean = false
|
||||
@State system_time:string = ''
|
||||
|
||||
private context: common.Context = getContext(this) as common.Context;
|
||||
private fileManager: FileManager = new FileManager(this.context);
|
||||
|
||||
dialog: CustomDialogController = new CustomDialogController({
|
||||
builder: HdLoadingDialog({ message: '加载中...' }),
|
||||
customStyle: true,
|
||||
alignment: DialogAlignment.Center
|
||||
})
|
||||
|
||||
alertView:CustomDialogController = new CustomDialogController({
|
||||
builder:DefaultHintProWindows({
|
||||
title:'提示',
|
||||
message:this.hintMessage,
|
||||
cancleTitleColor: '#666666',
|
||||
confirmTitleColor: $r('app.color.main_color'),
|
||||
selectedButton: (index:number)=>{
|
||||
this.alertView.close();
|
||||
if (index == 1) {//确定按钮
|
||||
if (this.btnStatus == OrderStatus.status_free) {
|
||||
if (this.hintMessage.includes('确定要下载')) {
|
||||
this.chackNetStatusAction()
|
||||
}
|
||||
} else if (this.btnStatus == OrderStatus.status_pay) {
|
||||
if (this.hintMessage.includes('免费下载机会')) {
|
||||
if (this.kejianDetailsData.welfareNum !== '0') {
|
||||
this.isUserWelfareNum = true
|
||||
this.useWelfareData()
|
||||
} else {
|
||||
if (this.kejianDetailsData.freeRecord !== '0') {
|
||||
this.isUseFreeRecord = true
|
||||
this.chackNetStatusAction()
|
||||
} else {
|
||||
this.chackNetStatusAction()
|
||||
}
|
||||
}
|
||||
} else if (this.hintMessage.includes('确定要下载')) {
|
||||
this.creatOrderData()
|
||||
} else if (this.hintMessage.includes('正使用手机网络')) {
|
||||
this.downloadFileAction()
|
||||
}
|
||||
}
|
||||
} else {//取消按钮
|
||||
if (this.btnStatus == OrderStatus.status_pay) {
|
||||
if (this.hintMessage.includes('免费下载机会')) {
|
||||
this.creatOrderData()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
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.chackNetStatusAction()
|
||||
}
|
||||
};
|
||||
|
||||
onPageShow(): void {
|
||||
this.getKeJianDetailsData()
|
||||
}
|
||||
|
||||
aboutToDisappear(): void {
|
||||
emitter.off(BasicConstant.notification_kejian_pay_success, this.refreshDataCallback)
|
||||
}
|
||||
|
||||
aboutToAppear(): void {
|
||||
let innerEvent: emitter.InnerEvent = {
|
||||
eventId: BasicConstant.notification_kejian_pay_success
|
||||
}
|
||||
emitter.on(innerEvent, this.refreshDataCallback)
|
||||
if (this.params.model.preview_path.includes('http')) {
|
||||
this.url = this.params.model.preview_path
|
||||
}
|
||||
}
|
||||
|
||||
onBackPress(): boolean | void {
|
||||
if (this.controller.accessStep(-1)) {
|
||||
this.controller.backward();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
if (WXApi.isWXAppInstalled()) {
|
||||
HdNav({
|
||||
title: this.title,
|
||||
showRightIcon: true,
|
||||
rightIcon: $r('app.media.fenxiang'),
|
||||
twoRightIcon: this.collectionIcon,
|
||||
hasBorder: true,
|
||||
isLeftAction: true,
|
||||
showTwoRightItem: true,
|
||||
leftItemAction: () => {
|
||||
if (this.controller.accessBackward()) {
|
||||
this.controller.backward();
|
||||
} else {
|
||||
if (this.fileManager.isDownloadingFile()) {
|
||||
promptAction.showToast({message:'当前有课件正在下载,请稍等...'})
|
||||
} else {
|
||||
router.back();
|
||||
}
|
||||
}
|
||||
},
|
||||
rightItemAction: () => {
|
||||
let shareUrl = new wxopensdk.WXWebpageObject
|
||||
shareUrl.type = 5
|
||||
shareUrl.webpageUrl = `${this.url}&fromtype=doctor`
|
||||
let mediaMessage = new wxopensdk.WXMediaMessage()
|
||||
mediaMessage.title = this.params.model.title
|
||||
mediaMessage.description = '肝胆相照-国内专业优质肝胆课件共享平台'
|
||||
mediaMessage.mediaObject = shareUrl
|
||||
let req = new wxopensdk.SendMessageToWXReq()
|
||||
req.scene = 0
|
||||
req.message = mediaMessage
|
||||
let finished = this.wxApi.sendReq(getContext(this) as common.UIAbilityContext, req)
|
||||
console.log("send request finished: ", finished)
|
||||
},
|
||||
twoRightItemAction: () => {
|
||||
this.setCollectionData(this.kejianDetailsData.iscollection == '0' ? '1' : '0')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
HdNav({
|
||||
title: this.title,
|
||||
showRightIcon: true,
|
||||
rightIcon: this.collectionIcon,
|
||||
hasBorder: true,
|
||||
isLeftAction: true,
|
||||
leftItemAction: () => {
|
||||
if (this.controller.accessBackward()) {
|
||||
this.controller.backward();
|
||||
} else {
|
||||
if (this.fileManager.isDownloadingFile()) {
|
||||
promptAction.showToast({message:'当前有课件正在下载,请稍等...'})
|
||||
} else {
|
||||
router.back();
|
||||
}
|
||||
}
|
||||
},
|
||||
rightItemAction: () => {
|
||||
this.setCollectionData(this.kejianDetailsData.iscollection == '0' ? '1' : '0')
|
||||
}
|
||||
})
|
||||
}
|
||||
Stack() {
|
||||
Web({
|
||||
src: this.url,
|
||||
controller: this.controller
|
||||
})
|
||||
.id('webView')
|
||||
.mixedMode(MixedMode.All)
|
||||
.overScrollMode(OverScrollMode.ALWAYS)
|
||||
.domStorageAccess(true)
|
||||
.onControllerAttached(() => {
|
||||
let userAgent = this.controller.getUserAgent() + this.customUserAgent;
|
||||
this.controller.setCustomUserAgent(userAgent);
|
||||
})
|
||||
.onPageBegin(() => {
|
||||
this.dialog.open()
|
||||
this.controller.runJavaScript(`document.cookie = 'hcp_from=expert_app; domain=.igandan.com; path=/';`)
|
||||
this.controller.runJavaScript(`document.cookie = 'hcp_token=${this.hcp_token}; domain=.igandan.com; path=/';`)
|
||||
})
|
||||
.onPageEnd(() => {
|
||||
this.dialog.close()
|
||||
// 注入JS获取body高度
|
||||
this.controller.runJavaScript(
|
||||
'document.documentElement.scrollWidth', (error, result) => {
|
||||
if (!error) this.contentWidth = Number(result);
|
||||
}
|
||||
);
|
||||
this.controller.runJavaScript('document.body.scrollHeight', (error, result) => {
|
||||
if (!error) this.contentHeight = Number(result);
|
||||
})
|
||||
})
|
||||
.width('100%')
|
||||
.layoutWeight(1)
|
||||
|
||||
Row(){
|
||||
Image(this.downloadImage)
|
||||
.size({width:16,height:16})
|
||||
.visibility(this.isShowDownloadImage?Visibility.Visible:Visibility.None)
|
||||
Text(this.downloadState)
|
||||
.fontSize(18)
|
||||
.fontColor(Color.White)
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.backgroundColor(Color.Gray)
|
||||
.width('100%')
|
||||
.height(44)
|
||||
.onClick(()=>{
|
||||
if (this.btnStatus == OrderStatus.status_check) {
|
||||
// 查看已下载文件
|
||||
this.fileManager.previewFile(this.params.model.uuid)
|
||||
} else if (this.btnStatus == OrderStatus.status_download) {
|
||||
// 重新下载
|
||||
this.downloadFileAction()
|
||||
} else if (this.btnStatus == OrderStatus.status_pay) {
|
||||
if (this.kejianDetailsData.welfareNum == '0') {
|
||||
if (this.kejianDetailsData.freeRecord == '0') {
|
||||
this.hintMessage = '您确定要下载该课件吗'
|
||||
this.alertView.open()
|
||||
} else {
|
||||
this.hintMessage = `您还有${this.getFreeDownLoadCount()}次免费下载机会,希望本次下载免费吗?`
|
||||
this.alertView.open()
|
||||
}
|
||||
} else {
|
||||
this.hintMessage = `您还有${this.getFreeDownLoadCount()}次免费下载机会,希望本次下载免费吗?`
|
||||
this.alertView.open()
|
||||
}
|
||||
} else if (this.btnStatus == OrderStatus.status_free) {
|
||||
this.hintMessage = '您确定要下载该课件吗'
|
||||
this.alertView.open()
|
||||
}
|
||||
})
|
||||
}
|
||||
.alignContent(Alignment.Top)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
|
||||
getKeJianDetailsData() {
|
||||
const hashMap: HashMap<string, string> = new HashMap()
|
||||
this.dialog.open()
|
||||
hashMap.clear()
|
||||
hashMap.set('file_uuid', this.params.model.uuid)
|
||||
hdHttp.httpReq<string>(BasicConstant.ganDanFileDetials,hashMap).then(async (res: HdResponse<string>) => {
|
||||
console.info('Response ganDanFileDetials'+res)
|
||||
this.dialog.close()
|
||||
let json:Record<string,string | RequestData> = JSON.parse(res+'') as Record<string,string | RequestData>;
|
||||
if(json.code == '200') {
|
||||
this.kejianDetailsData = json.data as RequestData
|
||||
if (this.kejianDetailsData.iscollection == '0') {
|
||||
this.collectionIcon = $r('app.media.wei_shou_cang')
|
||||
} else {
|
||||
this.collectionIcon = $r('app.media.yi_shou_cang')
|
||||
}
|
||||
if (this.kejianDetailsData.order == null || this.kejianDetailsData.order == undefined) {//没有订单
|
||||
if (parseFloat(this.kejianDetailsData.price) < 0) {
|
||||
this.btnStatus = 0
|
||||
this.downloadImage = ''
|
||||
this.isShowDownloadImage = false
|
||||
this.downloadState = '本课件不支持下载'
|
||||
} else {
|
||||
this.btnStatus = 2
|
||||
this.downloadImage = $r('app.media.kejian_download_white')
|
||||
this.isShowDownloadImage = true
|
||||
this.downloadState = ' 本课件免费下载'
|
||||
}
|
||||
if (parseFloat(this.kejianDetailsData.price) > 0) {
|
||||
this.btnStatus = 1
|
||||
this.downloadImage = $r('app.media.kejian_download_white')
|
||||
this.isShowDownloadImage = true
|
||||
this.downloadState = `本课件下载${ChangeUtil.formatPrice(this.kejianDetailsData.price)}元`
|
||||
}
|
||||
} else {//有订单
|
||||
try {
|
||||
const downloadedFiles = await this.fileManager.getDownloadedFiles();
|
||||
const downloadedFile = downloadedFiles.find(file => file.fileId === this.params.model.uuid);
|
||||
if (downloadedFile && downloadedFile.filePath && fileIo.accessSync(downloadedFile.filePath)) {
|
||||
// 本地已存在,显示查看文件
|
||||
this.btnStatus = OrderStatus.status_check
|
||||
this.downloadImage = ''
|
||||
this.isShowDownloadImage = false
|
||||
this.downloadState = '查看课件'
|
||||
} else {
|
||||
// 本地不存在,显示重新下载
|
||||
this.down_order_id = `${this.kejianDetailsData.order['order_id']}&R`
|
||||
this.btnStatus = OrderStatus.status_download
|
||||
this.downloadImage = ''
|
||||
this.isShowDownloadImage = false
|
||||
this.downloadState = '重新下载本课件'
|
||||
}
|
||||
} catch (e) {
|
||||
// 异常情况下,默认提供重新下载
|
||||
this.btnStatus = OrderStatus.status_download
|
||||
this.downloadImage = ''
|
||||
this.isShowDownloadImage = false
|
||||
this.downloadState = ' 重新下载'
|
||||
}
|
||||
}
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close()
|
||||
console.error(`Response fails: ${err}`);
|
||||
})
|
||||
}
|
||||
|
||||
chackNetStatusAction() {
|
||||
if (hdHttp.getNetworkType() == 2) {
|
||||
this.hintMessage = '您当前正使用手机网络,是否继续下载?'
|
||||
this.alertView.open()
|
||||
} else if (hdHttp.getNetworkType() == 1 || hdHttp.getNetworkType() == 3) {
|
||||
this.downloadFileAction()
|
||||
} else if (hdHttp.getNetworkType() == 0 || hdHttp.getNetworkType() == -1) {
|
||||
this.hintMessage = '未连接网络,请设置'
|
||||
this.alertView.open()
|
||||
}
|
||||
}
|
||||
|
||||
downloadFileAction() {
|
||||
let httpRequest = http.createHttp();
|
||||
let timeStampurl = BasicConstant.getSystemTime;
|
||||
let promise = httpRequest.request(timeStampurl, {
|
||||
method: http.RequestMethod.GET,
|
||||
connectTimeout: 60000,
|
||||
readTimeout: 60000,
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
promise.then(async (data) => {
|
||||
if (data.responseCode === http.ResponseCode.OK) {
|
||||
let json:TimestampBean = JSON.parse(data.result.toString()) as TimestampBean
|
||||
let daijiami:string = ''
|
||||
if (this.btnStatus == OrderStatus.status_free) {
|
||||
daijiami = `${this.params.model.uuid}|FREE|${authStore.getUser().uuid}|${json.system_time}`
|
||||
} else if (this.btnStatus == OrderStatus.status_download) {
|
||||
daijiami = `${this.params.model.uuid}|${this.down_order_id}|${authStore.getUser().uuid}|${json.system_time}`
|
||||
}
|
||||
if (this.isUseFreeRecord) {
|
||||
daijiami = `${this.params.model.uuid}|FREERECORD|${authStore.getUser().uuid}|${json.system_time}`
|
||||
}
|
||||
if (this.kejianDetailsData.welfareNum != '0') {
|
||||
if (this.isUserWelfareNum) {
|
||||
daijiami = `${this.params.model.uuid}|USEWELFARENUM|${authStore.getUser().uuid}|${json.system_time}`
|
||||
}
|
||||
}
|
||||
const scanData = await AESEncryptionDecryption.aesEncrypt(daijiami,BasicConstant.ExpertAesKey)
|
||||
let x: number = 10;
|
||||
let valueINTT: number = Math.floor(Math.random() * x) + 1;
|
||||
let pinString = `${getChars(valueINTT)}${scanData}`
|
||||
let downloadUrl = `${BasicConstant.urlExpertApp}downloadGanDanFile?&gdf=${pinString}&a=${valueINTT}`
|
||||
console.info('开始下载文件,URL:', downloadUrl);
|
||||
const fileInfo: FileInfo = {
|
||||
fileId: this.params.model.uuid,
|
||||
fileName: this.params.model.title,
|
||||
fileType: this.params.model.type,
|
||||
fileSize: 0,
|
||||
fileUrl: downloadUrl,
|
||||
downloadStatus: 'pending',
|
||||
downloadProgress: 0,
|
||||
createTime: Date.now(),
|
||||
updateTime: Date.now()
|
||||
};
|
||||
promptAction.showToast({ message: '开始下载,请勿重复点击', duration: 1000 })
|
||||
this.fileManager.downloadFile(fileInfo, {
|
||||
onSuccess: (filePath: string) => {
|
||||
this.btnStatus = OrderStatus.status_check
|
||||
this.downloadImage = ''
|
||||
this.downloadState = '查看课件'
|
||||
},
|
||||
onFailed: (error: string) => {
|
||||
console.info('fileDownload,error:',error)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
).catch((err: BusinessError) => {
|
||||
return Promise.reject(err);
|
||||
}).finally(() => {
|
||||
httpRequest.destroy()
|
||||
})
|
||||
}
|
||||
|
||||
setCollectionData(type:string) {//0取消收藏;1收藏
|
||||
const entity = {
|
||||
"other_uuid":this.params.model.uuid,
|
||||
"user_uuid": authStore.getUser().uuid,
|
||||
"title":this.params.model.title,
|
||||
"path":this.params.model.preview_path,
|
||||
"type":"6"
|
||||
} as Record<string,string>
|
||||
this.dialog.open()
|
||||
hdHttp.post<string>(type=='0'?BasicConstant.discollection:BasicConstant.collection, 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') {
|
||||
if (type == '0') {
|
||||
this.collectionIcon = $r('app.media.wei_shou_cang')
|
||||
promptAction.showToast({ message: '取消收藏成功', duration: 1000 })
|
||||
} else {
|
||||
this.collectionIcon = $r('app.media.yi_shou_cang')
|
||||
promptAction.showToast({ message: '收藏成功', duration: 1000 })
|
||||
}
|
||||
this.getKeJianDetailsData()
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close();
|
||||
console.error(`Response fails: ${err}`);
|
||||
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
|
||||
})
|
||||
}
|
||||
|
||||
creatOrderData() {
|
||||
const hashMap: HashMap<string, string> = new HashMap()
|
||||
this.dialog.open()
|
||||
hashMap.clear()
|
||||
hashMap.set('file_uuid', this.params.model.uuid)
|
||||
hdHttp.httpReq<string>(BasicConstant.createGanDanFileOrder,hashMap).then(async (res: HdResponse<string>) => {
|
||||
console.info('Response ganDanFileDetials'+res)
|
||||
this.dialog.close()
|
||||
let json:Record<string,string | FileOrderData> = JSON.parse(res+'') as Record<string,string | FileOrderData>;
|
||||
if(json.code == '200') {
|
||||
router.pushUrl({
|
||||
url:"pages/Pay/PayPage",
|
||||
params:{"data":json.data,"page":"课件详情"}
|
||||
})
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close()
|
||||
console.error(`Response fails: ${err}`);
|
||||
})
|
||||
}
|
||||
|
||||
useWelfareData() {
|
||||
const hashMap: HashMap<string, string> = new HashMap()
|
||||
this.dialog.open()
|
||||
hashMap.clear()
|
||||
hashMap.set('type', '2')
|
||||
hashMap.set('other_uuid',this.params.model.uuid)
|
||||
hdHttp.httpReq<string>(BasicConstant.useWelfareNum,hashMap).then(async (res: HdResponse<string>) => {
|
||||
console.info('Response useWelfareNum'+res)
|
||||
this.dialog.close()
|
||||
let json:Record<string,string > = JSON.parse(res+'') as Record<string,string>;
|
||||
if(json.code == '1') {
|
||||
this.downloadFileAction()
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close()
|
||||
console.error(`Response fails: ${err}`);
|
||||
})
|
||||
}
|
||||
|
||||
private getFreeDownLoadCount():string {
|
||||
let count = Number(this.kejianDetailsData.welfareNum)+Number(this.kejianDetailsData.freeRecord)
|
||||
return count.toString()
|
||||
}
|
||||
}
|
||||
|
||||
interface RouteParams {
|
||||
model:KeJianModel
|
||||
}
|
||||
|
||||
interface RequestData {
|
||||
iscollection:string
|
||||
welfareNum:string
|
||||
freeRecord:string
|
||||
fileSize:string
|
||||
fileMD5:string
|
||||
price:string
|
||||
order:object
|
||||
}
|
||||
|
||||
interface FileOrderData {
|
||||
trade_no:string
|
||||
order_id:string
|
||||
amount:string
|
||||
account:string
|
||||
provider_name:string
|
||||
file_uuid:string
|
||||
order_status:string
|
||||
}
|
||||
|
||||
export interface TimestampBean {
|
||||
system_time:string
|
||||
}
|
||||
|
||||
export function getChars(number_od_chars:number):string {
|
||||
// 创建字符数组并填充随机大写字母
|
||||
let data: string[] = [];
|
||||
for (let i: number = 0; i < number_od_chars; i++) {
|
||||
// 生成A-Z的随机字母
|
||||
let randomChar: string = String.fromCharCode(65 + Math.floor(Math.random() * 26));
|
||||
data.push(randomChar);
|
||||
}
|
||||
|
||||
// 将字符数组转换为字符串
|
||||
let stringValue: string = data.join('');
|
||||
return stringValue
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
import webview from '@ohos.web.webview';
|
||||
import { authStore, BasicConstant, hdHttp, HdLoadingDialog, HdNav, HdResponse } from '@itcast/basic';
|
||||
import router from '@ohos.router';
|
||||
import { promptAction } from '@kit.ArkUI';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { newsRequestOfData } from 'study';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct NewsDetailsWebPage {
|
||||
private controller: webview.WebviewController = new webview.WebviewController();
|
||||
@State params:RouteParams = router.getParams() as RouteParams;
|
||||
@State isDianZan:boolean = String(this.params.isAgree)=='1'?true:false
|
||||
@State isShouCang:boolean = false
|
||||
@State agreenum:string = this.params.model.agreenum.toString()
|
||||
@State readnum:string = this.params.model.readnum.toString()
|
||||
|
||||
// 修改为移动端User-Agent,解决链接中有视频的问题
|
||||
private customUserAgent: string = 'Mozilla/5.0 (Linux; Android 10; HarmonyOS) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 gdxz-expert';
|
||||
|
||||
@State contentWidth: number = 0;
|
||||
@State contentHeight: number = 0;
|
||||
@State url: string = BasicConstant.urlHtml+this.params.model.path;
|
||||
@Prop title: string = '新闻详情';
|
||||
|
||||
dialog: CustomDialogController = new CustomDialogController({
|
||||
builder: HdLoadingDialog({ message: '加载中...' }),
|
||||
customStyle: true,
|
||||
alignment: DialogAlignment.Center
|
||||
})
|
||||
|
||||
aboutToAppear(): void {
|
||||
this.getNewsDetailsData()
|
||||
}
|
||||
|
||||
onBackPress(): boolean | void {
|
||||
if (this.controller.accessStep(-1)) {
|
||||
this.controller.backward();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
build() {
|
||||
Column() {
|
||||
HdNav({ title: this.title, showRightIcon: false, hasBorder: true ,isLeftAction:true,leftItemAction:()=>{
|
||||
if (this.controller.accessBackward()) {
|
||||
this.controller.backward();
|
||||
} else {
|
||||
router.back();
|
||||
}
|
||||
}})
|
||||
Web({
|
||||
src: this.url,
|
||||
controller: this.controller
|
||||
})
|
||||
.id('webView')
|
||||
.mixedMode(MixedMode.All)
|
||||
.overScrollMode(OverScrollMode.ALWAYS)
|
||||
.domStorageAccess(true)
|
||||
.onControllerAttached(() => {
|
||||
let userAgent = this.controller.getUserAgent() + this.customUserAgent;
|
||||
this.controller.setCustomUserAgent(userAgent);
|
||||
})
|
||||
.onPageEnd(() => {
|
||||
// 注入JS获取body高度
|
||||
this.controller.runJavaScript(
|
||||
'document.documentElement.scrollWidth', (error, result) => {
|
||||
if (!error) this.contentWidth = Number(result);
|
||||
}
|
||||
);
|
||||
this.controller.runJavaScript('document.body.scrollHeight',(error,result)=>{
|
||||
if (!error) this.contentHeight = Number(result);
|
||||
})
|
||||
|
||||
})
|
||||
.width('100%')
|
||||
.height('calc(100% - 156vp)')
|
||||
.clip(true)
|
||||
|
||||
Row(){
|
||||
Row(){
|
||||
Image($r('app.media.eye_main_color'))
|
||||
.size({width:20,height:20})
|
||||
.objectFit(ImageFit.Contain)
|
||||
Text(this.readnum)
|
||||
.margin({left:10})
|
||||
.fontSize(15)
|
||||
.fontColor(Color.Gray)
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.width(80)
|
||||
.margin({top:12})
|
||||
.layoutWeight(1)
|
||||
Row(){
|
||||
Image(this.isDianZan?$r('app.media.yi_dian_zan'):$r('app.media.wei_dian_zan'))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.size({width:20,height:20})
|
||||
Text(this.agreenum)
|
||||
.margin({left:10})
|
||||
.fontSize(15)
|
||||
.fontColor(Color.Gray)
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.width(80)
|
||||
.margin({top:12})
|
||||
.layoutWeight(1)
|
||||
.onClick(()=>{
|
||||
this.setAgreeData(this.isDianZan?"0":"1")
|
||||
})
|
||||
Row(){
|
||||
Image(this.isShouCang?$r('app.media.yi_shou_cang'):$r('app.media.wei_shou_cang'))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.size({width:20,height:20})
|
||||
Text('收藏')
|
||||
.margin({left:10})
|
||||
.fontSize(15)
|
||||
.fontColor(Color.Gray)
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.width(80)
|
||||
.margin({top:12})
|
||||
.layoutWeight(1)
|
||||
.onClick(()=>{
|
||||
this.setCollectionData(this.isShouCang?"0":"1")
|
||||
})
|
||||
Row(){
|
||||
Image($r('app.media.fenxiang'))
|
||||
.objectFit(ImageFit.Contain)
|
||||
.size({width:20,height:20})
|
||||
Text('分享')
|
||||
.margin({left:10})
|
||||
.fontSize(15)
|
||||
.fontColor(Color.Gray)
|
||||
}
|
||||
.justifyContent(FlexAlign.Center)
|
||||
.width(80)
|
||||
.margin({top:12})
|
||||
.layoutWeight(1)
|
||||
.onClick(()=>{
|
||||
promptAction.showToast({ message:'敬请期待', duration: 1000 })
|
||||
})
|
||||
}
|
||||
.width('100%')
|
||||
.alignItems(VerticalAlign.Top)
|
||||
}
|
||||
.width('100%')
|
||||
.height('100%')
|
||||
}
|
||||
|
||||
getNewsDetailsData() {
|
||||
const entity = {
|
||||
"uuid":this.params.model.uuid,
|
||||
"user_uuid": authStore.getUser().uuid
|
||||
} as Record<string,string>
|
||||
this.dialog.open()
|
||||
hdHttp.post<string>(BasicConstant.newsDetial, 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') {
|
||||
let isCollection = json.isCollection
|
||||
if (isCollection == '1') {
|
||||
this.isShouCang = true
|
||||
} else {
|
||||
this.isShouCang = false
|
||||
}
|
||||
this.readnum = String(json.readnum)
|
||||
this.agreenum = String(json.agreenum)
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close();
|
||||
console.error(`Response fails: ${err}`);
|
||||
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
|
||||
})
|
||||
}
|
||||
|
||||
setCollectionData(type:string) {//0取消收藏;1收藏
|
||||
const entity = {
|
||||
"other_uuid":this.params.model.uuid,
|
||||
"user_uuid": authStore.getUser().uuid,
|
||||
"title":this.params.model.title,
|
||||
"path":this.params.model.path,
|
||||
"imgpath":this.params.model.imgpath,
|
||||
"readnum":this.readnum,
|
||||
"type":"1"
|
||||
} as Record<string,string>
|
||||
this.dialog.open()
|
||||
hdHttp.post<string>(type=='0'?BasicConstant.discollection:BasicConstant.collection, 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') {
|
||||
if (type == '0') {
|
||||
this.isShouCang = false
|
||||
promptAction.showToast({ message: '取消收藏成功', duration: 1000 })
|
||||
} else {
|
||||
this.isShouCang = true
|
||||
promptAction.showToast({ message: '收藏成功', duration: 1000 })
|
||||
}
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close();
|
||||
console.error(`Response fails: ${err}`);
|
||||
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
|
||||
})
|
||||
}
|
||||
|
||||
setAgreeData(type:string) {//0取消点赞;1点赞
|
||||
const entity = {
|
||||
"news_article_uuid":this.params.model.uuid,
|
||||
"user_uuid": authStore.getUser().uuid,
|
||||
"type":"1"
|
||||
} as Record<string,string>
|
||||
this.dialog.open()
|
||||
hdHttp.post<string>(type=='0'?BasicConstant.disagree:BasicConstant.agree, 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') {
|
||||
if (type == '0') {
|
||||
this.agreenum = String(Number(this.agreenum)-1)
|
||||
this.isDianZan = false
|
||||
promptAction.showToast({ message: '取消点赞成功', duration: 1000 })
|
||||
} else {
|
||||
this.agreenum = String(Number(this.agreenum)+1)
|
||||
this.isDianZan = true
|
||||
promptAction.showToast({ message: '点赞成功', duration: 1000 })
|
||||
}
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
}).catch((err: BusinessError) => {
|
||||
this.dialog.close();
|
||||
console.error(`Response fails: ${err}`);
|
||||
promptAction.showToast({ message: String('患教文库数据请求失败!'), duration: 1000 })
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface RouteParams {
|
||||
model:newsRequestOfData
|
||||
isAgree:string
|
||||
}
|
||||
@@ -72,7 +72,16 @@
|
||||
"name": "ohos.permission.WRITE_MEDIA",
|
||||
"reason": "$string:media_reason",
|
||||
"usedScene": {}
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.READ_WRITE_USER_FILE",
|
||||
"reason": "$string:write_file",
|
||||
"usedScene": {}
|
||||
}
|
||||
],
|
||||
"querySchemes": [
|
||||
"weixin",
|
||||
"wxopensdk"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,17 @@
|
||||
"pages/VideoPage/CustomScanResultPage",
|
||||
"pages/VideoPage/EducationVideoPage",
|
||||
"pages/Courseware/CoursewarePage",
|
||||
"pages/WebView/EducationDetailsWebPage"
|
||||
"pages/WebView/EducationDetailsWebPage",
|
||||
"pages/WebView/KeJianDetailsWebPage",
|
||||
"pages/Pay/PayPage",
|
||||
"pages/News/GandanNewsPages",
|
||||
"pages/WebView/NewsDetailsWebPage",
|
||||
"pages/Meeting/MeetingPage",
|
||||
"pages/News/GandanNewsListPage",
|
||||
"pages/Pay/SendFollowPage",
|
||||
"pages/Download/AllDownloadPage",
|
||||
"pages/Download/KeJianDownloadPage",
|
||||
"pages/Flower/FlowerDetailsPage",
|
||||
"pages/Courseware/CourseDetailsPage"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user