Authored by 李奇

猜你喜欢修改

... ... @@ -10,6 +10,11 @@ const _ = require('lodash');
const model = require('../models/detail');
const searchModel = require('../models/search');
const GENDER = {
1: '1,3',
2: '2,3'
};
// 频道映射
const CHANNEL_MAP = {
men: 1,
... ... @@ -229,26 +234,42 @@ const component = {
},
/**
* 为你优选
* 猜你喜欢
* @param req
* @param res
* @param next
*/
prefer: (req, res, next) => {
let udid = req.sessionID;
let channel = req.query.channel || req.cookies._Channel || 'men';
let params = {
udid,
mightLike: (req, res, next) => {
const uid = req.user.uid;
if (!uid) {
return res.json({
code: 200,
data: []
});
}
const channel = req.query.channel || req.cookies._Channel || 'men';
const params = {
uid: req.user.uid,
page: req.query.page || 1,
limit: 20,
gender: GENDER[CHANNEL_MAP[channel]],
udid: req.sessionID ,
rec_pos: req.query.rec_pos || 100001,
yh_channel: CHANNEL_MAP[channel] || 1,
limit: 30,
page: 1,
rec_pos: 100003
client_id: req.cookies._yasvd || '1'
};
model.preferList(params)
.then((list) => {
res.json(list);
}).catch(next);
model.mightLike(params).then(result => {
if (result && result.code === 200) {
res.json({
code: 200,
data: result.data.product_list || [],
message: result.message
});
}
}).catch(next);
}
};
... ...
... ... @@ -147,21 +147,13 @@ const model = {
},
/**
* 为你优选
* 猜你喜欢
* @param params
* @param uid
* @returns {Array}
*/
preferList(params, uid) {
if (uid !== 0 && uid !== null) {
params.uid = uid;
}
mightLike(params) {
return api.get('', Object.assign({
method: 'app.home.newPreference'
}, params)).then(data => {
return _processProduct(data.data.product_list);
});
method: 'app.search.newLast7day'
}, params));
}
};
... ...
... ... @@ -47,7 +47,7 @@ router.get(/\/product\/pro_([\d]+)_([\d]+)\/(.*).html/, detail.index); // 商品
router.get(/\/product\/product_([\d]+)\.json/, detail.product);
router.get(/\/product\/intro_([\d]+)\.json/, detail.intro);
router.get('/product/refundExchange/:skn', detail.supportRefundExchange); // 是否支持7天无理由退换货
router.get('/product/prefer', detail.prefer); // 为你优选列表
router.get('/product/mightLike', detail.mightLike); // 猜你喜欢
router.post(/\product\/cart.json/, detail.addToCart);
router.post(/\product\/favorite.json/, auth, detail.favorite);
router.get(/\/product\/cart-count.json/, detail.getCartCount);
... ...
... ... @@ -18,16 +18,16 @@ module.exports = {
app_type: 1
},
domains: {
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
api: 'http://api-test2.yohops.com:9999/',
service: 'http://service-test2.yohops.com:9999/',
singleApi: 'http://api-test2.yohops.com:9999/',
/* api: 'http://dev-api.yohops.com:9999/',
service: 'http://dev-service.yohops.com:9999/',*/
// singleApi: 'http://192.168.102.27:8092/'
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
// singleApi: 'http://single.yoho.cn/'
// singleApi: 'http://192.168.102.205:8080/gateway/',//'http://single.yoho.cn/',
// api: 'http://192.168.102.205:8080/gateway/',//'http://api.yoho.cn/',
... ...
... ... @@ -2,7 +2,7 @@
<div class='title-wrap'>{{title}}</div>
<div class="list-wrap">
<div class="product-item" v-for="item in list">
<a :href="item.goodsUrl">
<a :href="item.url">
<img :src="item.default_images">
<p class="product-name">{{item.product_name}}</p>
</a>
... ...
... ... @@ -265,7 +265,7 @@
</div>
</show-box>
<show-box class="prefer-detail" :is-last="true">
<show-box class="prefer-detail" :is-last="true" v-if="preferList.length > 0s">
<prefer-list :title="preferTitle" :list="preferList"></prefer-list>
</show-box>
... ... @@ -359,27 +359,7 @@
isSoldOut: false,
isReady: false,
preferTitle: 'You Might Also Like',
preferList: [{
default_images: '',
sales_price: '100',
market_price: '200',
product_name: 'dfdfs哈哈哈上的符号倒计时的的胜多负少'
}, {
default_images: '',
sales_price: '100',
market_price: '200',
product_name: 'dfdfs哈哈哈上的符号倒计时的的胜多负少'
}, {
default_images: '',
sales_price: '100',
market_price: '200',
product_name: 'dfdfs哈哈哈上的符号倒计时的的胜多负少'
}, {
default_images: '',
sales_price: '100',
market_price: '200',
product_name: 'dfdfs哈哈哈上的符号倒计时的的胜多负少'
}],
preferList: [],
extSwitch: {
productInfo: false,
sizeInfo: false,
... ... @@ -449,6 +429,12 @@
url: location.href
});
},
getMightLike() {
$.get('/product/mightLike').then(res => {
this.preferList = res.data || [];
});
}
},
created() {
const self = this;
... ... @@ -459,6 +445,9 @@
self.showFeatureSelector = false;
});
// 猜你喜欢
this.getMightLike();
// 读取基础数据
$.get(`/product/product_${pid}.json`).then((result) => {
if (!result.data) {
... ... @@ -509,12 +498,6 @@
this.$set('intro.supportRefundExchange', support);
});
if(self.showPrefer) {
$.get('/product/prefer').then(list => {
self.preferList = list;
});
}
});
}
})
... ... @@ -527,6 +510,7 @@
this.refreshCart();
bus.$on('app.shoppingcart.refresh', this.refreshCart);
}
}
};
</script>
... ...