王士厅

图集swiperItem细节优化

import { PhotoListBean } from 'wdBean';
import { Logger } from 'wdKit';
import router from '@ohos.router';
import display from '@ohos.display';
const TAG = 'MultiPictureDetailPageComponent';
@Component
export struct MultiPictureDetailItemComponent {
private MultiPictureDetailItem: PhotoListBean = {} as PhotoListBean
//alt app.media.picture_loading 设计稿尺寸
@State imageWidth:string | number = 167
@State ratio:number = 167/60
private scroller: Scroller = new Scroller()
private displayTool = display.getDefaultDisplaySync()
@State picHeight: number = 0
async aboutToAppear() {
Logger.info(TAG, 'pictures preview')
this.picHeight = this.displayTool.width * 578 / 375
}
build() {
Stack({ alignContent: Alignment.BottomStart }) {
Row() {
Image(this.MultiPictureDetailItem.picPath)
.alt($r('app.media.picture_loading'))
.width('100%')
.aspectRatio(this.MultiPictureDetailItem.width / this.MultiPictureDetailItem.height)
.width(this.imageWidth)
.aspectRatio(this.ratio)
.objectFit(ImageFit.Fill)
.interpolation(ImageInterpolation.High)
.onComplete(event => {
this.imageWidth = '100%'
this.ratio = this.MultiPictureDetailItem.width / this.MultiPictureDetailItem.height
})
/*.onDrop(event => {
router.back();
})
.draggable(true)*/
/*Scroll(this.scroller) {
}
.scrollable(ScrollDirection.Vertical)
.scrollBarWidth(0)
.height(px2vp(this.picHeight))*/
}
.height('100%')
.width('100%')
}
.backgroundColor(Color.Black)
.width('100%')
.justifyContent(FlexAlign.Center)
}
}
\ No newline at end of file
... ...
import { Logger } from 'wdKit';
import { Logger, SPHelper } from 'wdKit';
import { ResponseDTO } from 'wdNetwork';
import {
ContentDetailDTO,
... ... @@ -17,6 +17,7 @@ import { DateTimeUtils } from 'wdKit/Index';
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../repository/PageRepository';
import { SpConstants } from 'wdConstant/Index';
const TAG = 'MultiPictureDetailPageComponent';
... ... @@ -350,9 +351,10 @@ export struct MultiPictureDetailPageComponent {
/**
* 关注号主
*/
handleAccention() {
async handleAccention() {
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
... ...
import { ToastUtils, Logger, NumberFormatterUtils } from 'wdKit';
import { ToastUtils, Logger, NumberFormatterUtils, SPHelper } from 'wdKit';
import {
InputMethodProperty,
batchLikeAndCollectResult,
... ... @@ -15,6 +15,7 @@ import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailV
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../../repository/PageRepository';
import { SpConstants } from 'wdConstant/Index';
export interface OperationItem {
icon: Resource;
... ... @@ -53,8 +54,9 @@ export struct OperRowListView {
}
]
aboutToAppear() {
if (HttpUrlUtils.getUserId()) {
async aboutToAppear() {
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (user_id) {
this.getInteractDataStatus()
}
this.queryContentInteractCount()
... ... @@ -338,9 +340,10 @@ export struct OperRowListView {
/**
* 点赞、取消点赞
*/
toggleLikeStatus() {
async toggleLikeStatus() {
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
... ... @@ -361,9 +364,10 @@ export struct OperRowListView {
/**
* 收藏、取消收藏
*/
toggleCollectStatus() {
async toggleCollectStatus() {
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
const user_id = await SPHelper.default.get(SpConstants.USER_ID, '')
if (!user_id) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
... ...