123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- // 统计数据
- // 统计类型 1:首页banner;2:直播模块;3:最新活动;4:热门文章;5:新品橱窗;6:活动列表
- var cmSysVitaMixins = function () {
- return {
- data() {
- return {
- cmSysParams:{
- accessClient: 0,// 来源 0网站 1小程序
- pagePath:'',//页面路径
- accessDuration:0,//停留时间
- pageType:'',//页面类型
- pageLabel:'',//页面标签
- userId:0,//用户Id
- productId:0,//商品Id
- shopId:0,//供应商Id
- behaviorType:1, // 用户行为类型
- headUserId: '', // 内容库协销ID
- productArchiveId: '', // 内容库文件id
- },
- handleProsId:'',
- handleShopId:'',
- handlearticleId:'',
- handleProsKey:'',
- handleShopKey:'',
- consultParams:{
- ip:'',
- shopProductId:'',
- createTime:'',
- consultMobile: '',
- consultName: '',
- isClick:1
- },
- popUpParams:{
- shopId:'',
- productId:'',
- infoId:'',
- keyword:''
- },
- advertisement:{},// 弹窗广告信息
- showRossHtml:false,
- isDisabled:true,
- shopAdvert:[]
- }
- },
- methods: {
- // 校验返回页面类型
- checkedIsIncludeType(url){
- if (!url) return false
- return includeList.find(item => url === item.url)
- },
- // 校验是否为配置的路径
- checkedIsInclude(url) {
- if (!url) return false
- return includeList.some(item => url === item.url)
- },
- handleCmSysNetInfo() {
- //设置定时器
- const globalUserData = JSON.parse(localStorage.getItem('userInfo'));
- const databaseShareData = JSON.parse(sessionStorage.getItem('saveParams'))
- console.log('handleProsKey',this.handleProsKey)
- if(globalUserData){ this.cmSysParams.userId = globalUserData.userId * 1; }
- if( this.handleProsId || this.handleShopId || this.handlearticleId || this.handleProsKey || this.handleShopKey ){
- this.popUpParams.shopId = this.handleShopId
- this.popUpParams.productId = this.handleProsId
- this.popUpParams.infoId = this.handlearticleId
- this.popUpParams.keyword = this.handleProsKey ? this.handleProsKey : '' || this.handleShopKey ? this.handleShopKey : ''
- this.cmSysParams.behaviorType = 2;
- if (!GLOBAL_USER_ID>0) {
- this.userInformationIsClick()
- }
- }
- const pageUrls = window.location.pathname;
- const pagePath = window.location.href;
- if(this.checkedIsInclude(pageUrls)){
- const pageData = this.checkedIsIncludeType(pageUrls);
- this.cmSysParams.pageType = pageData ? pageData.pageType : '';
- this.cmSysParams.pageLabel = pageData ? pageData.pageLabel : '';
- }
- this.cmSysParams.pagePath = pagePath;
- this.cmSysParams.headUserId = databaseShareData?.suid || ''
- this.cmSysParams.productArchiveId = databaseShareData?.id || ''
- console.log(this.cmSysParams)
- setTimeout(()=>{
- this.handleSetNetworks(this.cmSysParams);
- },2000)
- },
- handleSetNetworks(params){// 进入页面执行统计
- console.log(`页面路径:${params.pagePath}`,`标签:${params.pageLabel}`)
- PublicApi.userRecordStatisticsApp(params,function(response){
- if(response.code === 0){
- console.log('上送浏览记录统计成功~')
- }else{
- console.log('上送浏览记录统计失败~')
- }
- });
- },
- handleInputName(e){
- this.consultParams.consultName = e.target.value;
- this.handldeCheckInput();
- },
- handleInputPhone(e){
- this.consultParams.consultMobile = e.target.value;
- this.handldeCheckInput();
- },
- handldeCheckInput(){
- this.isDisabled = !(this.consultParams.consultName !== "" && this.consultParams.consultMobile !== "");
- },
- handleSubmit(){
- // 提交联系人信息
- if(this.isDisabled){ return }
- let reg = RegExp(/^1\d{10}$/);
- if(!reg.test(this.consultParams.consultMobile)){
- CAIMEI.dialog('请输入正确的手机号');
- return
- }
- this.userInformationInsertRoos(this.consultParams);
- },
- handleClose(){
- // 关闭Ross 广告弹窗
- this.userInformationInsertRoos(this.consultParams);
- },
- getUserPopUpInfo(params){
- //查看供应商广告弹框信息
- let _self = this;
- PublicApi.getUserPopUpInfo(params, function (response) {
- if(response.code === 0){
- _self.advertisement = response.data
- _self.consultParams.shopProductId = response.data.shopProductId
- }else{
- console.log('error',response.msg);
- }
- })
- },
- userInformationIsClick(){
- //查询是否需要弹广告
- let _self = this;
- PublicApi.userInformationIsClick(_self.popUpParams, function (response) {
- if(response.code === 0){
- if(response.data){
- setTimeout(()=>{
- _self.showRossHtml = true
- _self.getUserPopUpInfo(_self.popUpParams)
- },5000)
- }
- }else{
- console.log('error',response.msg);
- }
- })
- },
- userInformationInsertRoos(params){
- //提交记录咨询人&&关闭弹窗
- let _self = this;
- PublicApi.userInformationInsertRoos(params, function (response) {
- if(response.code === 0){
- _self.showRossHtml = false
- }else{
- console.log('error',response.msg);
- }
- })
- },
- getShopAdvert(params){
- //查看访问者是否浏览过roos相关页面
- let _self = this;
- PublicApi.getShopAdvert(params, function (response) {
- if(response.code === 0){
- _self.shopAdvert = response.data
- console.log('shopAdvert',_self.shopAdvert);
- }else{
- console.log('error',response.msg);
- }
- })
- },
- userRecordStatistics() {// navigator.sendBeacon 方式 暂时废弃
- const NODE_ENV_BASE_URL = $("#coreServer").val();
- const url = `${NODE_ENV_BASE_URL}/user/record/StatisticsPc`;
- const blob = new Blob([JSON.stringify(this.cmSysParams)], {
- type: 'application/json; charset=UTF-8',
- });
- navigator.sendBeacon(url, blob);
- },
- handleWindow(type){ // 暂时废弃
- const isBrowser = isPC ? 1 : 0;
- const map = {
- 0: 'pagehide',
- 1: 'beforeunload',
- };
- const FunMap = {
- 0:window.addEventListener(map[isBrowser], e => this.beforeunloadHandler(e)), // 绑定
- 1:window.removeEventListener(map[isBrowser], e => this.beforeunloadHandler(e)) // 接触绑定
- }
- return FunMap[type];
- },
- },
- mounted() {
- // 页面加载完成后[监听]执行事件
- this.handleCmSysNetInfo()
- // 查看访问者是否浏览过roos相关页面
- this.getShopAdvert({ userId: this.cmSysParams.userId })
- },
- destroyed() {
- }
- }
- }();
|