Authored by 陈峰

yas

... ... @@ -7,6 +7,7 @@
<script>
import {REPORT_YAS} from 'store/yoho/types';
import _ from 'lodash';
import {mapState} from 'vuex';
import {throttle} from 'common/utils';
export default {
... ... @@ -16,8 +17,19 @@ export default {
componentStatus: {}
};
},
computed: {
...mapState(['yoho'])
},
// watch: {
// ['yoho.visible'](visible) {
// if (visible) {
// this.checkReport();
// }
// }
// },
mounted() {
this.scrollEvent = throttle(50, this.resourceScroll);
this.scrollEvent = throttle(50, this.checkReport);
if (_.get(this.$parent, '$options.name') === 'Scroller') {
this.$scrollEl = this.$parent.$el;
} else {
... ... @@ -25,14 +37,7 @@ export default {
}
if (this.$scrollEl) {
this.$scrollEl.addEventListener('scroll', this.scrollEvent);
_.each(this.$children, (component, index) => {
const visiable = this.isVisiable(component.$el, this.$scrollEl);
this.componentStatus[index] = visiable;
if (visiable) {
this.report(component, index + 1);
}
});
this.checkReport();
}
},
destroyed() {
... ... @@ -41,7 +46,7 @@ export default {
}
},
methods: {
resourceScroll() {
checkReport() {
_.each(this.$children, (component, index) => {
const visiable = this.isVisiable(component.$el, this.$scrollEl);
... ...
... ... @@ -14,7 +14,6 @@
</script>
</head>
<body>
<!--vue-ssr-outlet-->
<script>
(function(w, d, s, j, f) {
var a = d.createElement(s);
... ... @@ -96,5 +95,6 @@
})();
</script>
<!--vue-ssr-outlet-->
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -6,6 +6,7 @@ import {
PAGE_INIT_VISIBLE,
REPORT_YAS,
} from './types';
import cookie from 'yoho-cookie';
import _ from 'lodash/core';
export function createYoho() {
... ... @@ -61,8 +62,18 @@ export function createYoho() {
}
},
actions: {
[REPORT_YAS](action, {params: {appop, param}, asyncindx = false}) {
[REPORT_YAS]({state}, {params: {appop, param}, asyncindx = false}) {
if (window._yas && window._yas.sendAppLogs) {
param = param || {};
if (!param.C_ID) {
const channel = {
men: 1,
women: 2
}[cookie.get('_Channel') || 'men'];
param.C_ID = channel;
}
window._yas.sendAppLogs({
appop,
param: param ? JSON.stringify(param) : '{}'
... ...