Authored by baoss

替换猜你喜欢上报参数,优化列表上报

@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 </template> 35 </template>
36 36
37 <script> 37 <script>
38 -import { get, find } from 'lodash'; 38 +import { get, find, findIndex } from 'lodash';
39 import { Style, Scroll, Sticky } from 'cube-ui'; 39 import { Style, Scroll, Sticky } from 'cube-ui';
40 import { createNamespacedHelpers } from 'vuex'; 40 import { createNamespacedHelpers } from 'vuex';
41 import queryString from 'querystring'; 41 import queryString from 'querystring';
@@ -58,6 +58,7 @@ export default { @@ -58,6 +58,7 @@ export default {
58 PAGE_URL: '', 58 PAGE_URL: '',
59 listYasParams: {}, 59 listYasParams: {},
60 homeYasParams: [], 60 homeYasParams: [],
  61 + listScrollY: 0,
61 options: { 62 options: {
62 pullUpLoad: true, 63 pullUpLoad: true,
63 }, 64 },
@@ -106,10 +107,19 @@ export default { @@ -106,10 +107,19 @@ export default {
106 }; 107 };
107 }, 108 },
108 computed: { 109 computed: {
109 - ...mapState(['channelList']), 110 + ...mapState(['channelList','contentCode']),
110 navList() { 111 navList() {
111 return get(find(this.channelList.list, ['template_name', 'guessLike']), 'data') || []; 112 return get(find(this.channelList.list, ['template_name', 'guessLike']), 'data') || [];
112 }, 113 },
  114 + navInfo() {
  115 + let index = findIndex(this.channelList.list, ['template_name', 'guessLike'])
  116 + let id = get(find(this.channelList.list, ['template_name', 'guessLike']), 'template_id')
  117 + return {
  118 + F_ID: id,
  119 + F_NAME: 'guessLike',
  120 + F_INDEX: index + 1
  121 + }
  122 + },
113 noItemStyle() { 123 noItemStyle() {
114 return { 124 return {
115 height: this.total + 'px' 125 height: this.total + 'px'
@@ -270,16 +280,36 @@ export default { @@ -270,16 +280,36 @@ export default {
270 // console.log(this.listYasParams) 280 // console.log(this.listYasParams)
271 } 281 }
272 }, 282 },
  283 + guessLikeListParams(params) {
  284 + if (params && typeof params === 'object' && Object.keys(params).length) {
  285 + this.listYasParams = Object.assign({}, {
  286 + P_NAME: 'XY_UFOHome',
  287 + P_PARAM: this.contentCode,
  288 + PAGE_URL: this.PAGE_URL,
  289 + ...this.navInfo,
  290 + I_INDEX: Number(params.index) + 1,
  291 + TAB_ID: Number(params.index) + 1,
  292 + TAB_NAME: params.title});
  293 + console.log(this.listYasParams)
  294 + }
  295 + },
273 getIndex({index, params}) { 296 getIndex({index, params}) {
274 this.selectedCategory = params; 297 this.selectedCategory = params;
275 this.active = Number(index); 298 this.active = Number(index);
276 this.isShow && this.$refs.scroll.scrollTo(this.navTop); 299 this.isShow && this.$refs.scroll.scrollTo(this.navTop);
277 - this.setYasParam({index, ...params}); 300 + // this.setYasParam({index, ...params});
  301 + this.guessLikeListParams({index, ...params});
  302 + // 商品列表曝光
  303 + this.listScrollY > 0 && this.$refs.product && this.$refs.product.yasShowEvent(this.listScrollY);
278 }, 304 },
279 scrollEndHandler({y}) { 305 scrollEndHandler({y}) {
280 let scrollHeight = Math.abs(y); 306 let scrollHeight = Math.abs(y);
281 -  
282 - this.$refs.product && this.$refs.product.yasShowEvent(scrollHeight + this.navTop); 307 + let viewHeight = this.$refs.scroll.$el.offsetHeight;
  308 + let productListTop = this.$refs.product && this.$refs.product.$el.offsetTop || this.navTop + this.navHeight;
  309 + let listScrollY = scrollHeight + viewHeight - productListTop;
  310 + this.listScrollY = listScrollY
  311 + // 商品列表曝光
  312 + listScrollY > 0 && this.$refs.product && this.$refs.product.yasShowEvent(listScrollY);
283 if (scrollHeight >= this.navTop) { 313 if (scrollHeight >= this.navTop) {
284 return; 314 return;
285 } 315 }
@@ -307,7 +337,8 @@ export default { @@ -307,7 +337,8 @@ export default {
307 await this.fetchList(this.searchParams); 337 await this.fetchList(this.searchParams);
308 338
309 // 列表上报数据 339 // 列表上报数据
310 - this.setYasParam({index: 0, ...this.searchParams}); 340 + // this.setYasParam({index: 0, ...this.searchParams});
  341 + this.guessLikeListParams({index: 0, ...this.searchParams});
311 }, 342 },
312 343
313 async onPullingUp() { 344 async onPullingUp() {
@@ -18,6 +18,7 @@ export default function() { @@ -18,6 +18,7 @@ export default function() {
18 // scrollnavidList: [], // 导航菜单 18 // scrollnavidList: [], // 导航菜单
19 current: 0, 19 current: 0,
20 }, 20 },
  21 + contentCode: contentCode,
21 showMsg: false, 22 showMsg: false,
22 }, 23 },
23 mutations: { 24 mutations: {