删除埋点,im和客服
This commit is contained in:
@@ -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