Authored by zhangwenxue

商品详情: 添加埋点

@@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
27 <div class="info-name"><div>{{productDetail.product_name}}</div></div> 27 <div class="info-name"><div>{{productDetail.product_name}}</div></div>
28 </div> 28 </div>
29 <a class="banner" v-if="resource" @click.prevent="gotoNewPage(resource.url)"> 29 <a class="banner" v-if="resource" @click.prevent="gotoNewPage(resource.url)">
30 - <img-size :src="sizeImg(resource.src)"/> 30 + <img-size ref="resourceImg" :src="sizeImg(resource.src)"/>
31 </a> 31 </a>
32 <div class="info"> 32 <div class="info">
33 <transition-group name="info-list" tag="div" class="info-list"> 33 <transition-group name="info-list" tag="div" class="info-list">
@@ -50,7 +50,7 @@ @@ -50,7 +50,7 @@
50 <img class="ref-img" v-lazy="prdDetailImage" /> 50 <img class="ref-img" v-lazy="prdDetailImage" />
51 51
52 <div class="recommend" v-if="recommend"><h2>相关推荐</h2> 52 <div class="recommend" v-if="recommend"><h2>相关推荐</h2>
53 - <product-list :list="recommend" priceKey="price"/> 53 + <product-list ref="recommendList" :list="recommend" priceKey="price" :yas-params="recommendYasParams"/>
54 </div> 54 </div>
55 </div> 55 </div>
56 <div class="footer"> 56 <div class="footer">
@@ -97,7 +97,7 @@ import TopList from './components/top-list'; @@ -97,7 +97,7 @@ import TopList from './components/top-list';
97 import SquareImg from './components/square-img'; 97 import SquareImg from './components/square-img';
98 import stateShortCutsMixins from './mixins'; 98 import stateShortCutsMixins from './mixins';
99 99
100 -const { mapActions } = createNamespacedHelpers('product'); 100 +const { mapActions, mapState } = createNamespacedHelpers('product');
101 101
102 export default { 102 export default {
103 name: 'ProductDetail', 103 name: 'ProductDetail',
@@ -133,10 +133,23 @@ export default { @@ -133,10 +133,23 @@ export default {
133 showSizeSelectSheet: false, 133 showSizeSelectSheet: false,
134 showSizeRequestSheet: false, 134 showSizeRequestSheet: false,
135 selectSizeConfig: {}, 135 selectSizeConfig: {},
  136 +
  137 + /**
  138 + * 商品详情页-推荐商品曝光时
  139 + * XY_UFO_SHOW_EVENT
  140 + * 1.P_NAME:页面名称,UFOProductDetail_LIST;
  141 + * 2.P_PARAM:页面参数;
  142 + * 3.I_INDEX:曝光顺序;
  143 + * 4.PRD_SKN:商品id;
  144 + */
  145 + recommendYasParams: {
  146 + P_NAME: 'UFOProductDetail_LIST',
  147 + },
136 }; 148 };
137 }, 149 },
138 computed: { 150 computed: {
139 ...mapGetters(['isQiugouEnabled']), 151 ...mapGetters(['isQiugouEnabled']),
  152 + ...mapState(['resourceContentCode']),
140 productDec() { 153 productDec() {
141 const goods = get(this.productDetail, 'goods_list[0]', {}); 154 const goods = get(this.productDetail, 'goods_list[0]', {});
142 155
@@ -198,6 +211,31 @@ export default { @@ -198,6 +211,31 @@ export default {
198 211
199 this.loadData(this.productId); 212 this.loadData(this.productId);
200 this.refresh(); 213 this.refresh();
  214 +
  215 + if (this._resourceImgWatcher) {
  216 + this._resourceImgWatcher();
  217 + }
  218 +
  219 + if (this.resource && this.resource.url) {
  220 + this.yasResourceVisible();
  221 + } else {
  222 + this._resourceImgWatcher = this.$watch(() => {
  223 + return this.resource && this.resource.url;
  224 + }, (url) => {
  225 + if (url) {
  226 + this._resourceImgWatcher && this._resourceImgWatcher();
  227 + this.yasResourceVisible();
  228 + }
  229 + }, {
  230 + immediate: true,
  231 + });
  232 + }
  233 + },
  234 + deactivated() {
  235 + if (this._resourceImgWatcher) {
  236 + this._resourceImgWatcher();
  237 + this._resourceImgWatcher = null;
  238 + }
201 }, 239 },
202 beforeRouteUpdate(to, from ,next) { 240 beforeRouteUpdate(to, from ,next) {
203 if (this.historyBackGuard() === false) { 241 if (this.historyBackGuard() === false) {
@@ -228,6 +266,31 @@ export default { @@ -228,6 +266,31 @@ export default {
228 refresh() { 266 refresh() {
229 this.$refs.slide && this.$refs.slide.refresh && this.$refs.slide.refresh(); 267 this.$refs.slide && this.$refs.slide.refresh && this.$refs.slide.refresh();
230 }, 268 },
  269 + yasResourceVisible() {
  270 + /**
  271 + * 商品详情页中的资源位曝光
  272 + * XY_UFO_SHOW_EVENT
  273 + * 1.P_NAME:当前页面名称,XY_UFOProductDetail;
  274 + * 2.P_PARAM:当前页面资源位code;
  275 + * 3.PRD_ID:商品ID;
  276 + * 4.ACTION_URL:资源位跳转URL;
  277 + */
  278 + this.$store.dispatch('reportYas', {
  279 + params: {
  280 + appop: 'XY_UFO_SHOW_EVENT',
  281 + param: {
  282 + P_NAME: 'XY_UFOProductDetail',
  283 + P_PARAM: this.resourceContentCode,
  284 + PRD_ID: this.productId,
  285 + ACTION_URL: this.resource.url,
  286 + },
  287 + }
  288 + });
  289 + if (this._resourceImgWatcher) {
  290 + this._resourceImgWatcher();
  291 + this._resourceImgWatcher = null;
  292 + }
  293 + },
231 sizeImg(src, width = 360, height = 72) { 294 sizeImg(src, width = 360, height = 72) {
232 if (src) { 295 if (src) {
233 return getImgUrl(src, width, height); 296 return getImgUrl(src, width, height);
@@ -344,19 +407,23 @@ export default { @@ -344,19 +407,23 @@ export default {
344 407
345 // 选择出售或购买 408 // 选择出售或购买
346 async onSelectTradeProduct(tradeProduct) { 409 async onSelectTradeProduct(tradeProduct) {
347 - if (this.selectSizeConfig.type === 'buy') {  
348 - //数据埋点 410 + /**
  411 + * 数据埋点
  412 + * 商品详情页点击出售/购买/求购按钮
  413 + * event: XY_UFO_PRD_DT_SALE_C
  414 + * params: 1.TAB_ID:1-出售,2-购买,3-求购;
  415 + * 2.PRD_ID:商品ID;
  416 + */
349 this.$store.dispatch('reportYas', { 417 this.$store.dispatch('reportYas', {
350 params: { 418 params: {
351 appop: 'XY_UFO_PRD_DT_BUY_SEL_C', 419 appop: 'XY_UFO_PRD_DT_BUY_SEL_C',
352 param: { 420 param: {
353 - PRD_ID: tradeProduct.productId,  
354 - PRD_SKU: tradeProduct.skup,  
355 - PRD_SIZE: tradeProduct.size_name, 421 + TAB_ID: this.selectSizeConfig.type === 'buy' ? 2 : 1,
  422 + PRD_ID: tradeProduct.productId
356 }, 423 },
357 } 424 }
358 }); 425 });
359 - 426 + if (this.selectSizeConfig.type === 'buy') {
360 try { 427 try {
361 const info = await this.payment({ 428 const info = await this.payment({
362 skup: tradeProduct.skup, 429 skup: tradeProduct.skup,
@@ -441,6 +508,21 @@ export default { @@ -441,6 +508,21 @@ export default {
441 508
442 // 资源位 509 // 资源位
443 gotoNewPage(url) { 510 gotoNewPage(url) {
  511 + /**
  512 + * 商品详情页中的资源位点击
  513 + * XY_UFO_GDS_DT_BANNER_C
  514 + * 1.PRD_ID:商品ID
  515 + * 2.ACTION_URL:跳转的URL
  516 + */
  517 + this.$store.dispatch('reportYas', {
  518 + params: {
  519 + appop: 'XY_UFO_GDS_DT_BANNER_C',
  520 + param: {
  521 + PRD_ID: this.productId,
  522 + ACTION_URL: url,
  523 + },
  524 + }
  525 + });
444 this.$xianyu.goXianyuNewPage({url}); 526 this.$xianyu.goXianyuNewPage({url});
445 }, 527 },
446 }, 528 },
@@ -6,13 +6,13 @@ export default { @@ -6,13 +6,13 @@ export default {
6 ensureProduct({ commit }, { productId }) { 6 ensureProduct({ commit }, { productId }) {
7 commit(Types.ENSURE_PRODUCT_DETAIL, { productId }); 7 commit(Types.ENSURE_PRODUCT_DETAIL, { productId });
8 }, 8 },
9 - async fetchProductInfo({ commit }, { productId }) { 9 + async fetchProductInfo({ commit, state }, { productId }) {
10 const queryTasks = ['', '/resource', '/activity', '/recommend'].map(path => { 10 const queryTasks = ['', '/resource', '/activity', '/recommend'].map(path => {
11 let params = { product_id: productId }; 11 let params = { product_id: productId };
12 12
13 if (path === '/resource') { 13 if (path === '/resource') {
14 params = { 14 params = {
15 - content_code: '05e4f5782dfc3a5e10d39b8f04a7dcb9', 15 + content_code: state.resourceContentCode,
16 }; 16 };
17 } 17 }
18 return this.$api.post(`/api/ufo/product${path}`, params).then(result => { 18 return this.$api.post(`/api/ufo/product${path}`, params).then(result => {
@@ -50,7 +50,7 @@ export function defaultProduct() { @@ -50,7 +50,7 @@ export function defaultProduct() {
50 export function defaultState() { 50 export function defaultState() {
51 return { 51 return {
52 products: {}, 52 products: {},
53 - 53 + resourceContentCode: '05e4f5782dfc3a5e10d39b8f04a7dcb9', // 资源位code,当前只有一个固定的code
54 /** 54 /**
55 1: 当前商品对应品牌系统的推荐 55 1: 当前商品对应品牌系统的推荐
56 2: 商品详情页面取前3 56 2: 商品详情页面取前3