张善主

fix(动态详情):屏蔽重复点击事件

@@ -61,3 +61,5 @@ export { MpaasUtils } from './src/main/ets/mpaas/MpaasUtils' @@ -61,3 +61,5 @@ export { MpaasUtils } from './src/main/ets/mpaas/MpaasUtils'
61 export { MpaasUpgradeCheck, UpgradeTipContent } from './src/main/ets/mpaas/MpaasUpgradeCheck' 61 export { MpaasUpgradeCheck, UpgradeTipContent } from './src/main/ets/mpaas/MpaasUpgradeCheck'
62 62
63 export { TingyunAPM } from './src/main/ets/tingyunAPM/TingyunAPM' 63 export { TingyunAPM } from './src/main/ets/tingyunAPM/TingyunAPM'
  64 +
  65 +export { FastClickUtil } from './src/main/ets/utils/FastClickUtil';
  1 +import systemDateTime from '@ohos.systemDateTime';
  2 +
  3 +/**
  4 + * 屏蔽快速点击事件,规定时间内只触发一次
  5 + */
  6 +export class FastClickUtil {
  7 +
  8 + static MIN_DELAY_TIME = 500
  9 +
  10 + static minDelayBeforeTime = 0
  11 +
  12 + static async isMinDelayTime(): Promise<boolean> {
  13 + let systime = await systemDateTime.getCurrentTime();
  14 + return new Promise<boolean>((success, error) => {
  15 + let rtnvalue = systime - FastClickUtil.minDelayBeforeTime <= FastClickUtil.MIN_DELAY_TIME;
  16 + this.minDelayBeforeTime = systime;
  17 + success(rtnvalue);
  18 + })
  19 + }
  20 +}
  21 +
@@ -5,7 +5,8 @@ import { @@ -5,7 +5,8 @@ import {
5 SPHelper, 5 SPHelper,
6 NumberFormatterUtils, 6 NumberFormatterUtils,
7 DisplayUtils, 7 DisplayUtils,
8 - NetworkUtil 8 + NetworkUtil,
  9 + FastClickUtil
9 } from 'wdKit'; 10 } from 'wdKit';
10 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; 11 import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
11 import { 12 import {
@@ -148,7 +149,11 @@ export struct DynamicDetailComponent { @@ -148,7 +149,11 @@ export struct DynamicDetailComponent {
148 .width($r('app.float.margin_48')) 149 .width($r('app.float.margin_48'))
149 .height($r('app.float.margin_48')) 150 .height($r('app.float.margin_48'))
150 .alignContent(Alignment.Center) 151 .alignContent(Alignment.Center)
151 - .onClick(() => { 152 + .onClick(async () => {
  153 + let retvalue = await FastClickUtil.isMinDelayTime()
  154 + if(retvalue){
  155 + return
  156 + }
152 ProcessUtils.gotoPeopleShipHomePage(this.contentDetailData.rmhInfo == null ? "" : 157 ProcessUtils.gotoPeopleShipHomePage(this.contentDetailData.rmhInfo == null ? "" :
153 this.contentDetailData.rmhInfo.rmhId) 158 this.contentDetailData.rmhInfo.rmhId)
154 }) 159 })
@@ -192,7 +197,11 @@ export struct DynamicDetailComponent { @@ -192,7 +197,11 @@ export struct DynamicDetailComponent {
192 .height($r('app.float.margin_24')) 197 .height($r('app.float.margin_24'))
193 .borderRadius($r('app.float.vp_3')) 198 .borderRadius($r('app.float.vp_3'))
194 .backgroundColor($r('app.color.color_ED2800')) 199 .backgroundColor($r('app.color.color_ED2800'))
195 - .onClick(() => { 200 + .onClick(async () => {
  201 + let retvalue = await FastClickUtil.isMinDelayTime()
  202 + if(retvalue){
  203 + return
  204 + }
196 this.handleAccention() 205 this.handleAccention()
197 }) 206 })
198 } else { 207 } else {
@@ -206,7 +215,11 @@ export struct DynamicDetailComponent { @@ -206,7 +215,11 @@ export struct DynamicDetailComponent {
206 .borderColor($r('app.color.color_CCCCCC_1A')) 215 .borderColor($r('app.color.color_CCCCCC_1A'))
207 .backgroundColor($r('app.color.color_CCCCCC_1A')) 216 .backgroundColor($r('app.color.color_CCCCCC_1A'))
208 .fontColor($r('app.color.color_CCCCCC')) 217 .fontColor($r('app.color.color_CCCCCC'))
209 - .onClick(() => { 218 + .onClick(async () => {
  219 + let retvalue = await FastClickUtil.isMinDelayTime()
  220 + if(retvalue){
  221 + return
  222 + }
210 this.handleAccention() 223 this.handleAccention()
211 }) 224 })
212 } 225 }
@@ -275,7 +288,11 @@ export struct DynamicDetailComponent { @@ -275,7 +288,11 @@ export struct DynamicDetailComponent {
275 288
276 } 289 }
277 } 290 }
278 - .onClick((event: ClickEvent) => { 291 + .onClick(async (event: ClickEvent) => {
  292 + let retvalue = await FastClickUtil.isMinDelayTime()
  293 + if(retvalue){
  294 + return
  295 + }
279 ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index) 296 ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
280 }) 297 })
281 } else { 298 } else {
@@ -292,7 +309,11 @@ export struct DynamicDetailComponent { @@ -292,7 +309,11 @@ export struct DynamicDetailComponent {
292 item.height = callback?.height || 0; 309 item.height = callback?.height || 0;
293 }) 310 })
294 } 311 }
295 - .onClick((event: ClickEvent) => { 312 + .onClick(async (event: ClickEvent) => {
  313 + let retvalue = await FastClickUtil.isMinDelayTime()
  314 + if(retvalue){
  315 + return
  316 + }
296 ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index) 317 ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
297 }) 318 })
298 } 319 }
@@ -304,7 +325,11 @@ export struct DynamicDetailComponent { @@ -304,7 +325,11 @@ export struct DynamicDetailComponent {
304 .aspectRatio(1) 325 .aspectRatio(1)
305 .borderRadius(this.caclImageRadius(index)) 326 .borderRadius(this.caclImageRadius(index))
306 } 327 }
307 - .onClick((event: ClickEvent) => { 328 + .onClick(async (event: ClickEvent) => {
  329 + let retvalue = await FastClickUtil.isMinDelayTime()
  330 + if(retvalue){
  331 + return
  332 + }
308 ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index) 333 ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
309 }) 334 })
310 } else { 335 } else {
@@ -315,7 +340,11 @@ export struct DynamicDetailComponent { @@ -315,7 +340,11 @@ export struct DynamicDetailComponent {
315 .aspectRatio(1) 340 .aspectRatio(1)
316 .borderRadius(this.caclImageRadius(index)) 341 .borderRadius(this.caclImageRadius(index))
317 } 342 }
318 - .onClick((event: ClickEvent) => { 343 + .onClick(async (event: ClickEvent) => {
  344 + let retvalue = await FastClickUtil.isMinDelayTime()
  345 + if(retvalue){
  346 + return
  347 + }
319 ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index) 348 ProcessUtils.gotoMultiPictureListPage(this.contentDetailData.photoList, index)
320 }) 349 })
321 } 350 }
@@ -372,7 +401,11 @@ export struct DynamicDetailComponent { @@ -372,7 +401,11 @@ export struct DynamicDetailComponent {
372 left: this.contentDetailData.videoInfo[0].videoLandScape === 1 ? 0 : 25, 401 left: this.contentDetailData.videoInfo[0].videoLandScape === 1 ? 0 : 25,
373 top: $r('app.float.margin_8') 402 top: $r('app.float.margin_8')
374 }) 403 })
375 - .onClick((event: ClickEvent) => { 404 + .onClick(async (event: ClickEvent) => {
  405 + let retvalue = await FastClickUtil.isMinDelayTime()
  406 + if(retvalue){
  407 + return
  408 + }
376 ProcessUtils.processPage(this.mJumpInfo) 409 ProcessUtils.processPage(this.mJumpInfo)
377 }) 410 })
378 } 411 }
@@ -430,7 +463,11 @@ export struct DynamicDetailComponent { @@ -430,7 +463,11 @@ export struct DynamicDetailComponent {
430 .borderWidth($r('app.float.margin_1')) 463 .borderWidth($r('app.float.margin_1'))
431 .borderColor($r('app.color.color_EDEDED')) 464 .borderColor($r('app.color.color_EDEDED'))
432 .borderRadius($r('app.float.margin_20')) 465 .borderRadius($r('app.float.margin_20'))
433 - .onClick((event: ClickEvent) => { 466 + .onClick(async (event: ClickEvent) => {
  467 + let retvalue = await FastClickUtil.isMinDelayTime()
  468 + if(retvalue){
  469 + return
  470 + }
434 //点赞操作 471 //点赞操作
435 this.toggleLikeStatus() 472 this.toggleLikeStatus()
436 }) 473 })
@@ -481,6 +518,13 @@ export struct DynamicDetailComponent { @@ -481,6 +518,13 @@ export struct DynamicDetailComponent {
481 * */ 518 * */
482 private async getContentDetailData() { 519 private async getContentDetailData() {
483 this.isNetConnected = NetworkUtil.isNetConnected() 520 this.isNetConnected = NetworkUtil.isNetConnected()
  521 + this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
  522 + this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId)
  523 + this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
  524 + this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType)
  525 + this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId)
  526 + this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle)
  527 + this.publishCommentModel.targetType = String(this.contentDetailData?.newsType)
484 try { 528 try {
485 let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) 529 let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
486 this.isPageEnd = true; 530 this.isPageEnd = true;