王士厅
... ... @@ -14,6 +14,9 @@ export class AppUtils {
AppUtils.buildVersion = BuildProfile.BUILD_VERSION;
}
// 全局应用context
public static gotApplicationContextFunc?: () => common.UIAbilityContext
/**
* 获取应用名称
* 即:人民日报
... ...
... ... @@ -315,8 +315,7 @@ export struct WdWebLocalComponent {
Text('重播').fontColor(Color.White).fontSize(14)
}
.backgroundColor(Color.Black)
.opacity(0.5)
.backgroundColor("#80000000")
.justifyContent(FlexAlign.Center)
.width(this.positionWidth)
.height(this.positionHeight)
... ...
... ... @@ -48,6 +48,8 @@ import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
import { ParamType, TrackConstants, TrackingButton, TrackingContent } from 'wdTracking/Index';
import { componentUtils, window } from '@kit.ArkUI';
import { onlyWifiLoadImg } from '../utils/lazyloadImg';
const TAG = 'DynamicDetailComponent'
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
... ... @@ -124,6 +126,7 @@ export struct DynamicDetailComponent {
}
aboutToDisappear() {
this.viewBlogInsightIntentShare()
}
onPageHide() {
... ... @@ -308,127 +311,128 @@ export struct DynamicDetailComponent {
//附件内容:图片/视频
if (this.contentDetailData.photoList != null && this.contentDetailData.photoList.length > 0) {
// 图片-从无图到9图展示
GridRow({
gutter: { x: 2, y: 2 }
}) {
ForEach(this.contentDetailData.photoList, (item: PhotoListBean, index: number) => {
if (this.contentDetailData.photoList.length === 1) {
if (this.getPicType(item) !== 3) {
GridCol({
span: this.getPicType(item) === 1 ? 12 : 8
}) {
Stack({
alignContent: Alignment.BottomEnd
}) {
if (this.getPicType(item) === 1) {
Image(item.picPath)
.width('100%')
.height(172)
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
} else if (this.getPicType(item) === 2) {
Image(item.picPath)
.width('100%')
.height(305)
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
}
Flex({ direction: FlexDirection.Row }) {
Image($r('app.media.icon_long_pic'))
.width(12)
.height(12)
.margin({ right: 4 })
Text('长图')
.fontSize(10)
.fontWeight(400)
.textShadow({
radius: 1,
color: `rgba(0,0,0,0.5)`,
offsetY:1,
offsetX:1
})
.fontColor(0xffffff)
.fontFamily('PingFang SC')
}
.width(48)
.padding({ bottom: 9 })
}
}
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
})
} else {
createImg({fullColumnImgUrls:this.contentDetailData.photoList})
// GridRow({
// gutter: { x: 2, y: 2 }
// }) {
// ForEach(this.contentDetailData.photoList, (item: PhotoListBean, index: number) => {
// if (this.contentDetailData.photoList.length === 1) {
// if (this.getPicType(item) !== 3) {
// GridCol({
// span: { xs: 8 }
// span: this.getPicType(item) === 1 ? 12 : 8
// }) {
// Stack({
// alignContent: Alignment.BottomEnd
// }) {
// if (this.getPicType(item) === 1) {
// Image(item.picPath)
// .width('100%')
// .height(172)
// .autoResize(true)
// .borderRadius(this.caclImageRadius(index))
// } else if (this.getPicType(item) === 2) {
// Image(item.picPath)
// .width('100%')
// .height(305)
// .autoResize(true)
// .borderRadius(this.caclImageRadius(index))
// }
// Flex({ direction: FlexDirection.Row }) {
// Image($r('app.media.icon_long_pic'))
// .width(12)
// .height(12)
// .margin({ right: 4 })
// Text('长图')
// .fontSize(10)
// .fontWeight(400)
// .textShadow({
// radius: 1,
// color: `rgba(0,0,0,0.5)`,
// offsetY:1,
// offsetX:1
// })
// .fontColor(0xffffff)
// .fontFamily('PingFang SC')
// }
// .width(48)
// .padding({ bottom: 9 })
// }
//
// }
// .onClick(async (event: ClickEvent) => {
// let retvalue = await FastClickUtil.isMinDelayTime()
// if(retvalue){
// return
// }
// ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
// })
// } else {
// // GridCol({
// // span: { xs: 8 }
// // }) {
// // Image(item.picPath)
// // .width('100%')
// // .borderRadius(this.caclImageRadius(index))
// // .autoResize(true)
// // .opacity(!item.width && !item.height ? 0 : 1)
// // .onComplete(callback => {
// // item.width = callback?.width || 0;
// // item.height = callback?.height || 0;
// // })
// // }
// GridCol({
// span: this.onePicW > this.onePicH ? 12 : 8
// }) {
// Stack({alignContent: Alignment.BottomEnd}) {
// Image(item.picPath)
// .backgroundColor(0xf5f5f5)
// .width('100%')
// .autoResize(true)
// .objectFit(ImageFit.Cover)
// .autoResize(true)
// .aspectRatio(3/4)
// .borderRadius(this.caclImageRadius(index))
// .borderStyle(BorderStyle.Solid)
// .borderWidth(0.5)
// .borderColor($r('app.color.color_0D000000'))
// .opacity(!item.width && !item.height ? 0 : 1)
// .onComplete(callback => {
// item.width = callback?.width || 0;
// item.height = callback?.height || 0;
// .onComplete((event?) => {
// this.onePicW = event?.width || 0;
// this.onePicH = event?.height || 0;
// })
// if(this.getPicType(item) !== 3){
// Flex({ direction: FlexDirection.Row }) {
// Image($r('app.media.icon_long_pic'))
// .width(12)
// .height(12)
// .margin({ right: 4 })
// Text('长图')
// .fontSize(10)
// .fontWeight(400)
// .textShadow({
// radius: 1,
// color: `rgba(0,0,0,0.5)`,
// offsetY:1,
// offsetX:1
// })
// .fontColor(0xffffff)
// .fontFamily('PingFang SC')
// }
// .width(48)
// .align(Alignment.BottomEnd)
// .padding({ bottom: 3 })
// }
// }
// }
// .onClick(async (event: ClickEvent) => {
// let retvalue = await FastClickUtil.isMinDelayTime()
// if(retvalue){
// return
// }
// ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
// })
// }
GridCol({
span: this.onePicW > this.onePicH ? 12 : 8
}) {
Stack({alignContent: Alignment.BottomEnd}) {
Image(item.picPath)
.backgroundColor(0xf5f5f5)
.width('100%')
.autoResize(true)
.objectFit(ImageFit.Cover)
.autoResize(true)
.aspectRatio(3/4)
.borderRadius(this.caclImageRadius(index))
.borderStyle(BorderStyle.Solid)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.opacity(!item.width && !item.height ? 0 : 1)
.onComplete((event?) => {
this.onePicW = event?.width || 0;
this.onePicH = event?.height || 0;
})
if(this.getPicType(item) !== 3){
Flex({ direction: FlexDirection.Row }) {
Image($r('app.media.icon_long_pic'))
.width(12)
.height(12)
.margin({ right: 4 })
Text('长图')
.fontSize(10)
.fontWeight(400)
.textShadow({
radius: 1,
color: `rgba(0,0,0,0.5)`,
offsetY:1,
offsetX:1
})
.fontColor(0xffffff)
.fontFamily('PingFang SC')
}
.width(48)
.align(Alignment.BottomEnd)
.padding({ bottom: 3 })
}
}
}
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
})
}
}
// }
// else if (this.contentDetailData.photoList.length === 4) {
// GridCol({
// span: { xs: 4 }
... ... @@ -469,53 +473,53 @@ export struct DynamicDetailComponent {
// ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
// })
// }
else {
GridCol({
span: { sm: 4, lg: 3 }
}) {
Stack({alignContent: Alignment.BottomEnd}) {
Image(item.picPath)
.aspectRatio(1)
.borderRadius(this.caclImageRadius(index))
if(this.getPicType(item) !== 3){
Flex({ direction: FlexDirection.Row }) {
Image($r('app.media.icon_long_pic'))
.width(12)
.height(12)
.margin({ right: 4 })
Text('长图')
.fontSize(10)
.fontWeight(400)
.textShadow({
radius: 1,
color: `rgba(0,0,0,0.5)`,
offsetY:1,
offsetX:1
})
.fontColor(0xffffff)
.fontFamily('PingFang SC')
}
.width(48)
.align(Alignment.BottomEnd)
.padding({ bottom: 3})
}
}
}
.onClick(async (event: ClickEvent) => {
let retvalue = await FastClickUtil.isMinDelayTime()
if(retvalue){
return
}
ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
})
}
})
}
.margin({
left: $r('app.float.margin_16'),
right: $r('app.float.margin_16'),
top: $r('app.float.margin_8')
})
// else {
// GridCol({
// span: { sm: 4, lg: 3 }
// }) {
// Stack({alignContent: Alignment.BottomEnd}) {
// Image(item.picPath)
// .aspectRatio(1)
// .borderRadius(this.caclImageRadius(index))
// if(this.getPicType(item) !== 3){
// Flex({ direction: FlexDirection.Row }) {
// Image($r('app.media.icon_long_pic'))
// .width(12)
// .height(12)
// .margin({ right: 4 })
// Text('长图')
// .fontSize(10)
// .fontWeight(400)
// .textShadow({
// radius: 1,
// color: `rgba(0,0,0,0.5)`,
// offsetY:1,
// offsetX:1
// })
// .fontColor(0xffffff)
// .fontFamily('PingFang SC')
// }
// .width(48)
// .align(Alignment.BottomEnd)
// .padding({ bottom: 3})
// }
// }
// }
// .onClick(async (event: ClickEvent) => {
// let retvalue = await FastClickUtil.isMinDelayTime()
// if(retvalue){
// return
// }
// ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
// })
// }
// })
// }
// .margin({
// left: $r('app.float.margin_16'),
// right: $r('app.float.margin_16'),
// top: $r('app.float.margin_8')
// })
}
} else {
if (this.contentDetailData.videoInfo != null && this.contentDetailData.videoInfo.length > 0) {
... ... @@ -955,6 +959,259 @@ export struct DynamicDetailComponent {
}
}
@Component
struct createImg {
@State fullColumnImgUrls: PhotoListBean[] = []
@State loadImg: boolean = false;
@State onePicW: number = 0; // 只有一张图时候图片的宽度
@State onePicH: number = 0; // 只有一张图时候图片的高度
async aboutToAppear(): Promise<void> {
if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位
this.fullColumnImgUrls.splice(2, 0, {
picPath: ''
} as PhotoListBean)
}
this.loadImg = await onlyWifiLoadImg();
console.log('card19-this.fullColumnImgUrls',JSON.stringify(this.fullColumnImgUrls))
}
caclImageRadius(index: number) {
let radius: radiusType = {
topLeft: index === 0 ? $r('app.float.image_border_radius') : 0,
topRight: 0,
bottomLeft: 0,
bottomRight: 0,
}
if (this.fullColumnImgUrls.length === 1) {
radius.topRight = index === 0 ? $r('app.float.image_border_radius') : 0
radius.bottomLeft = index === 0 ? $r('app.float.image_border_radius') : 0
radius.bottomRight = index === 0 ? $r('app.float.image_border_radius') : 0
} else if (this.fullColumnImgUrls.length === 2) {
radius.bottomLeft = index === 0 ? $r('app.float.image_border_radius') : 0
radius.topRight = index === 1 ? $r('app.float.image_border_radius') : 0
radius.bottomRight = index === 1 ? $r('app.float.image_border_radius') : 0
} else if (this.fullColumnImgUrls.length === 3) {
radius.bottomLeft = index === 0 ? $r('app.float.image_border_radius') : 0
radius.topRight = index === 2 ? $r('app.float.image_border_radius') : 0
radius.bottomRight = index === 2 ? $r('app.float.image_border_radius') : 0
} else if (this.fullColumnImgUrls.length === 6) {
radius.topRight = index === 2 ? $r('app.float.image_border_radius') : 0
radius.bottomLeft = index === 3 ? $r('app.float.image_border_radius') : 0
radius.bottomRight = index === 5 ? $r('app.float.image_border_radius') : 0
} else if (this.fullColumnImgUrls.length === 5 && !this.fullColumnImgUrls[2].picPath) {
radius.topRight = index === 1 ? $r('app.float.image_border_radius') : 0
radius.bottomLeft = index === 3 ? $r('app.float.image_border_radius') : 0
radius.bottomRight = index === 4 ? $r('app.float.image_border_radius') : 0
} else {
radius.topRight = index === 2 ? $r('app.float.image_border_radius') : 0
radius.bottomLeft = index === 6 ? $r('app.float.image_border_radius') : 0
radius.bottomRight = index === 8 ? $r('app.float.image_border_radius') : 0
}
return radius
}
getPicType(picWidth: number, picHeight: number) {
//console.info(`cj2024 getPicType picWidth = ${picWidth} picHeight = ${picHeight} picWidth / picHeight = ${picWidth / picHeight}`)
if (picWidth && picHeight) {
if (picWidth / picHeight > 2/1) {
return 1; //横长图
} else if (picWidth/picHeight > 1/2 && picWidth/picHeight < 3/4) { //截取图片
return 4;
} else if (picWidth/picHeight < 1/2) {
return 2; //竖长图
} else {
return 3
}
} else {
return 3; //普通图
}
}
@Builder
longPicTip(weight: number, height: number) {
Flex({ direction: FlexDirection.Row }) {
Image($r('app.media.icon_long_pic'))
.width(12)
.height(12)
.margin({ right: 4 })
Text('长图')
.fontSize(10)
.fontWeight(400)
.textShadow({
radius: 1,
color: `rgba(0,0,0,0.5)`,
offsetY:1,
offsetX:1
})
.fontColor(0xffffff)
.fontFamily('PingFang SC')
.visibility(
weight / height > 2 || height / weight > 2
? Visibility.Visible : Visibility.None
)
}
.width(48)
.align(Alignment.BottomEnd)
.padding({ bottom: 8 })
}
build() {
GridRow({
gutter: { x: 2, y: 2 }
}) {
ForEach(this.fullColumnImgUrls, (item: PhotoListBean, index: number) => {
if (this.fullColumnImgUrls.length === 1) {
if (this.getPicType(item.width, item.height) < 3) {
GridCol({
span: this.getPicType(item.width, item.height) === 1 ? 12 : 8
}){
Stack({
alignContent: Alignment.BottomEnd
}) {
if (this.getPicType(item.width, item.height) === 1) {
Image(this.loadImg ? item.picPath : '')
.backgroundColor(0xf5f5f5)
.width('100%')
.height(198)
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
.borderStyle(BorderStyle.Solid)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.onClick(() => {
ProcessUtils.gotoMultiPictureListPage(this.fullColumnImgUrls, index)
})
} else if (this.getPicType(item.width, item.height) === 2) {
Image(this.loadImg ? item.picPath : '')
.width('100%')
.height(305)
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
.borderStyle(BorderStyle.Solid)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.onClick(() => {
ProcessUtils.gotoMultiPictureListPage(this.fullColumnImgUrls, index)
})
}
this.longPicTip(item.width, item.height)
}
}
} else if (this.getPicType(item.width, item.height) === 4) {
GridCol({
span: this.onePicW > this.onePicH ? 12 : 8
}) {
Image(this.loadImg ? item.picPath : '')
.backgroundColor(0xf5f5f5)
// .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
.width('100%')
.autoResize(true)
.objectFit(ImageFit.Cover)
.autoResize(true)
.aspectRatio(3/4)
.borderRadius(this.caclImageRadius(index))
.borderStyle(BorderStyle.Solid)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.opacity(!item.width && !item.height ? 0 : 1)
.onComplete((event?) => {
this.onePicW = event?.width || 0;
this.onePicH = event?.height || 0;
})
.onClick(() => {
ProcessUtils.gotoMultiPictureListPage(this.fullColumnImgUrls, index)
})
}
} else {
GridCol({
span: this.onePicW > this.onePicH ? 12 : 8
}) {
Stack({alignContent: Alignment.BottomEnd}) {
Image(this.loadImg ? item.picPath : '')
.backgroundColor(0xf5f5f5)
// .aspectRatio(this.onePicW > this.onePicH ? 343 / 198 : 228 / 305)
.width('100%')
.constraintSize({
maxHeight: this.onePicW > this.onePicH ? 198 : 305
})
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
.borderStyle(BorderStyle.Solid)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.opacity(!item.width && !item.height ? 0 : 1)
.onComplete((event?) => {
this.onePicW = event?.width || 0;
this.onePicH = event?.height || 0;
})
if (this.onePicW && this.onePicH) {
this.longPicTip(this.onePicW, this.onePicH)
}
}
.onClick(() => {
ProcessUtils.gotoMultiPictureListPage(this.fullColumnImgUrls, index)
})
}
}
} else if (this.fullColumnImgUrls.length === 5) {
// 四图卡里面塞了一张补位卡
GridCol({
span: { xs: 4 }
}) {
Stack({alignContent: Alignment.BottomEnd}) {
Image(this.loadImg ? item.picPath : '')
.backgroundColor(index === 2 ? 0xffffff : 0xf5f5f5)
.aspectRatio(1)
.width('226lvp')
.height('226lvp')
.borderRadius(this.caclImageRadius(index))
.borderStyle(BorderStyle.Solid)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
if(this.getPicType(item.width, item.height) !== 3){
this.longPicTip(item.width, item.height)
}
}
.onClick(() => {
const photoList: PhotoListBean[] = []
this.fullColumnImgUrls.forEach((element,index) => {
if (index !== 2) {
photoList.push(element)
}
})
ProcessUtils.gotoMultiPictureListPage(photoList, index>2?index-1:index)
})
}
} else {
GridCol({
span: { sm: 4, lg: 3 }
}) {
Stack({ alignContent: Alignment.BottomEnd }) {
Image(this.loadImg ? item.picPath : '')
.backgroundColor(0xf5f5f5)
.aspectRatio(1)
.borderRadius(this.caclImageRadius(index))
.borderStyle(BorderStyle.Solid)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.width('100%')
.autoResize(true)
if (this.getPicType(item.width, item.height) !== 3) {
this.longPicTip(item.width, item.height)
}
}
.onClick(() => {
ProcessUtils.gotoMultiPictureListPage(this.fullColumnImgUrls, index)
})
}
}
})
}
}
}
interface radiusType {
topLeft: number | Resource;
topRight: number | Resource;
... ...
... ... @@ -58,7 +58,7 @@ export default struct MinePageUserSimpleInfoUI {
.alt(this.userType === "1"?$r('app.media.default_head_userPage'):$r('app.media.AccountOwner_DefaultIcon'))
.width(63.21)
.height(63.21)
.objectFit(ImageFit.Fill)
.objectFit(ImageFit.Cover)
.borderRadius(50)
if(StringUtils.isNotEmpty(this.levelHead)){
... ...
... ... @@ -358,7 +358,7 @@ export struct FollowChildComponent{
jumpCreatorHomePage() {
if(this.data.mainControl === 0){
ToastUtils.shortToast("无法查看此用户主页")
ToastUtils.shortToast("暂时无法查看该创作者主页")
}else if(this.data.banControl === 1){
ToastUtils.shortToast("该账号已封禁,不予访问")
}else{
... ...
... ... @@ -69,7 +69,7 @@ export struct SearchCreatorComponent{
jumpCreatorHomePage() {
if(Number.parseInt(this.item.mainControl) === 0){
ToastUtils.shortToast("无法查看此用户主页")
ToastUtils.shortToast("暂时无法查看该创作者主页")
}else if(Number.parseInt(this.item.banControl) === 1){
ToastUtils.shortToast("该账号已封禁,不予访问")
}else{
... ...
import { Logger } from 'wdKit/src/main/ets/utils/Logger'
import { LoginModel } from './LoginModel'
import { LoginBean } from './LoginBean'
import { EmitterEventId, EmitterUtils, SPHelper, StringUtils, UserDataLocal } from 'wdKit'
import { AppUtils, EmitterEventId, EmitterUtils, SPHelper, StringUtils, UserDataLocal } from 'wdKit'
import { CheckVerifyBean } from './CheckVerifyBean'
import cryptoFramework from '@ohos.security.cryptoFramework'
import buffer from '@ohos.buffer'
... ... @@ -105,7 +105,7 @@ export class LoginViewModel {
SPHelper.default.saveSync(SpConstants.USER_NAME, data.userName ?? "")
EmitterUtils.sendEmptyEvent(EmitterEventId.LOGIN_SUCCESS)
LoginModule.reportDeviceInfo()
LoginModule.reportDeviceInfo(AppUtils.gotApplicationContextFunc!())
}
async appLoginByPassword(phone: string, loginType: number, password: string, oldPassword: string) {
... ...
import { AbilityConstant, common, Want } from '@kit.AbilityKit'
import { DeviceUtil,
import {
AppUtils,
DeviceUtil,
EmitterEventId,
EmitterUtils,
KVStoreHelper,
... ... @@ -58,6 +60,11 @@ export class StartupManager {
// 路由注册
registerRouter();
// 设置全局context
AppUtils.gotApplicationContextFunc = () => {
return this.context!
}
// 网络模块
NetworkManager.getInstance().init()
... ...