Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
陈剑华
2024-06-25 16:31:18 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
a8a2c807ba0787241d97b473f1ee84dcf9637857
a8a2c807
2 parents
557a4a0e
f128504e
Merge remote-tracking branch 'origin/main'
Show whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
324 additions
and
612 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/Logger.ets
sight_harmony/features/wdComponent/oh-package.json5
sight_harmony/features/wdComponent/src/main/ets/components/CardParser.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageDownloadComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailItemComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/cardview/LiveBigImage02Component.ets
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleColumn09.ets
sight_harmony/features/wdComponent/src/main/ets/components/lottie/LottieView.ets
sight_harmony/features/wdComponent/src/main/ets/components/mine/MinePageUserSimpleInfoUI.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/peopleShipHomePage/PeopleShipHomeAttentionComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/peopleShipHomePage/PeopleShipHomePageTopComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/refresh/RefreshLoadLayout.ets
sight_harmony/features/wdComponent/src/main/ets/components/reusable/CustomPullToRefresh.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/EmptyComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/HorizontalStrokeCardThreeTwoRadioForMoreComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/ImageItemView.ets
sight_harmony/features/wdComponent/src/main/ets/pages/MultiPictureListPage.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/SearchResultCountItem.ets
sight_harmony/features/wdDetailPlayLive/oh-package.json5
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/video/PlayUIComponent.ets
sight_harmony/features/wdDetailPlayShortVideo/oh-package.json5
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
sight_harmony/features/wdLogin/src/main/ets/pages/guide/GuidePages.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
sight_harmony/oh-package.json5
sight_harmony/products/phone/oh-package.json5
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchAdvertisingPage.ets
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchInterestsHobbiesPage.ets
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchPage.ets
sight_harmony/products/phone/src/main/ets/pages/view/MultiPictureDetailPageComponent.ets
sight_harmony/commons/wdKit/src/main/ets/utils/Logger.ets
View file @
a8a2c80
...
...
@@ -40,15 +40,10 @@ export class Logger {
Logger.domain = domain;
}
static debug(
prefixStr?:string,
...args: string[]) {
static debug(...args: string[]) {
if (!Logger.isDebug) {
return
}
if(prefixStr){
Logger.prefix = prefixStr
}else {
Logger.prefix = 'SightApp';
}
Logger.logContent(LogLevel.DEBUG, ...args)
}
...
...
@@ -90,55 +85,68 @@ export class Logger {
static logContent(level: LogLevel, ...args: string[]) {
let msg = Logger.getMsg(...args)
let tag = Logger.getTag(...args)
let length = msg.length
if (length < Logger.CHUNK_SIZE) {
// 不超限,保持原来的打印
Logger.print(level, ...args)
Logger.print(
tag,
level, ...args)
} else {
// 超限,分段打印
for (let i = 0; i < length; i += Logger.CHUNK_SIZE) {
let count = Math.min(length - i, Logger.CHUNK_SIZE);
Logger.printExt(level, msg.substring(i, i + count));
Logger.printExt(
tag,
level, msg.substring(i, i + count));
}
}
}
static print(level: LogLevel, ...msg: string[]) {
static print(tag: string, level: LogLevel, ...msg: string[]) {
let prefix = Logger.prefix
if (tag) {
prefix = tag
}
switch (level) {
case LogLevel.DEBUG:
hilog.debug(Logger.domain,
Logger.
prefix, Logger.format, msg);
hilog.debug(Logger.domain, prefix, Logger.format, msg);
break
case LogLevel.INFO:
hilog.info(Logger.domain,
Logger.
prefix, Logger.format, msg);
hilog.info(Logger.domain, prefix, Logger.format, msg);
break
case LogLevel.WARN:
hilog.warn(Logger.domain,
Logger.
prefix, Logger.format, msg);
hilog.warn(Logger.domain, prefix, Logger.format, msg);
break
case LogLevel.ERROR:
hilog.error(Logger.domain,
Logger.
prefix, Logger.format, msg);
hilog.error(Logger.domain, prefix, Logger.format, msg);
break
case LogLevel.FATAL:
hilog.fatal(Logger.domain,
Logger.
prefix, Logger.format, msg);
hilog.fatal(Logger.domain, prefix, Logger.format, msg);
break
}
}
static printExt(level: LogLevel, msg: string) {
static printExt(tag: string, level: LogLevel, msg: string) {
let prefix = Logger.prefix
if (tag) {
prefix = tag
}
switch (level) {
case LogLevel.DEBUG:
hilog.debug(Logger.domain,
Logger.
prefix, Logger.format_ext, msg);
hilog.debug(Logger.domain, prefix, Logger.format_ext, msg);
break
case LogLevel.INFO:
hilog.info(Logger.domain,
Logger.
prefix, Logger.format_ext, msg);
hilog.info(Logger.domain, prefix, Logger.format_ext, msg);
break
case LogLevel.WARN:
hilog.warn(Logger.domain,
Logger.
prefix, Logger.format_ext, msg);
hilog.warn(Logger.domain, prefix, Logger.format_ext, msg);
break
case LogLevel.ERROR:
hilog.error(Logger.domain,
Logger.
prefix, Logger.format_ext, msg);
hilog.error(Logger.domain, prefix, Logger.format_ext, msg);
break
case LogLevel.FATAL:
hilog.fatal(Logger.domain,
Logger.
prefix, Logger.format_ext, msg);
hilog.fatal(Logger.domain, prefix, Logger.format_ext, msg);
break
}
}
...
...
@@ -153,6 +161,20 @@ export class Logger {
})
return msg.substring(2, msg.length);
}
static getTag(...args: string[]): string {
if (args == null || args.length <= 0) {
return '';
}
if (args.length > 1) {
return args[0]
} else {
return ''
}
}
}
// export default new Logger('SightApp', 0xFF00)
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/oh-package.json5
View file @
a8a2c80
...
...
@@ -7,7 +7,6 @@
"main"
:
"Index.ets"
,
"version"
:
"1.0.0"
,
"dependencies"
:
{
"@ohos/lottie"
:
"2.0.10"
,
"wdConstant"
:
"file:../../commons/wdConstant"
,
"wdPlayer"
:
"file:../../features/wdPlayer"
,
"wdLogin"
:
"file:../../features/wdLogin"
,
...
...
sight_harmony/features/wdComponent/src/main/ets/components/CardParser.ets
View file @
a8a2c80
...
...
@@ -186,8 +186,8 @@ export struct CardParser {
contentDTO: contentDTO,
compDTO: this.compDTO,
pageId: this.pageId,
pageName: this.pageName
pageName: this.pageName,
index:this.compIndex
})
} else {
// todo:组件未实现 / Component Not Implemented
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageDownloadComponent.ets
View file @
a8a2c80
...
...
@@ -5,6 +5,7 @@ import { promptAction } from '@kit.ArkUI';
import { image } from '@kit.ImageKit';
import { photoAccessHelper } from '@kit.MediaLibraryKit';
import fs from '@ohos.file.fs';
import { NetworkUtil } from 'wdKit';
const PERMISSIONS: Array<Permissions> = [
'ohos.permission.READ_IMAGEVIDEO',
...
...
@@ -47,8 +48,13 @@ export struct ImageDownloadComponent {
}
aboutToAppear(): void {
// 注册监听网络连接
let netStatus = NetworkUtil.isNetConnected()
if (netStatus) {
// 有网络
this.onChangeUrl()
}
}
async onChangeUrl(): Promise<void> {
console.info(`cj2024 图片下载 ${this.url}`)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/MultiPictureDetailItemComponent.ets
View file @
a8a2c80
...
...
@@ -27,6 +27,7 @@ export struct MultiPictureDetailItemComponent {
private MultiPictureDetailItem: PhotoListBean = {} as PhotoListBean
//alt app.media.picture_loading 设计稿尺寸
@State imageWidth:string | number = 167
private scroller: Scroller = new Scroller()
async aboutToAppear() {
...
...
@@ -179,6 +180,7 @@ export struct MultiPictureDetailItemComponent {
build() {
Row() {
Scroll(this.scroller) {
if(this.imageUri != null && (this.imageUri.includes('.gif') || this.imageUri.includes('.GIF'))){
Image(this.imageUri)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
.alt($r('app.media.datail_imageLoading_w'))
...
...
@@ -197,7 +199,7 @@ export struct MultiPictureDetailItemComponent {
this.imageWidth = '100%'
})
}else{
Image(this.imagePixelMap
)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
Image(this.imagePixelMap || 'app.media.datail_imageLoading_w'
)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
.alt($r('app.media.datail_imageLoading_w'))
.width(this.imageWidth)
.objectFit(ImageFit.Auto)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能
...
...
@@ -215,6 +217,10 @@ export struct MultiPictureDetailItemComponent {
})
}
}
.scrollable(ScrollDirection.Vertical)
.scrollBarWidth(0)
.height(this.imageDefaultSize.height || "100%")
}
.onBlur(() => {
this.resetCurrentImageInfo();
})
...
...
sight_harmony/features/wdComponent/src/main/ets/components/cardview/LiveBigImage02Component.ets
View file @
a8a2c80
...
...
@@ -19,7 +19,7 @@ export struct LiveBigImage02Component {
@State contentDTO: ContentDTO = new ContentDTO();
@State loadImg: boolean = false;
@State clicked: boolean = false;
index: number = 0
async aboutToAppear() {
const curRouter = router.getState().name;
this.clicked = hasClicked(this.contentDTO.objectId,curRouter)
...
...
@@ -102,8 +102,7 @@ export struct LiveBigImage02Component {
lottieWidth: 14,
lottieHeight: 14,
autoplay: true,
loop: true,
title: item.newsTitle
loop: true
})
.margin({
right: '2vp'
...
...
sight_harmony/features/wdComponent/src/main/ets/components/compview/ZhSingleColumn09.ets
View file @
a8a2c80
...
...
@@ -161,7 +161,7 @@ export struct ZhSingleColumn09 {
.height(90)
.columnsTemplate('1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr')
.margin({bottom:
10
})
.margin({bottom:
5
})
Row() {
Row() {
...
...
@@ -188,7 +188,7 @@ export struct ZhSingleColumn09 {
this.selfClosed = true;
})
}
.height(
4
0)
.height(
2
0)
.width('100%')
.borderRadius(3)
.justifyContent(FlexAlign.SpaceBetween)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/lottie/LottieView.ets
View file @
a8a2c80
...
...
@@ -14,28 +14,16 @@ export struct LottieView {
private politeChickyController: CanvasRenderingContext2D =
new CanvasRenderingContext2D(); // CanvasRenderingContext2D对象
private animateItem: AnimationItem | null = null; // 初始化loadAnimation接口的返回对象
@Prop title: string
// 页面隐藏销毁动画
// onPageHide(): void {
// this.animateItem?.destroy()
//
// if (this.onComplete) {
// this.animateItem?.removeEventListener('complete', this.onComplete)
// }
// }
/**
* 加载动画
* @param autoplay 控制动画是否自动播放参数
*/
loadAnimation() {
// 销毁动画,减少缓存
if (this.animateItem !== null) {
this.animateItem.destroy(this.name);
this.animateItem = null;
}
this.onDestroyAnimation()
this.animateItem = lottie.loadAnimation({
container: this.politeChickyController,
renderer: 'canvas',
...
...
@@ -55,32 +43,19 @@ export struct LottieView {
}
aboutToAppear(): void {
// console.error('XXXXZZZZ', '-------aboutToAppear-------' + this.title)
//lottie?.play()
// if(this.init){
// if(this.animateItem = null){
// this.loadAnimation();
// }
// }
/**
* 摧毁动画
*/
onDestroyAnimation(){
// 销毁动画,减少缓存
if (this.animateItem !== null) {
this.animateItem.destroy(this.name);
this.animateItem = null;
}
aboutToDisappear(): void {
// console.error('XXXXZZZZ', '-------aboutToDisappear-------' + this.title)
// if(this.init){
// lottie?.destroy(this.name)
//
// if (this.onComplete) {
// this.animateItem?.removeEventListener('complete', this.onComplete)
// }
// this.animateItem = null;
// // }
}
build() {
Stack({ alignContent: Alignment.TopStart }) {
Canvas(this.politeChickyController)
...
...
@@ -92,10 +67,10 @@ export struct LottieView {
this.onReady(this.animateItem)
}
})
.onDisAppear(() => {
lottie.destroy(this.name)
this.animateItem = null;
}).onAppear(()=>{
.onDisAppear(()=>{
this.onDestroyAnimation()
})
.onAppear(()=>{
this.loadAnimation();
})
...
...
sight_harmony/features/wdComponent/src/main/ets/components/mine/MinePageUserSimpleInfoUI.ets
View file @
a8a2c80
...
...
@@ -34,20 +34,13 @@ export default struct MinePageUserSimpleInfoUI {
Row(){
//头像
Stack(){
if (this.headPhotoUrl.length > 0){
Image(this.headPhotoUrl)
.alt(this.userType === "1"?$r('app.media.default_head'):$r('app.media.AccountOwner_DefaultIcon'))
.width(`${this.calcHeight(100)}lpx`)
.height(`${this.calcHeight(100)}lpx`)
.objectFit(ImageFit.Cover)
.borderRadius(50)
}else {
Image(this.userType === "1"?$r('app.media.default_head'):$r('app.media.AccountOwner_DefaultIcon'))
Image(this.isLogin?(this.headPhotoUrl?this.headPhotoUrl:this.userType === "1"?$r('app.media.default_head'):$r('app.media.AccountOwner_DefaultIcon')):$r('app.media.default_head'))
.alt($r('app.media.default_head'))
.width(`${this.calcHeight(100)}lpx`)
.height(`${this.calcHeight(100)}lpx`)
.objectFit(ImageFit.Cover)
.borderRadius(50)
}
if(StringUtils.isNotEmpty(this.levelHead)){
Image(this.levelHead)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageComponent.ets
View file @
a8a2c80
...
...
@@ -41,6 +41,7 @@ export default struct TemplatePageComponent {
extra: string = ''
async aboutToAppear() {
Logger.debug(TAG, 'aboutToAppear')
this.requestPageData()
...
...
@@ -78,9 +79,6 @@ export default struct TemplatePageComponent {
})
}
aboutToDisappear(): void {
}
build() {
if (this.templatePage.pageCompType === TemplatePageStateType.LOADING) {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/template/TemplatePageModel.ets
View file @
a8a2c80
import { ContentDTO } from 'wdBean/Index';
import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO';
import { LazyDataSource } from 'wdKit/Index';
import { WDViewDefaultType } from '../../view/EmptyComponent';
...
...
sight_harmony/features/wdComponent/src/main/ets/components/peopleShipHomePage/PeopleShipHomeAttentionComponent.ets
View file @
a8a2c80
...
...
@@ -5,7 +5,7 @@ export struct PeopleShipHomeAttentionComponent {
@Consume isAttention: string
@Consume isLoadingAttention: boolean
build() {
Flex({ alignItems: ItemAlign.
Center, justifyContent: FlexAlign.Center
}) {
Flex({ alignItems: ItemAlign.
Start, justifyContent: FlexAlign.Start
}) {
Button({type: ButtonType.Normal, stateEffect: false } ) {
Stack() {
Row()
...
...
@@ -117,7 +117,6 @@ export struct PeopleShipHomeAttentionComponent {
ToastUtils.showToast('分享为公共方法,待开发', 1000);
})
.visibility(Visibility.Hidden)
}
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/peopleShipHomePage/PeopleShipHomePageTopComponent.ets
View file @
a8a2c80
...
...
@@ -253,7 +253,7 @@ export struct PeopleShipHomePageTopComponent {
// 分享-关注
PeopleShipHomeAttentionComponent()
.width(
'100%'
)
.width(
`calc(100% - ${32 + 'vp'})`
)
.margin({
top: '10vp',
bottom: '16vp'
...
...
sight_harmony/features/wdComponent/src/main/ets/components/refresh/RefreshLoadLayout.ets
View file @
a8a2c80
...
...
@@ -85,8 +85,8 @@ export default struct CustomLayout {
name: this.animateName,
path: "lottie/refresh_step1.json", // 路径加载动画只支持entry/src/main/ets 文件夹下的相对路径
})
}
this.animateItem.goToAndStop(1)
}
let total = CustomLayout.REFRESH_HEIGHT
let progress = offset * 100 / total
this.animateItem?.goToAndStop(this.getFramesByProgress(progress), true);
...
...
@@ -103,9 +103,6 @@ export default struct CustomLayout {
path: "lottie/refresh_step2.json", // 路径加载动画只支持entry/src/main/ets 文件夹下的相对路径
})
}
// this.animateItem2.isLoaded
// TODO 是否拦截重复触发
this.animateItem2.goToAndPlay(1)
}
getFramesByProgress(progress: number): number {
...
...
sight_harmony/features/wdComponent/src/main/ets/components/reusable/CustomPullToRefresh.ets
View file @
a8a2c80
...
...
@@ -18,14 +18,18 @@ export struct CustomPullToRefresh {
.setAnimDuration(500);
private refreshSettings: RenderingContextSettings = new RenderingContextSettings(true)
private refreshContext: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.refreshSettings)
private refreshingSettings: RenderingContextSettings = new RenderingContextSettings(true)
private refreshingContext: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.refreshingSettings)
private loadMoreSettings: RenderingContextSettings = new RenderingContextSettings(true)
private loadMoreContext: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.loadMoreSettings)
private refreshAnimation: AnimationItem | null = null;
private refreshingAnimation: AnimationItem | null = null;
private loadMoreAnimation: AnimationItem | null = null;
private refreshAnimName: string = "refresh";
private refreshingAnimName: string = "refreshing";
private loadMoreAnimName: string = "loadMore";
private refreshAnimationDestroy = true
private refreshingAnimationDestroy = true
// refresh-1,refreshing-2,refreshed-3,idle-4
@State @Watch('stateChange') private refreshState: number = 4;
...
...
@@ -120,9 +124,23 @@ export struct CustomPullToRefresh {
})
.onDisAppear(() => {
lottie.destroy(this.refreshAnimName);
})
.visibility(this.refreshState == 1 ? Visibility.Visible : Visibility.Hidden)
Canvas(this.refreshingContext)
.width(60)
.height(60)
.backgroundColor(Color.Transparent)
.onReady(() => {
// 可在此生命回调周期中加载动画,可以保证动画尺寸正确
//抗锯齿的设置
this.refreshContext.imageSmoothingEnabled = true;
this.refreshContext.imageSmoothingQuality = 'medium'
})
.onDisAppear(() => {
lottie.destroy(this.refreshingAnimName);
})
.visibility(
(this.refreshState == 1 || this.refreshState == 2)
? Visibility.Visible : Visibility.Hidden)
.visibility(
this.refreshState == 2
? Visibility.Visible : Visibility.Hidden)
Text('已更新至最新')
.fontSize(14)
...
...
@@ -175,10 +193,7 @@ export struct CustomPullToRefresh {
}
private refreshAnim(percent: number) {
if (this.refreshAnimation == null || this.refreshAnimation.name != this.refreshAnimName ||
this.refreshAnimationDestroy) {
this.refreshAnimation?.destroy(this.refreshAnimName)
this.refreshAnimation?.destroy(this.refreshingAnimName)
if (this.refreshAnimation == null || this.refreshAnimationDestroy) {
this.refreshAnimation = lottie.loadAnimation({
container: this.refreshContext,
renderer: 'canvas', // canvas 渲染模式
...
...
@@ -212,21 +227,19 @@ export struct CustomPullToRefresh {
}
private refreshingAnim() {
// Logger.error('zzzz', 'animate2, 1')
// 先销毁之前的动画
if (this.refreshAnimation == null || this.refreshAnimation.name != this.refreshingAnimName ||
this.refreshAnimationDestroy) {
this.refreshAnimation?.destroy(this.refreshAnimName)
this.refreshAnimation?.destroy(this.refreshingAnimName)
this.refreshAnimation = lottie.loadAnimation({
container: this.refreshContext,
if (this.refreshingAnimation == null || this.refreshingAnimationDestroy) {
this.refreshingAnimation?.destroy(this.refreshingAnimName)
this.refreshingAnimation = lottie.loadAnimation({
container: this.refreshingContext,
renderer: 'canvas', // canvas 渲染模式
loop: 10,
autoplay: true,
name: this.refreshingAnimName,
path: "lottie/refresh_step2.json", // 路径加载动画只支持entry/src/main/ets 文件夹下的相对路径
})
this.addRefreshAnimListener()
this.refreshingAnimationDestroy = false
this.addRefreshingAnimListener()
}
// Logger.error('zzzz', 'animate2, 2')
}
...
...
@@ -242,6 +255,13 @@ export struct CustomPullToRefresh {
});
}
private addRefreshingAnimListener() {
this.refreshingAnimation?.addEventListener('destroy', (args: Object): void => {
// Logger.error('zzzz', "lottie destroy");
this.refreshingAnimationDestroy = true
});
}
loadMoreAnimate() {
if (this.loadMoreAnimation == null) {
this.loadMoreAnimation = lottie.loadAnimation({
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchComponent.ets
View file @
a8a2c80
...
...
@@ -66,31 +66,31 @@ export struct SearchComponent {
this.breakpointSystem.unregister();
}
getRelatedSearchContent() {
if (StringUtils.isNotEmpty(this.searchText)) {
SearcherAboutDataModel.getRelatedSearchContentData(encodeURI(this.searchText), getContext(this)).then((value) => {
getRelatedSearchContent(searchText: string) {
if (StringUtils.isNotEmpty(searchText)) {
SearcherAboutDataModel.getRelatedSearchContentData(encodeURI(searchText), getContext(this)).then((value) => {
if (value != null && value.length > 0) {
this.relatedSearchContentsData = []
value.forEach(item => {
let tempValue: string = item
let tempArr: string[] = []
if (tempValue.indexOf(
this.
searchText) === -1) {
if (tempValue.indexOf(searchText) === -1) {
tempArr.push(item)
this.relatedSearchContentsData.push(new SearchRelatedItem(item, tempArr))
} else {
while (tempValue.indexOf(this.searchText) != -1) {
let index = tempValue.indexOf(this.searchText)
while (tempValue.indexOf(searchText) != -1) {
let index = tempValue.indexOf(searchText)
if (index === 0) {
try {
tempArr.push(this.searchText)
tempValue = tempValue.substring(this.searchText.length, tempValue.length)
tempArr.push(searchText)
tempValue = tempValue.substring(searchText.length, tempValue.length)
} catch (e) {
}
} else {
try {
tempArr.push(tempValue.substring(0, index))
tempArr.push(this.searchText)
tempValue = tempValue.substring(index + this.searchText.length, tempValue.length)
tempArr.push(searchText)
tempValue = tempValue.substring(index + searchText.length, tempValue.length)
} catch (e) {
}
}
...
...
@@ -356,7 +356,7 @@ export struct SearchComponent {
this.resetSearch()
} else {
if (this.hasInputContent) {
this.getRelatedSearchContent()
this.getRelatedSearchContent(
value
)
}
}
})
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultComponent.ets
View file @
a8a2c80
...
...
@@ -142,7 +142,7 @@ export struct SearchResultComponent {
SearchResultContentComponent({ keywords: this.searchText, searchType: item ,sameSearch:this.sameSearch,isCurrentShow:this.currentIndex === index})
}.tabBar(this.TabBuilder(index, item))
.layoutWeight(1)
}, (item: string
, index: number) => index.toString()
)
}, (item: string
) => item
)
}
.vertical(false)
.barMode(BarMode.Fixed)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
View file @
a8a2c80
...
...
@@ -19,8 +19,7 @@ import { FollowListDetailItem } from '../../viewmodel/FollowListDetailItem'
import { FollowListStatusRequestItem } from '../../viewmodel/FollowListStatusRequestItem'
import { QueryListIsFollowedItem } from '../../viewmodel/QueryListIsFollowedItem'
import { SearchResultContentData } from '../../viewmodel/SearchResultContentData'
import {
SearchResultContentItem, SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
import { SearchResultContentItem, SearchRmhDescription } from '../../viewmodel/SearchResultContentItem'
import { CardParser } from '../CardParser'
import { FollowChildComponent } from '../mine/follow/FollowChildComponent'
import { ListHasNoMoreDataUI } from '../reusable/ListHasNoMoreDataUI'
...
...
@@ -30,7 +29,7 @@ import { JSON } from '@kit.ArkTS'
import { MoreComponent } from '../cardview/MoreComponent'
import { Card9Component } from '../cardview/Card9Component'
import { WDRouterRule, WDRouterPage } from 'wdRouter/Index'
import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'
const TAG = "SearchResultContentComponent"
@Component
...
...
@@ -38,7 +37,7 @@ export struct SearchResultContentComponent {
@State keywords: string = ""
@State searchType: string = ""
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
tempList
: ContentDTO[] = []
tempList: ContentDTO[] = []
@State data_rmh: SearchRmhDescription[] = []
@State count: number = -1;
@State isLoading: boolean = false
...
...
@@ -48,14 +47,14 @@ export struct SearchResultContentComponent {
scroller: Scroller = new Scroller()
private scroller2: Scroller = new Scroller()
@State ellipseW: number = 0
@State moreWidth:number = 20
@State moreWidth:
number = 20
@State listLeft: number = 0
@State isEnd: boolean = false
@Watch('updateData') @Prop sameSearch:number = 0
@Prop isCurrentShow:boolean = false;
@Watch('updateData') @Prop sameSearch: number = 0
@Prop isCurrentShow: boolean = false;
updateData(){
if(this.isCurrentShow){
updateData() {
if (this.isCurrentShow) {
this.data_rmh = []
this.data.clearAllData()
...
...
@@ -115,7 +114,7 @@ export struct SearchResultContentComponent {
data.headerPhotoUrl = item.headPhotoUrl.split("?")[0]
data.mainControl = item.mainControl + ""
if
(data_temp.length === 1)
{
if
(data_temp.length === 1)
{
this.bean.headPhotoUrl = item.headPhotoUrl.split("?")[0]
this.bean.cnUserName = item.userName
this.bean.creatorId = item.creatorId
...
...
@@ -133,8 +132,8 @@ export struct SearchResultContentComponent {
} else {
this.bean.cnFansNum = item.fansNum + ""
}
let regex:RegExp = new RegExp('\n','g')
this.bean.introduction = item.introduction.replace(regex,'')
let regex: RegExp = new RegExp('\n', 'g')
this.bean.introduction = item.introduction.replace(regex, '')
this.bean.mainControl = item.mainControl
this.bean.banControl = item.banControl
...
...
@@ -148,9 +147,13 @@ export struct SearchResultContentComponent {
data_temp.forEach((data) => {
this.data_rmh.push(data)
})
if(this.data_rmh.length > 0){
this.count = 1
}
//只有一条创作者,获取 创作者信息
if (this.data_rmh.length === 1) {
if
(StringUtils.isNotEmpty(UserDataLocal.getUserId()))
{
if
(StringUtils.isNotEmpty(UserDataLocal.getUserId()))
{
//查询是否被关注
let status = new FollowListStatusRequestItem()
status.creatorIds.push(new QueryListIsFollowedItem(this.data_rmh[0].creatorId))
...
...
@@ -159,7 +162,7 @@ export struct SearchResultContentComponent {
}).catch((err: Error) => {
console.log(TAG, "请求失败")
})
}
else
{
}
else
{
this.bean.status = ""
}
}
...
...
@@ -192,6 +195,8 @@ export struct SearchResultContentComponent {
})
})
if (data.contentList.length > 0) {
SearcherAboutDataModel.getInteractListData(data, getContext(this)).then((newValue) => {
newValue.forEach((item) => {
resultData.list.forEach((data) => {
...
...
@@ -206,32 +211,32 @@ export struct SearchResultContentComponent {
})
// 批量号主信息
let creatorIdList: string[] = []
resultData.list.forEach((value:
SearchResultContentItem) => {
resultData.list.forEach((value:
SearchResultContentItem) => {
creatorIdList.push(value.data.creatorId)
})
SearcherAboutDataModel.getCreatorDetailListData({creatorIdList:creatorIdList
}).then((rem) => {
SearcherAboutDataModel.getCreatorDetailListData({ creatorIdList: creatorIdList
}).then((rem) => {
resultData.list.forEach((value: SearchResultContentItem) => {
const landscape = value.data.landscape
let photos: FullColumnImgUrlDTO[] = []
// if (value.data.appStyle === 4) {
value.data.appStyleImages.split("&&").forEach((value) => {
let resizeParams = MinePageDatasModel.extractResizeParams(value)
if
(resizeParams && resizeParams.length === 2)
{
if
(resizeParams && resizeParams.length === 2)
{
photos.push(
{
fullUrl: value,
weight:resizeParams[0],
height:resizeParams[1],
weight: resizeParams[0],
height: resizeParams[1],
landscape: Number(landscape),
} as FullColumnImgUrlDTO
)
}
})
// }
let contentDTO = this.dataTransform(rem,value, photos);
if(value.data.type != "13"){
let contentDTO = this.dataTransform(rem, value, photos);
if (value.data.type != "13") {
this.data.push(contentDTO)
if
(value.data.sameContentList != null && value.data.sameContentList.length > 0) {
if
(value.data.sameContentList != null && value.data.sameContentList.length > 0) {
let contentDTO2 = new ContentDTO();
contentDTO2.sameContentListJson = JSON.stringify(value.data.sameContentList)
contentDTO2.sameContentListSize = value.data.sameContentList.length
...
...
@@ -257,22 +262,30 @@ export struct SearchResultContentComponent {
this.isLoading = false
this.count = this.count === -1 ? 0 : this.count
})
}else {
this.hasMore = false
}
}
build() {
Column() {
if (this.count == 0) {
ListHasNoMoreDataUI({ style: 2 })
// ListHasNoMoreDataUI({ style: 2 })
EmptyComponent({
emptyType: WDViewDefaultType.WDViewDefaultType_NoSearchResult,
emptyButton: false,
})
} else {
List({scroller:this.scroller2}) {
if (this.data_rmh != null && this.data_rmh.length > 0){
if (this.data_rmh.length === 1){
ListItem(){
List({ scroller: this.scroller2 }) {
if (this.data_rmh != null && this.data_rmh.length > 0) {
if (this.data_rmh.length === 1) {
ListItem() {
FollowChildComponent({ data: this.bean, type: 1 })
}.padding({left:"31lpx",right:"31lpx"})
}else{
ListItem(){
Column(){
}.padding({ left: "31lpx", right: "31lpx" })
} else {
ListItem() {
Column() {
this.SearchListUI()
}
}
...
...
@@ -283,36 +296,37 @@ export struct SearchResultContentComponent {
Column() {
if (this.searchType == "activity") {
ActivityItemComponent({ contentDTO: item })
}
else if(item.sameContentListSize > 0)
{
}
else if (item.sameContentListSize > 0)
{
MoreComponent({ contentDTO: item })
}else if(item.appStyle == "9"){
Column(){
Card9Component({ compDTO: new CompDTO, contentDTO:item, pageId: "", pageName: "" })
} else if (item.appStyle == "9") {
Column() {
Card9Component({
compDTO: new CompDTO,
contentDTO: item,
pageId: "",
pageName: ""
})
Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 0, right: 0 })
}
} else {
if(this.data?.get(index + 1)?.sameContentListSize > 0) {
if
(this.data?.get(index + 1)?.sameContentListSize > 0) {
Divider()
.width('100%')
.color($r('app.color.color_F5F5F5'))
.strokeWidth(4)
}
CardParser({
compDTO:
new CompDTO, contentDTO: item })
CardParser({
compDTO:
new CompDTO, contentDTO: item })
}
if (index != this.data.totalCount() - 1) {
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
// Divider()
// .width('100%')
// .height('1lpx')
// .color($r('app.color.color_F5F5F5'))
// .strokeWidth('1lpx')
}
}
}
}, (item: ContentDTO, index: number) => index.toString())
//没有更多数据 显示提示
if (!this.hasMore &&
this.data.totalCount() > 0
) {
if (!this.hasMore &&
(this.data.totalCount() > 0|| (this.data_rmh != null && this.data_rmh.length > 0))
) {
ListItem() {
ListHasNoMoreDataUI()
}
...
...
@@ -320,6 +334,7 @@ export struct SearchResultContentComponent {
}.cachedCount(5)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.height('100%')
.onReachEnd(() => {
console.log(TAG, "触底了");
if (!this.isLoading) {
...
...
@@ -334,23 +349,23 @@ export struct SearchResultContentComponent {
@Builder
SearchListUI() {
List({initialIndex: 0,space:'8lpx',scroller: this.scroller}) {
ListItemGroup(){
List({ initialIndex: 0, space: '8lpx', scroller: this.scroller }) {
ListItemGroup() {
ForEach(this.data_rmh, (item: SearchRmhDescription, index: number) => {
ListItem() {
SearchCreatorComponent({
item:item
})
SearchCreatorComponent({
item: item
})
}
.width('150lpx')
.height('100%')
})
}.offset({ left: this.listLeft })
ListItem(){
if (this.data_rmh.length === 10){
ListItem() {
if (this.data_rmh.length === 10) {
this.itemEnd()
}
}.height('100%')
.margin({
left:'23lpx'
})
.margin({
left: '23lpx'
})
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
...
...
@@ -359,10 +374,10 @@ export struct SearchResultContentComponent {
.height('219lpx')
.onReachEnd(() => {
this.isEnd = true
console.log(TAG,'is end')
console.log(TAG,
'is end')
})
.onScrollFrameBegin((offset: number, state: ScrollState) => {
console.log(TAG,'offset', offset)
console.log(TAG,
'offset', offset)
if (!this.scroller.isAtEnd()) {
this.isEnd = false
}
...
...
@@ -374,31 +389,35 @@ export struct SearchResultContentComponent {
.parallelGesture(
PanGesture({ direction: PanDirection.Horizontal, distance: 1 })
.onActionStart((event: GestureEvent) => {
console.info(TAG,'Pan start')
console.info(TAG,
'Pan start')
})
.onActionUpdate((event: GestureEvent) => {
///小于10个不展示滑动
if (this.data_rmh.length < 10) return;
if (this.data_rmh.length < 10) {
return;
}
if (event && this.isEnd) {
// console.log('event.offsetX',event.offsetX)
this.listLeft = event.offsetX < -60 ? -60 : event.offsetX > 0 ? 0 : event.offsetX
this.ellipseW = (-this.listLeft) / 1.5
console.log(TAG,"this.ellipseW==>" + this.ellipseW)
console.log(TAG,
"this.ellipseW==>" + this.ellipseW)
}
})
.onActionEnd((event: GestureEvent) => {
if (this.data_rmh.length < 10) return;
console.info(TAG,'Pan end')
if (this.data_rmh.length < 10) {
return;
}
console.info(TAG, 'Pan end')
this.listLeft = 0
// this.moreWidth = 20
if (event.offsetX < 0 && this.ellipseW >=20) {
console.log(TAG,'跳转')
if (event.offsetX < 0 && this.ellipseW >= 20) {
console.log(TAG, '跳转')
let params: Params = {
pageID: this.keywords
}
WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage,params)
WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage,
params)
}
this.ellipseW = 0
})
...
...
@@ -411,18 +430,17 @@ export struct SearchResultContentComponent {
.strokeWidth('12lpx')
}
@Builder
itemEnd() {
Row() {
Ellipse()
.width(2* this.ellipseW)
.width(2
* this.ellipseW)
.height('100%')
.fill('rgb(240,235,238)')
.position({ left: -this.ellipseW, top: 0 })
Column(){
Text(this.ellipseW === 0 ? '' : this.ellipseW < 20? '查看更多' : '松手查看')
Column() {
Text(this.ellipseW === 0 ? '' : this.ellipseW < 20 ? '查看更多' : '松手查看')
.width('19lpx')
.fontSize('19lpx')
.fontWeight('400lpx')
...
...
@@ -437,17 +455,18 @@ export struct SearchResultContentComponent {
.height('100%')
}
private dataTransform(rem:CreatorDetailResponseItem[],value: SearchResultContentItem, photos: FullColumnImgUrlDTO[]): ContentDTO {
let rmhInfo = this.getRmhInfo(rem,value)
console.log('获取photos',JSON.stringify(photos))
console.log('获取value2',JSON.stringify(value))
private dataTransform(rem: CreatorDetailResponseItem[], value: SearchResultContentItem,
photos: FullColumnImgUrlDTO[]): ContentDTO {
let rmhInfo = this.getRmhInfo(rem, value)
console.log('获取photos', JSON.stringify(photos))
console.log('获取value2', JSON.stringify(value))
let liveType = value.data?.liveType;
let seoTags = value.data?.seoTags
let cornerMark = value.data?.cornerMark
let contentDTO = new ContentDTO();
contentDTO.liveType = liveType?liveType: ""
contentDTO.seoTags = seoTags?seoTags: ""
contentDTO.cornerMark = cornerMark?cornerMark: ""
contentDTO.liveType = liveType ? liveType : ""
contentDTO.seoTags = seoTags ? seoTags : ""
contentDTO.cornerMark = cornerMark ? cornerMark : ""
contentDTO.appStyle = value.data.appStyle + ""
contentDTO.cityCode = value.data.cityCode
contentDTO.coverSize = ""
...
...
@@ -529,13 +548,13 @@ export struct SearchResultContentComponent {
}
// 搜索数据转化rmhInfo
private getRmhInfo(rem:CreatorDetailResponseItem[],value:SearchResultContentItem)
{
private getRmhInfo(rem: CreatorDetailResponseItem[], value: SearchResultContentItem)
{
let obj = value.data
let rmhInfo:RmhInfoDTO = {
rmhHeadUrl:obj.headerPhotoUrl,
rmhName:obj.creatorName,
rmhId:obj.creatorId,
authIcon:obj.authIcon,
let rmhInfo: RmhInfoDTO = {
rmhHeadUrl: obj.headerPhotoUrl,
rmhName: obj.creatorName,
rmhId: obj.creatorId,
authIcon: obj.authIcon,
authTitle: obj.authTitle,
authTitle2: '',
banControl: 0,
...
...
@@ -546,44 +565,43 @@ export struct SearchResultContentComponent {
cnMainControl: 0,
cnShareControl: 0,
cnIsComment: 0,
cnIsLike:
0,
cnIsLike:
0,
posterShareControl: 0,
rmhDesc: obj.introduction,
userId: obj.userId,
userType: obj.userType,
honoraryIcon:'',
rmhPlatform:0
honoraryIcon: '',
rmhPlatform: 0
}
if(rem.length>0){
rem.forEach(item=>{
if(item.creatorId === obj.creatorId){
if (rem.length > 0) {
rem.forEach(item => {
if (item.creatorId === obj.creatorId) {
rmhInfo = {
rmhHeadUrl:item.headPhotoUrl,
rmhName:item.userName,
rmhId:item.creatorId,
authIcon:item.authIcon,
rmhHeadUrl: item.headPhotoUrl,
rmhName: item.userName,
rmhId: item.creatorId,
authIcon: item.authIcon,
authTitle: item.authTitle,
authTitle2: '',
banControl: 0,
cnIsAttention:
item.isAttention,
cnIsAttention:
item.isAttention,
cnAttention: 0,
cnlsComment: 0,
cnlsLike: 0,
cnMainControl: 0,
cnShareControl: 0,
cnIsComment: 0,
cnIsLike:
0,
cnIsLike:
0,
posterShareControl: 0,
rmhDesc: item.introduction,
userId: item.userId,
userType: item.userType,
honoraryIcon:'',
rmhPlatform:0
honoraryIcon: '',
rmhPlatform: 0
}
}
})
}
return rmhInfo
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/EmptyComponent.ets
View file @
a8a2c80
...
...
@@ -58,6 +58,7 @@ export struct EmptyComponent {
@State emptyHeight: string | number = CommonConstants.FULL_PARENT;
@State emptyType: number = WDViewDefaultType.WDViewDefaultType_Default; // 缺省图类型,传枚举
@State emptyButton: boolean = false
@State isBlack: boolean = false // 背景是否为黑色 默认白色
@State timeNum: number = 10
/**
* The empty image width percentage setting.
...
...
@@ -135,7 +136,7 @@ export struct EmptyComponent {
})
if (this.isShowButton()) {
if (this.emptyType !== 15) {
if (this.emptyType !== 15
&& !this.isBlack
) {
Button('点击重试')
.type(ButtonType.Normal)
.width(80)
...
...
@@ -253,7 +254,7 @@ export struct EmptyComponent {
}
isShowButton() {
if (this.emptyType === 1 || this.emptyType === 9 || this.emptyType === 15) {
if (this.emptyType === 1 || this.emptyType === 9 || this.emptyType === 15
&& this.emptyButton
) {
return true
} else {
return false
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/HorizontalStrokeCardThreeTwoRadioForMoreComponent.ets
View file @
a8a2c80
...
...
@@ -57,10 +57,10 @@ export struct HorizontalStrokeCardThreeTwoRadioForMoreComponent {
liveToMore() {
if (!!this.compDTO.dataSourceType) {
if (this.compDTO.dataSourceType === 'OBJECT_POS') {
ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string, this.compDTO.objectTitle)
return;
}
// if (this.compDTO.dataSourceType === 'OBJECT_POS') {
// ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string, this.compDTO.objectTitle)
// return;
// }
if (this.compDTO.linkUrl) {
let taskAction: Action = {
type: 'JUMP_H5_BY_WEB_VIEW',
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/ImageItemView.ets
deleted
100644 → 0
View file @
557a4a0
import { image } from '@kit.ImageKit';
import { matrix4, promptAction, window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
import { ScaleModel } from '../../model/ScaleModel';
import { OffsetModel } from '../../model/OffsetModel';
import { windowSizeManager } from '../../utils/Managers';
import { runWithAnimation } from '../../utils/FuncUtils';
import { PhotoListBean } from 'wdBean/Index';
import { http } from '@kit.NetworkKit';
// TODO:知识点:组件复用
@Reusable
@Component
export struct ImageItemView {
// @Consume private bgc: Color;
@Link isEnableSwipe: boolean; // TODO:需求:多图切换
@State isEnableOffset: boolean = false;
@State imageScaleInfo: ScaleModel = new ScaleModel(1.0, 1.0, 1.5, 0.3);
@State imageOffsetInfo: OffsetModel = new OffsetModel(0, 0);
@State matrix: matrix4.Matrix4Transit = matrix4.identity().copy();
@State imagePixelMap: image.PixelMap | null = null; // 当前图片pixelMap,用于Image组件显示
@State fitWH: "width" | "height" | undefined = undefined; // 表示当前图片是根据宽度适配还是高度适配
@State imageDefaultSize: image.Size = { width: 0, height: 0 }; // 图片默认大小,即,与屏幕大小最适配的显示大小
imageUri: string = ""; // 当前图片uri
imageWHRatio: number = 0; // 图片原始宽高比
private MultiPictureDetailItem: PhotoListBean = {} as PhotoListBean
@State imageBuffer: ArrayBuffer | undefined = undefined; // 图片ArrayBuffer
//alt app.media.picture_loading 设计稿尺寸
@State imageWidth:string | number = 167
private scroller: Scroller = new Scroller()
aboutToAppear(): void {
this.imageUri = this.MultiPictureDetailItem.picPath
this.getPicture()
}
/**
* 通过http的request方法从网络下载图片资源
*/
async getPicture() {
// 每一个httpRequest对应一个HTTP请求任务,不可复用
let httpRequest = http.createHttp();
// 用于订阅HTTP响应头事件
httpRequest.on('headersReceive', (header: Object) => {
console.info('header: ' + JSON.stringify(header));
});
// 用于订阅HTTP流式响应数据接收事件
let res = new ArrayBuffer(0);
httpRequest.on('dataReceive', (data: ArrayBuffer) => {
const newRes = new ArrayBuffer(res.byteLength + data.byteLength);
const resView = new Uint8Array(newRes);
resView.set(new Uint8Array(res));
resView.set(new Uint8Array(data), res.byteLength);
res = newRes;
// console.info('dataReceive res length: ' + res.byteLength);
});
// 用于订阅HTTP流式响应数据接收完毕事件
httpRequest.on('dataEnd', () => {
this.transcodePixelMap(res);
// 判断网络获取到的资源是否为ArrayBuffer类型
console.info(`dataEnd getPicture ${res}`)
if (res instanceof ArrayBuffer) {
console.info(`dataEnd getPicture`)
this.imageBuffer = res as ArrayBuffer;
}
console.info('No more data in response, data receive end');
});
httpRequest.requestInStream(this.imageUri,
(error: BusinessError, data: number) => {
if (error) {
// 下载失败时弹窗提示检查网络,不执行后续逻辑
promptAction.showToast({
message: $r('app.string.image_request_fail'),
duration: 2000
})
this.getPicture()
console.error(`http reqeust failed with. Code: ${error.code}, message: ${error.message}`);
return;
}
// 取消订阅HTTP响应头事件
httpRequest.off('headersReceive');
// 取消订阅HTTP流式响应数据接收事件
httpRequest.off('dataReceive');
// 取消订阅HTTP流式响应数据接收完毕事件
httpRequest.off('dataEnd');
// 当该请求使用完毕时,调用destroy方法主动销毁
httpRequest.destroy();
}
)
}
/**
* 使用createPixelMap将ArrayBuffer类型的图片装换为PixelMap类型
* @param data:网络获取到的资源
*/
transcodePixelMap(data: ArrayBuffer) {
const imageData: ArrayBuffer = data;
// 通过ArrayBuffer创建图片源实例。
const imageSource: image.ImageSource = image.createImageSource(imageData);
this.initCurrentImageInfo(imageSource);
}
/**
* 根据图片宽高比及窗口大小计算图片的默认宽高,即,图片最适配屏幕的大小
* @param imageWHRatio:图片原始宽高比
* @param size:窗口大小{with:number,height:number}
* @returns image.Size
*/
calcImageDefaultSize(imageWHRatio: number, size: window.Size): image.Size {
let width = 0
let height = 0;
width = size.width;
height = size.width / imageWHRatio;
return { width: width, height: height };
}
/**
* TODO:知识点:根据图片大小(宽高<=屏幕宽高)和屏幕大小计算图片放大适配屏幕进行显示的缩放倍率
* @param imageSize:图片当前大小
* @param windowSize:窗口大小
* @returns:缩放倍率
*/
calcFitScaleRatio(imageSize: image.Size, windowSize: window.Size): number {
let ratio: number = 1.0;
if (windowSize.width > imageSize.width) {
ratio = windowSize.width / imageSize.width;
} else {
ratio = windowSize.height / imageSize.height;
}
return ratio;
}
/**
* 设置当前图片的相关信息:uri、whRatio、pixelMap、fitWH、defaultSize、maxScaleValue
* TODO:知识点:提前获取图片的信息,以进行Image组件的尺寸设置及后续的相关计算
*/
initCurrentImageInfo(imageSource: image.ImageSource): void {
this.matrix = matrix4.identity().copy();
// const imageSource: image.ImageSource = image.createImageSource(this.imageUri);
imageSource.getImageInfo(0).then((data: image.ImageInfo) => {
this.imageWHRatio = data.size.width / data.size.height;
console.error(`this.imageDefaultSize this.imageWHRatio = ${this.imageWHRatio}`);
console.error(`this.imageDefaultSize width = ${data.size.width}`);
console.error(`this.imageDefaultSize height = ${data.size.height}`);
this.imageDefaultSize = this.calcImageDefaultSize(this.imageWHRatio, windowSizeManager.get());
console.error(`this.imageDefaultSize = ${JSON.stringify(windowSizeManager.get())}`);
console.error(`this.imageDefaultSize = ${JSON.stringify(this.imageDefaultSize)}`);
if (this.imageDefaultSize.width === windowSizeManager.get().width) {
this.fitWH = "width";
} else {
this.fitWH = "height";
}
this.imageScaleInfo.maxScaleValue += this.fitWH === "width" ?
(windowSizeManager.get().height / this.imageDefaultSize.height) :
(windowSizeManager.get().width / this.imageDefaultSize.width);
}).catch((err: BusinessError) => {
console.error(`[error][getImageInfo]${err.message}`);
});
imageSource.createPixelMap().then((data: image.PixelMap) => {
this.imagePixelMap = data;
}).catch((err: BusinessError) => {
console.error(`[error][createPixelMap]${err.message}`);
});
this.isEnableOffset = false;
this.imageScaleInfo.reset();
this.imageOffsetInfo.reset();
}
/**
* 在图片消失时,将当前图片的信息设置为默认值
*/
resetCurrentImageInfo(): void {
this.imageScaleInfo.reset();
this.imageOffsetInfo.reset();
this.matrix = matrix4.identity().copy();
}
/**
* TODO:需求:在偏移时评估是否到达边界,以便进行位移限制与图片的切换
* @returns:长度为4的boolean数组,表示上下左右是否到达边界
*/
evaluateBound(): boolean[] {
return [false, false, false, false];
}
build() {
Stack() {
Scroll(this.scroller) {
if(this.imageUri != null && (this.imageUri.includes('.gif') || this.imageUri.includes('.GIF'))){
Image(this.imageUri)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
.alt($r('app.media.datail_imageLoading_w'))
.width(this.imageWidth)
.objectFit(ImageFit.Auto)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能
.interpolation(ImageInterpolation.High)
.autoResize(false)
.transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放
.defaultFocus(true)
.offset({
// TODO:知识点:通过offset控制图片的偏移
x: this.imageOffsetInfo.currentX,
y: this.imageOffsetInfo.currentY
})
.onComplete(event => {
this.imageWidth = '100%'
})
} else {
Image(this.imagePixelMap)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
.alt($r('app.media.datail_imageLoading_w'))
.width(this.imageWidth)
.objectFit(ImageFit.Auto)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能
.interpolation(ImageInterpolation.High)
.autoResize(false)
.transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放
.defaultFocus(true)
.offset({
// TODO:知识点:通过offset控制图片的偏移
x: this.imageOffsetInfo.currentX,
y: this.imageOffsetInfo.currentY
})
.onComplete(event => {
this.imageWidth = '100%'
})
}
}
.scrollable(ScrollDirection.Vertical)
.scrollBarWidth(0)
.constraintSize({
maxHeight: this.imageDefaultSize.height
})
}
.onBlur(() => {
this.resetCurrentImageInfo();
})
// .backgroundColor(this.bgc)
.alignContent(Alignment.Center)
.width("100%")
.height("100%")
.backgroundColor(Color.Black)
.gesture(
GestureGroup(
GestureMode.Exclusive,
// TODO:知识点:双击切换图片大小
TapGesture({ count: 2 })
.onAction(() => {
let fn: Function;
// 已经是放大状态下,双击缩小
if (this.imageScaleInfo.scaleValue > this.imageScaleInfo.defaultScaleValue) {
fn = () => {
this.isEnableSwipe = true;
this.imageScaleInfo.reset();
this.imageOffsetInfo.reset();
this.matrix = matrix4.identity().copy();
};
} else {
// 已经是缩小状态,双击放大
fn = () => {
this.isEnableSwipe = false;
const ratio: number = this.calcFitScaleRatio(this.imageDefaultSize, windowSizeManager.get());
this.imageScaleInfo.scaleValue = ratio;
this.imageOffsetInfo.reset();
this.matrix = matrix4.identity().scale({
x: ratio,
y: ratio,
}).copy();
this.imageScaleInfo.stash();
}
}
runWithAnimation(fn);
}),
// 单击切换背景色
// TapGesture({ count: 1 }).onAction(() => {
// runWithAnimation(() => {
// this.bgc = this.bgc === Color.White ? Color.Black : Color.White;
// });
// }),
// TODO:知识点:双指捏合缩放图片
PinchGesture({ fingers: 2, distance: 1 })
.onActionUpdate((event: GestureEvent) => {
this.imageScaleInfo.scaleValue = this.imageScaleInfo.lastValue * event.scale;
// TODO:知识点:缩放时不允许大于最大缩放因子+额外缩放因子,不允许小于默认大小-额外缩放因子,额外缩放因子用于提升用户体验
if (this.imageScaleInfo.scaleValue > this.imageScaleInfo.maxScaleValue *
(1 + this.imageScaleInfo.extraScaleValue)
) {
this.imageScaleInfo.scaleValue = this.imageScaleInfo.maxScaleValue *
(1 + this.imageScaleInfo.extraScaleValue);
}
if (this.imageScaleInfo.scaleValue < this.imageScaleInfo.defaultScaleValue *
(1 - this.imageScaleInfo.extraScaleValue)) {
this.imageScaleInfo.scaleValue = this.imageScaleInfo.defaultScaleValue *
(1 - this.imageScaleInfo.extraScaleValue);
}
// TODO:知识点:matrix默认缩放中心为组件中心
this.matrix = matrix4.identity().scale({
x: this.imageScaleInfo.scaleValue,
y: this.imageScaleInfo.scaleValue,
}).copy();
console.debug(this.imageScaleInfo.toString());
})
.onActionEnd((event: GestureEvent) => {
/**
* TODO:知识点:当小于默认大小时,恢复为默认大小
*/
if (this.imageScaleInfo.scaleValue < this.imageScaleInfo.defaultScaleValue) {
runWithAnimation(() => {
this.imageScaleInfo.reset();
this.imageOffsetInfo.reset();
this.matrix = matrix4.identity().copy();
})
}
// TODO:知识点:当大于最大缩放因子时,恢复到最大
if (this.imageScaleInfo.scaleValue > this.imageScaleInfo.maxScaleValue) {
runWithAnimation(() => {
this.imageScaleInfo.scaleValue = this.imageScaleInfo.maxScaleValue;
this.matrix = matrix4.identity()
.scale({
x: this.imageScaleInfo.maxScaleValue,
y: this.imageScaleInfo.maxScaleValue
});
})
}
this.imageScaleInfo.stash();
}),
// // TODO:知识点:滑动图片
// PanGesture({ fingers: 1 })// TODO:需求:默认大小下左右滑动应当是切换图片
// .onActionUpdate((event: GestureEvent) => {
// if (this.imageScaleInfo.scaleValue === this.imageScaleInfo.defaultScaleValue) {
// // 默认大小下不允许移动
// return;
// }
// this.imageOffsetInfo.currentX = this.imageOffsetInfo.lastX + event.offsetX;
// this.imageOffsetInfo.currentY = this.imageOffsetInfo.lastY + event.offsetY;
// })
// .onActionEnd((event: GestureEvent) => {
// this.imageOffsetInfo.stash();
// })
),
)
}
}
\ No newline at end of file
sight_harmony/features/wdComponent/src/main/ets/pages/MultiPictureListPage.ets
View file @
a8a2c80
import { PhotoListBean } from 'wdBean/Index';
import { display, router } from '@kit.ArkUI';
import { ImageItemView } from '../components/view/ImageItemView';
import { ImageDownloadComponent } from '../components/ImageDownloadComponent';
import { MultiPictureDetailItemComponent } from '../components/MultiPictureDetailItemComponent';
import { Action } from 'wdBean';
import { WindowModel } from 'wdKit/Index';
...
...
@@ -68,11 +69,10 @@ export struct MultiPictureListPage {
})
.id("backImg")
if (this.photoList && this.photoList?.length > 0) {
Swiper(this.swiperController) {
ForEach(this.photoList, (item: PhotoListBean) => {
ImageItemView
({ MultiPictureDetailItem: item, isEnableSwipe: this.isEnableSwipe })
MultiPictureDetailItemComponent
({ MultiPictureDetailItem: item, isEnableSwipe: this.isEnableSwipe })
})
}
.index(this.swiperIndex)
...
...
@@ -135,7 +135,6 @@ export struct MultiPictureListPage {
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
}
ImageDownloadComponent({ url: this.currentUrl })
.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
...
...
@@ -152,6 +151,7 @@ export struct MultiPictureListPage {
.width('100%')
.height('100%')
.id('e_picture_container')
.backgroundColor(Color.Black)
}
aboutToDisappear(): void {
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/SearchResultCountItem.ets
View file @
a8a2c80
...
...
@@ -5,11 +5,25 @@
*/
export class SearchResultCountItem{
/*
"allTotal":0,
"activityTotal":0,
"cmsTotal":0,
"trueTotal":0,
"pageSize":1,
"keyword":"wuhuhuan",
"totalCount":0,
"pageNum":1,
"videoTotal":0,
"rmhTotal":5
*/
keyword:string ='' //搜索关键字
allTotal: number = 0 //所有tab总量
cmsTotal: number = 0 //精选总量
rmhTotal: number = 0 //人民号总量
videoTotal: number = 0 //视频总量
activityTotal: number = 0 //活动数据总量
}
\ No newline at end of file
...
...
sight_harmony/features/wdDetailPlayLive/oh-package.json5
View file @
a8a2c80
...
...
@@ -7,7 +7,6 @@
"main"
:
"Index.ets"
,
"version"
:
"1.0.0"
,
"dependencies"
:
{
"@ohos/lottie"
:
"2.0.10"
,
"wdComponent"
:
"file:../../features/wdComponent"
,
"wdPlayer"
:
"file:../../features/wdPlayer"
,
"wdNetwork"
:
"file:../../commons/wdNetwork"
,
...
...
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/video/PlayUIComponent.ets
View file @
a8a2c80
...
...
@@ -370,6 +370,7 @@ export struct PlayUIComponent {
this.playerController?.pause()
} else {
this.isPlayStatus = true
this.playerController?.firstPlay(this.liveUrl)
this.playerController?.play()
}
})
...
...
sight_harmony/features/wdDetailPlayShortVideo/oh-package.json5
View file @
a8a2c80
...
...
@@ -7,7 +7,6 @@
"main"
:
"Index.ets"
,
"version"
:
"1.0.0"
,
"dependencies"
:
{
"@ohos/lottie"
:
"2.0.0"
,
"wdPlayer"
:
"file:../../features/wdPlayer"
,
"wdKit"
:
"file:../../commons/wdKit"
,
"wdBean"
:
"file:../../features/wdBean"
,
...
...
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailVideoListPage.ets
View file @
a8a2c80
...
...
@@ -204,7 +204,7 @@ export struct DetailVideoListPage {
build() {
if (this.netStatus !== undefined) {
EmptyComponent({
emptyType: 1, emptyButton: true, retry: () => {
emptyType: 1, emptyButton: true,
isBlack: true,
retry: () => {
this.getContentDetail(this.contentId, this.relId, this.relType)
}
})
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/guide/GuidePages.ets
View file @
a8a2c80
...
...
@@ -36,6 +36,7 @@ struct GuidePages {
ChildItem(index: number) {
RelativeContainer() {
Image(this.guideImage[index])
.objectFit(ImageFit.Contain)
.alignRules({
top: { anchor: "__container__", align: VerticalAlign.Top },
bottom: { anchor: "__container__", align: VerticalAlign.Bottom }
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginPage.ets
View file @
a8a2c80
...
...
@@ -122,7 +122,16 @@ struct LoginPage {
this.disableScreenCapture()
}
onPageHide(): void {
///关闭禁止截图
this.isPrivacyMode = false
this.disableScreenCapture()
this.loginPageBrowse()
}
loginPageBrowse(){
this.pageHideTime = DateTimeUtils.getTimeStamp()
let duration = 0
duration = Math.floor((this.pageHideTime - this.pageShowTime)/1000)
...
...
@@ -132,8 +141,6 @@ struct LoginPage {
}else{
TrackingPageBrowse.trackCommonPageExposureEnd(TrackConstants.PageName.Login_Page,TrackConstants.PageName.Login_Page,duration)
}
this.isPrivacyMode = false
this.disableScreenCapture()
}
build() {
...
...
@@ -372,7 +379,7 @@ struct LoginPage {
.lineHeight(`${this.calcHeight(38)}lpx`)
}
.onClick(() => {
this.
onPageHid
e()
this.
loginPageBrows
e()
if(this.checkCodePage){
trackTypeClick(0,TrackConstants.PageName.Phone_Login_Page)
...
...
sight_harmony/oh-package.json5
View file @
a8a2c80
...
...
@@ -10,7 +10,8 @@
"main"
:
""
,
"version"
:
"1.0.0"
,
"dependencies"
:
{
"@ohos/pulltorefresh"
:
"^2.0.5"
,
"@ohos/pulltorefresh"
:
"^2.0.6-rc.0"
,
"@ohos/lottie"
:
"v2.0.11-rc.6"
,
"@mpaas/udid"
:
"0.0.2"
,
"@mpaas/upgrade"
:
"0.0.2"
,
"@mpaas/framework"
:
"0.0.2"
,
...
...
sight_harmony/products/phone/oh-package.json5
View file @
a8a2c80
...
...
@@ -7,7 +7,6 @@
"main"
:
""
,
"version"
:
"1.0.0"
,
"dependencies"
:
{
"@ohos/lottie"
:
"v2.0.11-rc.6"
,
"wdComponent"
:
"file:../../features/wdComponent"
,
"wdConstant"
:
"file:../../commons/wdConstant"
,
"wdKit"
:
"file:../../commons/wdKit"
,
...
...
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchAdvertisingPage.ets
View file @
a8a2c80
...
...
@@ -91,11 +91,11 @@ struct LaunchAdvertisingPage {
Text('广告')
.fontColor(Color.White)
.textAlign(TextAlign.Center)
.fontSize('24lpx')
.width('72lpx')
.height('36lpx')
.fontSize(12)
.width(36)
.height(18)
.borderRadius(2)
.margin({top:'
15lpx',left:'19l
px'})
.margin({top:'
8px',left:'10
px'})
.backgroundColor('#80000000')
.margin({left:16})
}
...
...
@@ -104,13 +104,13 @@ struct LaunchAdvertisingPage {
Button(){
Text(this.time + 's 跳过')
.fontSize(
'27lpx'
)
.fontSize(
14
)
.fontColor(Color.White)
.margin({left:
'28lpx',right:'28lpx'
})
.margin({left:
14,right:14
})
}
.width('148lpx')
.height('56lpx')
.margin({top:'10lpx',right:'19lpx'})
.width(74)
.height(28)
.margin({top:5,right:10})
.backgroundColor('#80000000')
.onClick(() => {
this.trackingLaunchJumpOver()
...
...
@@ -125,21 +125,21 @@ struct LaunchAdvertisingPage {
Button(){
Row(){
Text(this.defaultModel.isAd == '1'?'点击跳转至详情或第三方应用':'点击跳转至详情')
.fontSize(
'31lpx'
)
.fontSize(
16
)
.fontColor(Color.White)
.margin({
left:
'55lpx'
left:
28
})
Image($r('app.media.Slice'))
.width('46lpx')
.height('46lpx')
.margin({right:'55lpx'})
.width(28)
.height(23)
.margin({right:28})
}.alignItems(VerticalAlign.Center)
}
.width('566lpx')
.height('111lpx')
.width(284)
.height(56)
.margin({
bottom:
'51lpx'
bottom:
26
})
.borderWidth(1)
.borderColor(Color.White)
...
...
@@ -151,8 +151,8 @@ struct LaunchAdvertisingPage {
if(this.defaultModel.screenType == '1') {
Column(){
Image($r('app.media.LaunchPage_logo'))
.width('278lpx')
.height('154lpx')
.width(140)
.height(77)
.margin({top:20})
}.width('100%').height('16%').backgroundColor(Color.White)
// .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM])
...
...
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchInterestsHobbiesPage.ets
View file @
a8a2c80
...
...
@@ -40,11 +40,11 @@ struct LaunchInterestsHobbiesPage {
Row(){
Blank()
Text('跳过')
.fontSize(
'27lpx'
)
.fontSize(
14
)
.fontColor('#333333')
.width('54lpx')
.height('35lpx')
.margin({top:'30lpx',right:'46lpx'})
.width(30)
.height(18)
.margin({top:15,right:23})
.onClick(()=>{
//直接跳过到首页
//跳转首页
...
...
@@ -58,20 +58,20 @@ struct LaunchInterestsHobbiesPage {
.justifyContent(FlexAlign.End)
Text('选择感兴趣的内容')
.fontSize(
'46lpx'
)
.fontSize(
23
)
.fontWeight(FontWeight.Bold)
.textAlign(TextAlign.Center)
.fontColor('#333333')
.width('100%')
.height('61lpx')
.margin({top:'54lpx'})
.height(30)
.margin({top:27})
Text('完善信息,将为您推荐个性化的内容')
.fontSize(
'27lpx'
)
.fontSize(
14
)
.textAlign(TextAlign.Center)
.fontColor('#9E9E9E')
.width('100%')
.height('35lpx')
.margin({top:'12lpx'})
.height(17)
.margin({top:6})
if(!this.isConnectNetwork){
EmptyComponent({ emptyType: 1,emptyHeight:"60%" ,retry: () => {
...
...
@@ -141,39 +141,36 @@ struct LaunchInterestsHobbiesPage {
})
}
.width('90%')
.margin({top:
'61lpx',bottom:'300lpx'
})
.margin({top:
30,bottom:150
})
.columnsTemplate('1fr 1fr 1fr')
.columnsGap('23lpx')
.rowsGap('23lpx')
.scrollBar(BarState.Off)
}
}
.width('100%')
.height('100%')
}
.width('100%')
.height(`calc(100% - ${158 + 'lpx'})`)
// .backgroundColor(Color.Red)
.height(`calc(100% - ${260 + 'px'})`)
Stack({alignContent:Alignment.Center}){
Button(this.selectCount == 0?'选好了':'选好了(' + this.selectCount + ')')
.fontSize(
'35lpx'
)
.fontSize(
18
)
.fontColor('#FFFFFF')
.backgroundColor('#ED2800')
.type(ButtonType.Normal)
.borderRadius('10lpx')
.width('662lpx')
.height('84lpx')
.margin({top:'10lpx'})
.borderRadius(5)
.width(320)
.height(44)
.margin({top:5})
Image('')
.width('662lpx')
.height('84lpx')
.margin({top:'10lpx'})
.width(320)
.height(44)
.margin({top:5})
.backgroundColor(Color.White)
.opacity(this.selectCount == 0 ? 0.6 : 0)
.borderRadius(
'10lpx'
)
.borderRadius(
5
)
.onClick(()=>{
if (this.selectCount == 0) {
this.dialogToast.open()
...
...
@@ -188,8 +185,8 @@ struct LaunchInterestsHobbiesPage {
})
}
.width('100%')
.height('108lpx')
.margin({top:0})
.height(54)
.margin({top:5})
// .backgroundColor(Color.Orange)
}
.width('100%')
...
...
sight_harmony/products/phone/src/main/ets/pages/launchPage/LaunchPage.ets
View file @
a8a2c80
...
...
@@ -166,10 +166,10 @@ struct LaunchPage {
Stack({alignContent:Alignment.Bottom}){
Image($r('app.media.LaunchPage_logo'))
.width('278lpx')
.height('154lpx')
.width(139)
.height(87)
.margin({
bottom:
'48lpx'
bottom:
24
})
}
...
...
sight_harmony/products/phone/src/main/ets/pages/view/MultiPictureDetailPageComponent.ets
View file @
a8a2c80
...
...
@@ -525,7 +525,7 @@ export struct MultiPictureDetailPageComponent {
@Builder
noNet() {
EmptyComponent({
emptyType: 1, emptyButton: true, retry: () => {
emptyType: 1, emptyButton: true,
isBlack: true,
retry: () => {
this.getContentDetailData()
}
})
...
...
@@ -534,6 +534,7 @@ export struct MultiPictureDetailPageComponent {
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
.backgroundColor(Color.Black)
}
@Builder
...
...
Please
register
or
login
to post a comment