Authored by 李靖

开发完成

'use strict';
const materialModel = require('../models/material-new');
const headerModel = require('../../../doraemon/models/header'); // 头部model
exports.list = (req, res, next) => {
let responseData = {
pageHeader: headerModel.setNav({
navTitle: '商品素材列表页',
}),
title: '商品素材列表页',
module: '3party',
page: 'material-new',
width750: true,
localCss: true
};
let params = {
uid: req.user.uid,
page: 1,
isApp: req.yoho.isApp,
unionType: req.query.union_type
};
req.ctx(materialModel).canLogin(params).then(result => {
if (result === 'N') {
return next();
} else {
req.ctx(materialModel).list(params).then(list => {
res.render('material-new', Object.assign(responseData, list));
}).catch(next);
}
}).catch(next);
};
exports.moreGoods = (req, res, next) => {
let params = {
page: req.query.page || 2,
isApp: req.yoho.isApp,
unionType: req.query.union_type
};
req.ctx(materialModel).list(params).then(result => {
res.json(result);
}).catch(next);
};
... ...
'use strict';
const platformApi = new global.yoho.ApiBase(global.yoho.config.domains.platformApi, {
name: 'imCs',
cache: global.yoho.cache,
useCache: false
});
const _ = require('lodash');
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
class materialModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
canLogin(params) {
return platformApi.get('/platform/product/material/canlogin', {
uid: params.uid
}).then(result => {
if (result && result.code === 200) {
return result.data.canLogin;
}
});
}
list(params) {
let options = {
data: {
method: 'app.search.li',
type: 'default'
},
param: {
code: 200
}
};
return this.get(options).then(result => {
if (result && result.code === 200) {
let resu = {
goods: []
};
if (result && result.data && result.data.product_list) {
let build = [];
build = productProcess.processProductList(result.data.product_list || [], {
isApp: params.isApp,
showSimilar: false
});
if (params.unionType) {
_.forEach(build, (val) => {
let newUrl = val.url;
val.url = newUrl.replace('.html', `.html?union_type=${params.unionType}`);
});
}
resu.goods = build;
}
return resu;
}
});
}
}
module.exports = materialModel;
... ...
... ... @@ -13,7 +13,9 @@ const check = require(`${cRoot}/check`);
const question = require(`${cRoot}/question`);
const validateCode = require('../passport/controllers/validateCode');
const auth = require('../../doraemon/middleware/auth');
const material = require(`${cRoot}/material`);
// const material = require(`${cRoot}/material`);
const materialNew = require(`${cRoot}/material-new`);
// routers
... ... @@ -26,7 +28,6 @@ router.get('/questionnaire', auth, question.list);
router.post('/questionnaire/check', question.check);
router.post('/questionnaire/submit', question.submit);
router.get('/questionnaire/:id', auth, question.detail);
router.get('/material', auth, material.list);
router.get('/material/moreGoods', auth, material.moreGoods);
router.get('/material', auth, materialNew.list);
module.exports = router;
... ...
<div class="material-c reds-shop">
<div class="filter-box">
{{> product/filter-tab}}
{{> common/filter}}
</div>
<div id="all-goods" class="tab-panel active">
<div class="good-list-page yoho-page">
<div id="goods-container" class="goods-container">
<div class="default-goods container clearfix">
{{#goods}}
{{> common/goods}}
{{/goods}}
</div>
</div>
</div>
</div>
<input type="hidden" id="material-flag" value="material" />
</div>
... ...
... ... @@ -186,6 +186,11 @@ const _searchGoods = (params) => {
method = 'app.search.coupon';
}
// 物料商品列表增加
if (params.material === 'true') {
method = 'app.search.recommendProduct';
}
return api.get('', _.assign({
method: method
}, params), {
... ... @@ -248,8 +253,15 @@ const getSearchData = (params) => {
newList.list = productProcess.processProductList(result.data.product_list || [], {
isApp: params.isApp || (params.appVersion && params.appVersion !== 'false'),
gender: _coverChannel[params.coverChannel],
showSimilar: params.shop_id ? false : true
showSimilar: params.shop_id || params.material === 'true' ? false : true
});
if (params.unionType && (params.material === 'true')) {
_.forEach(newList.list, (val) => {
let newUrl = val.url;
val.url = newUrl.replace('.html', `.html?union_type=${params.unionType}`);
});
}
if (result.data.rec_shop_list && result.data.rec_shop_list.length > 0 &&
!params.shop_id && !params.brand && !params.isApp) {
... ...
'use strict';
import {
Controller
} from 'yoho-mvc';
const allProduct = require('../../product/shop/all-product');
const lazyLoad = require('yoho-jquery-lazyload');
class MaterialController extends Controller {
constructor() {
super();
allProduct.getFilter();
lazyLoad($('img.lazy'));
}
}
module.exports = MaterialController;
... ...
require('3party/material-new.page.css');
const MaterialNewController = require('./controller');
new MaterialNewController();
... ...
... ... @@ -55,6 +55,19 @@ let isScrollLoad = false; // 是否是滚动加载
let page = 1; // 页码
let nav;
// 物料商品列表标记
if ($('#material-flag').val() === 'material') {
let material = true;
if ($('.first-li-more').hasClass('active')) {
page = 2; // 已默认加载第一页
}
Object.assign(defaultOpt, {
material: material,
unionType: window.queryString.union_type
});
}
/**
* 处理筛选参数
*/
... ...
@import "common/good";
@import "common/filter";
@import "../product/shop/reds-shop/nav";
.reds-shop {
.filter-box {
display: block;
}
}
.material-c {
position: relative;
.first-li-more {
.drop {
display: none;
}
}
}
.no-result-new {
text-align: center;
padding-top: 90px;
padding-bottom: 110px;
p {
color: #ccc;
margin-bottom: 25px;
font-size: 26px;
&:first-child {
color: #444;
font-size: 32px;
}
}
}
.search-divide {
height: 50px;
width: 100%;
padding: 10px 0;
color: #ccc;
text-align: center;
}
... ...