删除埋点,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();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,9 @@ class ItemPosition {
|
||||
final double itemTrailingEdge;
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
bool operator ==(Object other) {
|
||||
if (other.runtimeType != runtimeType) return false;
|
||||
final ItemPosition otherPosition = other;
|
||||
final otherPosition = other as ItemPosition;
|
||||
return otherPosition.index == index &&
|
||||
otherPosition.itemLeadingEdge == itemLeadingEdge &&
|
||||
otherPosition.itemTrailingEdge == itemTrailingEdge;
|
||||
|
||||
@@ -44,9 +44,7 @@ class PositionedList extends StatefulWidget {
|
||||
this.addSemanticIndexes = true,
|
||||
this.addRepaintBoundaries = true,
|
||||
this.addAutomaticKeepAlives = true,
|
||||
}) : assert(itemCount != null),
|
||||
assert(itemBuilder != null),
|
||||
assert((positionedIndex == 0) || (positionedIndex < itemCount)),
|
||||
}) : assert((positionedIndex == 0) || (positionedIndex < itemCount)),
|
||||
super(key: key);
|
||||
|
||||
/// Number of items the [itemBuilder] can produce.
|
||||
@@ -89,7 +87,6 @@ class PositionedList extends StatefulWidget {
|
||||
/// See [ScrollView.reverse].
|
||||
final bool reverse;
|
||||
|
||||
/// {@template flutter.widgets.scroll_view.shrinkWrap}
|
||||
/// Whether the extent of the scroll view in the [scrollDirection] should be
|
||||
/// determined by the contents being viewed.
|
||||
///
|
||||
|
||||
@@ -60,9 +60,7 @@ class ScrollablePositionedList extends StatefulWidget {
|
||||
this.addRepaintBoundaries = true,
|
||||
this.minCacheExtent,
|
||||
this.scrollAction,
|
||||
}) : assert(itemCount != null),
|
||||
assert(itemBuilder != null),
|
||||
itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?,
|
||||
}) : itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?,
|
||||
scrollOffsetNotifier = scrollOffsetListener as ScrollOffsetNotifier?,
|
||||
separatorBuilder = null,
|
||||
super(key: key);
|
||||
@@ -91,9 +89,7 @@ class ScrollablePositionedList extends StatefulWidget {
|
||||
this.addRepaintBoundaries = true,
|
||||
this.minCacheExtent,
|
||||
this.scrollAction,
|
||||
}) : assert(itemCount != null),
|
||||
assert(itemBuilder != null),
|
||||
assert(separatorBuilder != null),
|
||||
}) : assert(separatorBuilder != null),
|
||||
itemPositionsNotifier = itemPositionsListener as ItemPositionsNotifier?,
|
||||
scrollOffsetNotifier = scrollOffsetListener as ScrollOffsetNotifier?,
|
||||
super(key: key);
|
||||
@@ -141,7 +137,6 @@ class ScrollablePositionedList extends StatefulWidget {
|
||||
/// See [ScrollView.reverse].
|
||||
final bool reverse;
|
||||
|
||||
/// {@template flutter.widgets.scroll_view.shrinkWrap}
|
||||
/// Whether the extent of the scroll view in the [scrollDirection] should be
|
||||
/// determined by the contents being viewed.
|
||||
///
|
||||
|
||||
@@ -100,7 +100,6 @@ class UnboundedRenderViewport extends RenderViewport {
|
||||
|
||||
@override
|
||||
set anchor(double value) {
|
||||
assert(value != null);
|
||||
if (value == _anchor) return;
|
||||
_anchor = value;
|
||||
markNeedsLayout();
|
||||
@@ -124,7 +123,6 @@ class UnboundedRenderViewport extends RenderViewport {
|
||||
|
||||
@override
|
||||
Rect describeSemanticsClip(RenderSliver? child) {
|
||||
assert(axis != null);
|
||||
|
||||
if (_calculatedCacheExtent == null) {
|
||||
return semanticBounds;
|
||||
@@ -178,7 +176,6 @@ class UnboundedRenderViewport extends RenderViewport {
|
||||
double correction;
|
||||
var count = 0;
|
||||
do {
|
||||
assert(offset.pixels != null);
|
||||
correction = _attemptLayout(mainAxisExtent, crossAxisExtent,
|
||||
offset.pixels + centerOffsetAdjustment);
|
||||
if (correction != 0.0) {
|
||||
|
||||
@@ -419,14 +419,10 @@ abstract class CustomViewport extends MultiChildRenderObjectWidget {
|
||||
this.cacheExtentStyle = CacheExtentStyle.pixel,
|
||||
this.clipBehavior = Clip.hardEdge,
|
||||
List<Widget> slivers = const <Widget>[],
|
||||
}) : assert(offset != null),
|
||||
assert(slivers != null),
|
||||
assert(center == null ||
|
||||
}) : assert(center == null ||
|
||||
slivers.where((Widget child) => child.key == center).length == 1),
|
||||
assert(cacheExtentStyle != null),
|
||||
assert(cacheExtentStyle != CacheExtentStyle.viewport ||
|
||||
cacheExtent != null),
|
||||
assert(clipBehavior != null),
|
||||
super(key: key, children: slivers);
|
||||
|
||||
/// The direction in which the [offset]'s [ViewportOffset.pixels] increases.
|
||||
@@ -497,7 +493,6 @@ abstract class CustomViewport extends MultiChildRenderObjectWidget {
|
||||
/// otherwise, the default cross axis direction is downwards.
|
||||
static AxisDirection getDefaultCrossAxisDirection(
|
||||
BuildContext context, AxisDirection axisDirection) {
|
||||
assert(axisDirection != null);
|
||||
switch (axisDirection) {
|
||||
case AxisDirection.up:
|
||||
assert(debugCheckHasDirectionality(
|
||||
@@ -662,11 +657,9 @@ abstract class CustomRenderViewport
|
||||
double? cacheExtent,
|
||||
CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel,
|
||||
Clip clipBehavior = Clip.hardEdge,
|
||||
}) : assert(anchor != null),
|
||||
assert(anchor >= 0.0 && anchor <= 1.0),
|
||||
}) : assert(anchor >= 0.0 && anchor <= 1.0),
|
||||
assert(cacheExtentStyle != CacheExtentStyle.viewport ||
|
||||
cacheExtent != null),
|
||||
assert(clipBehavior != null),
|
||||
_center = center,
|
||||
super(
|
||||
axisDirection: axisDirection,
|
||||
|
||||
Reference in New Issue
Block a user