wangliang_wd

feat:优化下拉刷新,优化广告背景透明度

... ... @@ -137,6 +137,8 @@ export struct MorningEveningPaperComponent {
let pageInfoBean = await MorningEveningViewModel.getMorningEveningPageInfo("" + this.dailyPaperTopicPageId) //"25091"
this.pageInfoBean = pageInfoBean;
let compInfoBean = await MorningEveningViewModel.getMorningEveningCompInfo(pageInfoBean?.id, pageInfoBean?.groups[0]?.id, currentTime + "", pageInfoBean?.topicInfo?.topicId)
// this.title = this.pageInfoBean?.topicInfo?.title
this.setComponentTitle()
this.topicInfo = this.pageInfoBean?.topicInfo
... ... @@ -155,7 +157,6 @@ export struct MorningEveningPaperComponent {
let coverUrl = this.isHasTopView?this.pageInfoBean?.topicInfo?.frontLinkObject?.coverUrl as string :''
this.setComponentBgColor(coverUrl)
let compInfoBean = await MorningEveningViewModel.getMorningEveningCompInfo(pageInfoBean?.id, pageInfoBean?.groups[0]?.id, currentTime + "", pageInfoBean?.topicInfo?.topicId)
// this.compInfoBean = compInfoBean
console.log(TAG, "compInfoBean = " + JSON.stringify(compInfoBean))
if (compInfoBean?.compList[0]) {
... ...
... ... @@ -210,7 +210,7 @@ export struct CardMediaInfo {
.fontColor($r('app.color.white'))
.width(28)
.height(16)
.backgroundColor('#4D000000')
.backgroundColor('#80000000')
.borderRadius(3)
.textAlign(TextAlign.Center)
}
... ...
... ... @@ -34,5 +34,9 @@ export const enum LoadStatus {
/**
* 触发刷新结束,展示‘已更新最新’
*/
GOLOADED,
/**
* 触发刷新结束
*/
LOADED,
}
\ No newline at end of file
... ...
... ... @@ -122,20 +122,15 @@ export default struct CustomLayout {
if (!this.refreshBean.isVisible) {
return
}
let maxH = CustomLayout.REFRESH_HEIGHT
let tmpHeight = this.refreshBean.offset > maxH ? maxH : this.refreshBean.offset
if (this.refreshBean.loadStatus === LoadStatus.PRELOAD) {
// 下拉刷新
this.animate1(this.refreshBean.offset)
} else if (this.refreshBean.loadStatus == LoadStatus.LOADING) {
// 正在刷新
this.animate2()
} else {
// 刷新完成
!!this.animateItem && lottie.destroy(this.animateName)
!!this.animateItem2 && lottie.destroy(this.animateName2)
}
let maxH = CustomLayout.REFRESH_HEIGHT
let tmpHeight = this.refreshBean.offset > maxH ? maxH : this.refreshBean.offset
if (this.refreshBean.loadStatus === LoadStatus.LOADED) {
}else if (this.refreshBean.loadStatus == LoadStatus.GOLOADED) {
this.textVisible = true
if (tmpHeight <= 0) {
setTimeout(() => {
... ... @@ -144,6 +139,14 @@ export default struct CustomLayout {
this.setHeight0WithAnimation()
}, 800)
}
} else {
// 刷新完成
!!this.animateItem && lottie.destroy(this.animateName)
!!this.animateItem2 && lottie.destroy(this.animateName2)
}
if (this.refreshBean.loadStatus === LoadStatus.LOADED) {
} else {
// 直接设置高度
this.layoutHeight = tmpHeight
... ...
... ... @@ -213,6 +213,13 @@ export function pullRefreshState(pageModel: PageModel, state: number) {
pageModel.isRefreshing = true;
pageModel.load = LoadStatus.LOADING
break;
case RefreshState.GOLOADED:
//已刷新至最新
pageModel.offsetY = vp2px(pageModel.pullDownRefreshHeight);
pageModel.isCanRefresh = true;
pageModel.isRefreshing = true;
pageModel.load = LoadStatus.GOLOADED
break;
case RefreshState.Success:
pageModel.pullDownRefreshText = $r('app.string.refresh_success_text');
pageModel.pullDownRefreshImage = $r('app.media.ic_succeed_refresh');
... ... @@ -235,7 +242,8 @@ export function pullRefreshState(pageModel: PageModel, state: number) {
export function closeRefresh(pageModel: PageModel, isRefreshSuccess: boolean) {
let self = pageModel;
// 取消超时关闭定时器
clearTimeout(self.refreshTimeoutTimerId)
pullRefreshState(pageModel,RefreshState.GOLOADED);
setTimeout(() => {
let delay = Const.RefreshConstant_DELAY_PULL_DOWN_REFRESH;
if (self.isCanRefresh === true) {
... ...
... ... @@ -217,6 +217,13 @@ export function pullRefreshState(pageModel: PageModel, state: number) {
pageModel.isRefreshing = true;
pageModel.load = LoadStatus.LOADING
break;
case RefreshState.GOLOADED:
//已刷新至最新
pageModel.offsetY = vp2px(pageModel.pullDownRefreshHeight);
pageModel.isCanRefresh = true;
pageModel.isRefreshing = true;
pageModel.load = LoadStatus.GOLOADED
break;
case RefreshState.Success:
pageModel.pullDownRefreshText = $r('app.string.refresh_success_text');
pageModel.pullDownRefreshImage = $r('app.media.ic_succeed_refresh');
... ... @@ -240,6 +247,9 @@ export function closeRefresh(pageModel: PageModel, isRefreshSuccess: boolean) {
let self = pageModel;
// 取消超时关闭定时器
clearTimeout(self.refreshTimeoutTimerId)
pullRefreshState(pageModel,RefreshState.GOLOADED);
setTimeout(() => {
let delay = Const.RefreshConstant_DELAY_PULL_DOWN_REFRESH;
if (self.isCanRefresh === true) {
... ... @@ -258,4 +268,5 @@ export function closeRefresh(pageModel: PageModel, isRefreshSuccess: boolean) {
self.offsetY = 0;
})
}, self.isCanRefresh ? Const.DELAY_ANIMATION_DURATION : 0);
}
\ No newline at end of file
... ...
... ... @@ -66,5 +66,6 @@ export const enum RefreshState {
Release = 1,
Refreshing = 2,
Success = 3,
Fail = 4
Fail = 4,
GOLOADED = 5,
}
\ No newline at end of file
... ...