Authored by 沈志敏

个性化推荐

... ... @@ -91,7 +91,88 @@
<h1>4d28dd2c7955</h1>
</a>
<hr>
<input id="imgwh" type="hidden" name="" value="200x300">
<div class="feature-product-info">
<a class="product-brand" href="">
<span class="brand-name"></span>
<span class="brand-go">进入店铺</span>
</a>
<a class="product-detail" href="">
<div>
<img class="product-detail-img" src="">
</div>
<div class="product-detail-text">
<div class="name">
<span class="product-name"></span>
</div>
<div class="price">
<span class="sale-price"></span>
<span class="market-price"></span>
</div>
</div>
</a>
</div>
<div class="feature-product-info">
<a class="product-brand" href="">
<span class="brand-name"></span>
<span class="brand-go">进入店铺</span>
</a>
<a class="product-detail" href="">
<div>
<img class="product-detail-img" src="">
</div>
<div class="product-detail-text">
<div class="name">
<span class="product-name"></span>
</div>
<div class="price">
<span class="sale-price"></span>
<span class="market-price"></span>
</div>
</div>
</a>
</div>
<div class="feature-product-info">
<a class="product-brand" href="">
<span class="brand-name"></span>
<span class="brand-go">进入店铺</span>
</a>
<a class="product-detail" href="">
<div>
<img class="product-detail-img" src="">
</div>
<div class="product-detail-text">
<div class="name">
<span class="product-name"></span>
</div>
<div class="price">
<span class="sale-price"></span>
<span class="market-price"></span>
</div>
</div>
</a>
</div>
<div class="feature-product-info">
<a class="product-brand" href="">
<span class="brand-name"></span>
<span class="brand-go">进入店铺</span>
</a>
<a class="product-detail" href="">
<div>
<img class="product-detail-img" src="">
</div>
<div class="product-detail-text">
<div class="name">
<span class="product-name"></span>
</div>
<div class="price">
<span class="sale-price"></span>
<span class="market-price"></span>
</div>
</div>
</a>
</div>
<script src="//cdn.bootcss.com/jquery/1.8.3/jquery.min.js"></script>
<script src="../dist/js/coupon.js"></script>
<script src="../dist/js-sdk/1.0.0/jssdk.js"></script>
</body>
</html>
... ...
import $ from 'jquery';
import utils from './utils';
import user from './user';
import cookies from './cookies';
export default {
uid: '',
udid: '',
init() {
let that = this;
if (utils.isApp()) {
document.addEventListener('deviceready', function() {
window.yohoInterface.triggerEvent(function(data) {
that.uid= data.uid;
that.udid = data.udid;
// 获取个性话数据
that.getProduct();
}, function() {}, {
method: 'get.analyticAppData'
});
}, false);
} else {
that.uid = user.getUid();
that.udid = cookies.cookie('_yasvd');
// 获取个性话数据
that.getProduct();
}
},
getProduct() {
$.ajax({
url: '//m.yohobuy.com/activity/individuation',
data: {
uid: this.uid,
udid: this.udid
},
dataType: 'jsonp'
}).then((res)=> {
if (res && res.length) {
let data,
goods = $('.feature-product-info');
if (!goods.length) {
return;
}
// 获取图片宽x高
let imgwh = $('#imgwh').val();
imgwh = imgwh.split('x') || [];
let w = imgwh[0] || 300,
h = imgwh[1] || 300;
goods.each(function(idex, el) {
data = res[idex];
el = $(el);
el.find('.brand-name').html(data.brand_name);
el.find('a.product-brand').attr('href', `//m.yohobuy.com/product/index/brand?domain=${data.brand_domain}`);
el.find('a.product-detail').attr('href', `//m.yohobuy.com//product/pro_${data.product_id}_${data.goods_id}/${data.cn_alphabet}.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":${data.product_skn}}}`);
el.find('.product-detail-img').attr('src', utils.image(data.default_images, w, h, 2, 60));
el.find('.product-name').html(data.product_name);
el.find('.sale-price').html(${data.sales_price}`);
el.find('.market-price').html(${data.market_price}`);
});
}
});
}
};
\ No newline at end of file
... ...
... ... @@ -7,7 +7,9 @@ import promotion from './promotion';
import individuation from './individuation';
// init
$(function() {});
$(function() {
individuation.init();
});
export default {
getUid: user.getUid,
... ...
... ... @@ -2,12 +2,12 @@
// 2. YOHO币领取
import $ from 'jquery';
import util from './utils';
import utils from './utils';
export default {
getCoupon(data) {
if (util.isApp()) {
data.app = util.queryString();
if (utils.isApp()) {
data.app = utils.queryString();
}
$.ajax({
... ... @@ -16,19 +16,19 @@ export default {
data: data
}).then(function(res) {
if (res.code === 200) {
util.showTip({
utils.showTip({
title: '领取成功',
content: '恭喜您,领取成功',
close: true
});
} else if (res.code === 401) {
util.showTip({
utils.showTip({
title: '已经领取',
content: '快去分享给更多<br>喜爱<span class="highlight">潮流</span>的小伙伴吧!',
close: true
});
} else if (res.message) {
util.showTip({
utils.showTip({
title: '领取失败<br>请刷新重新领取',
content: res.message + '<br>如多次领取失败,请联系客服人员<br>带来不便敬请谅解',
close: false
... ... @@ -37,8 +37,8 @@ export default {
});
},
getCoin(data) {
if (util.isApp()) {
data.app = util.queryString();
if (utils.isApp()) {
data.app = utils.queryString();
}
return $.ajax({
... ... @@ -48,7 +48,7 @@ export default {
}).then(function(res) {
if (res.code === 200 && res.data) {
if (res.data.code === 200) {
util.showCoinTip({
utils.showCoinTip({
title: '恭喜您,成功领取有货币!',
content: '特殊情况下到账有延时<br>请耐心等待',
close: true,
... ... @@ -56,35 +56,35 @@ export default {
img: res.data.popupImg
});
} else if (res.data.code === 501) {
util.showCoinTip({
utils.showCoinTip({
title: '领取失败',
content: '哎呀,你来的有点早,活动还没开始呢<br/>稍后再来哦',
close: true,
img: res.data.popupImg
});
} else if (res.data.code === 502) {
util.showCoinTip({
utils.showCoinTip({
title: '领取失败',
content: '抱歉,活动已结束了,下次要快哟~~',
close: true,
img: res.data.popupImg
});
} else if (res.data.code === 503) {
util.showCoinTip({
utils.showCoinTip({
title: '已经领取',
content: '贪心会长胖,你已经领取过了啦~~',
close: true,
img: res.data.popupImg
});
} else if (res.data.code === 504) {
util.showCoinTip({
utils.showCoinTip({
title: '领取失败',
content: '哎呀,你来晚了,有货币已经领完了,<br/>下次早点来哦',
close: true,
img: res.data.popupImg
});
} else if (res.data.msg) {
util.showCoinTip({
utils.showCoinTip({
title: '领取失败',
content: '抱歉,系统错误,有货君正奋力解决中...请稍后再来',
close: true,
... ... @@ -92,7 +92,7 @@ export default {
});
}
} else if (res.message) {
util.showCoinTip({
utils.showCoinTip({
title: '领取失败',
content: '抱歉,系统错误,有货君正奋力解决中...请稍后再来',
close: true,
... ...
... ... @@ -3,7 +3,7 @@
// 3. 收藏商品
import $ from 'jquery';
import util from './utils';
import utils from './utils';
export default {
uid: '',
... ... @@ -11,18 +11,18 @@ export default {
if (this.uid) {
return this.uid;
}
if (!util.isApp()) {
if (!utils.isApp()) {
// 获取当前登录用户信息
$.ajax({
url: '//m.yohobuy.com/passport/login/user',
dataType: 'jsonp'
}).then(function(res) {
}).then((res)=> {
if (res.code === 200) {
this.uid = res.data;
}
});
} else {
this.uid = util.queryString().uid;
this.uid = utils.queryString().uid;
}
return this.uid;
... ... @@ -33,11 +33,11 @@ export default {
if (!uid) {
let referrer = location.href.split('?')[0];
if (!util.isApp()) {
if (!utils.isApp()) {
let qs = {
refer: referrer
};
return `//m.yohobuy.com/signin.html?${util.encode(qs)}`;
return `//m.yohobuy.com/signin.html?${utils.encode(qs)}`;
} else {
return '//m.yohobuy.com/signin.html?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + referrer.replace(/\//g, '\\/') + '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}';
}
... ... @@ -55,12 +55,12 @@ export default {
dataType: 'jsonp'
}).then(function(res) {
if (res.code === 200) {
util.showTip({
utils.showTip({
content: '恭喜您,收藏成功',
close: true
});
} else {
util.showTip({
utils.showTip({
content: res.message,
close: true
});
... ...
... ... @@ -39,7 +39,6 @@ export default {
for (i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
... ... @@ -82,6 +81,16 @@ export default {
}
return '';
},
image(url, width, height, mode, quality) {
mode = !isNaN(Number(mode)) ? mode : 2;
url = url || '';
url = url.replace(/{width}/g, width).replace(/{height}/g, height).replace(/{mode}/g, mode);
if (url.indexOf('imageView2') > 0) {
quality = quality || 90;
url += '/q/' + quality;
}
return url.replace('http:', '');
},
showTip(data) {
data = data || {
title: '',
... ...