Merge branch 'release/3.0' into 'gray'
yas See merge request !31
Showing
7 changed files
with
93 additions
and
23 deletions
@@ -31,6 +31,9 @@ | @@ -31,6 +31,9 @@ | ||
31 | {{{body}}} | 31 | {{{body}}} |
32 | </div> | 32 | </div> |
33 | 33 | ||
34 | + {{#unless devEnv}} | ||
35 | + {{> analysis}} | ||
36 | + {{/unless}} | ||
34 | {{#if devEnv}} | 37 | {{#if devEnv}} |
35 | <script src="//{{devHost}}:5004/libs.js"></script> | 38 | <script src="//{{devHost}}:5004/libs.js"></script> |
36 | {{#unless noLocalJS}} | 39 | {{#unless noLocalJS}} |
@@ -42,8 +45,5 @@ | @@ -42,8 +45,5 @@ | ||
42 | <script src="//cdn.yoho.cn/yohoblk-wap/{{version}}/{{module}}.{{page}}.js"></script> | 45 | <script src="//cdn.yoho.cn/yohoblk-wap/{{version}}/{{module}}.{{page}}.js"></script> |
43 | {{/unless}} | 46 | {{/unless}} |
44 | {{/if}} | 47 | {{/if}} |
45 | - {{#unless devEnv}} | ||
46 | - {{> analysis}} | ||
47 | - {{/unless}} | ||
48 | </body> | 48 | </body> |
49 | </html> | 49 | </html> |
1 | <script> | 1 | <script> |
2 | -{{!--(function(w, d, s, j, f) { | 2 | +(function(w, d, s, j, f) { |
3 | var a = d.createElement(s); | 3 | var a = d.createElement(s); |
4 | var m = d.getElementsByTagName(s)[0]; | 4 | var m = d.getElementsByTagName(s)[0]; |
5 | 5 | ||
6 | w.YohoAcquisitionObject = f; | 6 | w.YohoAcquisitionObject = f; |
7 | + | ||
7 | w[f] = function() { | 8 | w[f] = function() { |
8 | w[f].p = arguments; | 9 | w[f].p = arguments; |
9 | }; | 10 | }; |
11 | + | ||
10 | a.async = 1; | 12 | a.async = 1; |
11 | a.src = j; | 13 | a.src = j; |
12 | m.parentNode.insertBefore(a, m); | 14 | m.parentNode.insertBefore(a, m); |
13 | -}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.1.2/yas.js', '_yas')); | 15 | +}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.2/yas.js', '_yas')); |
14 | 16 | ||
15 | (function() { | 17 | (function() { |
16 | function getUid() { | 18 | function getUid() { |
@@ -18,12 +20,12 @@ | @@ -18,12 +20,12 @@ | ||
18 | name = '_UID', | 20 | name = '_UID', |
19 | cookies = (document.cookie && document.cookie.split(';')) || []; | 21 | cookies = (document.cookie && document.cookie.split(';')) || []; |
20 | 22 | ||
21 | - cookies.forEach(function(c) { | ||
22 | - if (c.indexOf(name) > -1) { | ||
23 | - uid = decodeURIComponent(c.replace(name + '=', '').trim()); | ||
24 | - return; | 23 | + for (var i = 0; i < cookies.length; i++) { |
24 | + if (cookies[i].indexOf(name) > -1) { | ||
25 | + uid = decodeURIComponent(cookies[i].replace(name + '=', '').trim()); | ||
26 | + break; | ||
25 | } | 27 | } |
26 | - }); | 28 | + } |
27 | 29 | ||
28 | if (!uid) return 0; | 30 | if (!uid) return 0; |
29 | 31 | ||
@@ -48,13 +50,26 @@ | @@ -48,13 +50,26 @@ | ||
48 | } | 50 | } |
49 | 51 | ||
50 | var uid = getUid() || queryString().uid; | 52 | var uid = getUid() || queryString().uid; |
53 | + var isYohoBuy = /YohoBuy/i.test(navigator.userAgent || ''); | ||
54 | + var isIos = /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''); | ||
55 | + var isAndroid = /Android/i.test(navigator.userAgent || ''); | ||
51 | 56 | ||
52 | uid = uid === 0 ? '' : uid; | 57 | uid = uid === 0 ? '' : uid; |
53 | window._ozuid = uid; // 暴露ozuid | 58 | window._ozuid = uid; // 暴露ozuid |
54 | if (window._yas) { | 59 | if (window._yas) { |
55 | - window._yas(1 * new Date(), '2.1.2', 'yohoblk_m', uid, '', ''); | 60 | + let ak = 'yohoblk_m'; |
61 | + | ||
62 | + if (isYohoBuy) { | ||
63 | + if (isIos) { | ||
64 | + ak = 'yohobuy_ios'; | ||
65 | + } else if (isAndroid) { | ||
66 | + ak = 'yohobuy_android'; | ||
67 | + } | ||
68 | + } | ||
69 | + | ||
70 | + window._yas(1 * new Date(), '2.4.2', ak, uid, '', ''); | ||
56 | } | 71 | } |
57 | -}());--}} | 72 | +}()); |
58 | var _hmt = _hmt || []; | 73 | var _hmt = _hmt || []; |
59 | (function() { | 74 | (function() { |
60 | var hm = document.createElement("script"); | 75 | var hm = document.createElement("script"); |
public/js/common/yas.js
0 → 100644
1 | +export default () => { | ||
2 | + return { | ||
3 | + REC_ID: '', | ||
4 | + generateREC_ID() { | ||
5 | + return (new Date().getTime() + '_H5_YOHOBLK_' + Math.floor(Math.random() * 1000000 + 1000000) + | ||
6 | + '_' + Math.floor(Math.random() * 1000000 + 1000000)); | ||
7 | + }, | ||
8 | + event(op, param) { | ||
9 | + if (window._yas && window._yas.sendCustomInfo) { | ||
10 | + setTimeout(() => { | ||
11 | + window._yas.sendCustomInfo({ | ||
12 | + op: op, | ||
13 | + param: JSON.stringify(Object.assign(param, { | ||
14 | + REC_ID: this.REC_ID | ||
15 | + })) | ||
16 | + }, true); | ||
17 | + }, 0); | ||
18 | + } | ||
19 | + }, | ||
20 | + eventData(op, param) { | ||
21 | + this.REC_ID = this.generateREC_ID(); | ||
22 | + this.event(op, param); | ||
23 | + } | ||
24 | + }; | ||
25 | +}; |
@@ -25,6 +25,7 @@ import FastClick from 'fastclick'; | @@ -25,6 +25,7 @@ import FastClick from 'fastclick'; | ||
25 | import directive from 'common/vue-directive'; | 25 | import directive from 'common/vue-directive'; |
26 | import filter from 'common/vue-filter'; | 26 | import filter from 'common/vue-filter'; |
27 | import VueTouch from 'vue-touch'; | 27 | import VueTouch from 'vue-touch'; |
28 | +import yas from 'common/yas'; | ||
28 | 29 | ||
29 | /** | 30 | /** |
30 | * iOS 7 不支持 Promise, vue-lazyload 有用到,所以全局申明 | 31 | * iOS 7 不支持 Promise, vue-lazyload 有用到,所以全局申明 |
@@ -40,6 +41,9 @@ Vue.mixin({ | @@ -40,6 +41,9 @@ Vue.mixin({ | ||
40 | yoho.showLoading(false); | 41 | yoho.showLoading(false); |
41 | util.visibilitychange(); | 42 | util.visibilitychange(); |
42 | } | 43 | } |
44 | + }, | ||
45 | + created() { | ||
46 | + this.$yas = yas(); | ||
43 | } | 47 | } |
44 | }); | 48 | }); |
45 | directive(Vue); | 49 | directive(Vue); |
@@ -77,16 +77,20 @@ export default { | @@ -77,16 +77,20 @@ export default { | ||
77 | recItems: [ | 77 | recItems: [ |
78 | { | 78 | { |
79 | text: '推荐', | 79 | text: '推荐', |
80 | - val: '' | 80 | + val: '', |
81 | + type: 0 | ||
81 | }, { | 82 | }, { |
82 | text: '新品', | 83 | text: '新品', |
83 | - val: 's_t_desc' | 84 | + val: 's_t_desc', |
85 | + type: 2 | ||
84 | }, { | 86 | }, { |
85 | text: '价格从高到低', | 87 | text: '价格从高到低', |
86 | - val: 's_p_desc' | 88 | + val: 's_p_desc', |
89 | + type: 3 | ||
87 | }, { | 90 | }, { |
88 | text: '价格从低到高', | 91 | text: '价格从低到高', |
89 | - val: 's_p_asc' | 92 | + val: 's_p_asc', |
93 | + type: 3 | ||
90 | } | 94 | } |
91 | ], | 95 | ], |
92 | filterItems: [ | 96 | filterItems: [ |
@@ -174,7 +178,8 @@ export default { | @@ -174,7 +178,8 @@ export default { | ||
174 | this.activeSort = item; | 178 | this.activeSort = item; |
175 | bus.$emit('order.change', { | 179 | bus.$emit('order.change', { |
176 | val: item.val, | 180 | val: item.val, |
177 | - ref: this._uid | 181 | + ref: this._uid, |
182 | + type: item.type | ||
178 | }); | 183 | }); |
179 | this.recDown = true; | 184 | this.recDown = true; |
180 | this.hideLay(); | 185 | this.hideLay(); |
1 | <template> | 1 | <template> |
2 | <div class="goods-box" v-infinite-scroll="fetch" infinite-scroll-disable="disableFetch" infinite-scroll-distance="1200"> | 2 | <div class="goods-box" v-infinite-scroll="fetch" infinite-scroll-disable="disableFetch" infinite-scroll-distance="1200"> |
3 | <ul class="cardlist card-large clearfix"> | 3 | <ul class="cardlist card-large clearfix"> |
4 | - <li class="card" v-for="(item, index) in data" :key="item.product_skn"> | 4 | + <li class="card" v-for="(item, index) in data" :key="item.product_skn" @click="clickProduct(item, index)"> |
5 | <div class="card-pic"> | 5 | <div class="card-pic"> |
6 | <a v-good-href="item"> | 6 | <a v-good-href="item"> |
7 | <img v-img-src="{src: item.default_images, width: 330, height: 440}" :alt="item.product_name"> | 7 | <img v-img-src="{src: item.default_images, width: 330, height: 440}" :alt="item.product_name"> |
@@ -57,6 +57,9 @@ | @@ -57,6 +57,9 @@ | ||
57 | methods: { | 57 | methods: { |
58 | fetch: function() { | 58 | fetch: function() { |
59 | bus.$emit('list.paging'); | 59 | bus.$emit('list.paging'); |
60 | + }, | ||
61 | + clickProduct(item, index) { | ||
62 | + this.$emit('click-product', item, index); | ||
60 | } | 63 | } |
61 | } | 64 | } |
62 | }; | 65 | }; |
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | <filter-box :val="order" :filter="filterConfig" v-if="enableOrder" :search-page="true"></filter-box> | 3 | <filter-box :val="order" :filter="filterConfig" v-if="enableOrder" :search-page="true"></filter-box> |
4 | - <product-list :data="productList" :state="listState" class="list-items"></product-list> | 4 | + <product-list :data="productList" :state="listState" class="list-items" @click-product="clickProduct"></product-list> |
5 | </div> | 5 | </div> |
6 | </template> | 6 | </template> |
7 | <script> | 7 | <script> |
@@ -29,7 +29,8 @@ | @@ -29,7 +29,8 @@ | ||
29 | return { | 29 | return { |
30 | url: '/product/search.json', | 30 | url: '/product/search.json', |
31 | order: '', | 31 | order: '', |
32 | - query: decodeURIComponent(qs.query), | 32 | + orderType: 0, |
33 | + query: qs.query ? decodeURIComponent(qs.query) : '', | ||
33 | page: 0, // 未搜索 page=0; 全部加载完 page = totalPage; 无数据: page !=0 && productList.length=0 | 34 | page: 0, // 未搜索 page=0; 全部加载完 page = totalPage; 无数据: page !=0 && productList.length=0 |
34 | totalPage: null, | 35 | totalPage: null, |
35 | productList: [], | 36 | productList: [], |
@@ -63,6 +64,15 @@ | @@ -63,6 +64,15 @@ | ||
63 | FilterBox | 64 | FilterBox |
64 | }, | 65 | }, |
65 | methods: { | 66 | methods: { |
67 | + clickProduct(item, index) { | ||
68 | + this.$yas.event('YB_GOODS_LIST_DT', { | ||
69 | + TYPE_ID: 13, | ||
70 | + ENT_ID: this.query, | ||
71 | + I_INDEX: index + 1, | ||
72 | + PRD_ID: item.product_id, | ||
73 | + SORT_TYPE: this.orderType | ||
74 | + }); | ||
75 | + }, | ||
66 | search: function() { | 76 | search: function() { |
67 | const nextPage = this.page + 1; | 77 | const nextPage = this.page + 1; |
68 | 78 | ||
@@ -92,6 +102,15 @@ | @@ -92,6 +102,15 @@ | ||
92 | if (!this.filterConfig) { | 102 | if (!this.filterConfig) { |
93 | this.filterConfig = res.data.filter; | 103 | this.filterConfig = res.data.filter; |
94 | } | 104 | } |
105 | + this.$yas.eventData('YB_GOODS_LIST', { | ||
106 | + TYPE_ID: 13, | ||
107 | + ENT_ID: this.query, | ||
108 | + TOTAL: this.productList.length, | ||
109 | + PRD_LIST: this.productList.map(product => { | ||
110 | + return product.product_id; | ||
111 | + }).join(','), | ||
112 | + SORT_TYPE: this.orderType, | ||
113 | + }); | ||
95 | } | 114 | } |
96 | }) | 115 | }) |
97 | .fail(() => { | 116 | .fail(() => { |
@@ -128,10 +147,9 @@ | @@ -128,10 +147,9 @@ | ||
128 | self.search(); | 147 | self.search(); |
129 | }); | 148 | }); |
130 | 149 | ||
131 | - bus.$on('order.change', function({ | ||
132 | - val | ||
133 | - }) { | 150 | + bus.$on('order.change', function({val, type}) { |
134 | self.order = val; | 151 | self.order = val; |
152 | + self.orderType = type; | ||
135 | }); | 153 | }); |
136 | 154 | ||
137 | bus.$on('filter.change', function({val}) { | 155 | bus.$on('filter.change', function({val}) { |
-
Please register or login to post a comment