Authored by 陈轩

Merge remote-tracking branch 'origin/develop' into develop

Name | Path | Note
-------- | ------------------------------------ | ---------
首页 | / |
... ... @@ -34,10 +35,10 @@ yoho币 | /me/mycurrency |
退换货物流详情| /me/logistic?order_code=1609827614&type=refund|
--------------------------------------------------------------------------------
----
### order 常亮
Name | Note
---------|--------
-------- | ------
s_t_desc | 默认(最新)
s_p_asc | 价格升序
s_p_desc | 价格降序
... ...
... ... @@ -7,10 +7,14 @@
'use strict';
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const brandApi = require('./brand-api');
const logger = global.yoho.logger;
const _ = require('lodash');
const querystring = require('querystring');
const urlFormat = (path, qs) => {
return path + '?' + querystring.stringify(qs);
};
/**
* 处理品牌一览品牌列表数据
... ... @@ -101,7 +105,7 @@ const getCateListData = params => {
sub: []
};
if (_.isEmpty(cate.sub)) {
item.url = helpers.urlFormat('/list', {
item.url = urlFormat('/list', {
sort: item.sort,
sort_name: item.name,
gender: genderArr[categorykey]
... ... @@ -115,7 +119,7 @@ const getCateListData = params => {
id: item.id,
name: '全部' + item.name,
sort: item.sort,
url: helpers.urlFormat('/list', {
url: urlFormat('/list', {
sort: item.sort,
sort_name: item.name,
gender: genderArr[categorykey]
... ... @@ -130,7 +134,7 @@ const getCateListData = params => {
sort: sub.relation_parameter.sort,
url: ''
};
subitem.url = helpers.urlFormat('/list', {
subitem.url = urlFormat('/list', {
sort: subitem.sort,
sort_name: subitem.name,
gender: genderArr[categorykey]
... ...
... ... @@ -17,12 +17,12 @@ const camelCase = global.yoho.camelCase;
const component = {
index(req, res) {
res.render('detail', {
module: 'news',
module: 'editorial',
page: 'detail',
newsId: req.params[0]
editorialId: req.params[0]
});
},
news(req, res, next) {
editorial(req, res, next) {
const id = req.params[0];
let params = {
... ...
... ... @@ -14,20 +14,20 @@ module.exports = {
/* 资讯首页 */
index: (req, res) => {
res.render('index', {
module: 'news',
module: 'editorial',
page: 'index'
});
},
/* 获取资讯列表数据 */
getNewsList: (req, res, next) => {
getEditorialList: (req, res, next) => {
let params = {
page: req.body.page,
channel: req.body.channel,
uid: req.user.uid
};
listModel.newsList(params).then(result => {
listModel.editorialList(params).then(result => {
res.json(result);
}).catch(next);
}
... ...
... ... @@ -23,7 +23,7 @@ const yhChannel = {
module.exports = {
/* 资讯列表页数据获取 */
getNewsListData(params) {
getEditorialListData(params) {
return serviceAPI.get('guang/api/v2/article/getList', {
sort_id: '',
gender: yhChannel[params.channel || 'all'].channel,
... ...
... ... @@ -8,7 +8,7 @@
const logger = global.yoho.logger;
const api = global.yoho.API;
const newsListApi = require('./list-api');
const editorialListApi = require('./list-api');
const camelCase = global.yoho.camelCase;
/**
... ... @@ -16,11 +16,11 @@ const camelCase = global.yoho.camelCase;
* @param params
* @returns {*|Promise.<TResult>}
*/
const newsList = params => {
const editorialList = params => {
let finalResult = {};
return api.all([
newsListApi.getNewsListData(params)
editorialListApi.getEditorialListData(params)
]).then(result => {
if (result[0].code === 200 && result[0].data.list) {
Object.assign(finalResult, {
... ... @@ -31,7 +31,7 @@ const newsList = params => {
code: 200
});
} else {
logger.error('getNewsListData api code no 200');
logger.error('getEitorialListData api code no 200');
}
return camelCase(finalResult);
... ... @@ -39,5 +39,5 @@ const newsList = params => {
};
module.exports = {
newsList
editorialList
};
... ...
/**
* router of sub app news
* router of sub app editorial
* @author: Aiden Xu<aiden.xu@yoho.cn>
* @date: 2016/07/25
*/
... ... @@ -10,18 +10,18 @@ const expressRouter = require('express').Router;
const cRoot = './controllers';
const router = expressRouter();
const editorial = require(`${cRoot}/index`);
router.get('/list', editorial.index); // 首页
router.post('/list.json', editorial.getEditorialList); // 获取资讯数据
// 详情controller
const detail = require(`${cRoot}/detail`);
router.get(/\/([\d]+)(.*)/, detail.index); // 详情routers
router.get(/news_(\d+)\.json/, detail.news);
router.get(/\/([\d]+).html/, detail.index); // 详情routers
router.get(/editorial_(\d+)\.json/, detail.editorial);
router.get(/like_(\d+)\.json/, detail.like);
router.get(/favorite_(\d+)\.json/, detail.favorite);
router.get(/misc_(\d+)\.json/, detail.misc);
const news = require(`${cRoot}/index`);
router.get('', news.index); // 首页
router.post('/list.json', news.getNewsList); // 获取资讯数据
module.exports = router;
... ...
<div id="app" class="news-page" data-news-id="{{newsId}}">
<div id="app" class="editorial-page" data-editorial-id="{{editorialId}}">
<app/>
</div>
... ...
... ... @@ -10,6 +10,8 @@ const search = {
method: 'app.search.li'
}, params);
delete data.client_type;
delete data.client_secret;
return api.post('', data, {
cache: true,
code: 200
... ...
... ... @@ -10,7 +10,7 @@ module.exports = app => {
app.use('/', require('./apps/product')); // 商品模块
app.use('/', require('./apps/me')); // 个人中心
app.use('/api', require('./apps/api')); // 各模块公有 API
app.use('/news', require('./apps/news')); // 资讯
app.use('/editorial', require('./apps/editorial')); // 资讯
// 组件示例
if (!app.locals.proEnv) {
... ...
... ... @@ -24,7 +24,7 @@ const titleMap = {
action: ''
},
title: {
des: 'BLK',
des: '',
action: ''
}
},
... ... @@ -34,7 +34,7 @@ const titleMap = {
action: ''
},
title: {
des: 'BLK',
des: '',
action: ''
},
right: {
... ... @@ -48,7 +48,7 @@ const titleMap = {
action: ''
},
title: {
des: 'BLK',
des: '',
action: ''
},
right: {
... ... @@ -89,7 +89,7 @@ const titleMap = {
6: {
headerid: '6',
title: {
des: '资讯6',
des: '资讯',
action: ''
}
}
... ... @@ -97,10 +97,16 @@ const titleMap = {
const matchHeader = (url) => {
let header = {
headerid: '-1' // 默认不显示头部
headerid: '-1'
};
let path = url.split('?')[0];
if (/\/cate-all$/.test(path)) {
header = titleMap[1];
header.title.des = '全部分类';
return header;
}
if (/\/me\/mydetails$/.test(path)) {
header = titleMap[1];
header.title.des = '个人信息';
... ... @@ -201,12 +207,12 @@ module.exports = (url) => {
}
// 资讯
if (/\/news$/.test(path)) {
if (/\/editorial\/list$/.test(path)) {
return yoho.goTab({index: 2});
}
// 品牌 品类
if (/\/brands$/.test(path) || /\/cate$/.test(path)) {
if (/\/brand$/.test(path) || /\/cate$/.test(path)) {
return yoho.goTab({index: 1});
}
... ...
... ... @@ -25,7 +25,7 @@ const cate = {
};
/* TODO 资讯列表资源位 */
const news = {
const editorial = {
all: 'd4fdfcad1ec877d466d9780efaf4d296',
men: 'e1f8dce8cb9de1a0977479c13c4d3dcc',
women: '5c0b9963d8b75e6fd788a2b49402be14'
... ... @@ -35,5 +35,5 @@ module.exports = {
channel,
brand,
cate,
news
editorial
};
... ...
const Vue = require('vue');
const lazyload = require('vue-lazyload');
const app = require('news/detail.vue');
const app = require('editorial/detail.vue');
new Vue({
el: '#app',
... ...
... ... @@ -8,7 +8,7 @@ const Vue = require('vue');
const lazyload = require('vue-lazyload');
const infinitScroll = require('vue-infinite-scroll');
const indexBox = require('news/index-box.vue');
const indexBox = require('editorial/index-box.vue');
Vue.use(lazyload);
Vue.use(infinitScroll);
... ...
<template>
<top-nav :id="id" :article="article"></top-nav>
<div class="show-box no-padding first-box">
<div class="news-box">
<div class="editorial-box">
<h1>{{article.articleTitle}}</h1>
<div class="status-bar">
<span class="icon icon-timeshare"></span><span class="label">{{article.publishTime | formatUnixTime 'MM.DD HH:mm'}}</span>
... ... @@ -52,7 +52,7 @@
<style class="scss" scoped>
$bgcolor: #fff;
.news-page {
.editorial-page {
background: #f6f6f6;
}
... ... @@ -78,7 +78,7 @@
margin-bottom: 0;
}
.news-box {
.editorial-box {
padding: 30px;
background: $bgcolor;
}
... ... @@ -201,12 +201,12 @@
};
},
init() {
const newsId = $('#app').data('newsId');
const editorialId = $('#app').data('editorialId');
this.id = newsId;
this.id = editorialId;
let loadDeferred = null;
$.get(`/news/news_${newsId}.json`).then(result => {
$.get(`/editorial/editorial_${editorialId}.json`).then(result => {
const article = result[0],
content = result[1],
brands = result[2],
... ...
<template>
<resources v-bind:content-code.sync="contentCode"></resources>
<div v-infinite-scroll="getNewsList()" infinite-scroll-disabled="scrollDisabled">
<div v-for="news in newsList" class="news-box">
<div v-for="editorial in editorialList" class="editorial-box">
<div class="img">
<a href='{{"/news/" + news.id}}'>
<img v-lazy="news.src | resize 750 470" alt="" />
<a href='{{"/editorial/" + editorial.id + ".html"}}'>
<img v-lazy="editorial.src | resize 750 470" alt="" />
</a>
</div>
<div class="title"><a href='{{"/news/" + news.id}}'>{{news.title}}</a></div>
<div class="news-des">
{{news.intro}}
<div class="title"><a href='{{"/editorial/" + editorial.id + ".html"}}'>{{editorial.title}}</a></div>
<div class="editorial-des">
{{editorial.intro}}
</div>
<hr>
<div class="bottom clearfix">
<span class="icon time-icon">&#xe612;</span>
<span class="time">{{news.publishTime}}</span>
<span class="icon icon-share share" @click="share(news.title, news.intro, news.src, news.share.url)"></span>
<span class="time">{{editorial.publishTime}}</span>
<span class="icon icon-share share" @click="share(editorial.title, editorial.intro, editorial.src, editorial.share.url)"></span>
</div>
</div>
</div>
</template>
<style>
.news-box {
.editorial-box {
background: #f6f6f6;
.img {
... ... @@ -42,7 +42,7 @@
padding: 10px 20px;
}
.news-des {
.editorial-des {
background: #fff;
padding: 10px 20px;
color: #939393;
... ... @@ -77,8 +77,8 @@
module.exports = {
data() {
return {
contentCode: contentCode.news[qs.channel || 'all'],
newsList: [],
contentCode: contentCode.editorial[qs.channel || 'all'],
editorialList: [],
page: 0,
scrollDisabled: false
};
... ... @@ -93,17 +93,17 @@
/* 获取资讯列表数据 */
getNewsList() {
$.post({
url: '/news/list.json',
url: '/editorial/list.json',
data: {
page: this.page++,
channel: qs.channel || 'all'
}
}).done(result => {
if (result.code === 200) {
if (this.newsList.length > 0 && result.data.list.length > 0) {
this.$set('newsList', this.newsList.concat(result.data.list));
if (this.editorialList.length > 0 && result.data.list.length > 0) {
this.$set('editorialList', this.editorialList.concat(result.data.list));
} else {
this.newsList = result.data.list;
this.editorialList = result.data.list;
}
} else {
this.scrollDisabled = true;
... ...
... ... @@ -55,7 +55,7 @@
},
methods: {
like: function() {
$.get(`/news/like_${this.article.id}.json`, {
$.get(`/editorial/like_${this.article.id}.json`, {
flag: !this.isLiked
}, (results)=> {
const result = results[0], misc = results[1];
... ... @@ -70,7 +70,7 @@
});
},
favorite: function() {
$.get(`/news/favorite_${this.article.id}.json`, {
$.get(`/editorial/favorite_${this.article.id}.json`, {
flag: !this.isFavorite
}, (results)=> {
const result = results[0], misc = results[1];
... ... @@ -108,7 +108,7 @@
}
},
created() {
$.get(`/news/misc_${this.id}.json`).then(result => {
$.get(`/editorial/misc_${this.id}.json`).then(result => {
if (result.code === 200) {
this.isFavorite = result.data.isFavor === 'Y';
this.isLiked = result.data.isPraise === 'Y';
... ...