王士厅

底导、顶导配置国殇模式

... ... @@ -139,6 +139,9 @@ export class ContentDTO implements BaseDTO {
traceId: string = '';
traceInfo: string = '';
// 是否国殇
isMourning?: boolean = false;
static clone(old: ContentDTO): ContentDTO {
let content = new ContentDTO();
content.liveType = old.liveType;
... ...
... ... @@ -103,3 +103,5 @@ export { CommentListDialogView } from './src/main/ets/components/comment/view/Co
export { CustomPullToRefresh } from './src/main/ets/components/reusable/CustomPullToRefresh';
export { MorningEveningViewModel } from './src/main/ets/viewmodel/MorningEveningViewModel'
export { GrayManageModel } from './src/main/ets/viewmodel/GrayManageModel'
\ No newline at end of file
... ...
... ... @@ -11,6 +11,7 @@ import { ParamType, TrackConstants, Tracking, TrackingButton } from 'wdTracking/
import DailyPaperTopicModel from '../../model/DailyPaperTopicModel';
import { CompUtils } from '../../utils/CompUtils';
import ChannelViewModel from '../../viewmodel/ChannelViewModel';
import { GrayManageModel } from '../../viewmodel/GrayManageModel';
import { ColorUtils } from '../../utils/ColorUtils';
const TAG = 'TopNavigationComponent';
... ... @@ -24,6 +25,7 @@ const storage = LocalStorage.getShared();
@Component
export struct TopNavigationComponentNew {
private topRectHeight: number = AppStorage.get<number>('topSafeHeight') || 0;
private pageName: string = ''
private pageId: number = 0
readonly MAX_LINE: number = 1; // 顶部tab text最大行数
... ... @@ -70,6 +72,8 @@ export struct TopNavigationComponentNew {
// 顶部导航栏是否有临时跳转频道数据不
@State haveTempTabData: boolean = false
@State backgroundImageH: number = 0
// 国殇灰度管理
GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
build() {
Column() {
... ... @@ -217,6 +221,7 @@ export struct TopNavigationComponentNew {
// 预留状态栏
.margin({ top: this.topRectHeight + 'px' })
.id('topBar')
.grayscale(this.GrayManage.get().isMourning() ? 1 : 0)
}
/**
... ... @@ -229,11 +234,22 @@ export struct TopNavigationComponentNew {
}
@Builder
buildTabBarItems(mourningCheckFn: (channelId: string) => boolean) {
ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => {
ListItem() {
this.tabBarBuilder(navItem, index)
}
.grayscale(mourningCheckFn(`${navItem.channelId}`) ? 1 : 0)
});
}
@Builder
tabBar() {
if (CompUtils.isNews(this.navItem)) {
// 顶部背景图
Image(this.navItem.backgroundUrl).width('100%')
.grayscale(this.GrayManage.get().isMourning() ? 1 : 0)
// 顶部搜索、日报logo、早晚报
this.topBar()
... ... @@ -254,12 +270,14 @@ export struct TopNavigationComponentNew {
'top': { 'anchor': 'topBar', 'align': VerticalAlign.Bottom },
'right': { 'anchor': '__container__', 'align': HorizontalAlign.End }
})
.grayscale(this.GrayManage.get().isMourning() ? 1 : 0)
List({ scroller: this.listScroller }) {
ForEach(this.myChannelList, (navItem: TopNavDTO, index: number) => {
ListItem() {
this.tabBarBuilder(navItem, index)
}
.grayscale(this.GrayManage.get().isNewsMourning(`${navItem.channelId}`) ? 1 : 0)
})
}
.listDirection(Axis.Horizontal)
... ... @@ -275,7 +293,10 @@ export struct TopNavigationComponentNew {
})
} else {
// 顶部背景图
Image(this.navItem.backgroundUrl).width('100%').height(this.backgroundImageH)
Image(this.navItem.backgroundUrl)
.width('100%')
.height(this.backgroundImageH)
.grayscale(this.GrayManage.get().isMourning() ? 1 : 0)
Row() {
Image($r('app.media.icon_search'))
... ... @@ -299,13 +320,12 @@ export struct TopNavigationComponentNew {
let params = { 'tabName': "PEOPLE" } as Record<string, string>
WDRouterRule.jumpWithPage(WDRouterPage.searchPage, params)
})
.grayscale(this.GrayManage.get().isMourning() ? 1 : 0)
List({ scroller: this.listScroller }) {
ForEach(this.topNavList, (navItem: TopNavDTO, index: number) => {
ListItem() {
this.tabBarBuilder(navItem, index)
if (CompUtils.isRMH(this.navItem)) {
this.buildTabBarItems((channelId) => this.GrayManage.get().isRmhMourning(channelId));
}
})
}
.listDirection(Axis.Horizontal)
.scrollBar(BarState.Off)
... ...
... ... @@ -26,6 +26,7 @@ import { CardParser } from '../CardParser'
import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
import PageFollowHelper from '../../viewmodel/PageFollowHelper';
import { MineFollowListItem } from '../../viewmodel/MineFollowListItem';
import { GrayManageModel } from '../../viewmodel/GrayManageModel';
const TAG = 'PeopleShipMainComponent';
... ... @@ -60,6 +61,8 @@ export struct PeopleShipMainComponent {
// 页面展示监听
@Consume @Watch('onPageShowChange') pageShow: number
@State private pageAttentionChange: boolean = false
// 国殇灰度管理
GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
build() {
if (this.viewType == ViewType.LOADING) {
... ... @@ -73,6 +76,7 @@ export struct PeopleShipMainComponent {
this.getData()
}
})
.grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)
} else if (this.viewType == ViewType.EMPTY) {
//缺省页
EmptyComponent({
... ... @@ -82,6 +86,7 @@ export struct PeopleShipMainComponent {
this.getData()
}
})
.grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)
} else {
if (this.followList.length == 0) {
CustomPullToRefresh({
... ... @@ -133,6 +138,7 @@ export struct PeopleShipMainComponent {
@Builder
LoadingLayout() {
channelSkeleton()
.grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)
}
@Builder
... ... @@ -147,6 +153,7 @@ export struct PeopleShipMainComponent {
changeButton: this.changeButton
})
}
.grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
... ... @@ -163,6 +170,7 @@ export struct PeopleShipMainComponent {
followList: this.followList
})
}
.grayscale(this.GrayManage.get().isRmhMourning(`${this.channelId}`) ? 1 : 0)
ForEach(this.attentionList, (item: ContentDTO) => {
ListItem() {
... ... @@ -346,6 +354,12 @@ export struct PeopleShipMainComponent {
}
this.attentionList.push(element)
})
// 关注频道国殇模式开启,最多前8条数据配置成国殇色
if(this.GrayManage.get().isRmhMourning(`${this.channelId}`)) {
for (let i = 0; i < Math.min(8, this.attentionList.length); i++) {
this.attentionList[i].isMourning = true;
}
}
} catch (exception) {
this.resolveEnd(false, resolve)
... ...
import { HttpUtils } from 'wdNetwork/Index';
export interface mournsInfoModel{
switchOpen : boolean
bottomNavOpen : boolean
greyUserList : Array<string>
newsList : Array<string>
onlineState : number
rmhList : Array<string>
selectAll : boolean
serverList : Array<string>
videoList : Array<string>
md5 : string
}
const TAG: string = 'GrayManageModel';
/**
* 国殇管理
*/
export class GrayManageModel {
/**
* 用户ID
*/
private user_id = HttpUtils.getUserId()
/**
* 国殇模式开关:true-开启, false-关闭
*/
private switchOpen: boolean = false
/**
* 灰度状态: 0-待上线, 1-灰度中,2-全量发布
*/
private onlineState: number = 0
/**
* 底部导航开关(TAB图标/文字): true-开启,false-关闭
*/
private bottomNavOpen: boolean = false
/**
* 涉及范围选择,一键全选: true-全选, false-非全选
*/
private selectAll: boolean = false
/**
* 新闻频道集合
*/
private newsList: Array<string> = []
/**
* 人民号频道集合
*/
private rmhList: Array<string> = []
/**
* 视频频道集合
*/
private videoList: Array<string> = []
/**
* 服务频道集合
*/
private serverList: Array<string> = []
/**
* 灰度用户userId集合
*/
private grayUserList: Array<string> = []
public setMourning(mourns: mournsInfoModel) {
this.switchOpen = mourns.switchOpen
this.bottomNavOpen = mourns.bottomNavOpen
this.onlineState = mourns.onlineState
this.selectAll = mourns.selectAll
this.newsList = mourns.newsList
this.rmhList = mourns.rmhList
this.videoList = mourns.videoList
this.serverList = mourns.serverList
this.grayUserList = mourns.greyUserList
console.log(TAG, 'LaunchDataModel.mourns', JSON.stringify(mourns))
}
// 国殇模式开启
public isMourning(): boolean {
// 基础条件:用户已登录且国殇模式主开关开启
if (!this.user_id || !this.switchOpen) {
return false;
}
// 灰度发布状态下,需额外检查用户是否在灰度名单内
if (this.onlineState === 1 && !this.grayUserList.includes(`${this.user_id}`)) {
return false;
}
// 在线状态为2(全量发布)或未明确提及的其他状态,默认视为全量或同全量处理
return true;
}
// 国殇模式开启 底导国殇模式开启
public isBottomNavMourning(): boolean {
return (
!!this.user_id && // 确保用户已登录
this.switchOpen && // 国殇模式总开关开启
this.bottomNavOpen && // 底部导航国殇模式开关开启
(
this.onlineState !== 1 || // 非灰度发布状态直接开启
this.onlineState === 1 && this.grayUserList.includes(`${this.user_id}`) // 灰度发布且用户在灰度列表内
)
);
}
// 国殇模式开启 新闻频道国殇模式开启 一键全选: true-全选, false-非全选
public isNewsMourning(channelId: string): boolean {
// 检查最基本的前提条件
if (!this.user_id || !this.switchOpen) {
return false;
}
// 对于灰度发布状态(onlineState === 1),用户需在灰度名单内
if (this.onlineState === 1 && !this.grayUserList.includes(`${this.user_id}`)) {
return false;
}
// 在国殇模式开启、用户符合条件的前提下:
// - 如果一键全选开启,则直接返回true
// - 否则检查channelId是否在newsList中以决定是否开启国殇模式
return this.selectAll || this.newsList.includes(channelId);
}
// 国殇模式开启 人民号频道国殇模式开启 一键全选: true-全选, false-非全选
public isRmhMourning(channelId: string): boolean {
// 检查最基本的前提条件
if (!this.user_id || !this.switchOpen) {
return false;
}
// 对于灰度发布状态(onlineState === 1),用户需在灰度名单内
if (this.onlineState === 1 && !this.grayUserList.includes(`${this.user_id}`)) {
return false;
}
// 在国殇模式开启、用户符合条件的前提下:
// - 如果一键全选开启,则直接返回true
// - 否则检查channelId是否在rmhList中以决定是否开启国殇模式
return this.selectAll || this.rmhList.includes(channelId);
}
// 国殇模式开启 视频频道频道国殇模式开启 一键全选: true-全选, false-非全选
public isVideoMourning(channelId: string): boolean {
console.log(TAG, 'isVideo this.user_id', this.user_id)
console.log(TAG, 'isVideo this.switchOpen', this.switchOpen)
console.log(TAG, 'isVideo this.onlineState', this.onlineState)
console.log(TAG, 'isVideo channelId', channelId)
console.log(TAG, 'isVideo this.videoList', this.videoList)
console.log(TAG, 'isVideo this.videoList.includes(videoId)', this.videoList.includes(channelId))
// 检查最基本的前提条件
if (!this.user_id || !this.switchOpen) {
return false;
}
// 对于灰度发布状态(onlineState === 1),用户需在灰度名单内
if (this.onlineState === 1 && !this.grayUserList.includes(`${this.user_id}`)) {
return false;
}
// 在国殇模式开启、用户符合条件的前提下:
// - 否则检查channelId是否在videoList中以决定是否开启国殇模式
return this.videoList.includes(channelId);
}
// 国殇模式开启 视频频道频道国殇模式开启 一键全选: true-全选, false-非全选
public isServerMourning(channelId: string): boolean {
// 检查最基本的前提条件
if (!this.user_id || !this.switchOpen) {
return false;
}
// 对于灰度发布状态(onlineState === 1),用户需在灰度名单内
if (this.onlineState === 1 && !this.grayUserList.includes(`${this.user_id}`)) {
return false;
}
// 在国殇模式开启、用户符合条件的前提下:
// - 如果一键全选开启,则直接返回true
// - 否则检查channelId是否在serverList中以决定是否开启国殇模式
return this.selectAll || this.serverList.includes(channelId);
}
}
... ...
... ... @@ -15,6 +15,7 @@ import { Logger, SPHelper, UmengStats } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
import { TrackingModule } from 'wdTracking/Index'
import { StartupManager } from '../../startupmanager/StartupManager'
import { GrayManageModel, mournsInfoModel } from 'wdComponent/src/main/ets/viewmodel/GrayManageModel'
@Entry
@Component
... ... @@ -112,6 +113,11 @@ struct LaunchPage {
let dataModel : LaunchDataModel = JSON.parse(dataModelStr)
console.log(dataModelStr)
// 处理国殇模式数据
let mourns: mournsInfoModel = dataModel.mourns as mournsInfoModel
let GrayManage = new GrayManageModel()
GrayManage.setMourning(mourns)
AppStorage.setOrCreate('GrayManage', GrayManage)
if (dataModel.launchPageInfo || dataModel.launchAdInfo.length) {
//跳转广告页
... ...
... ... @@ -11,6 +11,7 @@ import { ALL, ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknife';
import { ParamType, Tracking } from 'wdTracking/Index';
import { AudioSuspensionModel } from 'wdComponent'
import { BusinessError } from '@kit.BasicServicesKit';
import { GrayManageModel } from 'wdComponent/src/main/ets/viewmodel/GrayManageModel';
const TAG = 'BottomNavigationComponent';
PersistentStorage.persistProp('channelIds', '');
... ... @@ -55,6 +56,8 @@ export struct BottomNavigationComponent {
@State autoRefresh: number = 0
private AudioSuspension = new AudioSuspensionModel()
@State isShowAudioCom: boolean = false
// 国殇灰度管理
GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
async aboutToAppear() {
... ... @@ -105,9 +108,7 @@ export struct BottomNavigationComponent {
}
}
.tabBar(this.tabBarBuilder(navItem, index))
});
})
}
.zIndex(10)
.scrollable(false)
... ... @@ -162,6 +163,7 @@ export struct BottomNavigationComponent {
Tracking.event("bar_click", params)
this.onBottomNavigationIndexChange(navItem, index)
})
.grayscale(this.GrayManage.get().isBottomNavMourning() ? 1 : 0)
}
... ...
... ... @@ -6,7 +6,7 @@ import { BottomNavDTO, TopNavDTO } from 'wdBean/Index'
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { DisplayDirection } from 'wdConstant/Index';
import { CompUtils, PageComponent } from 'wdComponent/Index';
import { CompUtils, GrayManageModel, PageComponent } from 'wdComponent/Index';
import { TrackingButton, TrackConstants } from 'wdTracking/Index';
import { Logger, WindowModel } from 'wdKit';
import { ParamType, Tracking } from 'wdTracking/Index';
... ... @@ -41,6 +41,8 @@ export struct VideoChannelPage {
@State backgroundImageH: number = 0
@Consume @Watch('setBarBackgroundColor') pageShow: number
// 国殇灰度管理
GrayManage: SubscribedAbstractProperty<GrayManageModel> = AppStorage.link<GrayManageModel>('GrayManage')
async aboutToAppear() {
// 背景图高度
... ... @@ -155,6 +157,7 @@ export struct VideoChannelPage {
this.swiperController.changeIndex(index, true)
})
.grayscale(this.GrayManage.get().isVideoMourning(`${item.channelId}`) ? 1 : 0)
}, (item: TopNavDTO) => item.channelId + '')
}
.width('100%')
... ... @@ -182,6 +185,7 @@ export struct VideoChannelPage {
WDRouterRule.jumpWithPage(WDRouterPage.searchPage, params)
})
.backgroundColor(Color.Transparent)
.grayscale(this.GrayManage.get().isMourning() ? 1 : 0)
}
.zIndex(20)
... ...
... ... @@ -56,12 +56,27 @@ export interface NetLayerLauncherH5TemplateInfoModel{
}
export interface mournsInfoModel{
switchOpen : boolean
bottomNavOpen : boolean
greyUserList : Array<string>
newsList : Array<string>
onlineState : number
rmhList : Array<string>
selectAll : boolean
serverList : Array<string>
videoList : Array<string>
md5 : string
}
export default interface LaunchDataModel{
launchPageInfo : NetLayerLaunchOperatModel
launchAdInfo : NetLayerLauncherADInfoModel[]
h5Template : NetLayerLauncherH5TemplateInfoModel[]
mourns: mournsInfoModel
}
... ...