// 统计Ross 用户 import Vue from 'vue' import { includeList } from '@/utils/router.config.js' // 配置信息 // 参数 const defaultParams = { accessClient: 1, // 来源 0 网站 1 小程序 pagePath: '', //页面路径 accessDuration: 0, //浏览时长初始值为 0 pageType: '', //页面类型 pageLabel: '', //页面标签 userId: 0, //用户Id productId: 0, //商品Id behaviorType: 1 // 统计类型 } const cmSrsMixins = { data() { return { handleProsId: 0, handleShopId: 0, handleProsKey: '', handleShopKey: '', productIdList: [7247, 7248], //Ross 商品ID集合 shopIds: [1378], // Ross 供应商Id keyWords: ['Binary Premium', '智能体疗管理系统', '448k', '肌肉重塑疗法', '西班牙ROSS', 'ROSS', '智能体疗', '西班牙Ross', 'Ross', '西班牙ross', 'ross', ], // Ross 搜索商品关键词 集合 shopKeyWords: ['深圳艾斯佰丽生物科技有限公司', '艾斯佰丽'], showRossHtml: false, isDisabled: true } }, methods: { checkedIsRossSet() { if (this.productIdList.includes(this.handleProsId * 1) || this.shopIds.includes(this.handleShopId * 1) || this.keyWords.includes(this.handleProsKey) || this.shopKeyWords.includes(this.handleShopKey) ) { uni.setStorageSync('behaviorType', 2) this.setingSysParams() if (!this.hasLogin) { this.userInformationIsClick() } }else{ this.setingSysParams() } }, // 接口参数设置 async setingSysParams(){ const sysParams = Object.assign({}, defaultParams) const userSync = uni.getStorageSync('userInfo') const pagePath = this.getPath() const pageData = this.isIncludeType(pagePath) // 协销不记录 if (userSync.userIdentity === 1) return // 参数设置 sysParams.userId = userSync.userId ? userSync.userId : 0 sysParams.pagePath = pagePath sysParams.pageType = pageData ? pageData.pageType : '' sysParams.behaviorType = uni.getStorageSync('behaviorType') ? uni.getStorageSync('behaviorType') : 1 // 根据path获取不同的参数 sysParams.pageLabel = uni.getStorageSync('pageLabel') ? uni.getStorageSync('pageLabel') : pageData.pageLabel console.log('记录路径:', sysParams.pagePath, '标签:', sysParams.pageLabel) // 统计接口调用 this.userRecordStatistics(sysParams) console.log('---用户行为轨迹记录成功---') }, userRecordStatistics(params){ // 上送 this.UserService.userRecordStatistics(params) .then(response => { console.log('---用户行为轨迹记录成功---') uni.removeStorageSync('pageLabel') uni.removeStorageSync('behaviorType') }) .catch(error => { console.log('---用户行为轨迹记录失败---') }) }, userInformationIsClick() { // 查看用户是否有过弹框游客当天是否有过弹框 this.UserService.userInformationIsClick() .then(response => { if (response.data) { setTimeout(() => { this.showRossHtml = true }, 5000) } }) .catch(error => { console.log('查询失败~') }) }, isIncludeType(url){ // 校验返回页面类型 if (!url) return false return includeList.find(item => url === item.url) }, getPath(){ // 获取路径 const pages = getCurrentPages() const len = pages.length const page = pages[len - 1] return '/' + page.route } } } export default cmSrsMixins