第一次提交

This commit is contained in:
xiaoxiao
2025-05-09 15:47:54 +08:00
parent 25e596b591
commit f9d7986df0
357 changed files with 26943 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test
+28
View File
@@ -0,0 +1,28 @@
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": false,
"files": [
"./obfuscation-rules.txt"
]
}
}
}
},
],
"targets": [
{
"name": "default"
},
{
"name": "ohosTest",
}
]
}
+6
View File
@@ -0,0 +1,6 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}
+23
View File
@@ -0,0 +1,23 @@
# Define project specific obfuscation rules here.
# You can include the obfuscation configuration files in the current module's build-profile.json5.
#
# For more details, see
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
# Obfuscation options:
# -disable-obfuscation: disable all obfuscations
# -enable-property-obfuscation: obfuscate the property names
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
# -compact: remove unnecessary blank spaces and all line feeds
# -remove-log: remove all console.* statements
# -print-namecache: print the name cache that contains the mapping from the old names to new names
# -apply-namecache: reuse the given cache file
# Keep options:
# -keep-property-name: specifies property names that you want to keep
# -keep-global-name: specifies names that you want to keep in the global scope
-enable-property-obfuscation
-enable-toplevel-obfuscation
-enable-filename-obfuscation
-enable-export-obfuscation
+66
View File
@@ -0,0 +1,66 @@
{
"meta": {
"stableOrder": true
},
"lockfileVersion": 3,
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
"specifiers": {
"@itcast/basic@../../commons/basic": "@itcast/basic@../../commons/basic",
"@ohos/crypto-js@^2.0.4": "@ohos/crypto-js@2.0.4",
"home@../../features/Home": "home@../../features/Home",
"mypage@../../features/mypage": "mypage@../../features/mypage",
"register@../../features/register": "register@../../features/register",
"utils@../../commons/utils": "utils@../../commons/utils"
},
"packages": {
"@itcast/basic@../../commons/basic": {
"name": "@itcast/basic",
"version": "1.0.0",
"resolved": "../../commons/basic",
"registryType": "local"
},
"@ohos/crypto-js@2.0.4": {
"name": "@ohos/crypto-js",
"version": "2.0.4",
"integrity": "sha512-589ur6oqU1UNibqefMly2cwEeEhkSoCAA3uc+oNUwRnYYtevn/kQnO+Coi36N+VJSeeg/uFzZk1K/wUMdovpOA==",
"resolved": "https://repo.harmonyos.com/ohpm/@ohos/crypto-js/-/crypto-js-2.0.4.har",
"registryType": "ohpm"
},
"home@../../features/Home": {
"name": "home",
"version": "1.0.0",
"resolved": "../../features/Home",
"registryType": "local",
"dependencies": {
"@itcast/basic": "file:../../commons/basic"
}
},
"mypage@../../features/mypage": {
"name": "mypage",
"version": "1.0.0",
"resolved": "../../features/mypage",
"registryType": "local",
"dependencies": {
"@itcast/basic": "file:../../commons/basic"
}
},
"register@../../features/register": {
"name": "register",
"version": "1.0.0",
"resolved": "../../features/register",
"registryType": "local",
"dependencies": {
"@itcast/basic": "file:../../commons/basic"
}
},
"utils@../../commons/utils": {
"name": "utils",
"version": "1.0.0",
"resolved": "../../commons/utils",
"registryType": "local",
"dependencies": {
"@ohos/crypto-js": "^2.0.4"
}
}
}
}
+15
View File
@@ -0,0 +1,15 @@
{
"name": "expert",
"version": "1.0.0",
"description": "Please describe the basic information.",
"main": "",
"author": "",
"license": "",
"dependencies": {
"@itcast/basic": "file:../../commons/basic",
"utils": "file:../../commons/utils",
"mypage":"file:../../features/mypage",
"home": 'file:../../features/Home',
"register": 'file:../../features/register'
}
}
@@ -0,0 +1,15 @@
import { TabBarCompModel } from '../models/TabBarCompModel'
export const TabBarItems: TabBarCompModel[] = [
{
defaultIcon: $r('app.media.video_tabbar_icon'),
activeIcon: $r('app.media.video_tabbar_selected_icon'),
label: '视频'
},
{
defaultIcon: $r('app.media.my_tabbar_icon'),
activeIcon: $r('app.media.my_tabbar_selected_icon'),
label: '我的'
}
]
@@ -0,0 +1,61 @@
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
import { window } from '@kit.ArkUI';
import notificationManager from '@ohos.notificationManager';
const DOMAIN = 0x0000;
export default class EntryAbility extends UIAbility {
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
AppStorage.Set('notificationEnabled', false); // 假设默认关闭
this.checkNotificationStatus(); // 首次检查
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
}
onDestroy(): void {
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: window.WindowStage): void {
// Main window is created, set main page for this ability
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/BootPage', (err) => {
if (err.code) {
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
return;
}
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
});
}
onWindowStageDestroy(): void {
// Main window is destroyed, release UI related resources
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground(): void {
// Ability has brought to foreground
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground(): void {
// Ability has back to background
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
}
// 检查系统通知状态并更新 AppStorage 的方法
async checkNotificationStatus() {
try {
let isEnabled = await notificationManager.isNotificationEnabled();
console.info(`Notification enabled status: ${isEnabled}`);
// 更新 AppStorage 中的通知状态
AppStorage.Set('notificationEnabled', isEnabled);
} catch (err) {
console.error(`Failed to check notification status: ${JSON.stringify(err)}`);
// 错误处理,例如保持当前状态或设置为默认值
}
}
}
@@ -0,0 +1,16 @@
import { hilog } from '@kit.PerformanceAnalysisKit';
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
const DOMAIN = 0x0000;
export default class EntryBackupAbility extends BackupExtensionAbility {
async onBackup() {
hilog.info(DOMAIN, 'testTag', 'onBackup ok');
await Promise.resolve();
}
async onRestore(bundleVersion: BundleVersion) {
hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
await Promise.resolve();
}
}
@@ -0,0 +1,14 @@
export interface StartBean{
code:string;
data:Start;
message:string;
}
export interface Start {
uuid:string
status:string
note:string
type:string
path:string
url:string
}
@@ -0,0 +1,6 @@
export class TabBarCompModel {
defaultIcon: ResourceStr = ''
activeIcon: ResourceStr = ''
label: string = ''
}
@@ -0,0 +1,242 @@
import { authStore, themeManager,hdHttp } from '@itcast/basic'
import { router } from '@kit.ArkUI'
import { preferenceStore,DataWebModel, logger,HdResponse } from '@itcast/basic'
import { BasicConstant } from '@itcast/basic'
import { BusinessError } from '@kit.BasicServicesKit';
import { StartBean } from '../models/StartModel'
@Entry
@Component
struct BootPage {
@StorageProp('topHeight')
topHeight: number = 0
@State
time: number = 3
timer: number | null = null
@State
isFirstRun:boolean=preferenceStore.getItemBooleanT('isFirstRun')
@State
isLogin:boolean=preferenceStore.getItemBooleanF('isLogin')
@State
photoUrl:ResourceStr=$r('app.media.startIcon')
@State
newUrl:string='';
aboutToAppear(): void {
themeManager.initThemeSetting()
themeManager.enableFullScreen()
authStore.initUser()
getContext().getApplicationContext().getRunningProcessInformation()
if(this.isFirstRun)
{
}
else if(this.isLogin)
{
this.getPhoto()
}
}
dialog = new CustomDialogController({
builder: PrivacyDialog(),
cornerRadius: 4,
})
startTick()
{
this.timer = setInterval(() => {
this.time--
if (this.time <= 0) {
this.goNextPage();
}
}, 1000)
}
goNextPage()
{
clearInterval(this.timer)
router.replaceUrl({ url: 'pages/Home' })
}
onPageShow(): void {
if(this.isFirstRun)
{
this.dialog.open()
}
else if(this.isLogin)
{
this.startTick()
}
else
{
router.replaceUrl({ url: 'pages/LoginPage/LoginPage' })
}
}
onPageHide(): void {
if(this.isFirstRun)
{
this.dialog.close()
}
}
aboutToDisappear(): void {
clearInterval(this.timer)
}
build() {
RelativeContainer() {
if(this.isFirstRun)
{
}
else
{
if(this.newUrl!='')
{
Text( this.time + 's' + ' | 跳过')
.width(70)
.height(30)
.borderRadius(15)
.textAlign(TextAlign.Center)
.fontSize(14)
.backgroundColor('#33000000')
.fontColor($r('app.color.white'))
.alignRules({
right: { anchor: "__container__", align: HorizontalAlign.End }
})
.margin({ right: 20, top: this.topHeight + 20 })
.onClick(()=>{
this.goNextPage()
})
Row()
{
Text('点击跳转至详情页')
.height(70)
.textAlign(TextAlign.Center)
.fontSize(21)
.fontColor($r('app.color.white'))
Image($r('app.media.gohere'))
.width(22)
.margin({left:2})
}
.backgroundColor('#80000000')
.borderRadius(39)
.border({
width: 3,
color: $r('app.color.white')
})
.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align:HorizontalAlign.Center }
})
.margin({bottom:200})
.padding({right:55,left:55})
.height(70)
.onClick(()=>{
clearInterval(this.timer)
this.goNextPage()
try {
router.pushUrl({
url: 'pages/WebView/WebPage',
params: { url: this.newUrl ,title:'肝胆相照'}
}, router.RouterMode.Standard);
} catch (err) {
console.error(`跳转失败: ${err.code}, ${err.message}`);
}
})
}
}
}
.width('100%')
.height('100%')
.backgroundImage(this.photoUrl)
.backgroundImageSize(ImageSize.FILL)
.geometryTransition("boot")
.transition(TransitionEffect.OPACITY)
}
getPhoto()
{
hdHttp.httpReqSimply<string>(BasicConstant.getStartpage).then(async (res: HdResponse<string>) => {
logger.info('Response StartBean'+res);
let json:StartBean = JSON.parse(res+'') as StartBean;
//
if(json.code=='1')
{
this.photoUrl=BasicConstant.urlHtml+json.data.path
this.newUrl=json.data.url
logger.info('Response photoUrl'+this.photoUrl);
}
}).catch((err: BusinessError) => {
console.info(`Response login succeeded: ${err}`);
})
}
}
@CustomDialog
struct PrivacyDialog {
controller: CustomDialogController
build() {
Column({ space: 10 }) {
Text('温馨提示')
.fontSize(18)
Text() {
Span('欢迎使用肝胆相照,在使用本软件前,请认真阅读').fontColor($r('app.color.common_gray_03'))
Span('《隐私政策》').fontColor('#ff0000').onClick(() => {
this.controller.close()
ToWeb(BasicConstant.getyyzc,'《隐私政策》')
})
Span(',您同意并接受全部条款后方可使用肝胆相照App。').fontColor($r('app.color.common_gray_03'))
}
.fontSize(16)
Flex({ justifyContent: FlexAlign.SpaceAround }) {
Button("不同意并退出")
.onClick(() => {
if (this.controller != undefined) {
this.controller.close()
router.back()
}
}).backgroundColor(0xffffff).fontColor($r('app.color.top_title'))
Button("同意")
.onClick(() => {
preferenceStore.setItemBoolean('isFirstRun',false)
if (this.controller != undefined ) {
this.controller.close()
router.replaceUrl({ url: 'pages/Index' })
}
}).backgroundColor(0xffffff).fontColor(Color.Black)
}.margin({ bottom: 10 })
}
.justifyContent(FlexAlign.Center)
.backgroundColor($r('app.color.white'))
.padding(20)
}
}
function ToWeb(u:string,t:string)
{
let paramsInfo: DataWebModel = {
url:u ,
title:t
};
router.pushUrl({
url: 'pages/WebView/WebPage', // 目标url
params: paramsInfo // 添加params属性,传递自定义参数
})
}
@@ -0,0 +1,62 @@
import { TabBarComp } from '../pages/Tabbar/TabBarComp';
import { themeManager } from '@itcast/basic';
import { emitter } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { promptAction } from '@kit.ArkUI';
@Entry
@Component
struct Home {
@State
@Watch('onChangeIndex')
activeIndex: number = 0
aboutToAppear(): void {
emitter.on({ eventId: 10000 }, (e) => {
if (e.data && e.data.activeIndex) {
this.activeIndex = e.data.activeIndex
}
})
}
onChangeIndex() {
if (this.activeIndex === 3) themeManager.settingStatusBarWhite()
else themeManager.settingStatusBarBlack()
}
onPageShow(): void {
console.log('--onPageShow--');
emitter.emit('notification_status_changed')
this.onChangeIndex()
}
onPageHide(): void {
console.log('onPageHide');
this.onChangeIndex()
themeManager.settingStatusBarBlack()
this.backTimes = 0
}
backTimes: number = 0
onBackPress(): boolean | void {
this.backTimes++
if (this.backTimes <= 1) {
promptAction.showToast({ message: '再按一次将退出应用' })
}
if (this.backTimes >= 2) {
const ctx = getContext() as common.UIAbilityContext
ctx.terminateSelf()
}
return true
}
build() {
Flex() {
TabBarComp({ activeIndex: this.activeIndex })
}
.backgroundColor($r('app.color.white'))
}
}
@@ -0,0 +1,11 @@
import { GuidePage } from 'register'
@Entry
@Component
struct Index {
build() {
Column() {
GuidePage()
}
}
}
@@ -0,0 +1,11 @@
import { LoginComp } from 'register'
@Entry
@Component
struct LoginPage {
build() {
Column() {
LoginComp()
}
}
}
@@ -0,0 +1,11 @@
import { LoginSetInfo } from 'register'
@Entry
@Component
struct LoginSetInfoPage {
build() {
Column() {
LoginSetInfo()
}
}
}
@@ -0,0 +1,82 @@
import { HdNav } from '@itcast/basic';
import { promptAction } from '@kit.ArkUI'
@Entry
@Component
struct CancelAccount {
@State feedbackText: string =
' 账户注销后不可恢复,您将永久放弃此账户现有权益\n' +
' 1.您将不能再使用此账户随访患者,不能接收随访患者发送的信息\n' +
' 2.您所有的咨询、订单、下载记录将被清除且不能找回\n' +
' 3.肝胆相照平台提供的文献、视频等服务将结束\n' +
' 4.申请注销账户前,请确保账户相关权益已结清\n' +
' 收到您的注销申请后,我们将在10个工作日内帮您完成注销及数据清除工作'
controller:TextAreaController = new TextAreaController();
build() {
Column() {
HdNav({ title: '注销账户', showRightIcon: false, hasBorder: true })
Row() {
Text(this.feedbackText)
.fontSize(13)
.margin(8)
}
.width('100%')
.height('auto')
.margin(0)
.backgroundColor(Color.White)
.borderRadius(5)
.border({
width:1,
color:$r('app.color.main_color')
})
// 提交按钮
Button('我已确认风险,提交注销申请', {
type: ButtonType.Normal,
stateEffect: true
})
.fontSize(13)
.fontColor(Color.White)
.width('90%')
.height(45)
.backgroundColor('#8B2316')
.borderRadius(3)
.margin(20)
.border({
width:1,
color:'#8B2316'
})
.onClick(() => this.submitFeedback())
}
.width('100%')
.height('100%')
.backgroundColor(Color.White)
}
// 提交反馈处理
private submitFeedback(): void {
// 提交逻辑实现
promptAction.showDialog({
title:'注销账户',
message:'确定要注销肝胆相照平台账号吗?\n注销后您的所有数据将无法恢复',
alignment:DialogAlignment.Center,
buttons:[
{
text:'取消',
color:'#333333'
},
{
text:'确定',
color:'#999999'
}
]
})
.then(data=>{
console.info('showDialog success, click button: '+data.index)
})
.catch((error:Error)=>{
console.info('showDialog error:'+error)
})
}
}
@@ -0,0 +1,13 @@
import { ChangePasswordComp } from 'mypage'
import { HdNav } from '@itcast/basic';
@Entry
@Component
struct ChangePassword {
build() {
Column(){
HdNav({ title: '修改登录密码', showRightIcon: false, hasBorder: true })
ChangePasswordComp();
}
}
}
@@ -0,0 +1,13 @@
import { ChangePhoneComp, ForgetPasswordComp } from 'mypage'
import { HdNav } from '@itcast/basic';
@Entry
@Component
struct ChangePhonePage {
build() {
Column(){
HdNav({ title: '更换手机号', showRightIcon: false, hasBorder: true })
ChangePhoneComp();
}
}
}
@@ -0,0 +1,13 @@
import { ChooseEmailComp } from 'mypage'
import { HdNav } from '@itcast/basic';
@Entry
@Component
struct ChooseEmail {
build() {
Column() {
HdNav({ title: '修改邮箱', showRightIcon: false, hasBorder: true })
ChooseEmailComp();
}
}
}
@@ -0,0 +1,13 @@
import { ChooseOfficePhoneComp } from 'mypage'
import { HdNav } from '@itcast/basic';
@Entry
@Component
struct ChooseOfficePhone {
build() {
Column() {
HdNav({ title: '修改科室电话', showRightIcon: false, hasBorder: true })
ChooseOfficePhoneComp();
}
}
}
@@ -0,0 +1,69 @@
import promptAction from '@ohos.promptAction';
import { authStore } from '@itcast/basic';
import { HdNav } from '@itcast/basic';
@Entry
@Component
struct EditIntroductionPage {
controller : TextAreaController = new TextAreaController()
@State inputValue: string = authStore.getUser().intro;
build() {
Column() {
HdNav({ title: '修改个人简介', showRightIcon: false, hasBorder: true })
// 手机号输入框
Row() {
TextArea({controller:this.controller,text:this.inputValue,placeholder:'请编辑您的个人简介(500字以内)'})
.fontSize(16)
.borderRadius(5)
.borderWidth(1)
.borderColor('#999999')
.backgroundColor(Color.White)
.height(150)
.onChange((value:string)=>{
this.inputValue = value;
})
}
.margin({ top: 10 })
.width('95%')
// 验证码输入区域
Row() {
Text('请填写您的个人简介,让更多的人了解您')
.fontSize(15)
.fontColor('#333333')
.width('95%')
}
.margin({top:15})
.width('95%')
.justifyContent(FlexAlign.SpaceBetween)
// 登录按钮
Button({type:ButtonType.Normal}){
Text('保 存')
}
.width('90%')
.height(48)
.borderRadius(8)
.borderWidth(1)
.borderColor('#8B2316')
.backgroundColor(Color.White)
.fontColor('#8B2316')
.fontSize(18)
.position({x:'5%',y:'80%'})
.onClick(() => {
// 处理登录逻辑
if (this.inputValue.length > 0) {
promptAction.showToast({message:'请输入简介'})
return
}
// 执行登录操作...
})
}
.width('100%')
.height('100%')
.backgroundColor('#FFFFFF')
}
}
@@ -0,0 +1,13 @@
import { authStore, HdNav } from '@itcast/basic';
import { EditUserDataComp } from 'mypage'
@Entry
@Component
struct EditUserDataPage {
build() {
Column(){
HdNav({ title: '个人资料', showRightIcon: false, hasBorder: true });
EditUserDataComp();
}
}
}
@@ -0,0 +1,56 @@
import { HdNav } from '@itcast/basic';
@Entry
@Component
struct FeedbackPage {
@State feedbackText: string = ''
controller:TextAreaController = new TextAreaController();
build() {
Column() {
HdNav({ title: '意见反馈', showRightIcon: false, hasBorder: true })
// 输入框区域
TextArea({
text:this.feedbackText,
placeholder:'欢迎对我们的软件提供建议,帮助我们更快更好地改进"肝胆相照"APP(200字以内)',
controller:this.controller
})
.placeholderFont({size:16})
.placeholderColor('#999999')
.width('95%')
.height(230)
.margin(10)
.fontSize(16)
.backgroundColor(Color.White)
.borderRadius(5)
.border({
width:1,
color:'#999999'
})
// 提交按钮
Button('提交', {
type: ButtonType.Normal,
stateEffect: true
})
.width('90%')
.height(45)
.backgroundColor(Color.White)
.borderRadius(5)
.fontColor('#8B2316')
.position({x:'5%',y:'90%'})
.border({
width:1,
color:'#8B2316'
})
.onClick(() => this.submitFeedback())
}
.width('100%')
.height('100%')
.backgroundColor(Color.White)
}
// 提交反馈处理
private submitFeedback(): void {
// 提交逻辑实现
}
}
@@ -0,0 +1,13 @@
import { ForgetPasswordComp } from 'mypage'
import { HdNav } from '@itcast/basic';
@Entry
@Component
struct ForgetPassword {
build() {
Column(){
HdNav({ title: '忘记密码', showRightIcon: false, hasBorder: true })
ForgetPasswordComp();
}
}
}
@@ -0,0 +1,15 @@
import { MyHomePage } from 'mypage'
import { emitter } from '@kit.BasicServicesKit';
@Entry
@Component
export struct MyPage {
build() {
Column(){
MyHomePage()
}
.width('100%')
.height('100%')
.backgroundColor('#F3F3F3')
}
}
@@ -0,0 +1,210 @@
import { authStore, HdNav , preferenceStore} from '@itcast/basic';
import { bundleManager, common, ConfigurationConstant, Want } from '@kit.AbilityKit';
import { fileIo, storageStatistics } from '@kit.CoreFileKit';
import { promptAction, router } from '@kit.ArkUI';
import call from '@ohos.telephony.call';
@Entry
@Preview
@Component
struct SettingPage {
@State version: string = ''
@State cache: string = ''
@State settingList : Array<string> = [
'修改登录密码',
'更换手机号',
'版本',
'关于肝胆相照',
// '分享肝胆相照APP',
'肝胆相照直播群',
'清除缓存',
'意见反馈',
'注销账户',
'注册协议',
'隐私政策',
'项目办公室电话'
];
aboutToAppear(): void {
this.getVersion()
this.calcCache()
}
getVersion() {
bundleManager.getBundleInfoForSelf(
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION |
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA
)
.then((res) => {
this.version = 'v' + res.versionName
})
}
calcCache() {
storageStatistics.getCurrentBundleStats()
.then(res => {
this.cache = (res.cacheSize / (1000 * 1000)).toFixed(2) + 'MB'
})
}
clearCache() {
const ctx = getContext()
const ctxCacheDir = ctx.cacheDir
const ctxExist = fileIo.accessSync(ctxCacheDir)
if (ctxExist) {
fileIo.rmdirSync(ctxCacheDir)
}
const app = ctx.getApplicationContext()
const appCacheDir = app.cacheDir
const appExist = fileIo.accessSync(appCacheDir)
if (appExist) {
fileIo.rmdirSync(appCacheDir)
}
promptAction.showToast({ message: '清理完毕' })
this.calcCache()
}
build() {
Column(){
HdNav({ title: '设置与帮助', showRightIcon: false, hasBorder: true })
Blank()
List(){
ForEach(this.settingList,(item:string,index:number)=>{
ListItem() {
Column() {
Row() {
Text(item)
.fontSize(16)
.fontColor('#333333')
.margin({ left: 10 })
Blank()
if (item=='版本') {
Text(this.version)
.fontSize(16)
.fontColor($r('app.color.main_color'))
.margin({ right: 10 })
} else if (item == '清除缓存') {
Text(this.cache)
.fontSize(16)
.fontColor($r('app.color.main_color'))
.margin({ right: 10 })
Image($r('sys.media.ohos_ic_public_arrow_right'))
.width(15)
.height(15)
.margin({ right: 10 })
} else if (item == '项目办公室电话') {
Text('010-87573022')
.fontSize(16)
.fontColor($r('app.color.main_color'))
.margin({ right: 10 })
} else {
Image($r('sys.media.ohos_ic_public_arrow_right'))
.width(15)
.height(15)
.margin({ right: 10 })
}
}
.width('100%')
.height(52)
.justifyContent(FlexAlign.SpaceBetween)
Divider()
.color('#F4F4F4')
.strokeWidth(1)
.height(1)
.margin({left:10,top:0})
}
.justifyContent(FlexAlign.Start)
}
.height(53)
.onClick(()=>{
if (index == 0) {
router.pushUrl({url:'pages/MinePage/ChangePassword'})
} else if (index == 1) {
router.pushUrl({url:'pages/MinePage/ChangePhonePage'})
} else if (index == 2) {
console.info('当前版本:',this.settingList[index]);
} else if (index == 3) {
try {
router.pushUrl({
url: 'pages/WebView/WebPage',
params: { url: 'http://doc.igandan.com/app/html/about/2017/about2.html' ,title:'关于肝胆相照'}
}, router.RouterMode.Standard);
} catch (err) {
console.error(`跳转失败: ${err.code}, ${err.message}`);
}
} else if (index == 4) {
try {
router.pushUrl({
url: 'pages/WebView/WebPage',
params: { url: 'http://wx.igandan.com/qun/gdxzqun' ,title:'肝胆相照直播群'}
}, router.RouterMode.Standard);
} catch (err) {
console.error(`跳转失败: ${err.code}, ${err.message}`);
}
} else if (index == 5) {
this.clearCache();
} else if (index == 6) {
router.pushUrl({url:'pages/MinePage/FeedbackPage'})
} else if (index == 7) {
router.pushUrl({url:'pages/MinePage/CancelAccount'})
} else if (index == 8) {
try {
router.pushUrl({
url: 'pages/WebView/WebPage',
params: { url: 'http://app.igandan.com/expert_zcxy.jsp' ,title:'注册协议'}
}, router.RouterMode.Standard);
} catch (err) {
console.error(`跳转失败: ${err.code}, ${err.message}`);
}
} else if (index == 9) {
try {
router.pushUrl({
url: 'pages/WebView/WebPage',
params: { url: 'https://doc.igandan.com/app/integral/permission_expert.html' ,title:'隐私政策'}
}, router.RouterMode.Standard);
} catch (err) {
console.error(`跳转失败: ${err.code}, ${err.message}`);
}
} else {
if (call.hasVoiceCapability()) {
call.makeCall('010-87573022',(err)=>{
if (err) {
promptAction.showToast({message:'拨号失败'})
} else {
promptAction.showToast({message:'拨号成功'})
}
})
} else {
promptAction.showToast({message:'不支持通话'})
}
}
})
})
}
.height('auto')
Button({ type: ButtonType.Normal }){
Text('退出登录')
}
.width('90%')
.height(53)
.fontSize(16)
.borderWidth(1)
.borderRadius(8)
.fontColor($r('app.color.main_color'))
.borderColor($r('app.color.main_color'))
.backgroundColor(Color.White)
.margin({top:10,left:10,right:10})
.onClick(()=>{
authStore.delUser();
preferenceStore.setItemBoolean('isLogin',false)
router.back()
router.replaceUrl({
url: 'pages/LoginPage/LoginPage', // 目标url
},router.RouterMode.Single)
})
}
}
}
@@ -0,0 +1,61 @@
import { TabBarComp } from '../Tabbar/TabBarComp';
import { themeManager } from '@itcast/basic';
import { emitter } from '@kit.BasicServicesKit';
import { common } from '@kit.AbilityKit';
import { promptAction } from '@kit.ArkUI';
@Entry
@Component
struct Index {
@State
@Watch('onChangeIndex')
activeIndex: number = 0
aboutToAppear(): void {
emitter.on({ eventId: 10000 }, (e) => {
if (e.data && e.data.activeIndex) {
this.activeIndex = e.data.activeIndex
}
})
}
onChangeIndex() {
if (this.activeIndex === 3) themeManager.settingStatusBarWhite()
else themeManager.settingStatusBarBlack()
}
onPageShow(): void {
console.log('--onPageShow--');
this.onChangeIndex()
}
onPageHide(): void {
console.log('onPageHide');
this.onChangeIndex()
themeManager.settingStatusBarBlack()
this.backTimes = 0
}
backTimes: number = 0
onBackPress(): boolean | void {
this.backTimes++
if (this.backTimes <= 1) {
promptAction.showToast({ message: '再按一次将退出应用' })
}
if (this.backTimes >= 2) {
const ctx = getContext() as common.UIAbilityContext
ctx.terminateSelf()
}
return true
}
build() {
Flex() {
TabBarComp({ activeIndex: this.activeIndex })
}
.backgroundColor($r('app.color.white'))
}
}
@@ -0,0 +1,61 @@
import { VideoPage } from 'home'
import { MyHomePage } from 'mypage'
import { TabBarCompModel } from '../../models/TabBarCompModel'
import { TabBarItems } from '../../contants/TabBarItems'
import { BasicConstant } from '@itcast/basic'
import mediaquery from '@ohos.mediaquery';
@Component
export struct TabBarComp {
@StorageProp('bottomHeight')
bottomHeight: number = 0
@Link
activeIndex: number
@State
isLandscape: boolean = false
listenerScreen = mediaquery.matchMediaSync('(orientation: landscape) and (device-type: tablet)')
aboutToAppear() {
this.listenerScreen.on('change', (mediaQueryResult) => {
this.isLandscape = mediaQueryResult.matches
})
}
@Builder
TabBarBuilder(item: TabBarCompModel, index: number) {
Column({ space: BasicConstant.SPACE_SM }) {
Image(this.activeIndex === index ? item.activeIcon : item.defaultIcon)
.width($r('app.float.tab_bar_item_icon_size'))
Text(item.label)
.fontSize($r('app.float.tab_bar_item_font_size'))
.fontColor(this.activeIndex === index ? $r('app.color.black') : $r('app.color.common_gray_01'))
.animation({ duration: 300 })
}
}
build() {
Tabs({
index: this.activeIndex
}) {
ForEach(TabBarItems, (item: TabBarCompModel, index: number) => {
TabContent() {
if (index === 0) VideoPage()
// else if (index === 1) ProjectComp()
// else if (index === 2) InterviewComp()
else MyHomePage()
}
.tabBar(this.TabBarBuilder(item, index))
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
})
}
.divider({ strokeWidth: $r('app.float.common_border_width'), color: $r('app.color.common_gray_border') })
.vertical(this.isLandscape)
.barPosition(this.isLandscape ? BarPosition.Start : BarPosition.End)
.onTabBarClick((index) => {
this.activeIndex = index
})
.barHeight(this.isLandscape ? $r('app.float.tab_bar_item_height_lg') : $r('app.float.tab_bar_item_height_sm'))
.scrollable(false)
.margin({ bottom: this.bottomHeight })
}
}
@@ -0,0 +1,31 @@
@Entry
@Component
export struct ScienceVideoPage {
@State message: string = 'Hello World';
onPageShow(): void {
console.log('ScienceVideoPage onPageShow!');
}
onPageHide(): void {
console.log('ScienceVideoPage onPageShow!');
}
build() {
RelativeContainer() {
Text(this.message)
.id('ScienceVideoPageHelloWorld')
.fontSize($r('app.float.page_text_font_size'))
.fontWeight(FontWeight.Bold)
.alignRules({
center: { anchor: '__container__', align: VerticalAlign.Center },
middle: { anchor: '__container__', align: HorizontalAlign.Center }
})
.onClick(() => {
this.message = 'Welcome';
})
}
.height('100%')
.width('100%')
}
}
@@ -0,0 +1,39 @@
import webview from '@ohos.web.webview';
import { HdNav } from '@itcast/basic';
import router from '@ohos.router';
@Entry
@Component
struct WebPage {
private controller: webview.WebviewController = new webview.WebviewController();
@State params:RouteParams = router.getParams() as RouteParams;
@State url: string = this.params.url;
@State title: string = this.params.title;
customUserAgent: string = 'gdxz-expert';
build() {
Column() {
HdNav({ title: this.title, showRightIcon: false, hasBorder: true })
Web({
src: this.url,
controller: this.controller
})
.mixedMode(MixedMode.All)
.domStorageAccess(true)
.onControllerAttached(() => {
let userAgent = this.controller.getUserAgent() + this.customUserAgent;
this.controller.setCustomUserAgent(userAgent);
})
.width('100%')
.layoutWeight(1)// 占据剩余空间
.height('100%')
}
.height('100%')// 关键:约束父容器高度
}
}
interface RouteParams {
url:string;
title:string;
}
+69
View File
@@ -0,0 +1,69 @@
{
"module": {
"name": "default",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"phone",
"tablet",
"2in1"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:app_icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:startIcon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "EntryBackupAbility",
"srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
"type": "backup",
"exported": false,
"metadata": [
{
"name": "ohos.extension.backup",
"resource": "$profile:backup_config"
}
]
}
],
"requestPermissions": [
{
"name": "ohos.permission.INTERNET",
"reason": "$string:load_picture",
"usedScene": {"abilities": ["EntryAbility"],"when": "always"}
},
{
"name": "ohos.permission.CAMERA",
"reason": "$string:camera_reason",
"usedScene": {}
},
{
"name": "ohos.permission.READ_MEDIA",
"reason": "$string:media_reason",
"usedScene": {}
}
]
}
}
@@ -0,0 +1,12 @@
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
},
{
"name": "item_title_font",
"value": "#E6000000"
}
]
}
@@ -0,0 +1,28 @@
{
"float": [
{
"name": "tab_bar_item_font_size",
"value": "10fp"
},
{
"name": "tab_bar_item_icon_size",
"value": "22vp"
},
{
"name": "tab_bar_item_height_sm",
"value": "50vp"
},
{
"name": "tab_bar_item_height_lg",
"value": "400vp"
},
{
"name": "font_size",
"value": "14fp"
},
{
"name": "page_text_font_size",
"value": "50fp"
}
]
}
@@ -0,0 +1,28 @@
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "肝胆相照专家端"
},
{
"name": "camera_reason",
"value": "用于拍摄照片"
},
{
"name": "media_reason",
"value": "用于选取相册照片"
},
{
"name": "load_picture",
"value": "加载网络图片"
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

@@ -0,0 +1,3 @@
{
"allowToBackupRestore": true
}
@@ -0,0 +1,22 @@
{
"src": [
"pages/Index",
"pages/BootPage",
"pages/Home",
"pages/LoginPage/LoginPage",
"pages/LoginPage/LoginSetInfoPage",
"pages/MinePage/MyPage",
"pages/VideoPage/ScienceVideoPage",
"pages/MinePage/SettingPage",
"pages/MinePage/ChangePassword",
"pages/MinePage/ForgetPassword",
"pages/MinePage/ChangePhonePage",
"pages/WebView/WebPage",
"pages/MinePage/FeedbackPage",
"pages/MinePage/CancelAccount",
"pages/MinePage/EditUserDataPage",
"pages/MinePage/ChooseEmail",
"pages/MinePage/ChooseOfficePhone",
"pages/MinePage/EditIntroductionPage"
]
}
@@ -0,0 +1,8 @@
{
"color": [
{
"name": "start_window_background",
"value": "#000000"
}
]
}
@@ -0,0 +1,2 @@
{
}
@@ -0,0 +1,35 @@
import { hilog } from '@kit.PerformanceAnalysisKit';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function abilityTest() {
describe('ActsAbilityTest', () => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
})
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
})
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
})
})
}
@@ -0,0 +1,5 @@
import abilityTest from './Ability.test';
export default function testsuite() {
abilityTest();
}
+13
View File
@@ -0,0 +1,13 @@
{
"module": {
"name": "default_test",
"type": "feature",
"deviceTypes": [
"phone",
"tablet",
"2in1"
],
"deliveryWithInstall": true,
"installationFree": false
}
}
+5
View File
@@ -0,0 +1,5 @@
import localUnitTest from './LocalUnit.test';
export default function testsuite() {
localUnitTest();
}
@@ -0,0 +1,33 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
export default function localUnitTest() {
describe('localUnitTest', () => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
});
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
});
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
});
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
});
it('assertContain', 0, () => {
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
let a = 'abc';
let b = 'b';
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
expect(a).assertContain(b);
expect(a).assertEqual(a);
});
});
}