liyubing

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

... ... @@ -6,6 +6,8 @@ import { WDRouterRule } from '../router/WDRouterRule';
import { ContentConstants } from 'wdConstant';
import { common, Want } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { CompAdvMatInfoBean } from 'wdBean/src/main/ets/bean/adv/CompAdvInfoBean';
import { AdvertsBean } from 'wdBean/src/main/ets/bean/adv/AdvertsBean';
// import { LiveModel } from '../viewmodel/LiveModel';
... ... @@ -16,6 +18,65 @@ const TAG = 'ProcessUtils';
*/
export class ProcessUtils {
/**
* 广告中心的业务广告跳转方法( 现用在挂角广告)
* @param advContent
*/
static openAdvDetail(matInfo: CompAdvMatInfoBean) {
if (matInfo == null) {
return;
}
// 优先openType,再取linkType
let type: string;
if (!StringUtils.isEmpty(matInfo.openType)) {
type = matInfo.openType;
} else {
type = matInfo.linkType;
}
if ('0' == type) {
// 0 :无链接
return;
}
let linkUrl: string = matInfo.linkUrl;
if (StringUtils.isEmpty(linkUrl)) {
return;
}
if ('1' == type) {
// 内链
let content: ContentDTO = {} as ContentDTO;
content.linkUrl = linkUrl;
ProcessUtils.gotoWeb(content);
} else if ('2' == type) {
// 外链
ProcessUtils.jumpExternalWebPage(linkUrl);
}
}
/**
* 展现中心的广告跳转 ( 现用在挂角广告)
* @param advert 展现中心的展现广告
*/
static advJumpMainPage(advert: AdvertsBean) {
let content: ContentDTO = {
linkUrl: advert.linkUrl,
pageId: advert.pageId,
objectId: advert.objectId,
objectType: advert.objectType,
relId: advert.relId,
bottomNavId: advert.bottomNavId
} as ContentDTO;
ProcessUtils.processPage(content);
}
/**
* 页面跳转
*/
static processPage(content: ContentDTO) {
... ... @@ -97,7 +158,7 @@ export class ProcessUtils {
* 图集详情页
* @param content
* */
public static gotoMultiPictureListPage(photoList: PhotoListBean[]) {
public static gotoMultiPictureListPage(photoList: PhotoListBean[]) {
let taskAction: Action = {
type: 'JUMP_DETAIL_PAGE',
params: {
... ...
... ... @@ -95,4 +95,8 @@ export interface CompAdvBean {
* 下一轮展示继续上面逻辑。
*/
displayRound: number;
}
... ...
... ... @@ -78,4 +78,6 @@ export interface ContentDTO {
titleShow?: number;
isSearch?: boolean; // 是否是搜索的结果,区分搜索和主页的数据
commentInfo?: commentInfo
//底部导航栏 id(用于频道跳转)
bottomNavId:string;
}
\ No newline at end of file
... ...
... ... @@ -14,6 +14,7 @@ import { CompParser } from '../CompParser';
import { CompDTO } from 'wdBean';
import PageHelper from '../../viewmodel/PageHelper';
import { channelSkeleton } from '../skeleton/channelSkeleton'
import { ProcessUtils } from 'wdRouter/Index';
const TAG = 'PageComponent';
... ... @@ -119,29 +120,72 @@ export struct PageComponent {
@Builder
pageHornAd() {
if (this.pageModel.isShowAds) {
if (this.pageModel.pageLeftCornerAdv.matInfo != null) {
if (this.pageModel.pageCornerAdv.matInfo != null) {
if (1 == this.pageModel.isRightAdv) {
// 页面右边挂角
this.drawRightCornerAdvView(1)
} else if (2 == this.pageModel.isRightAdv) {
// 页面左边挂角
this.drawLeftCornerAdvView(1)
}
} else if (this.pageModel.pageCornerContentInfo.advert != null) {
if (1 == this.pageModel.isRightAdv) {
// 页面右边挂角
this.drawRightCornerAdvView(2)
} else if (2 == this.pageModel.isRightAdv) {
// 页面左边挂角
this.drawLeftCornerAdvView(2)
}
}
}
}
// 页面左挂角
Image(this.pageModel.pageLeftCornerAdv.matInfo.matImageUrl[0])
.width($r('app.float.vp_80'))
.height($r('app.float.vp_80'))
.id("left_iv")
.alignRules({
bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
left: { anchor: '__container__', align: HorizontalAlign.Start },
})
.margin({ bottom: "65vp", left: $r('app.float.card_comp_pagePadding_lf') })
/**
*
* @param type 1:广告中心的挂角广告;2:展现中心的挂角广告
*/
@Builder
drawLeftCornerAdvView(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("left_iv")
.alignRules({
bottom: { anchor: '__container__', align: VerticalAlign.Bottom },
left: { anchor: '__container__', align: HorizontalAlign.Start },
})
.margin({
bottom: "65vp",
left: ('app.float.card_comp_pagePadding_lf')
})
.onClick(() => {
// 广告业务跳转
ProcessUtils.openAdvDetail(this.pageModel.pageCornerAdv.matInfo);
})
Image($r('app.media.icon_adv_horn_close')).id('left_close').width($r('app.float.vp_16')).alignRules({
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({
})
.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'))
... ... @@ -162,41 +206,56 @@ export struct PageComponent {
})
}
if (this.pageModel.pageRightCornerAdv.matInfo != null && this.pageModel.isShowRightAds) {
// 页面右边挂角
Image(this.pageModel.pageRightCornerAdv.matInfo.matImageUrl[0])
.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(()=>{
}
/**
*
* @param type 1:广告中心的挂角广告;2:展现中心的挂角广告
*/
@Builder
drawRightCornerAdvView(type: number) {
// 关闭挂角广告
this.pageModel.isShowLeftAds = false;
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);
} else {
// 展现中心的业务跳转
ProcessUtils.advJumpMainPage(this.pageModel.pageCornerContentInfo.advert)
Image($r('app.media.icon_adv_horn_close'))
.id('right_close')
.width($r('app.float.vp_16'))
.alignRules({
top: { anchor: 'right_iv', align: VerticalAlign.Top },
right: { anchor: 'right_iv', align: HorizontalAlign.End },
})
.offset({
x: 10,
y: -10
})
.onClick(() => {
// 关闭挂角广告
this.pageModel.isShowRightAds = false;
}
})
})
Image($r('app.media.icon_adv_horn_close'))
.id('right_close')
.width($r('app.float.vp_16'))
.alignRules({
top: { anchor: 'right_iv', align: VerticalAlign.Top },
right: { anchor: 'right_iv', align: HorizontalAlign.End },
})
.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'))
... ... @@ -216,6 +275,8 @@ export struct PageComponent {
bottomRight: $r('app.float.vp_2')
})
}
}
async aboutToAppear() {
... ...
... ... @@ -192,7 +192,8 @@ export struct SearchResultContentComponent{
rmhPlatform: 0,
newTags: '',
isSearch: true,
publishTimestamp:""
publishTimestamp:"",
bottomNavId:'',
}
this.data.push(contentDTO)
... ...
... ... @@ -64,29 +64,50 @@ export class PageHelper {
// 优先展示展现中心广告
let cornersAdv = pageInfo.cornersAdv
if (cornersAdv == null) {
return
}
if (cornersAdv.advert == null) {
return
}
if ("left_down" == cornersAdv.pos) {
// 左边挂角广告
pageModel.isRightAdv = 2
} else {
// 右边挂角广告
pageModel.isRightAdv = 1
}
pageModel.pageCornerContentInfo = cornersAdv;
pageModel.isShowAds = true
} else if (pageInfo.cornersAdv2 != null && pageInfo.cornersAdv2.length > 0) {
// 广告中心-挂角广告信息
let cornersAdv2 = pageInfo.cornersAdv2
// 获取
let showCompAdvBean = cornersAdv2[0]
if (showCompAdvBean.matInfo == null) {
return
}
//
let slotInfo = showCompAdvBean.slotInfo;
let postion = slotInfo.position
if (postion == 0) {
//左边挂角
pageModel.pageLeftCornerAdv = showCompAdvBean
pageModel.isShowLeftAds = true
pageModel.isRightAdv = 2
} else {
// 右边挂角
pageModel.pageRightCornerAdv = showCompAdvBean
pageModel.isShowRightAds = true
pageModel.isRightAdv = 1
}
Logger.error("XXX", JSON.stringify(pageInfo.cornersAdv2))
pageModel.pageCornerAdv = showCompAdvBean
pageModel.isShowAds = true
}
}
... ...
... ... @@ -4,7 +4,7 @@ import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
import { RefreshConstants as Const } from '../utils/RefreshConstants';
import { PageUIReqBean } from '../components/page/bean/PageUIReqBean';
import { GroupInfoDTO, PageInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO';
import { CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
import { AdvRuleBean, CompAdvBean } from 'wdBean/src/main/ets/bean/adv/AdvsRuleBean';
/**
* 页面下拉刷新、上拉加载数据bean。
... ... @@ -52,12 +52,10 @@ export default class PageModel {
timestamp: String = '1';
//左右挂角广告对象
pageLeftCornerAdv:CompAdvBean = {} as CompAdvBean
isShowLeftAds : boolean = true;
pageRightCornerAdv:CompAdvBean = {} as CompAdvBean
isShowRightAds : boolean = true;
pageCornerAdv:CompAdvBean = {} as CompAdvBean // 挂角广告
isShowAds : boolean = false;
isRightAdv : number = 1;// 1:右边;2:左边 -> 默认右边
pageCornerContentInfo:AdvRuleBean = {} as AdvRuleBean // 展现中心业务信息
/**
... ...