Authored by htoooth

update js

... ... @@ -1048,7 +1048,10 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
result.md5 = origin.md5;// 用于前端数据变化的对比
origin = origin.data;
if (uid) {
origin.uid = uid;
}
let propOrigin = _.partial(_.get, origin);
... ... @@ -1243,8 +1246,8 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
statGoodsInfo.productId = propOrigin('product_id');
statGoodsInfo.productName = result.name.replace('\'', '’');
statGoodsInfo.brandName = (result.brandName || '').replace('\'', '’');
statGoodsInfo.marketPrice = result.marketPrice;
statGoodsInfo.salePrice = result.salePrice ? result.salePrice : result.marketPrice;
statGoodsInfo.marketPrice = result.marketPrice.replace('¥', ''); // 数字
statGoodsInfo.salePrice = (result.salePrice ? result.salePrice : result.marketPrice).replace('¥', ''); // 数字
statGoodsInfo.imageUrl = 'http:' + result.img.split('?')[0];
statGoodsInfo.productUrl = 'http:' +
helpers.urlFormat(url.parse(propOrigin('product_url')).pathname, null, 'item');
... ...
... ... @@ -19,19 +19,8 @@ function dataLazyLoad(doc) {
// 工具方法 begin
var Util = {
getElementsByClassName: function(cls) {
if (doc.getElementsByClassName) {
return doc.getElementsByClassName(cls);
}
var o = doc.getElementsByTagName("*"),
rs = [];
for (var i = 0, t, len = o.length; i < len; i++) {
(t = o[i]) && ~t.className.indexOf(cls) && rs.push(t);
}
return rs;
getElements: function(cls) {
return $(cls).toArray();
},
addEvent: function(ele, type, fn) {
ele.attachEvent ? ele.attachEvent("on" + type, fn) : ele.addEventListener(type, fn, false);
... ... @@ -79,7 +68,7 @@ function dataLazyLoad(doc) {
fn: null, // {Function} scroll、resize、touchmove 所绑定方法,即为 pollTextareas()
evalScripts: function(code) {
var head = doc.getElementsByClassName("yoho-footer")[0],
var head = $(".yoho-footer")[0],
js = doc.createElement("script");
js.text = code;
... ... @@ -188,7 +177,7 @@ function dataLazyLoad(doc) {
var cls = config.cls;
this.threshold = config.threshold ? config.threshold : 0;
this.els = Array.prototype.slice.call(Util.getElementsByClassName(cls));
this.els = Array.prototype.slice.call(Util.getElements(cls));
this.fn = this.pollTextareas.bind(this);
this.fn();
... ... @@ -206,7 +195,7 @@ module.exports = dataLazyLoad;
/**
* demo
* datalazyload.init({
* cls: "datalazyload", // 需要延迟加载的类,即 textarea 的类名
* cls: ".datalazyload", // 需要延迟加载的类,即 textarea 的类名
* threshold: 100 // 距离底部多高,进行延迟加载的阈值
* });
*/
... ...
... ... @@ -819,4 +819,4 @@ bindEvent.fire();
}());
// 数据懒加载
dataLazyLoad.init({cls: 'datalazyload', threshold: 0});
dataLazyLoad.init({cls: '.datalazyload', threshold: 0});
... ...
... ... @@ -65,4 +65,4 @@ function fetchLatestWalk() {
window.fetchLatestWalk = fetchLatestWalk;
// 数据懒加载
dataLazyLoad.init({cls: 'latest-walk-datalazyload', threshold: 700});
dataLazyLoad.init({cls: '.latest-walk-datalazyload', threshold: 700});
... ...