Browse Source

feat: 日志收集

v1.0.1
jiannibang 3 years ago
parent
commit
133c1d507f
  1. 2
      src/components/Search/Search.vue
  2. 5
      src/composables/useStatistics.js
  3. 3
      src/store/root/actions.js

2
src/components/Search/Search.vue

@ -96,7 +96,7 @@ const hotRecommend = computed(() => indexList.value.hotSearch ?? [])
const showClassify = ref(false)
async function handleShop(item) {
useStatistics('brandSearch')
useStatistics('brandSearch', { shopId: item.shopId })
const shop = shopList.value.find(_shop => _shop.shopId === item.shopId)
store.SET_SHOP(shop)
if (router.currentRoute.value.fullPath !== '/guide') {

5
src/composables/useStatistics.js

@ -5,14 +5,15 @@ import { getStatistics } from '@/http/api'
/**
* @param {string} tag 设备点击量:device,导航使用次数:navigation,店铺点击次数:shop,业态点击次数:industry, 搜索店铺: brandSearch
*/
export const useStatistics = tag => {
export const useStatistics = (tag, rest = {}) => {
const store = useStore()
const { currentFloor } = storeToRefs(store)
const { projectCode, deviceCode } = currentFloor.value
const params = {
projectCode,
deviceCode,
tag
tag,
...rest
}
getStatistics(params)
}

3
src/store/root/actions.js

@ -1,5 +1,5 @@
import { i18n } from '@/i18n'
import { useStatistics } from '@/composables/useStatistics'
export const actions = {
SET_SHOP_LIST(list) {
this.shopList = list
@ -28,6 +28,7 @@ export const actions = {
},
SET_SHOP(shop) {
this.shop = shop
if (shop) useStatistics('shop', { shopId: shop.shopId })
},
SET_CURRENT_FLOOR(currentFloor) {
this.currentFloor = currentFloor

Loading…
Cancel
Save