yuzhilin

fix:频道订阅逻辑优化

@@ -7,7 +7,7 @@ export class CallBackMessage { @@ -7,7 +7,7 @@ export class CallBackMessage {
7 callbackId: string = ""; //callbackId 7 callbackId: string = ""; //callbackId
8 responseId: string = ""; //responseId 8 responseId: string = ""; //responseId
9 responseData: string = ""; //responseData 9 responseData: string = ""; //responseData
10 - data?: string; //data of message 10 + data?: object; //data of message
11 handlerName: string = ""; //name of handler 11 handlerName: string = ""; //name of handler
12 12
13 /** 13 /**
@@ -128,11 +128,11 @@ export class BridgeWebViewControl extends webview.WebviewController { @@ -128,11 +128,11 @@ export class BridgeWebViewControl extends webview.WebviewController {
128 * native 主动调用JSBridge方法 128 * native 主动调用JSBridge方法
129 * @param msg 129 * @param msg
130 */ 130 */
131 - callHandle(handlerName: string, data: string, callBack: Callback) { 131 + callHandle(handlerName: string, data: object, callBack: Callback) {
132 this.doSend(handlerName, data, callBack) 132 this.doSend(handlerName, data, callBack)
133 } 133 }
134 134
135 - private doSend(handlerName: string, data: string, callBack: Callback) { 135 + private doSend(handlerName: string, data: object, callBack: Callback) {
136 let msg: CallBackMessage = new CallBackMessage() 136 let msg: CallBackMessage = new CallBackMessage()
137 if (StringUtils.isNotEmpty(data)) { 137 if (StringUtils.isNotEmpty(data)) {
138 msg.data = data 138 msg.data = data
@@ -119,7 +119,7 @@ export struct ImageAndTextWebComponent { @@ -119,7 +119,7 @@ export struct ImageAndTextWebComponent {
119 private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) { 119 private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
120 Logger.debug('ImageAndTextWebComponent', 'jsCall_receiveAppData'); 120 Logger.debug('ImageAndTextWebComponent', 'jsCall_receiveAppData');
121 this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData, 121 this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
122 - JSON.stringify(h5ReceiveAppData), (data: string) => { 122 + h5ReceiveAppData, (data: string) => {
123 Logger.debug('ImageAndTextWebComponent', "from js data = " + data); 123 Logger.debug('ImageAndTextWebComponent', "from js data = " + data);
124 }) 124 })
125 } 125 }
@@ -39,7 +39,7 @@ export struct SpacialTopicPageComponent { @@ -39,7 +39,7 @@ export struct SpacialTopicPageComponent {
39 39
40 private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) { 40 private sendContentData2H5(h5ReceiveAppData: H5ReceiveDetailBean) {
41 this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData, 41 this.webviewControl.callHandle(NativeCallH5Type.jsCall_receiveAppData,
42 - JSON.stringify(h5ReceiveAppData), (data: string) => { 42 + h5ReceiveAppData, (data: string) => {
43 }) 43 })
44 } 44 }
45 45
@@ -91,13 +91,14 @@ export struct SpacialTopicPageComponent { @@ -91,13 +91,14 @@ export struct SpacialTopicPageComponent {
91 } 91 }
92 .width(CommonConstants.FULL_WIDTH) 92 .width(CommonConstants.FULL_WIDTH)
93 .height(CommonConstants.FULL_HEIGHT) 93 .height(CommonConstants.FULL_HEIGHT)
94 - .padding({ bottom: 126 }) 94 + // .padding({ bottom: 76 })
95 95
96 if (!this.isPageEnd) { 96 if (!this.isPageEnd) {
97 detailedSkeleton() 97 detailedSkeleton()
98 } 98 }
99 //底部交互区 99 //底部交互区
100 - OperRowListView({ contentDetailData: this.contentDetailData[0], 100 + OperRowListView({
  101 + contentDetailData: this.contentDetailData[0],
101 publishCommentModel: this.publishCommentModel 102 publishCommentModel: this.publishCommentModel
102 }) 103 })
103 } 104 }
@@ -250,10 +250,10 @@ struct ChannelDialog { @@ -250,10 +250,10 @@ struct ChannelDialog {
250 .fontSize(16) 250 .fontSize(16)
251 .fontWeight(600) 251 .fontWeight(600)
252 .margin({ right: 4 }) 252 .margin({ right: 4 })
253 - Text(!this.isEditIng ? MY_CHANNEL_TIP1 : MY_CHANNEL_TIP2)  
254 - .fontSize(12)  
255 - .fontWeight(400)  
256 - .fontColor('#222222') 253 + // Text(!this.isEditIng ? MY_CHANNEL_TIP1 : MY_CHANNEL_TIP2)
  254 + // .fontSize(12)
  255 + // .fontWeight(400)
  256 + // .fontColor('#222222')
257 } 257 }
258 258
259 Text(this.isEditIng ? EDIT_DOWN : EDIT_TEXT) 259 Text(this.isEditIng ? EDIT_DOWN : EDIT_TEXT)
@@ -276,9 +276,9 @@ struct ChannelDialog { @@ -276,9 +276,9 @@ struct ChannelDialog {
276 Row() { 276 Row() {
277 Text(item.name) 277 Text(item.name)
278 .fontSize(14) 278 .fontSize(14)
279 - .fontColor(this.currentTopNavSelectedItem.channelId === item.channelId ? '#ED2800' : (item.homeChannel === '1' || item.movePermitted === 0 ? '#999999' : '#222222')) 279 + .fontColor(this.currentTopNavSelectedItem.channelId === item.channelId ? '#ED2800' : (item.headlinesOn === 1 || item.movePermitted === 0 ? '#999999' : '#222222'))
280 280
281 - if (this.isEditIng && item.delPermitted === 1) { 281 + if (this.isEditIng && item.delPermitted === 1 && item.movePermitted === 1) {
282 Image($r('app.media.icon_audio_close')) 282 Image($r('app.media.icon_audio_close'))
283 .width(12) 283 .width(12)
284 .margin({ left: 1 }) 284 .margin({ left: 1 })
@@ -287,12 +287,12 @@ struct ChannelDialog { @@ -287,12 +287,12 @@ struct ChannelDialog {
287 .width('100%') 287 .width('100%')
288 .height('100%') 288 .height('100%')
289 .justifyContent(FlexAlign.Center) 289 .justifyContent(FlexAlign.Center)
290 - .backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff') 290 + .backgroundColor(item.headlinesOn === 1 || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff')
291 } 291 }
292 .width('23%') 292 .width('23%')
293 .height(40) 293 .height(40)
294 .border({ 294 .border({
295 - width: item.homeChannel === '1' ? 0 : 1, 295 + width: item.headlinesOn === 1 || item.movePermitted === 0 ? 0 : 1,
296 color: '#EDEDED', 296 color: '#EDEDED',
297 radius: 3 297 radius: 3
298 }) 298 })
@@ -303,7 +303,7 @@ struct ChannelDialog { @@ -303,7 +303,7 @@ struct ChannelDialog {
303 TapGesture() 303 TapGesture()
304 .onAction((event?: GestureEvent) => { 304 .onAction((event?: GestureEvent) => {
305 if (this.isEditIng) { 305 if (this.isEditIng) {
306 - if (item.delPermitted === 1) { 306 + if (item.delPermitted === 1 && item.movePermitted === 1) {
307 this.delChannelItem(index) 307 this.delChannelItem(index)
308 } 308 }
309 } else { 309 } else {
@@ -59,7 +59,6 @@ export struct TopNavigationComponent { @@ -59,7 +59,6 @@ export struct TopNavigationComponent {
59 @State autoRefresh2Page: number = 0 59 @State autoRefresh2Page: number = 0
60 // 当前底导index 60 // 当前底导index
61 @State navIndex: number = 0 61 @State navIndex: number = 0
62 -  
63 @State animationDuration: number = 0 62 @State animationDuration: number = 0
64 @State indicatorLeftMargin: number = 0 63 @State indicatorLeftMargin: number = 0
65 @State indicatorWidth: number = 0 64 @State indicatorWidth: number = 0
@@ -93,7 +92,8 @@ export struct TopNavigationComponent { @@ -93,7 +92,8 @@ export struct TopNavigationComponent {
93 92
94 //defaultMyChannelList 93 //defaultMyChannelList
95 defaultList.forEach(item => { 94 defaultList.forEach(item => {
96 - if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 || item.headlinesOn === 1) { 95 + if (item.defaultPermitted === 1 || item.movePermitted === 0 || item.delPermitted === 0 ||
  96 + item.headlinesOn === 1) {
97 defaultMyChannelList.push(item); 97 defaultMyChannelList.push(item);
98 } 98 }
99 if (item.defaultPermitted === 1) { 99 if (item.defaultPermitted === 1) {
@@ -136,7 +136,8 @@ export struct TopNavigationComponent { @@ -136,7 +136,8 @@ export struct TopNavigationComponent {
136 } 136 }
137 137
138 //频道分类 138 //频道分类
139 - if (item.myChannel === '1' && item.name !== '播报') { 139 + if (item.name !== '播报') { //暂时隐藏播报
  140 + if (item.myChannel === '1') {
140 _myChannelList.push(item) 141 _myChannelList.push(item)
141 _channelIds.push(item.channelId) 142 _channelIds.push(item.channelId)
142 } else if (item.moreChannel === '1') { 143 } else if (item.moreChannel === '1') {
@@ -144,6 +145,7 @@ export struct TopNavigationComponent { @@ -144,6 +145,7 @@ export struct TopNavigationComponent {
144 } else if (item.localChannel === '1') { 145 } else if (item.localChannel === '1') {
145 this.localChannelList.push(item) 146 this.localChannelList.push(item)
146 } 147 }
  148 + }
147 149
148 }) 150 })
149 151
@@ -169,7 +171,6 @@ export struct TopNavigationComponent { @@ -169,7 +171,6 @@ export struct TopNavigationComponent {
169 return item.name === '版面' 171 return item.name === '版面'
170 } 172 }
171 173
172 -  
173 build() { 174 build() {
174 Column() { 175 Column() {
175 // 顶部搜索、日报logo、早晚报 176 // 顶部搜索、日报logo、早晚报
@@ -216,7 +217,8 @@ export struct TopNavigationComponent { @@ -216,7 +217,8 @@ export struct TopNavigationComponent {
216 // 频道分类list 217 // 频道分类list
217 Stack({ alignContent: Alignment.TopEnd }) { 218 Stack({ alignContent: Alignment.TopEnd }) {
218 Tabs({ index: this.currentTopNavSelectedIndex, controller: this.tabsController }) { 219 Tabs({ index: this.currentTopNavSelectedIndex, controller: this.tabsController }) {
219 - ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList, (navItem: TopNavDTO, index: number) => { 220 + ForEach(this.currentBottomNavName === '新闻' ? this.myChannelList : this.topNavList,
  221 + (navItem: TopNavDTO, index: number) => {
220 TabContent() { 222 TabContent() {
221 if (this.currentBottomNavName === '视频' && navItem.name === '视频') { 223 if (this.currentBottomNavName === '视频' && navItem.name === '视频') {
222 VideoChannelDetail({ 224 VideoChannelDetail({
@@ -226,16 +228,14 @@ export struct TopNavigationComponent { @@ -226,16 +228,14 @@ export struct TopNavigationComponent {
226 pageId: navItem.pageId + '', 228 pageId: navItem.pageId + '',
227 channelId: navItem.channelId + '', 229 channelId: navItem.channelId + '',
228 }) 230 })
229 - }  
230 - else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') { 231 + } else if (this.currentBottomNavName === '人民号' && navItem.name === '关注') {
231 PeopleShipMainComponent({ 232 PeopleShipMainComponent({
232 currentTopNavSelectedIndex: $currentTopNavSelectedIndex, 233 currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
233 navIndex: index, 234 navIndex: index,
234 pageId: navItem.pageId + '', 235 pageId: navItem.pageId + '',
235 channelId: navItem.channelId + '', 236 channelId: navItem.channelId + '',
236 }) 237 })
237 - }  
238 - else 238 + } else
239 if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) { 239 if (!this.isBroadcast(navItem) && !this.isLayout(navItem)) {
240 PageComponent({ 240 PageComponent({
241 currentTopNavSelectedIndex: $currentTopNavSelectedIndex, 241 currentTopNavSelectedIndex: $currentTopNavSelectedIndex,
@@ -254,13 +254,14 @@ export struct TopNavigationComponent { @@ -254,13 +254,14 @@ export struct TopNavigationComponent {
254 .barMode(BarMode.Scrollable) 254 .barMode(BarMode.Scrollable)
255 .vertical(false) 255 .vertical(false)
256 .barBackgroundColor(this.barBackgroundColor) 256 .barBackgroundColor(this.barBackgroundColor)
257 - .onAreaChange((oldValue: Area,newValue: Area)=> { 257 + .onAreaChange((oldValue: Area, newValue: Area) => {
258 let width = Number.parseFloat(newValue.width.toString()) 258 let width = Number.parseFloat(newValue.width.toString())
259 this.tabsWidth = Number.isNaN(width) ? 0 : width 259 this.tabsWidth = Number.isNaN(width) ? 0 : width
260 }) 260 })
261 .animationDuration(this.animationDuration) 261 .animationDuration(this.animationDuration)
262 .onChange((index: number) => { 262 .onChange((index: number) => {
263 - this.currentTopNavName = this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name 263 + this.currentTopNavName =
  264 + this._currentNavIndex === 0 ? this.myChannelList[index].name : this.topNavList[index].name
264 Logger.info(TAG, `onChange index : ${index}`); 265 Logger.info(TAG, `onChange index : ${index}`);
265 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && 266 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
266 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) 267 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
@@ -288,24 +289,24 @@ export struct TopNavigationComponent { @@ -288,24 +289,24 @@ export struct TopNavigationComponent {
288 let targetIndexInfo = this.getTextInfo(targetIndex) 289 let targetIndexInfo = this.getTextInfo(targetIndex)
289 this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width) 290 this.startAnimateTo(this.animationDuration, targetIndexInfo.left, targetIndexInfo.width)
290 }) 291 })
291 - .onAnimationEnd((index: number,event: TabsAnimationEvent) => { 292 + .onAnimationEnd((index: number, event: TabsAnimationEvent) => {
292 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && 293 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
293 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) 294 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
294 ) { 295 ) {
295 return 296 return
296 } 297 }
297 // 切换动画结束时触发该回调。下划线动画停止。 298 // 切换动画结束时触发该回调。下划线动画停止。
298 - let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event)  
299 - this.startAnimateTo(0,currentIndicatorInfo.left,currentIndicatorInfo.width) 299 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event)
  300 + this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width)
300 }) 301 })
301 - .onGestureSwipe((index: number,event: TabsAnimationEvent) => { 302 + .onGestureSwipe((index: number, event: TabsAnimationEvent) => {
302 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) && 303 if (!this.isBroadcast(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) &&
303 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index]) 304 !this.isLayout(this._currentNavIndex === 0 ? this.myChannelList[index] : this.topNavList[index])
304 ) { 305 ) {
305 return 306 return
306 } 307 }
307 // 在页面跟手滑动过程中,逐帧触发该回调。 308 // 在页面跟手滑动过程中,逐帧触发该回调。
308 - let currentIndicatorInfo = this.getCurrentIndicatorInfo(index,event) 309 + let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event)
309 this.currentTopNavSelectedIndex = currentIndicatorInfo.index 310 this.currentTopNavSelectedIndex = currentIndicatorInfo.index
310 this.indicatorLeftMargin = currentIndicatorInfo.left 311 this.indicatorLeftMargin = currentIndicatorInfo.left
311 this.indicatorWidth = currentIndicatorInfo.width 312 this.indicatorWidth = currentIndicatorInfo.width
@@ -351,8 +352,9 @@ export struct TopNavigationComponent { @@ -351,8 +352,9 @@ export struct TopNavigationComponent {
351 .padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') }) 352 .padding({ top: $r('app.float.top_tab_item_padding_top'), bottom: $r('app.float.top_tab_item_padding_bottom') })
352 .maxLines(this.MAX_LINE) 353 .maxLines(this.MAX_LINE)
353 .id(index.toString()) 354 .id(index.toString())
354 - .onAreaChange((oldValue: Area,newValue: Area) => {  
355 - if (this.currentTopNavSelectedIndex === index && (this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)){ 355 + .onAreaChange((oldValue: Area, newValue: Area) => {
  356 + if (this.currentTopNavSelectedIndex === index &&
  357 + (this.indicatorLeftMargin === 0 || this.indicatorWidth === 0)) {
356 if (newValue.position.x != undefined) { 358 if (newValue.position.x != undefined) {
357 let positionX = Number.parseFloat(newValue.position.x.toString()) 359 let positionX = Number.parseFloat(newValue.position.x.toString())
358 this.indicatorLeftMargin = Number.isNaN(positionX) ? 0 : positionX 360 this.indicatorLeftMargin = Number.isNaN(positionX) ? 0 : positionX
@@ -396,7 +398,8 @@ export struct TopNavigationComponent { @@ -396,7 +398,8 @@ export struct TopNavigationComponent {
396 } 398 }
397 399
398 onTopNavigationDataUpdated() { 400 onTopNavigationDataUpdated() {
399 - Logger.info(TAG, `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`); 401 + Logger.info(TAG,
  402 + `onTopNavigationDataUpdated currentTopNavIndex: ${this.currentTopNavSelectedIndex},topNavList.length:${this.topNavList.length}`);
400 } 403 }
401 404
402 onAutoRefresh() { 405 onAutoRefresh() {