广告点击添加
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hgdj/assets_tool/images.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/hj_utils/screen.dart';
|
||||||
import 'package:hgdj/routers/jump_router.dart';
|
import 'package:hgdj/routers/jump_router.dart';
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ class TiktokSimpleCell extends StatelessWidget {
|
|||||||
void _onTap() {
|
void _onTap() {
|
||||||
if (videoModel?.isRandomAd() == true) {
|
if (videoModel?.isRandomAd() == true) {
|
||||||
pushToPageByLink(videoModel?.randomAdsInfo?.href);
|
pushToPageByLink(videoModel?.randomAdsInfo?.href);
|
||||||
|
CommonService.adsClick(videoModel?.randomAdsInfo?.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pushToVideoPage(videoModel: videoModel);
|
pushToVideoPage(videoModel: videoModel);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:hgdj/hj_utils/api_service/common_service.dart';
|
||||||
import 'package:hgdj/hj_utils/screen.dart';
|
import 'package:hgdj/hj_utils/screen.dart';
|
||||||
|
|
||||||
import '../../../hj_model/video_model.dart';
|
import '../../../hj_model/video_model.dart';
|
||||||
@@ -77,6 +78,7 @@ class VideoHorCell extends StatelessWidget {
|
|||||||
void _onTap() {
|
void _onTap() {
|
||||||
if (videoModel?.isRandomAd() == true) {
|
if (videoModel?.isRandomAd() == true) {
|
||||||
pushToPageByLink(videoModel?.randomAdsInfo?.href);
|
pushToPageByLink(videoModel?.randomAdsInfo?.href);
|
||||||
|
CommonService.adsClick(videoModel?.randomAdsInfo?.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pushToVideoPage(videoModel: videoModel);
|
pushToVideoPage(videoModel: videoModel);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:hgdj/assets_tool/images.dart';
|
import 'package:hgdj/assets_tool/images.dart';
|
||||||
import 'package:hgdj/config/config.dart';
|
import 'package:hgdj/config/config.dart';
|
||||||
import 'package:hgdj/extension/extensions.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/hj_utils/screen.dart';
|
||||||
import 'package:hgdj/routers/jump_router.dart';
|
import 'package:hgdj/routers/jump_router.dart';
|
||||||
import 'package:hgdj/tools_base/banner/ads_item.dart';
|
import 'package:hgdj/tools_base/banner/ads_item.dart';
|
||||||
@@ -69,6 +70,7 @@ class VideoSimpleCell extends StatelessWidget {
|
|||||||
void _onTap() {
|
void _onTap() {
|
||||||
if (videoModel?.isRandomAd() == true) {
|
if (videoModel?.isRandomAd() == true) {
|
||||||
pushToPageByLink(videoModel?.randomAdsInfo?.href);
|
pushToPageByLink(videoModel?.randomAdsInfo?.href);
|
||||||
|
CommonService.adsClick(videoModel?.randomAdsInfo?.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_needVipUnlock) {
|
if (_needVipUnlock) {
|
||||||
@@ -306,6 +308,7 @@ class _VideoSimpleAdsCellState extends State<VideoSimpleAdsCell> {
|
|||||||
void _onAdTap() {
|
void _onAdTap() {
|
||||||
final ad = adsInfoArr![adIndex];
|
final ad = adsInfoArr![adIndex];
|
||||||
pushToPageByLink(ad.href);
|
pushToPageByLink(ad.href);
|
||||||
|
CommonService.adsClick(ad.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ class RecommendAppPage extends StatelessWidget {
|
|||||||
_buildVItem(AdsInfoModel item, int index) {
|
_buildVItem(AdsInfoModel item, int index) {
|
||||||
return AdsItem(
|
return AdsItem(
|
||||||
adInfo: item,
|
adInfo: item,
|
||||||
clickType: 0,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +113,6 @@ class RecommendAppPage extends StatelessWidget {
|
|||||||
AdsItem(
|
AdsItem(
|
||||||
adInfo: item,
|
adInfo: item,
|
||||||
showType: AdShowType.hor,
|
showType: AdShowType.hor,
|
||||||
clickType: 0,
|
|
||||||
),
|
),
|
||||||
12.sizeBoxH,
|
12.sizeBoxH,
|
||||||
],
|
],
|
||||||
@@ -125,7 +123,6 @@ class RecommendAppPage extends StatelessWidget {
|
|||||||
return AdsItem(
|
return AdsItem(
|
||||||
adInfo: item,
|
adInfo: item,
|
||||||
showType: AdShowType.vImgText,
|
showType: AdShowType.vImgText,
|
||||||
clickType: 0,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:hgdj/hj_model/video_model.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 'package:hgdj/routers/jump_router.dart';
|
||||||
|
|
||||||
import '../../../hj_model/splash/ads_model.dart';
|
import '../../../hj_model/splash/ads_model.dart';
|
||||||
@@ -14,7 +15,10 @@ class FeedAdView extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final AdsInfoModel? adv = mediaInfo?.randomAdsInfo;
|
final AdsInfoModel? adv = mediaInfo?.randomAdsInfo;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => pushToPageByLink(adv?.href),
|
onTap: () {
|
||||||
|
pushToPageByLink(adv?.href);
|
||||||
|
CommonService.adsClick(adv?.id);
|
||||||
|
},
|
||||||
// 强制全屏铺满(与视频页一致),避免 iOS 上未撑满导致显示不全
|
// 强制全屏铺满(与视频页一致),避免 iOS 上未撑满导致显示不全
|
||||||
child: SizedBox.expand(
|
child: SizedBox.expand(
|
||||||
child: NetworkImageLoader(
|
child: NetworkImageLoader(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hgdj/hj_model/splash/ads_model.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/routers/jump_router.dart';
|
||||||
import 'package:hgdj/tools_base/ad_manager.dart';
|
import 'package:hgdj/tools_base/ad_manager.dart';
|
||||||
import 'package:hgdj/tools_base/widget/net_image_widget.dart';
|
import 'package:hgdj/tools_base/widget/net_image_widget.dart';
|
||||||
@@ -35,7 +36,10 @@ class _FloatAdViewState extends State<FloatAdView> {
|
|||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
children: [
|
children: [
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () => pushToPageByLink(ad.href),
|
onTap: () {
|
||||||
|
pushToPageByLink(ad.href);
|
||||||
|
CommonService.adsClick(ad.id);
|
||||||
|
},
|
||||||
child: NetworkImageLoader(
|
child: NetworkImageLoader(
|
||||||
imageUrl: cover,
|
imageUrl: cover,
|
||||||
width: 70,
|
width: 70,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:hgdj/assets_tool/app_colors.dart';
|
import 'package:hgdj/assets_tool/app_colors.dart';
|
||||||
import 'package:hgdj/assets_tool/images.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/hj_utils/screen.dart';
|
||||||
|
|
||||||
import '../../hj_model/splash/ads_model.dart';
|
import '../../hj_model/splash/ads_model.dart';
|
||||||
@@ -72,7 +73,10 @@ class _SplashAdViewState extends State<SplashAdView> {
|
|||||||
if (dataLen == 1) {
|
if (dataLen == 1) {
|
||||||
final ad = widget.adData!.first;
|
final ad = widget.adData!.first;
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => pushToPageByLink(ad.href ?? ""),
|
onTap: () {
|
||||||
|
pushToPageByLink(ad.href ?? "");
|
||||||
|
CommonService.adsClick(ad.id);
|
||||||
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: NetworkImageLoader(
|
child: NetworkImageLoader(
|
||||||
|
|||||||
@@ -225,11 +225,12 @@ class CommonService {
|
|||||||
return result.isSuccess ? result.data : null;
|
return result.isSuccess ? result.data : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//广告点击统计 广告类型 0:应用 1:广告
|
/// 广告点击日志:[id] 广告 id(后端必填,空就不报);type 固定传 0(普通广告)
|
||||||
static Future<bool> adsClick(int? type) async {
|
static Future<bool> adsClick(String? id) async {
|
||||||
|
if (id == null || id.isEmpty) return false;
|
||||||
final result = await httpManager.fetchResponseByPOST(
|
final result = await httpManager.fetchResponseByPOST(
|
||||||
'/ads/click/stat',
|
'/ads/click',
|
||||||
param: {'type': type},
|
param: {'id': id, 'type': 0},
|
||||||
);
|
);
|
||||||
return result.isSuccess;
|
return result.isSuccess;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class AdsItem extends StatefulWidget {
|
|||||||
final double? aspectRatio;
|
final double? aspectRatio;
|
||||||
final AdShowType? showType;
|
final AdShowType? showType;
|
||||||
final double borderRadius;
|
final double borderRadius;
|
||||||
final int clickType; //0:应用 1:广告
|
|
||||||
final Widget? child; //自定义子视图(IM 广告用)
|
final Widget? child; //自定义子视图(IM 广告用)
|
||||||
final VoidCallback? onTap; //点击附加回调(IM 广告已读上报用)
|
final VoidCallback? onTap; //点击附加回调(IM 广告已读上报用)
|
||||||
|
|
||||||
@@ -32,7 +31,6 @@ class AdsItem extends StatefulWidget {
|
|||||||
this.aspectRatio,
|
this.aspectRatio,
|
||||||
this.showType,
|
this.showType,
|
||||||
this.borderRadius = 12,
|
this.borderRadius = 12,
|
||||||
this.clickType = 1,
|
|
||||||
this.child,
|
this.child,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
});
|
});
|
||||||
@@ -46,7 +44,7 @@ class _AdsItemState extends State<AdsItem> {
|
|||||||
|
|
||||||
void _onTap() {
|
void _onTap() {
|
||||||
pushToPageByLink(adInfo.href);
|
pushToPageByLink(adInfo.href);
|
||||||
CommonService.adsClick(widget.clickType);
|
CommonService.adsClick(adInfo.id);
|
||||||
widget.onTap?.call();
|
widget.onTap?.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user