cmSysMixins.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. // 统计数据
  2. // 统计类型 1:首页banner;2:直播模块;3:最新活动;4:热门文章;5:新品橱窗;6:活动列表
  3. var cmSysVitaMixins = function () {
  4. return {
  5. data() {
  6. return {
  7. cmSysParams:{
  8. accessClient: 0,// 来源 0网站 1小程序
  9. pagePath:'',//页面路径
  10. accessDuration:0,//停留时间
  11. pageType:'',//页面类型
  12. pageLabel:'',//页面标签
  13. userId:0,//用户Id
  14. productId:0,//商品Id
  15. behaviorType:1 // 用户行为类型
  16. },
  17. handleProsId:0,
  18. handleShopId:0,
  19. handlearticleId:0,
  20. handleProsKey:"",
  21. handleShopKey:"",
  22. productIds:[7247,7248],//Ross 商品ID集合
  23. shopIds:[1378],// Ross 供应商Id
  24. articleIds:[7184,7199,7531,7497,7471,7458,7440,7424,7398,7370,7356,7344,7300,7298,7232,6674],//Ross 相关文章ID 集合
  25. keyWords:['Binary Premium','智能体疗管理系统','448k','肌肉重塑疗法','西班牙ROSS','ROSS','智能体疗','西班牙Ross','Ross','西班牙ross','ross',],// Ross 搜索商品关键词 集合
  26. shopKeyWords:['深圳艾斯佰丽生物科技有限公司','艾斯佰丽'],
  27. showRossHtml:false,
  28. consultParams:{
  29. ip:'',
  30. createTime:'',
  31. consultMobile: '',
  32. consultName: '',
  33. isClick:1
  34. },
  35. isDisabled:true,
  36. isRossShow:false
  37. }
  38. },
  39. methods: {
  40. // 校验返回页面类型
  41. checkedIsIncludeType(url){
  42. if (!url) return false
  43. return includeList.find(item => url === item.url)
  44. },
  45. // 校验是否为配置的路径
  46. checkedIsInclude(url) {
  47. if (!url) return false
  48. return includeList.some(item => url === item.url)
  49. },
  50. handleCmSysNetInfo() {
  51. //设置定时器
  52. const globalUserData = JSON.parse(localStorage.getItem('userInfo'));
  53. if(globalUserData){ this.cmSysParams.userId = globalUserData.userId * 1; }
  54. if( this.productIds.includes(this.handleProsId*1) ||
  55. this.shopIds.includes(this.handleShopId*1) ||
  56. this.articleIds.includes(this.handlearticleId*1) ||
  57. this.keyWords.includes(this.handleProsKey) ||
  58. this.shopKeyWords.includes(this.handleShopKey)
  59. ){
  60. this.cmSysParams.behaviorType = 2;
  61. if (!GLOBAL_USER_ID>0) {
  62. this.userInformationIsClick()
  63. }
  64. }
  65. const pageUrls = window.location.pathname;
  66. const pagePath = window.location.href;
  67. if(this.checkedIsInclude(pageUrls)){
  68. const pageData = this.checkedIsIncludeType(pageUrls);
  69. this.cmSysParams.pageType = pageData ? pageData.pageType : '';
  70. this.cmSysParams.pageLabel = pageData ? pageData.pageLabel : '';
  71. }
  72. this.cmSysParams.pagePath = pagePath;
  73. setTimeout(()=>{
  74. this.handleSetNetworks(this.cmSysParams);
  75. },2000)
  76. },
  77. handleSetNetworks(params){// 进入页面执行统计
  78. console.log(`页面路径:${params.pagePath}`,`标签:${params.pageLabel}`)
  79. PublicApi.userRecordStatisticsApp(params,function(response){
  80. if(response.code === 0){
  81. console.log('上送浏览记录统计成功~')
  82. }else{
  83. console.log('上送浏览记录统计失败~')
  84. }
  85. });
  86. },
  87. handleInputName(e){
  88. this.consultParams.consultName = e.target.value;
  89. this.handldeCheckInput();
  90. },
  91. handleInputPhone(e){
  92. this.consultParams.consultMobile = e.target.value;
  93. this.handldeCheckInput();
  94. },
  95. handldeCheckInput(){
  96. this.isDisabled = !(this.consultParams.consultName !== "" && this.consultParams.consultMobile !== "");
  97. },
  98. handleSubmit(){
  99. // 提交联系人信息
  100. if(this.isDisabled){ return }
  101. let reg = RegExp(/^1\d{10}$/);
  102. if(!reg.test(this.consultParams.consultMobile)){
  103. CAIMEI.dialog('请输入正确的手机号');
  104. return
  105. }
  106. this.userInformationInsertRoos(this.consultParams);
  107. },
  108. handleClose(){
  109. // 关闭Ross 广告弹窗
  110. this.userInformationInsertRoos(this.consultParams);
  111. },
  112. userInformationIsClick(){
  113. //查询是否需要弹Ross广告
  114. let _self = this;
  115. PublicApi.userInformationIsClick({}, function (response) {
  116. if(response.code === 0){
  117. if(response.data){
  118. setTimeout(()=>{
  119. _self.showRossHtml = true
  120. },5000)
  121. }
  122. }else{
  123. console.log('error',response.msg);
  124. }
  125. })
  126. },
  127. userInformationInsertRoos(params){
  128. //提交记录咨询人&&关闭弹窗
  129. let _self = this;
  130. PublicApi.userInformationInsertRoos(params, function (response) {
  131. if(response.code === 0){
  132. _self.showRossHtml = false
  133. }else{
  134. console.log('error',response.msg);
  135. }
  136. })
  137. },
  138. userInformationVisitRoos(params){
  139. //查看访问者是否浏览过roos相关页面
  140. let _self = this;
  141. PublicApi.userInformationVisitRoos(params, function (response) {
  142. if(response.code === 0){
  143. _self.isRossShow = response.data
  144. }else{
  145. console.log('error',response.msg);
  146. }
  147. })
  148. },
  149. userRecordStatistics() {// navigator.sendBeacon 方式 暂时废弃
  150. const NODE_ENV_BASE_URL = $("#coreServer").val();
  151. const url = `${NODE_ENV_BASE_URL}/user/record/StatisticsPc`;
  152. const blob = new Blob([JSON.stringify(this.cmSysParams)], {
  153. type: 'application/json; charset=UTF-8',
  154. });
  155. navigator.sendBeacon(url, blob);
  156. },
  157. handleWindow(type){ // 暂时废弃
  158. const isBrowser = isPC ? 1 : 0;
  159. const map = {
  160. 0: 'pagehide',
  161. 1: 'beforeunload',
  162. };
  163. const FunMap = {
  164. 0:window.addEventListener(map[isBrowser], e => this.beforeunloadHandler(e)), // 绑定
  165. 1:window.removeEventListener(map[isBrowser], e => this.beforeunloadHandler(e)) // 接触绑定
  166. }
  167. return FunMap[type];
  168. },
  169. },
  170. mounted() {
  171. // 页面加载完成后[监听]执行事件
  172. this.handleCmSysNetInfo()
  173. // 查看访问者是否浏览过roos相关页面
  174. this.userInformationVisitRoos({ userId: this.cmSysParams.userId })
  175. },
  176. destroyed() {
  177. }
  178. }
  179. }();