Authored by htoooth

update js

@@ -1048,7 +1048,10 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => { @@ -1048,7 +1048,10 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
1048 result.md5 = origin.md5;// 用于前端数据变化的对比 1048 result.md5 = origin.md5;// 用于前端数据变化的对比
1049 1049
1050 origin = origin.data; 1050 origin = origin.data;
1051 - origin.uid = uid; 1051 +
  1052 + if (uid) {
  1053 + origin.uid = uid;
  1054 + }
1052 1055
1053 let propOrigin = _.partial(_.get, origin); 1056 let propOrigin = _.partial(_.get, origin);
1054 1057
@@ -1243,8 +1246,8 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => { @@ -1243,8 +1246,8 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
1243 statGoodsInfo.productId = propOrigin('product_id'); 1246 statGoodsInfo.productId = propOrigin('product_id');
1244 statGoodsInfo.productName = result.name.replace('\'', '’'); 1247 statGoodsInfo.productName = result.name.replace('\'', '’');
1245 statGoodsInfo.brandName = (result.brandName || '').replace('\'', '’'); 1248 statGoodsInfo.brandName = (result.brandName || '').replace('\'', '’');
1246 - statGoodsInfo.marketPrice = result.marketPrice;  
1247 - statGoodsInfo.salePrice = result.salePrice ? result.salePrice : result.marketPrice; 1249 + statGoodsInfo.marketPrice = result.marketPrice.replace('¥', ''); // 数字
  1250 + statGoodsInfo.salePrice = (result.salePrice ? result.salePrice : result.marketPrice).replace('¥', ''); // 数字
1248 statGoodsInfo.imageUrl = 'http:' + result.img.split('?')[0]; 1251 statGoodsInfo.imageUrl = 'http:' + result.img.split('?')[0];
1249 statGoodsInfo.productUrl = 'http:' + 1252 statGoodsInfo.productUrl = 'http:' +
1250 helpers.urlFormat(url.parse(propOrigin('product_url')).pathname, null, 'item'); 1253 helpers.urlFormat(url.parse(propOrigin('product_url')).pathname, null, 'item');
@@ -19,19 +19,8 @@ function dataLazyLoad(doc) { @@ -19,19 +19,8 @@ function dataLazyLoad(doc) {
19 19
20 // 工具方法 begin 20 // 工具方法 begin
21 var Util = { 21 var Util = {
22 - getElementsByClassName: function(cls) {  
23 - if (doc.getElementsByClassName) {  
24 - return doc.getElementsByClassName(cls);  
25 - }  
26 -  
27 - var o = doc.getElementsByTagName("*"),  
28 - rs = [];  
29 -  
30 - for (var i = 0, t, len = o.length; i < len; i++) {  
31 - (t = o[i]) && ~t.className.indexOf(cls) && rs.push(t);  
32 - }  
33 -  
34 - return rs; 22 + getElements: function(cls) {
  23 + return $(cls).toArray();
35 }, 24 },
36 addEvent: function(ele, type, fn) { 25 addEvent: function(ele, type, fn) {
37 ele.attachEvent ? ele.attachEvent("on" + type, fn) : ele.addEventListener(type, fn, false); 26 ele.attachEvent ? ele.attachEvent("on" + type, fn) : ele.addEventListener(type, fn, false);
@@ -79,7 +68,7 @@ function dataLazyLoad(doc) { @@ -79,7 +68,7 @@ function dataLazyLoad(doc) {
79 fn: null, // {Function} scroll、resize、touchmove 所绑定方法,即为 pollTextareas() 68 fn: null, // {Function} scroll、resize、touchmove 所绑定方法,即为 pollTextareas()
80 69
81 evalScripts: function(code) { 70 evalScripts: function(code) {
82 - var head = doc.getElementsByClassName("yoho-footer")[0], 71 + var head = $(".yoho-footer")[0],
83 js = doc.createElement("script"); 72 js = doc.createElement("script");
84 73
85 js.text = code; 74 js.text = code;
@@ -188,7 +177,7 @@ function dataLazyLoad(doc) { @@ -188,7 +177,7 @@ function dataLazyLoad(doc) {
188 var cls = config.cls; 177 var cls = config.cls;
189 this.threshold = config.threshold ? config.threshold : 0; 178 this.threshold = config.threshold ? config.threshold : 0;
190 179
191 - this.els = Array.prototype.slice.call(Util.getElementsByClassName(cls)); 180 + this.els = Array.prototype.slice.call(Util.getElements(cls));
192 this.fn = this.pollTextareas.bind(this); 181 this.fn = this.pollTextareas.bind(this);
193 182
194 this.fn(); 183 this.fn();
@@ -206,7 +195,7 @@ module.exports = dataLazyLoad; @@ -206,7 +195,7 @@ module.exports = dataLazyLoad;
206 /** 195 /**
207 * demo 196 * demo
208 * datalazyload.init({ 197 * datalazyload.init({
209 - * cls: "datalazyload", // 需要延迟加载的类,即 textarea 的类名 198 + * cls: ".datalazyload", // 需要延迟加载的类,即 textarea 的类名
210 * threshold: 100 // 距离底部多高,进行延迟加载的阈值 199 * threshold: 100 // 距离底部多高,进行延迟加载的阈值
211 * }); 200 * });
212 */ 201 */
@@ -819,4 +819,4 @@ bindEvent.fire(); @@ -819,4 +819,4 @@ bindEvent.fire();
819 }()); 819 }());
820 820
821 // 数据懒加载 821 // 数据懒加载
822 -dataLazyLoad.init({cls: 'datalazyload', threshold: 0}); 822 +dataLazyLoad.init({cls: '.datalazyload', threshold: 0});
@@ -65,4 +65,4 @@ function fetchLatestWalk() { @@ -65,4 +65,4 @@ function fetchLatestWalk() {
65 window.fetchLatestWalk = fetchLatestWalk; 65 window.fetchLatestWalk = fetchLatestWalk;
66 66
67 // 数据懒加载 67 // 数据懒加载
68 -dataLazyLoad.init({cls: 'latest-walk-datalazyload', threshold: 700}); 68 +dataLazyLoad.init({cls: '.latest-walk-datalazyload', threshold: 700});