删除埋点,im和客服
This commit is contained in:
@@ -5,7 +5,6 @@ import 'package:jydj/tools_base/widget/image_browser_page.dart';
|
||||
import 'package:jydj/tools_base/widget/net_image_widget.dart';
|
||||
|
||||
import '../../hj_model/splash/ads_model.dart';
|
||||
import '../../track_event_manager/track_manager.dart';
|
||||
import 'ads_item.dart';
|
||||
|
||||
/// 广告轮播的指示器位置
|
||||
@@ -31,8 +30,6 @@ class AdsBanner extends StatefulWidget {
|
||||
final Color? color; //未选中色,不传按位置/样式取默认
|
||||
final Color? selectColor; //选中色,不传按位置/样式取默认
|
||||
|
||||
final AdExposureModel? exposureModel; //曝光埋点模型
|
||||
|
||||
const AdsBanner(
|
||||
this.models, {
|
||||
super.key,
|
||||
@@ -46,7 +43,6 @@ class AdsBanner extends StatefulWidget {
|
||||
this.indicatorStyle = IndicatorStyle.bar,
|
||||
this.color,
|
||||
this.selectColor,
|
||||
this.exposureModel,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -59,13 +55,6 @@ class _AdsBannerState extends State<AdsBanner> {
|
||||
|
||||
int get _count => widget.models?.length ?? 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
//adType 兜底设一次(不放 itemBuilder 里,避免每次构建都 mutate)
|
||||
widget.exposureModel?.adType ??= AdType.bigBanner;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_index.dispose();
|
||||
@@ -134,7 +123,6 @@ class _AdsBannerState extends State<AdsBanner> {
|
||||
adInfo: widget.models![index],
|
||||
showType: AdShowType.img,
|
||||
borderRadius: widget.borderRadius,
|
||||
exposureModel: widget.exposureModel,
|
||||
),
|
||||
onTap: widget.onTap,
|
||||
onIndexChanged: (index) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'package:jydj/hj_utils/screen.dart';
|
||||
import 'package:jydj/tools_base/ad_manager.dart';
|
||||
|
||||
import '../../hj_model/splash/ads_model.dart';
|
||||
import '../../track_event_manager/track_manager.dart';
|
||||
import 'ads_banner.dart';
|
||||
import 'ads_item.dart';
|
||||
|
||||
@@ -24,7 +23,6 @@ class AdsGridView extends StatelessWidget {
|
||||
final List<AdsInfoModel>? ads; //外部直接传入的广告,优先于 position
|
||||
final bool autoStyle; //true:按第一个广告的 coverImgSize 选样式;false:固定两排九宫格
|
||||
final EdgeInsetsGeometry? padding;
|
||||
final AdExposureModel? exposureModel; //曝光埋点模型
|
||||
|
||||
const AdsGridView(
|
||||
this.position, {
|
||||
@@ -32,7 +30,6 @@ class AdsGridView extends StatelessWidget {
|
||||
this.ads,
|
||||
this.autoStyle = false,
|
||||
this.padding,
|
||||
this.exposureModel,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -50,14 +47,9 @@ class AdsGridView extends StatelessWidget {
|
||||
};
|
||||
}
|
||||
|
||||
//统一构造广告项;每个 item 用独立的曝光模型副本,避免共享同一实例导致曝光 adType 被覆盖串号
|
||||
//统一构造广告项
|
||||
Widget _item(AdsInfoModel model, {double? aspectRatio}) {
|
||||
final em = exposureModel;
|
||||
return AdsItem(
|
||||
adInfo: model,
|
||||
aspectRatio: aspectRatio,
|
||||
exposureModel: em == null ? null : AdExposureModel(pageType: em.pageType, adType: model.adType, tabIndex: em.tabIndex),
|
||||
);
|
||||
return AdsItem(adInfo: model, aspectRatio: aspectRatio);
|
||||
}
|
||||
|
||||
//两排共 10 个
|
||||
@@ -89,7 +81,6 @@ class AdsGridView extends StatelessWidget {
|
||||
child: AdsBanner(
|
||||
list.length > 20 ? list.take(20).toList() : list,
|
||||
autoPlayMs: 2000,
|
||||
exposureModel: exposureModel,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -3,11 +3,9 @@ import 'package:get/get.dart';
|
||||
import 'package:jydj/assets_tool/images.dart';
|
||||
import 'package:jydj/hj_utils/api_service/common_service.dart';
|
||||
import 'package:jydj/hj_utils/screen.dart';
|
||||
import 'package:visibility_detector/visibility_detector.dart';
|
||||
|
||||
import '../../hj_model/splash/ads_model.dart';
|
||||
import '../../routers/jump_router.dart';
|
||||
import '../../track_event_manager/track_manager.dart';
|
||||
import '../widget/net_image_widget.dart';
|
||||
|
||||
enum AdShowType {
|
||||
@@ -17,14 +15,12 @@ enum AdShowType {
|
||||
splash, //启动全屏图
|
||||
}
|
||||
|
||||
/// 广告项:按 [AdShowType] 出不同样式(不传是上图下标题的九宫格项);进入可视区上报曝光,点击按链接跳转并上报
|
||||
/// 广告项:按 [AdShowType] 出不同样式(不传是上图下标题的九宫格项);点击按链接跳转并上报
|
||||
class AdsItem extends StatefulWidget {
|
||||
final AdsInfoModel adInfo;
|
||||
final AdShowType? showType;
|
||||
final double? aspectRatio;
|
||||
final double borderRadius; //纯图样式的圆角
|
||||
final int clickType; //点击上报类型 0:应用 1:广告
|
||||
final AdExposureModel? exposureModel;
|
||||
final Widget? child; //自定义子视图(IM 广告用)
|
||||
final VoidCallback? onTap; //点击附加回调(IM 广告已读上报用)
|
||||
|
||||
@@ -34,8 +30,6 @@ class AdsItem extends StatefulWidget {
|
||||
this.showType,
|
||||
this.aspectRatio,
|
||||
this.borderRadius = 12,
|
||||
this.clickType = 1,
|
||||
this.exposureModel,
|
||||
this.child,
|
||||
this.onTap,
|
||||
});
|
||||
@@ -44,57 +38,28 @@ class AdsItem extends StatefulWidget {
|
||||
State<AdsItem> createState() => _AdsItemState();
|
||||
}
|
||||
|
||||
class _AdsItemState extends State<AdsItem> with AdExposureMixin {
|
||||
class _AdsItemState extends State<AdsItem> {
|
||||
AdsInfoModel get adInfo => widget.adInfo;
|
||||
|
||||
AdExposureModel? get exposureModel => widget.exposureModel;
|
||||
|
||||
//⚠️ 曝光去重 key 必须稳定
|
||||
Key get _visibilityKey => ValueKey(
|
||||
'ad_${adInfo.id ?? adInfo.href ?? ''}_${exposureModel?.pageType?.name ?? ''}_${exposureModel?.tabIndex}',
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return VisibilityDetector(
|
||||
key: _visibilityKey,
|
||||
onVisibilityChanged: (info) {
|
||||
if (info.visibleFraction > 0.1) _expose();
|
||||
},
|
||||
child: InkWell(
|
||||
enableFeedback: false,
|
||||
onTap: _onTap,
|
||||
child: widget.child ??
|
||||
switch (widget.showType) {
|
||||
AdShowType.img => _image(),
|
||||
AdShowType.hor => _hor(),
|
||||
AdShowType.vImgText => _imageText(),
|
||||
AdShowType.splash => _splash(),
|
||||
null => _normal(),
|
||||
},
|
||||
),
|
||||
return InkWell(
|
||||
enableFeedback: false,
|
||||
onTap: _onTap,
|
||||
child: widget.child ??
|
||||
switch (widget.showType) {
|
||||
AdShowType.img => _image(),
|
||||
AdShowType.hor => _hor(),
|
||||
AdShowType.vImgText => _imageText(),
|
||||
AdShowType.splash => _splash(),
|
||||
null => _normal(),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
//进入可视区上报曝光
|
||||
void _expose() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted || exposureModel?.pageType == null) return;
|
||||
adExposure(adInfo: adInfo, exposureModel: exposureModel);
|
||||
});
|
||||
}
|
||||
|
||||
void _onTap() {
|
||||
pushToPageByLink(
|
||||
adInfo.href,
|
||||
id: adInfo.id,
|
||||
arguments: {
|
||||
'pageType': exposureModel?.pageType ?? TrackEventPageType.acgHome,
|
||||
'adInfo': adInfo,
|
||||
'payload': {'ad_type': exposureModel?.adType?.value ?? ''},
|
||||
},
|
||||
);
|
||||
CommonService.adsClick(widget.clickType);
|
||||
pushToPageByLink(adInfo.href);
|
||||
CommonService.adsClick(adInfo.id);
|
||||
widget.onTap?.call();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user