Browse Source

修复搜索统计

zhengjinyi 2 years ago
parent
commit
7743ad7d84

+ 59 - 0
mixins/cmSrsMixins.js

@@ -1,5 +1,17 @@
 // 统计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 {
@@ -25,11 +37,46 @@ const cmSrsMixins = {
 				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()
@@ -43,6 +90,18 @@ const cmSrsMixins = {
                 .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
         }
     }
 }

+ 2 - 0
pages/seller/cart/components/cm-unit-cart-popup.vue

@@ -168,6 +168,8 @@ export default {
 			const userInfo = await this.$api.getStorage()
 			this.userIdentity = userInfo.userIdentity
 			this.skuList = this.skuProduct.skus
+			this.handleMinNumber = this.skuList[0].minBuyNumber
+			this.handleStock = this.skuList[0].stock
 			this.addParams.oldSkuId = this.skuProduct.skuId
 			this.addParams.newSkuId = this.skuList[0].skuId
 			this.isBtnDisabled = this.skuList[0].stock === 0

+ 0 - 1
pages/seller/cart/components/cm-unit-popup.vue

@@ -280,7 +280,6 @@ export default {
 			if(sku.ladderPriceList.length>0){
 				this.ladderPriceList = sku.ladderPriceList
 			}
-			console.log('1111111111111',this.ladderPriceList)
 			this.$emit('skuClick', sku)
 		},
 		hidePopup() {

+ 1 - 1
pages/user/member/member.vue

@@ -250,7 +250,7 @@ export default {
 					privName: '每三个月可领'
 				},
 				{
-					icon: 'https://static.caimei365.com/app/img/icon/icon-member-prer8@2x.png',
+					icon: 'https://static.caimei365.com/app/img/icon/icon-member-prer9@2x.png',
 					privText: '免运费',
 					privName: '下单全包邮'
 				},

+ 2 - 2
utils/router.config.js

@@ -6,8 +6,8 @@ export const includeList = [
     {title:'发布二手', url:'/pages/second/form/form',pageLabel:'发布二手', pageType:4},
     {title:'二手市场', url:'/pages/second/product/product-list',pageLabel:'二手市场', pageType:3},
     {title:'二手详情', url:'/pages/second/product/product-details',pageLabel:'二手详情', pageType:7},
-    // {title:'搜索商品', url:'/pages/search/search',pageLabel:'搜索商品', pageType:8},
-    // {title:'搜索供应商', url:'/pages/search/search-supplier',pageLabel:'搜索供应商', pageType:9 },
+    {title:'搜索商品', url:'/pages/search/search',pageLabel:'搜索商品', pageType:8},
+    {title:'搜索供应商', url:'/pages/search/search-supplier',pageLabel:'搜索供应商', pageType:9 },
     {title:'分类商品列表', url:'/pages/goods/goods-classify',pageLabel:'分类商品列表', pageType:10 },
     {title:'二级楼层', url:'/pages/goods/good-floor',pageLabel:'二级楼层', pageType:13 },
     {title:'项目详情', url:'/pages/goods/goods-instrument',pageLabel:'项目详情', pageType:13 },