liyubing

feat(广告):展现中心挂角广告,以及挂角广告跳转

... ... @@ -125,18 +125,18 @@ export struct PageComponent {
if (this.pageModel.pageCornerAdv.matInfo != null) {
if (1 == this.pageModel.isRightAdv) {
// 页面右边挂角
this.drawRightCornerAdvView(1)
this.drawPageCornerAdvView(1, true)
} else if (2 == this.pageModel.isRightAdv) {
// 页面左边挂角
this.drawLeftCornerAdvView(1)
this.drawPageCornerAdvView(1, false)
}
} else if (this.pageModel.pageCornerContentInfo.advert != null) {
if (1 == this.pageModel.isRightAdv) {
// 页面右边挂角
this.drawRightCornerAdvView(2)
this.drawPageCornerAdvView(2, true)
} else if (2 == this.pageModel.isRightAdv) {
// 页面左边挂角
this.drawLeftCornerAdvView(2)
this.drawPageCornerAdvView(2, false)
}
}
}
... ... @@ -144,11 +144,11 @@ export struct PageComponent {
}
/**
*
* 绘制页面挂角
* @param type 1:广告中心的挂角广告;2:展现中心的挂角广告
*/
@Builder
drawLeftCornerAdvView(type: number) {
drawPageCornerAdvView(type: number, isRightCorne: boolean) {
// 页面左挂角
Image(type === 1 ? this.pageModel.pageCornerAdv.matInfo.matImageUrl[0]
: this.pageModel.pageCornerContentInfo.advert.displayUrl)
... ... @@ -157,76 +157,16 @@ export struct PageComponent {
.id("left_iv")
.alignRules({
bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
left: { anchor: '__container__', align: HorizontalAlign.Start },
left: { anchor: isRightCorne ? "" : '__container__', align: HorizontalAlign.Start },
right: { anchor: isRightCorne ? '__container__' : "", align: HorizontalAlign.End },
})
.margin({
bottom: "65vp",
left: ('app.float.card_comp_pagePadding_lf')
})
.onClick(() => {
// 广告业务跳转
ProcessUtils.openAdvDetail(this.pageModel.pageCornerAdv.matInfo);
})
left: isRightCorne ? 0 : $r('app.float.card_comp_pagePadding_lf'),
right: isRightCorne ? $r('app.float.card_comp_pagePadding_lf') : 0,
Image($r('app.media.icon_adv_horn_close'))
.id('left_close')
.width($r('app.float.vp_16'))
.alignRules({
top: { anchor: 'left_iv', align: VerticalAlign.Top },
left: { anchor: 'left_iv', align: HorizontalAlign.Start },
})
.offset({
x: -10,
y: -10
})
.onClick(() => {
// 关闭挂角广告
this.pageModel.isShowAds = false;
})
if (type == 1) {
Text($r('app.string.comp_advertisement'))
.width($r('app.float.vp_28'))
.height($r('app.float.vp_16'))
.fontSize($r('app.float.font_size_10'))
.fontColor(Color.White)
.id('left_tag')
.alignRules({
bottom: { anchor: 'left_iv', align: VerticalAlign.Bottom },
left: { anchor: 'left_iv', align: HorizontalAlign.Start },
})
.textAlign(TextAlign.Center)
.backgroundColor($r('app.color.res_color_general_000000_30'))
.borderRadius({
topLeft: $r('app.float.vp_2'),
topRight: $r('app.float.vp_2'),
bottomLeft: $r('app.float.vp_2'),
bottomRight: $r('app.float.vp_2')
})
}
}
/**
*
* @param type 1:广告中心的挂角广告;2:展现中心的挂角广告
*/
@Builder
drawRightCornerAdvView(type: number) {
Image(type === 1 ? this.pageModel.pageCornerAdv.matInfo.matImageUrl[0]
: this.pageModel.pageCornerContentInfo.advert.displayUrl)
.width($r('app.float.vp_80'))
.height($r('app.float.vp_80'))
.id("right_iv")
.alignRules({
bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
right: { anchor: '__container__', align: HorizontalAlign.End },
})
.margin({ bottom: "65vp", right: $r('app.float.card_comp_pagePadding_lf') })
.onClick(() => {
if (type === 1) {
// 广告业务跳转
ProcessUtils.openAdvDetail(this.pageModel.pageCornerAdv.matInfo);
... ... @@ -235,19 +175,19 @@ export struct PageComponent {
ProcessUtils.advJumpMainPage(this.pageModel.pageCornerContentInfo.advert)
}
})
// 关闭按钮
Image($r('app.media.icon_adv_horn_close'))
.id('right_close')
.id('left_close')
.width($r('app.float.vp_16'))
.alignRules({
top: { anchor: 'right_iv', align: VerticalAlign.Top },
right: { anchor: 'right_iv', align: HorizontalAlign.End },
top: { anchor: 'left_iv', align: VerticalAlign.Top },
left: { anchor: isRightCorne ? '' : 'left_iv', align: HorizontalAlign.Start },
right: { anchor: isRightCorne ? 'left_iv' : '', align: HorizontalAlign.End },
})
.offset({
x: 10,
y: -10
x: isRightCorne ? 10 : -10,
y: isRightCorne ? -10 : -10
})
.onClick(() => {
// 关闭挂角广告
... ... @@ -261,10 +201,11 @@ export struct PageComponent {
.height($r('app.float.vp_16'))
.fontSize($r('app.float.font_size_10'))
.fontColor(Color.White)
.id('right_tag')
.id('left_tag')
.alignRules({
bottom: { anchor: 'right_iv', align: VerticalAlign.Bottom },
right: { anchor: 'right_iv', align: HorizontalAlign.End },
bottom: { anchor: 'left_iv', align: VerticalAlign.Bottom },
left: { anchor: isRightCorne ? '' : 'left_iv', align: HorizontalAlign.Start },
right: { anchor: isRightCorne ? 'left_iv' : '', align: HorizontalAlign.End },
})
.textAlign(TextAlign.Center)
.backgroundColor($r('app.color.res_color_general_000000_30'))
... ... @@ -276,9 +217,9 @@ export struct PageComponent {
})
}
}
async aboutToAppear() {
// 选中tab,才请求数据。拦截大量接口请求
if (this.navIndex === this.currentTopNavSelectedIndex) {
... ...