陈剑华

Merge remote-tracking branch 'origin/main'

Showing 18 changed files with 368 additions and 105 deletions
... ... @@ -42,6 +42,7 @@ export class CompDTO implements BaseDTO {
imageScale: number = -1; // 封面图比例 1-4:3, 2-16:9, 3-3:2
audioDataList: AudioDTO[] = [];
titleShowPolicy: string | number = '';
titleShow: string | number = '';
/**
* 组件内容源类型 (LIVE_HORIZONTAL_CARD\LIVE_RESERVATION\LIVE_LARGE_CARD\LIVE_END\LIVE_MONTHLY_RANKING )
*/
... ... @@ -105,6 +106,7 @@ export class CompDTO implements BaseDTO {
comp.imageScale = old.imageScale
comp.audioDataList = old.audioDataList
comp.titleShowPolicy = old.titleShowPolicy
comp.titleShow = old.titleShow
comp.pageId = old.pageId
comp.extraData = old.extraData
comp.dataSourceType = old.dataSourceType
... ...
... ... @@ -91,6 +91,8 @@ export { OperRowListView } from './src/main/ets/components/view/OperRowListView'
export { LiveOperRowListView } from './src/main/ets/components/view/LiveOperRowListView';
export { SaveNetWorkPictures } from './src/main/ets/components/SaveNetWorkPictures';
export { ImageDownloadComponent } from './src/main/ets/components/ImageDownloadComponent';
export { PageRepository } from './src/main/ets/repository/PageRepository';
... ...
... ... @@ -50,10 +50,7 @@ export struct ENewspaperItemComponent {
})
.objectFit(ImageFit.Contain)
.zIndex(10)
newsSkeleton({showBottom: false})
.visibility(this.isShowSkeleton ? Visibility.Visible : Visibility.None)
.width('100%')
.zIndex(1)
if (this.contentWidth !== 0) {
Canvas(this.context)
.width(px2vp(this.contentWidth))
... ...
... ... @@ -155,8 +155,8 @@ export struct MultiPictureDetailItemComponent {
build() {
Swiper(this.swiperControllerItem){
Row(){ // 居中显示
List(){
ListItem(){
// List(){
// ListItem(){
if(this.imageUri != null && (this.imageUri.includes('.gif') || this.imageUri.includes('.GIF'))){
Image(this.imageUri)// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
.alt($r('app.media.datail_imageLoading_w'))
... ... @@ -179,7 +179,7 @@ export struct MultiPictureDetailItemComponent {
Image(this.imagePixelMap || 'app.media.datail_imageLoading_w')// TODO:知识点:宽高只根据其尺寸设置一个,通过保持宽高比来设置另一个属性
.alt($r('app.media.datail_imageLoading_w'))
.width(this.imageWidth)
.objectFit(ImageFit.Auto)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能
.objectFit(ImageFit.Cover)// TODO:知识点:保持宽高比进行缩放,可以超出父组件,以便实现多图切换的增强功能
.interpolation(ImageInterpolation.High)
.autoResize(false)
.transform(this.matrix)// TODO:知识点:通过matrix控制图片的缩放
... ... @@ -189,14 +189,15 @@ export struct MultiPictureDetailItemComponent {
x: this.imageOffsetInfo.currentX,
y: this.imageOffsetInfo.currentY
})
.onComplete(event => {
this.imageWidth = '100%'
})
}
}
}
.alignListItem(ListItemAlign.Center)
.scrollBarWidth(0)
// }
// }
// .alignListItem(ListItemAlign.Center)
// .scrollBarWidth(0)
}
.justifyContent(FlexAlign.Center)
}
... ...
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import http from '@ohos.net.http';
import ResponseCode from '@ohos.net.http';
import { image } from '@kit.ImageKit';
import { BusinessError } from '@ohos.base';
import common from '@ohos.app.ability.common';
import photoAccessHelper from '@ohos.file.photoAccessHelper';
import fs from '@ohos.file.fs';
import promptAction from '@ohos.promptAction';
import picker from '@ohos.file.picker';
import { taskpool } from '@kit.ArkTS';
import { httpRequest } from '../utils/httpRequest';
/**
* 实现步骤:
* 点击上部“下载”按钮进入”下载网络图片到手机相册”场景示例;点击下部“下载到指定路径”按钮进入”下载文件到指定用户目录”场景示例,
* 从而实现手机相册并进行网络图片的下载和保存。
* photoAccessHelper参考文档:
* https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-photoaccesshelper
* saveButton参考文档
* https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/savebutton-0000001820999677
*/
@Concurrent
async function getPicture(imageUrl: string): Promise<ArrayBuffer> {
let ret: ArrayBuffer = await new Promise((resolve, reject) => {
httpRequest.httpRequestInStream(imageUrl, (res: ArrayBuffer) => {
resolve(res); // 成功时解析Promise
}, () => {
// 下载失败时弹窗提示检查网络
promptAction.showToast({
message: $r('app.string.image_request_fail'),
duration: 2000
});
reject(new Error('Image download failed')); // 失败时拒绝Promise
});
});
return ret
}
@Component
export struct SaveNetWorkPictures {
@State image: PixelMap | undefined = undefined;
@State photoAccessHelper: photoAccessHelper.PhotoAccessHelper | undefined = undefined; // 相册模块管理实例
@State imageBuffer: ArrayBuffer | undefined = undefined; // 图片ArrayBuffer
// @Prop @Watch('onChangeUrl') url: string = ''
@Prop @Watch('onChangeUrl') url: string = ''
/**
* 通过http的request方法从网络下载图片资源
*/
async getPicture() {
http.createHttp()// 显示网络图片的地址
// .request('https://gitee.com/harmonyos-cases/cases/raw/master/CommonAppDevelopment/feature/variablewatch/src/main/resources/base/media/variablewatch_grape.png',
// .request('https://cdnjdphoto.aikan.pdnews.cn/zhbj-20240830/image/content/4d61839662044ac796ec7331a90da5d8.jpg',
.request(this.url,
(error: BusinessError, data: http.HttpResponse) => {
if (error) {
// 下载失败时弹窗提示检查网络,不执行后续逻辑
promptAction.showToast({
message: '下载失败',
duration: 2000
})
return;
}
this.transcodePixelMap(data);
// 判断网络获取到的资源是否为ArrayBuffer类型
if (data.result instanceof ArrayBuffer) {
this.imageBuffer = data.result as ArrayBuffer;
}
}
)
}
/**
* 使用createPixelMap将ArrayBuffer类型的图片装换为PixelMap类型
* @param data:网络获取到的资源
*/
transcodePixelMap(data: http.HttpResponse) {
if (ResponseCode.ResponseCode.OK === data.responseCode) {
const imageData: ArrayBuffer = data.result as ArrayBuffer;
// 通过ArrayBuffer创建图片源实例。
const imageSource: image.ImageSource = image.createImageSource(imageData);
const options: image.InitializationOptions = {
'alphaType': 0, // 透明度
'editable': false, // 是否可编辑
'pixelFormat': 3, // 像素格式
'scaleMode': 1, // 缩略值
'size': { height: 50, width: 50 }
}; // 创建图片大小
// 通过属性创建PixelMap
imageSource.createPixelMap(options).then((pixelMap: PixelMap) => {
this.image = pixelMap;
});
}
}
/**
* 保存ArrayBuffer到图库
* @param buffer:图片ArrayBuffer
* @returns
*/
async saveImage(buffer: ArrayBuffer | string): Promise<void> {
const context = getContext(this) as common.UIAbilityContext; // 获取getPhotoAccessHelper需要的context
const helper = photoAccessHelper.getPhotoAccessHelper(context); // 获取相册管理模块的实例
const uri = await helper.createAsset(photoAccessHelper.PhotoType.IMAGE, 'jpg'); // 指定待创建的文件类型、后缀和创建选项,创建图片或视频资源
const file = await fs.open(uri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
await fs.write(file.fd, buffer);
await fs.close(file.fd);
}
/**
* 保存ArrayBuffer到用户选择的路径
* @param buffer:图片ArrayBuffer
* @returns
*/
async pickerSave(buffer: ArrayBuffer | string): Promise<void> {
const photoSaveOptions = new picker.PhotoSaveOptions(); // 创建文件管理器保存选项实例
photoSaveOptions.newFileNames = ['PhotoViewPicker ' + new Date().getTime() + '.jpg']; // 保存文件名(可选)
const photoViewPicker = new picker.PhotoViewPicker;
photoViewPicker.save(photoSaveOptions)
.then(async (photoSvaeResult) => {
const uri = photoSvaeResult[0];
const file = await fs.open(uri, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
await fs.write(file.fd, buffer);
await fs.close(file.fd);
promptAction.showToast({
message: '保存成功',
duration: 2000
})
});
}
async aboutToAppear(): Promise<void> {
// this.getPicture();
this.onChangeUrl()
}
build() {
Stack({ alignContent: Alignment.Center }) {
// Column() {
// Text('下载')
// .fontWeight(FontWeight.Medium)
// }
Image(this.image)
.objectFit(ImageFit.Contain)
.width('50%')
.height(28)
SaveButton({ icon: SaveIconStyle.FULL_FILLED, buttonType: ButtonType.Capsule })
.iconSize(24)
.backgroundColor(Color.Transparent)
.iconColor(Color.White)// .markAnchor({ x: '100%' })
.position({ x: '25%' })
.onClick(async () => {
if (this.imageBuffer !== undefined) {
await this.saveImage(this.imageBuffer);
promptAction.showToast({
message: '保存成功',
duration: 2000
})
}
})
}
// .alignSelf(ItemAlign.Center)
// .align(Alignment.Center)
// .backgroundColor(Color.Red)
}
async onChangeUrl(): Promise<void> {
console.info(`cj2024 图片下载 ${this.url}`)
// const context = getContext(this) as common.UIAbilityContext;
// const atManager = abilityAccessCtrl.createAtManager();
// await atManager.requestPermissionsFromUser(context, PERMISSIONS);
// 通过任务池(taskpool)从网络下载图片资源
taskpool.execute(getPicture, this.url).then((res) => {
const imgBuffer = res as ArrayBuffer
this.imageBuffer = imgBuffer;
})
}
}
... ...
... ... @@ -155,6 +155,8 @@ export struct SpacialTopicPageComponent {
// .fontWeight(500)
// .visibility(this.action?.params?.backVisibility && this.isPageEnd ? Visibility.Visible : Visibility.None)
RelativeContainer() {
WdWebComponent({
webviewControl: this.webviewControl,
webUrl: this.webUrl,
... ... @@ -163,16 +165,16 @@ export struct SpacialTopicPageComponent {
isPageEnd: $isPageEnd,
receiveH5SendToNativeData: this.receiveH5SendToNativeData.bind(this)
})
.id('web_page')
// 挂角广告
this.pageHornAd()
}
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom: this.action?.params?.backVisibility ? 115 : 75 })
// RelativeContainer() {
// // 挂角广告
// this.pageHornAd()
// }
if (!this.isNetConnected) {
Column() {
Image($r('app.media.line'))
... ...
... ... @@ -29,24 +29,14 @@ export struct LiveFollowComponent {
@State followStatus: String = '0';
build() {
Stack() {
Stack()
.height(22)
.width(150)
.backgroundColor('#000000')
.opacity(0.3)
.borderRadius({
topLeft: 90,
bottomLeft: 90
})
Row() {
Stack({alignContent: Alignment.Bottom}){
Stack({ alignContent: Alignment.Bottom }) {
//号主头像
Image(this.rmhInfo.rmhHeadUrl)
.alt($r('app.media.icon_default_head_mater'))
.width(24)
.height(24)
.borderRadius(90)
.borderRadius(12)
.onClick(() => {
// 跳转到号主页
if (this.contentDetailData.rmhInfo?.cnMainControl === 1) {
... ... @@ -57,8 +47,8 @@ export struct LiveFollowComponent {
WDRouterRule.jumpWithPage(WDRouterPage.peopleShipHomePage, params)
}
})
if(this.contentDetailData.rmhInfo?.authIcon){
Row(){
if (this.contentDetailData.rmhInfo?.authIcon) {
Row() {
Image(this.contentDetailData.rmhInfo?.authIcon)
.width(10)
.height(10)
... ... @@ -67,20 +57,22 @@ export struct LiveFollowComponent {
.justifyContent(FlexAlign.End)
}
}.width(24).height(24)
.margin({
left: 0,
top: 0,
bottom: 0,
})
//号主名称
Text(this.rmhInfo.rmhName)
.fontColor(Color.White)
.textOverflow({overflow:TextOverflow.Ellipsis})
.textOverflow({ overflow: TextOverflow.Ellipsis })
.maxLines(1)
.fontWeight(500)
.fontSize('12fp')
.layoutWeight(1)
.margin({
left: 4,
right: 6
})
Blank()
//关注状态
Text(this.followStatus === '0' ? '关注' : '已关注')
.fontColor(Color.White)
... ... @@ -93,16 +85,21 @@ export struct LiveFollowComponent {
bottom: 3
})
.borderRadius(2)
.margin({ right: 2 })
.width(36)
.margin({right:2})
.backgroundColor(this.followStatus === '0' ? $r('app.color.color_ED2800') : $r('app.color.color_CCCCCC'))
.visibility(this.followStatus === '0' ? Visibility.Visible : Visibility.None)
.onClick(() => {
this.handleAccention()
})
}
.height(22)
.width(150)
}
.backgroundColor("#30000000")
.borderRadius({
topLeft: 12,
bottomLeft: 12,
topRight: 2,
bottomRight: 2
})
}
/**
... ...
... ... @@ -28,7 +28,7 @@ export struct Card5Component {
@State textArr: textItem[] = []
async aboutToAppear(): Promise<void> {
console.log('Card2Component', JSON.stringify(this.compDTO))
console.log('Card2Component', JSON.stringify(this.compDTO),this.contentDTO.titleShow)
const curRouter = router.getState().name;
this.clicked = hasClicked(this.contentDTO.objectId, curRouter)
this.loadImg = await onlyWifiLoadImg();
... ... @@ -66,7 +66,7 @@ export struct Card5Component {
)
.height(this.loadImg ? '' : 114)
.autoResize(true)
if (!!this.titleShowPolicy || this.titleShowPolicy === null) {
if (this.contentDTO.titleShow == 1 || this.contentDTO.titleShow == null) {
Row()
.borderRadius(
{
... ...
... ... @@ -13,7 +13,10 @@ const DiyCloseTipsString = '关闭后,将不会使用你的偏好进行内容
@Entry
@Component
export struct PrivacySettingPage {
@State listData: Array<PrivacySettingModel> = [new PrivacySettingModel(DiyString, false, 'ohos.permission.READ_IMAGEVIDEO'), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_IMAGEVIDEO'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.APPROXIMATELY_LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];
// @State listData: Array<PrivacySettingModel> = [new PrivacySettingModel(DiyString, false, 'ohos.permission.READ_IMAGEVIDEO'), new PrivacySettingModel('相册权限', false, 'ohos.permission.READ_IMAGEVIDEO'), new PrivacySettingModel('相机权限', false, 'ohos.permission.CAMERA'), new PrivacySettingModel('定位权限', false, 'ohos.permission.APPROXIMATELY_LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];
@State listData: Array<PrivacySettingModel> = [new PrivacySettingModel(DiyString, false, 'ohos.permission.READ_IMAGEVIDEO'), new PrivacySettingModel('定位权限', false, 'ohos.permission.APPROXIMATELY_LOCATION'), new PrivacySettingModel('麦克风权限', false, 'ohos.permission.MICROPHONE')];
tips: string = '设置前可查阅'
privacyTips: string = '《隐私政策》'
tipsEnd = '中相应权限使用规则'
... ... @@ -79,7 +82,7 @@ export struct PrivacySettingPage {
build() {
Column(){
Column(){
TitleBackComponent({title:"隐私设置"})
TitleBackComponent({title:"隐私设置"}).backgroundColor(Color.White)
//滑动区域
this.PrivacySettingComponentsUI()
... ...
... ... @@ -388,7 +388,10 @@ export struct TopNavigationComponentNew {
.fontColor(this.tabSelectedColor(this.currentTopNavSelectedIndex === index))
.padding({
top: $r('app.float.top_tab_item_padding_top'),
bottom: $r('app.float.top_tab_item_padding_bottom')
bottom: $r('app.float.top_tab_item_padding_bottom'),
left:2,
right:2
})
.maxLines(this.MAX_LINE)
.id(index.toString())
... ...
import { PhotoListBean } from 'wdBean/Index';
import { display, router } from '@kit.ArkUI';
import { ImageDownloadComponent } from '../components/ImageDownloadComponent';
import { MultiPictureDetailItemComponent } from '../components/MultiPictureDetailItemComponent';
import { Action } from 'wdBean';
import { WindowModel } from 'wdKit/Index';
import { SaveNetWorkPictures } from '../components/SaveNetWorkPictures';
const TAG = 'MultiPictureListPage';
... ... @@ -31,7 +31,6 @@ export struct MultiPictureListPage {
PageTransitionExit({ duration: !this.noAnimation ? 0 : 300 })
}
aboutToAppear(): void {
//获取宽高尺寸
this.screenWidth = this.displayTool.width
... ... @@ -47,17 +46,17 @@ export struct MultiPictureListPage {
onPageShow(): void {
console.log(TAG, 'onPageShow')
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff'})
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#ffffff' })
}
onPageHide(): void {
console.log(TAG, 'onPageHide')
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000'})
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000' })
}
build() {
RelativeContainer() {
Row(){
Row() {
Image($r('app.media.icon_arrow_left_white'))
.width(24)
.height(24)
... ... @@ -121,7 +120,9 @@ export struct MultiPictureListPage {
}
.alignSelf(ItemAlign.Center)
.fontColor(Color.White)
ImageDownloadComponent({ url: this.currentUrl })
// ImageDownloadComponent({ url: this.currentUrl })
SaveNetWorkPictures({ url: this.currentUrl })
}
.margin({
top: 14,
... ... @@ -129,6 +130,7 @@ export struct MultiPictureListPage {
bottom: 14,
right: 0
})
// .backgroundColor(Color.Blue)
.id('e_swiper_titles')
.alignRules({
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
... ...
... ... @@ -55,7 +55,7 @@ export struct TabLiveItemComponent {
.fontColor('#999999')
.margin({ left: 8 })
.visibility(StringUtils.isNotEmpty(this.item.time) ? Visibility.Visible : Visibility.None)
Blank()
Text('置顶')
.fontSize('11vp')
.fontWeight(400)
... ... @@ -126,6 +126,7 @@ export struct TabLiveItemComponent {
else if (this.item.dataType === LiveMessageOptType.ZH_VIDEO_MSG) {
RelativeContainer() {
Image(this.item.transcodeImageUrl)
.alt($r('app.media.cover_place_holder'))
.width('100%')
.objectFit(ImageFit.Cover)
.borderRadius(4)
... ... @@ -271,7 +272,7 @@ export struct TabLiveItemComponent {
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize(11)
.fontWeight(400)
.fontColor("#CB0000")
.fontColor("#ED2800")
.backgroundColor('#F1EFEB')
.padding({
left: 4,
... ...
... ... @@ -173,7 +173,7 @@ export struct PlayUIComponent {
.width('100%')
// .width(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? 'calc(100% - 80vp)' : 'calc(100% - 32vp)')
.padding({
top: 11,
top: 13,
bottom: 6,
left: this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '40vp' : '16vp',
right: this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '40vp' : '16vp'
... ... @@ -189,21 +189,19 @@ export struct PlayUIComponent {
// 预约
if (this.contentDetailData.liveInfo?.liveState == 'wait') {
Row() {
Image($r('app.media.icon_live_status_wait'))
.width(22)
.height(18)
Text('预约')
.fontSize('11fp')
.fontSize('11vp')
.fontWeight(400)
.fontColor(Color.White)
}
.backgroundColor('#4D000000')
.padding({
top: 1,
right: 4,
bottom: 1
right: 4
})
.borderRadius(2)
}
// 直播中
else if (this.contentDetailData.liveInfo?.liveState == 'running') {
... ... @@ -224,7 +222,7 @@ export struct PlayUIComponent {
}
Text('直播中')
.fontSize('11fp')
.fontSize('11vp')
.fontWeight(400)
.fontColor(Color.White)
... ... @@ -233,7 +231,7 @@ export struct PlayUIComponent {
.width(12)
.height(12)
Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`)
.fontSize('11fp')
.fontSize('11vp')
.fontWeight(400)
.fontColor(Color.White)
}
... ... @@ -241,9 +239,7 @@ export struct PlayUIComponent {
}
.backgroundColor('#4D000000')
.padding({
top: 1,
right: 4,
bottom: 1,
})
.margin(
{
... ... @@ -252,6 +248,7 @@ export struct PlayUIComponent {
: this.displayDirection === DisplayDirection.VIDEO_HORIZONTAL ? 34 : 0
}
)
.borderRadius(2)
}
//回看
else if (this.contentDetailData.liveInfo?.liveState == 'end') {
... ... @@ -272,15 +269,15 @@ export struct PlayUIComponent {
}
}
.height(18)
.backgroundColor('#4D000000')
.padding({
left: 4,
top: 1,
right: 4,
bottom: 1
}).margin({
left: this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '34vp' : 0
})
.borderRadius(2)
}
}
... ...
... ... @@ -144,7 +144,7 @@ export struct PlayerTitleComponent {
.width(12)
.height(12)
Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`)
.fontSize('11fp')
.fontSize('11vp')
.fontWeight(400)
.fontColor(Color.White)
}
... ...
import { CompInfoBean, ContentDTO, PageInfoBean } from 'wdBean/Index';
import { MorningEveningViewModel } from 'wdComponent/Index';
// import { MorningEveningViewModel } from 'wdComponent/Index';
import { CrptoUtils, FileUtils, Logger } from 'wdKit/Index';
import { FormNewspaperPaperType, FormNewspaperPaperContent,
FormNewspaperData } from "../dailynewspaperwidget/common/NewspaperWidgetData"
... ... @@ -8,6 +8,7 @@ import fs from '@ohos.file.fs';
import { BusinessError } from '@kit.BasicServicesKit';
import { JSON } from '@kit.ArkTS';
import { AppInnerLinkGenerator } from 'wdRouter';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
const TAG = "NewspaperDataFetcher"
... ... @@ -22,11 +23,11 @@ export class NewspaperDataFetcher {
data.paperInfo = { showLeftImage: false }
try {
let page: PageInfoBean = await MorningEveningViewModel.getDailyPaperTopic()
let page: PageInfoBean = await NewspaperDataFetcher.getDailyPaperTopic()
data.paperType = page.topicInfo?.topicPattern || FormNewspaperPaperType.unknown
let currentTime = new Date().getTime()
let compInfo = await MorningEveningViewModel.getMorningEveningCompInfo(
let compInfo = await NewspaperDataFetcher.getMorningEveningCompInfo(
page.id,
page.groups[0]?.id,
currentTime + "",
... ... @@ -208,5 +209,62 @@ export class NewspaperDataFetcher {
})
}
static async getDailyPaperTopic(): Promise<PageInfoBean> {
return new Promise<PageInfoBean>((success, error) => {
Logger.info(TAG, `getDailyPaperTopic pageInfo start`);
let url = HttpUrlUtils.getHost() + HttpUrlUtils.DAILY_PAPER_TOPIC;
WDHttp.get<ResponseDTO<PageInfoBean>>(url).then((resDTO: ResponseDTO<PageInfoBean>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getDailyPaperTopic then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getDailyPaperTopic then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getDailyPaperTopic then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getDailyPaperTopic catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
static async getMorningEveningCompInfo(pageId: number, groupId: number, refreshTime: string, topicId: string, pageNum: number = 1, pageSize: number = 20): Promise<CompInfoBean> {
return new Promise<CompInfoBean>((success, error) => {
Logger.info(TAG, `getMorningEveningCompInfo pageInfo start`);
let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH;
url = url + "?loadStrategy=first_load&pageNum=" + pageNum + "&refreshTime=" + refreshTime + "&pageId="
+ pageId + "&channelStrategy=2&groupId=" + groupId + "&topicId=" + topicId + "&pageSize=" + pageSize;
WDHttp.get<ResponseDTO<CompInfoBean>>(url).then((resDTO: ResponseDTO<CompInfoBean>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'getMorningEveningCompInfo then navResDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `getMorningEveningCompInfo then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
// let navResStr = JSON.stringify(navResDTO);
Logger.info(TAG, "getMorningEveningCompInfo then,navResDTO.timestamp:" + resDTO.timestamp);
success(resDTO.data);
})
.catch((err: Error) => {
Logger.error(TAG, `getMorningEveningCompInfo catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
}
\ No newline at end of file
... ...
import { NetworkUtil, Logger, SPHelper, StringUtils } from 'wdKit';
import { Logger, NetworkUtil, SPHelper, StringUtils } from 'wdKit';
import { ResponseDTO } from 'wdNetwork';
import {
ContentDetailDTO,
InteractDataDTO,
Params,
PhotoListBean,
postInteractBrowsOperateParams,
postBatchAttentionStatusParams,
postInteractAccentionOperateParams,
Params,
InteractDataDTO
postInteractBrowsOperateParams
} from 'wdBean';
import { DateTimeUtils } from 'wdKit/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { SpConstants } from 'wdConstant/Index';
import { common } from '@kit.AbilityKit';
import { CommentDialogView } from 'wdDetailPlayShortVideo/Index';
import { EmptyComponent,
ImageDownloadComponent,
import {
EmptyComponent,
MultiPictureDetailItemComponent,
MultiPictureDetailViewModel,
OperRowListView,
PageRepository,
publishCommentModel,
viewBlogItemInsightIntentShare} from 'wdComponent/Index';
import { ParamType, TrackConstants, TrackingButton, TrackingContent } from 'wdTracking/Index';
SaveNetWorkPictures,
viewBlogItemInsightIntentShare
} from 'wdComponent/Index';
import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index';
const TAG = 'MultiPictureDetailPageComponent';
/**
* 多图(图集详情页)UI
*/
... ... @@ -96,7 +99,7 @@ export struct MultiPictureDetailPageComponent {
this.contentTrackingDict()
}
contentTrackingDict(){
contentTrackingDict() {
this.pageParam = {
'contentType': `${this.contentDetailData.newsType}`,
'contentId': `${this.contentDetailData.newsId}`,
... ... @@ -138,6 +141,7 @@ export struct MultiPictureDetailPageComponent {
bottom: { anchor: "__container__", align: VerticalAlign.Bottom },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
CommentDialogView({
index: $index,
currentIndex: $currentIndex,
... ... @@ -156,7 +160,7 @@ export struct MultiPictureDetailPageComponent {
@Builder
rmh() {
if (!this.showDownload) {
Row(){
Row() {
Row() {
Row({ space: 8 }) {
if (this.getImgUrl()) {
... ... @@ -257,7 +261,7 @@ export struct MultiPictureDetailPageComponent {
Image($r('app.media.add'))
.width(12)
.height(12)
.margin({right: 3})
.margin({ right: 3 })
Text('关注').fontSize(12).fontColor(0xffffff)
}.alignItems(VerticalAlign.Center)
... ... @@ -268,7 +272,8 @@ export struct MultiPictureDetailPageComponent {
.height(24)
.onClick(() => {
this.handleAccention()
}).visibility(this.isShowButton ? Visibility.Visible : Visibility.None)
})
.visibility(this.isShowButton ? Visibility.Visible : Visibility.None)
} else {
Button({ type: ButtonType.Normal, stateEffect: true }) {
Row() {
... ... @@ -281,7 +286,8 @@ export struct MultiPictureDetailPageComponent {
.height(24)
.onClick(() => {
this.handleAccention()
}).visibility(this.isShowButton ? Visibility.Visible : Visibility.None)
})
.visibility(this.isShowButton ? Visibility.Visible : Visibility.None)
}
}
... ... @@ -429,6 +435,7 @@ export struct MultiPictureDetailPageComponent {
ListItem() {
this.ListItemTitle()
}
ListItem() {
this.ListItemDescription()
}
... ... @@ -499,11 +506,18 @@ export struct MultiPictureDetailPageComponent {
}
if (this.contentDetailData.photoList?.[this.swiperIndex].picPath) {
ImageDownloadComponent({ url: this.contentDetailData.photoList?.[this.swiperIndex].picPath })
// ImageDownloadComponent({ url: this.contentDetailData.photoList?.[this.swiperIndex].picPath })
// .parallelGesture(
// TapGesture()
// .onAction((event: GestureEvent) => {
// TrackingContent.download(1,TrackConstants.PageName.Atlas_Detail,TrackConstants.PageName.Atlas_Detail,this.pageParam)
// }))
SaveNetWorkPictures({ url: this.contentDetailData.photoList?.[this.swiperIndex].picPath })
.parallelGesture(
TapGesture()
.onAction((event: GestureEvent) => {
TrackingContent.download(1,TrackConstants.PageName.Atlas_Detail,TrackConstants.PageName.Atlas_Detail,this.pageParam)
TrackingContent.download(1, TrackConstants.PageName.Atlas_Detail, TrackConstants.PageName.Atlas_Detail,
this.pageParam)
}))
}
}
... ... @@ -521,7 +535,10 @@ export struct MultiPictureDetailPageComponent {
@Builder
noNet() {
EmptyComponent({
emptyType: 1, emptyButton: true, isBlack: true, retry: () => {
emptyType: 1,
emptyButton: true,
isBlack: true,
retry: () => {
this.getDetail()
}
})
... ... @@ -659,10 +676,12 @@ export struct MultiPictureDetailPageComponent {
// console.log(TAG, '关注号主==', JSON.stringify(res.data))
if (this.followStatus == '1') {
this.followStatus = '0'
TrackingContent.follow(true,this.followUserId,this.followUserName,TrackConstants.PageName.Atlas_Detail,TrackConstants.PageName.Atlas_Detail,this.pageParam)
TrackingContent.follow(true, this.followUserId, this.followUserName, TrackConstants.PageName.Atlas_Detail,
TrackConstants.PageName.Atlas_Detail, this.pageParam)
} else {
this.followStatus = '1'
TrackingContent.follow(false,this.followUserId,this.followUserName,TrackConstants.PageName.Atlas_Detail,TrackConstants.PageName.Atlas_Detail,this.pageParam)
TrackingContent.follow(false, this.followUserId, this.followUserName, TrackConstants.PageName.Atlas_Detail,
TrackConstants.PageName.Atlas_Detail, this.pageParam)
}
})
}
... ...
... ... @@ -184,26 +184,6 @@
],
"requestPermissions": [
{
"name": "ohos.permission.READ_MEDIA",
"reason": "$string:permission_photo_tip",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.WRITE_MEDIA",
"reason": "$string:permission_photo_tip",
"usedScene": {
"abilities": [
"FormAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.APPROXIMATELY_LOCATION",
"reason": "$string:permission_location_tip",
"usedScene": {
... ...