diff --git a/lib/hj_page/home/home_cell_style/tiktok_simple_cell.dart b/lib/hj_page/home/home_cell_style/tiktok_simple_cell.dart index 2247160..a79bfc8 100644 --- a/lib/hj_page/home/home_cell_style/tiktok_simple_cell.dart +++ b/lib/hj_page/home/home_cell_style/tiktok_simple_cell.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:hgdj/assets_tool/images.dart'; +import 'package:hgdj/hj_utils/api_service/common_service.dart'; import 'package:hgdj/hj_utils/screen.dart'; import 'package:hgdj/routers/jump_router.dart'; @@ -52,6 +53,7 @@ class TiktokSimpleCell extends StatelessWidget { void _onTap() { if (videoModel?.isRandomAd() == true) { pushToPageByLink(videoModel?.randomAdsInfo?.href); + CommonService.adsClick(videoModel?.randomAdsInfo?.id); return; } pushToVideoPage(videoModel: videoModel); diff --git a/lib/hj_page/home/home_cell_style/video_hor_cell.dart b/lib/hj_page/home/home_cell_style/video_hor_cell.dart index 6d98f65..be8c1f7 100644 --- a/lib/hj_page/home/home_cell_style/video_hor_cell.dart +++ b/lib/hj_page/home/home_cell_style/video_hor_cell.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:hgdj/hj_utils/api_service/common_service.dart'; import 'package:hgdj/hj_utils/screen.dart'; import '../../../hj_model/video_model.dart'; @@ -77,6 +78,7 @@ class VideoHorCell extends StatelessWidget { void _onTap() { if (videoModel?.isRandomAd() == true) { pushToPageByLink(videoModel?.randomAdsInfo?.href); + CommonService.adsClick(videoModel?.randomAdsInfo?.id); return; } pushToVideoPage(videoModel: videoModel); diff --git a/lib/hj_page/home/home_cell_style/video_simple_cell.dart b/lib/hj_page/home/home_cell_style/video_simple_cell.dart index 6db4d8d..9947b8d 100644 --- a/lib/hj_page/home/home_cell_style/video_simple_cell.dart +++ b/lib/hj_page/home/home_cell_style/video_simple_cell.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:hgdj/assets_tool/images.dart'; import 'package:hgdj/config/config.dart'; import 'package:hgdj/extension/extensions.dart'; +import 'package:hgdj/hj_utils/api_service/common_service.dart'; import 'package:hgdj/hj_utils/screen.dart'; import 'package:hgdj/routers/jump_router.dart'; import 'package:hgdj/tools_base/banner/ads_item.dart'; @@ -69,6 +70,7 @@ class VideoSimpleCell extends StatelessWidget { void _onTap() { if (videoModel?.isRandomAd() == true) { pushToPageByLink(videoModel?.randomAdsInfo?.href); + CommonService.adsClick(videoModel?.randomAdsInfo?.id); return; } if (_needVipUnlock) { @@ -306,6 +308,7 @@ class _VideoSimpleAdsCellState extends State { void _onAdTap() { final ad = adsInfoArr![adIndex]; pushToPageByLink(ad.href); + CommonService.adsClick(ad.id); } @override diff --git a/lib/hj_page/mine/welfare/widget/recommend_app_page.dart b/lib/hj_page/mine/welfare/widget/recommend_app_page.dart index 89828e3..21200e9 100644 --- a/lib/hj_page/mine/welfare/widget/recommend_app_page.dart +++ b/lib/hj_page/mine/welfare/widget/recommend_app_page.dart @@ -102,7 +102,6 @@ class RecommendAppPage extends StatelessWidget { _buildVItem(AdsInfoModel item, int index) { return AdsItem( adInfo: item, - clickType: 0, ); } @@ -114,7 +113,6 @@ class RecommendAppPage extends StatelessWidget { AdsItem( adInfo: item, showType: AdShowType.hor, - clickType: 0, ), 12.sizeBoxH, ], @@ -125,7 +123,6 @@ class RecommendAppPage extends StatelessWidget { return AdsItem( adInfo: item, showType: AdShowType.vImgText, - clickType: 0, ); } } diff --git a/lib/hj_page/short_video/view/feed_ad_view.dart b/lib/hj_page/short_video/view/feed_ad_view.dart index ba1b851..71a3222 100644 --- a/lib/hj_page/short_video/view/feed_ad_view.dart +++ b/lib/hj_page/short_video/view/feed_ad_view.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:hgdj/hj_model/video_model.dart'; +import 'package:hgdj/hj_utils/api_service/common_service.dart'; import 'package:hgdj/routers/jump_router.dart'; import '../../../hj_model/splash/ads_model.dart'; @@ -14,7 +15,10 @@ class FeedAdView extends StatelessWidget { Widget build(BuildContext context) { final AdsInfoModel? adv = mediaInfo?.randomAdsInfo; return GestureDetector( - onTap: () => pushToPageByLink(adv?.href), + onTap: () { + pushToPageByLink(adv?.href); + CommonService.adsClick(adv?.id); + }, // 强制全屏铺满(与视频页一致),避免 iOS 上未撑满导致显示不全 child: SizedBox.expand( child: NetworkImageLoader( diff --git a/lib/hj_page/short_video/view/float_ad_view.dart b/lib/hj_page/short_video/view/float_ad_view.dart index 557ab98..b2ec634 100644 --- a/lib/hj_page/short_video/view/float_ad_view.dart +++ b/lib/hj_page/short_video/view/float_ad_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:hgdj/hj_model/splash/ads_model.dart'; +import 'package:hgdj/hj_utils/api_service/common_service.dart'; import 'package:hgdj/routers/jump_router.dart'; import 'package:hgdj/tools_base/ad_manager.dart'; import 'package:hgdj/tools_base/widget/net_image_widget.dart'; @@ -35,7 +36,10 @@ class _FloatAdViewState extends State { clipBehavior: Clip.none, children: [ GestureDetector( - onTap: () => pushToPageByLink(ad.href), + onTap: () { + pushToPageByLink(ad.href); + CommonService.adsClick(ad.id); + }, child: NetworkImageLoader( imageUrl: cover, width: 70, diff --git a/lib/hj_page/splash/splash_ad_view.dart b/lib/hj_page/splash/splash_ad_view.dart index c15e637..78d2c21 100644 --- a/lib/hj_page/splash/splash_ad_view.dart +++ b/lib/hj_page/splash/splash_ad_view.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:hgdj/assets_tool/app_colors.dart'; import 'package:hgdj/assets_tool/images.dart'; +import 'package:hgdj/hj_utils/api_service/common_service.dart'; import 'package:hgdj/hj_utils/screen.dart'; import '../../hj_model/splash/ads_model.dart'; @@ -72,7 +73,10 @@ class _SplashAdViewState extends State { if (dataLen == 1) { final ad = widget.adData!.first; return GestureDetector( - onTap: () => pushToPageByLink(ad.href ?? ""), + onTap: () { + pushToPageByLink(ad.href ?? ""); + CommonService.adsClick(ad.id); + }, child: Container( alignment: Alignment.center, child: NetworkImageLoader( diff --git a/lib/hj_utils/api_service/common_service.dart b/lib/hj_utils/api_service/common_service.dart index 08c04e2..bdb3a88 100644 --- a/lib/hj_utils/api_service/common_service.dart +++ b/lib/hj_utils/api_service/common_service.dart @@ -225,11 +225,12 @@ class CommonService { return result.isSuccess ? result.data : null; } - //广告点击统计 广告类型 0:应用 1:广告 - static Future adsClick(int? type) async { + /// 广告点击日志:[id] 广告 id(后端必填,空就不报);type 固定传 0(普通广告) + static Future adsClick(String? id) async { + if (id == null || id.isEmpty) return false; final result = await httpManager.fetchResponseByPOST( - '/ads/click/stat', - param: {'type': type}, + '/ads/click', + param: {'id': id, 'type': 0}, ); return result.isSuccess; } diff --git a/lib/tools_base/banner/ads_item.dart b/lib/tools_base/banner/ads_item.dart index 3f0883c..abb26da 100644 --- a/lib/tools_base/banner/ads_item.dart +++ b/lib/tools_base/banner/ads_item.dart @@ -22,7 +22,6 @@ class AdsItem extends StatefulWidget { final double? aspectRatio; final AdShowType? showType; final double borderRadius; - final int clickType; //0:应用 1:广告 final Widget? child; //自定义子视图(IM 广告用) final VoidCallback? onTap; //点击附加回调(IM 广告已读上报用) @@ -32,7 +31,6 @@ class AdsItem extends StatefulWidget { this.aspectRatio, this.showType, this.borderRadius = 12, - this.clickType = 1, this.child, this.onTap, }); @@ -46,7 +44,7 @@ class _AdsItemState extends State { void _onTap() { pushToPageByLink(adInfo.href); - CommonService.adsClick(widget.clickType); + CommonService.adsClick(adInfo.id); widget.onTap?.call(); }