Authored by 刘传洋

guang detail

... ... @@ -6,9 +6,9 @@
'use strict';
// const _ = require('lodash');
const _ = require('lodash');
const channelModel = require('../models/index');
const guangModel = require('../models/index');
const headerModel = require('../../../doraemon/models/header');
const cookie = global.yoho.cookie;
const ghelper = require('../models/guang-helper');
... ... @@ -23,7 +23,7 @@ exports.index = (req, res, next) => {
let pageSize = req.query.pageSize || 20;
let type = req.query.type || 0;
let pathNav = channelModel.getPathNav(channel);
let pathNav = guangModel.getPathNav(channel);
let uid = cookie.getUid(req);
let udid = ghelper.getUdid(req);
let gender = ghelper.getGenderByCookie(req);
... ... @@ -33,12 +33,12 @@ exports.index = (req, res, next) => {
});
Promise.all([
channelModel.getBanner(channel),
channelModel.getCategory(type),
channelModel.getArticleList(gender, type, uid, udid, page, '', '', pageSize),
channelModel.getHotTags(page, pageSize),
channelModel.getAds(channel),
channelModel.getExcellectRecos(gender, 1, 10),
guangModel.getBanner(channel),
guangModel.getCategory(type),
guangModel.getArticleList(gender, type, uid, udid, page, '', '', pageSize),
guangModel.getHotTags(page, pageSize),
guangModel.getAds(channel),
guangModel.getTjArticles(gender, 1, 10),
headerModel.requestHeaderData(channel)
]).then(ret => {
res.render('index', {
... ... @@ -55,9 +55,9 @@ exports.index = (req, res, next) => {
type: type,
pathNav: pathNav,
page: page,
total : (ret[2] && ret[2].total) || 0
total: (ret[2] && ret[2].total) || 0
},
headerData : ret[6]['headerData'] || ret[6]
headerData: ret[6]['headerData'] || ret[6]
});
}).catch(next);
... ... @@ -77,38 +77,40 @@ exports.tags = (req, res, next) => {
let udid = ghelper.getUdid(req);
let gender = ghelper.getGenderByCookie(req);
let channel = req.yoho.channel;
let pathNav = channelModel.getPathNav(channel, query);
let pathNav = guangModel.getPathNav(channel, query);
// $this->setWebNavHeader();
//$this->setTitle($query, true);
// $this->setTitle($query, true);
Promise.all([
channelModel.getBanner(channel),
//channelModel.getCategory(type),
channelModel.getArticleList(gender, 0, uid, udid, page, query, '', pageSize),
channelModel.getHotTags(1, 20),
channelModel.getAds(channel),
channelModel.getExcellectRecos(gender, 1, 10),
guangModel.getBanner(channel),
// guangModel.getCategory(type),
guangModel.getArticleList(gender, 0, uid, udid, page, query, '', pageSize),
guangModel.getHotTags(1, 20),
guangModel.getAds(channel),
guangModel.getTjArticles(gender, 1, 10),
headerModel.requestHeaderData(channel)
]).then(ret => {
res.render('tag', {
guang: {
slider: ret[0],
//msgTypes: ret[1],
// msgTypes: ret[1],
msgs: (ret[1] && ret[1].msgs) || ret[1],
hotTags: ret[2],
ads: ret[3],
exRecos: ret[4],
tag : query,
tag: query,
guangIndexPage: true,
pageSize: pageSize,
type: type,
pathNav: pathNav,
page: page,
total : (ret[1] && ret[1].total) || 0
total: (ret[1] && ret[1].total) || 0
},
headerData : ret[5]['headerData'] || ret[5]
headerData: ret[5]['headerData'] || ret[5]
});
}).catch(next);
};
... ... @@ -125,50 +127,50 @@ exports.editor = (req, res, next) => {
let uid = cookie.getUid(req);
let udid = ghelper.getUdid(req);
let pathNav = channelModel.getPathNav(channel);
let pathNav = guangModel.getPathNav(channel);
Object.assign(res.locals, {
page: 'editor'
});
//$this->setWebNavHeader();
// $this->setWebNavHeader();
// 设置标签页标题
//$authorName = $author['data']['name'];
//$this->setTitle($authorName, true, '');
// $authorName = $author['data']['name'];
// $this->setTitle($authorName, true, '');
let page = req.query.page || 1;
let pageSize = req.query.pageSize || 20;
Promise.all([
channelModel.getAuthor(authorId),
channelModel.getArticleList(gender, null, uid, udid, page, '', authorId, pageSize),
channelModel.getHotTags(1, 20),
channelModel.getAds(channel),
channelModel.getExcellectRecos(gender, 1, 10),
guangModel.getAuthor(authorId),
guangModel.getArticleList(gender, null, uid, udid, page, '', authorId, pageSize),
guangModel.getHotTags(1, 20),
guangModel.getAds(channel),
guangModel.getTjArticles(gender, 1, 10),
headerModel.requestHeaderData(channel)
]).then(ret => {
res.render('editor', {
guang: {
editor : {
avatar : ret[0] && ret[0]['avatar'],
name : ret[0] && ret[0]['name'],
intro : ret[0] && ret[0]['author_desc'],
info : '设计理念:时尚,线条流畅'
editor: {
avatar: ret[0] && ret[0]['avatar'],
name: ret[0] && ret[0]['name'],
intro: ret[0] && ret[0]['author_desc'],
info: '设计理念:时尚,线条流畅'
},
msgs: (ret[1] && ret[1].msgs) || ret[1],
hotTags: ret[2],
ads: ret[3],
exRecos: ret[4],
gender : gender,
gender: gender,
pageSize: pageSize,
pathNav: pathNav,
page: page,
total : (ret[1] && ret[1].total) || 0
total: (ret[1] && ret[1].total) || 0
},
guangList : true,
guangListPage : true,
headerData : ret[5]['headerData'] || ret[5]
guangList: true,
guangListPage: true,
headerData: ret[5]['headerData'] || ret[5]
});
}).catch(next);
};
... ... @@ -188,10 +190,12 @@ exports.detail = (req, res, next) => {
let gender = ghelper.getGenderByCookie(req);
let channel = req.yoho.channel;
if (!_.isNumber(id)) {
return next(new Error('文章不存在!'));
//return next(new Error('文章不存在!'));
//return next();
id = parseInt(id);
}
// $id = $this->param('id','');
// $id = 34374;
// if(empty($id)) {
... ... @@ -202,13 +206,10 @@ exports.detail = (req, res, next) => {
// $pjax = $this->get("_pjax");
// $limit = 20; //评论每页显示条数
/*if(pjax) {
return channelModel.getComment(id, page, pageSize).then(res => {
return res.render('comment', {
});
if(pjax) {
return guangModel.getArticleComments(id, page, pageSize).then(res => {
return res.render('comment', res);
});
}
// if ($pjax) {
... ... @@ -219,76 +220,101 @@ exports.detail = (req, res, next) => {
// $udid = $this->getUdid();
//登陆后自动收藏
if (col == 1 && uid > 0) {
InfoData::setFavorite($id, $uid);
guangModel.collectArticle(id, uid);
}
// $gender = Helpers::getGenderByCookie();
// $channel = Helpers::getChannelNameByCookie();
let info = InfoModel::articleInfo($id, $uid, $udid, $page, $gender, $channel, $limit);
// 判断参数是否有效, 无效会跳转到错误页面
if (!info['header']) {
return next(new Error('文章不存在'));
}
$data = array(
'guangDetailPage' => true,
'pathNav' => $info['pathNav'],
'guang' => array(
'id' => $id,
'header' => isset($info['header']) ? $info['header']: array(),
'content' => isset($info['content']) ? $info['content'] : array(),
'brands' => isset($info['brands']) ? $info['brands'] : array(),
'userInfo' => isset($info['userInfo']) ? $info['userInfo'] : array(),
'tag' => isset($info['tag']) ? $info['tag'] : array(),
//分享
'shareImg' => $info['header']['shareImg'],
'sharedTitle' => $info['header']['title'],
'shareDesc' => $info['header']['desc'],
'weixinUrl' => $info['header']['weixinUrl'],
'relatedPost' => isset($info['relatedPost']) ? $info['relatedPost'] : array(),
'commentInfo' => $this->getSession('comment_'.$udid),
'comment' => isset($info['comment']) ? $info['comment'] : array(),
'exRecos' => isset($info['exRecos']) ? $info['exRecos'] : array(),
'hotTags' => isset($info['hotTags']) ? $info['hotTags'] : array(),
'ads' => IndexModel::getAds($channel),
)
);
$this->setTitle($info['header']['title'].' | YOHO!BUY有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证');
$this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流');
$this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');
$this->setWebNavHeader($channel);
$this->_view->display('info', $data);
Promise.all([
channelModel.getAuthor(authorId),
channelModel.getArticle(id, uid, udid, page, gender, channel, pageSize),
channelModel.getHotTags(1, 20),
channelModel.getAds(channel),
channelModel.getExcellectRecos(gender, 1, 10),
headerModel.requestHeaderData(channel)
]).then(ret => {
res.render('editor', {
guang: {
editor : {
avatar : ret[0] && ret[0]['avatar'],
name : ret[0] && ret[0]['name'],
intro : ret[0] && ret[0]['author_desc'],
info : '设计理念:时尚,线条流畅'
},
msgs: (ret[1] && ret[1].msgs) || ret[1],
hotTags: ret[2],
ads: ret[3],
exRecos: ret[4],
guangModel.getArticleInfo(id).then(info => {
// 判断参数是否有效, 无效会跳转到错误页面
if (!info || !info.title) {
return new Error('文章不存在');
}
console.log(info);
let promises = [
headerModel.requestHeaderData(channel),
guangModel.getArticleContent(id),
guangModel.getHotTags(1, 20),
guangModel.getArticleComments(id, page, pageSize),
guangModel.getArticleBaseInfo(id, uid, udid),
guangModel.getArticleRelateBrand(id),
guangModel.getTjArticles(gender, 1, 10),
guangModel.getAds(channel)
];
if (info.author_id) {
promises.push(guangModel.getAuthor(info.author_id));
} else {
promises.push({});
}
if (info.tag) {
promises.push(guangModel.getRelateArticleList(id, info.tag, 2));
} else {
promises.push({});
}
let pathNav = guangModel.getPathNav(channel, info.article_title);
Promise.all(promises).then(ret => {
res.render('detail', {
guangDetailPage : true,
pathNav : pathNav,
headerData: ret[1]['headerData'] || ret[1],
guang : {
id : id,
header : Object.assign({}, info, info.authorId && ret[8] || {}, { commentNum : ret[3].commentNum }),
content : ret[1],
hotTags : ret[2],
comment : ret[3],
commentInfo : req.session['comment_' + udid], //$this->getSession('comment_'.$udid)
userInfo : ret[4],
brands : ret[5],
tag : info.tags,
relatedPost : ret[9],
exRecos : ret[6],
ads : ret[7],
//分享
shareImg : info.shareImg,
sharedTitle : info.title,
shareDesc : info.desc,
weixinUrl : info.weixinUrl
}
});
}).catch(next);
});
gender : gender,
pageSize: pageSize,
pathNav: pathNav,
page: page,
total : (ret[1] && ret[1].total) || 0
},
guangList : true,
guangListPage : true,
headerData : ret[5]['headerData'] || ret[5]
});
}).catch(next);*/
};
\ No newline at end of file
// $data = array(
// 'guangDetailPage' => true,
// 'pathNav' => $info['pathNav'],
// 'guang' => array(
// 'id' => $id,
// 'header' => isset($info['header']) ? $info['header']: array(),
// 'content' => isset($info['content']) ? $info['content'] : array(),
// 'brands' => isset($info['brands']) ? $info['brands'] : array(),
// 'userInfo' => isset($info['userInfo']) ? $info['userInfo'] : array(),
// 'tag' => isset($info['tag']) ? $info['tag'] : array(),
// //分享
// 'shareImg' => $info['header']['shareImg'],
// 'sharedTitle' => $info['header']['title'],
// 'shareDesc' => $info['header']['desc'],
// 'weixinUrl' => $info['header']['weixinUrl'],
// 'relatedPost' => isset($info['relatedPost']) ? $info['relatedPost'] : array(),
// 'commentInfo' => $this->getSession('comment_'.$udid),
// 'comment' => isset($info['comment']) ? $info['comment'] : array(),
// 'exRecos' => isset($info['exRecos']) ? $info['exRecos'] : array(),
// 'hotTags' => isset($info['hotTags']) ? $info['hotTags'] : array(),
// 'ads' => IndexModel::getAds($channel),
// )
// );
// $this->setTitle($info['header']['title'].' | YOHO!BUY有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证');
// $this->setKeywords('Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流');
// $this->setDescription('潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜');
// $this->setWebNavHeader($channel);
// $this->_view->display('info', $data);
};
... ...
... ... @@ -5,23 +5,23 @@
*/
'use strict';
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars');
var express = require('express'),
path = require('path'),
hbs = require('express-handlebars');
// glob = require('glob');
var app = express();
var app = express();
// set view engin
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
var partials = path.join(__dirname, './views'); // parent view root
var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root
var partials = path.join(__dirname, './views'); // parent view root
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
app.on('mount', function(parent) {
delete parent.locals.settings; // 不继承父 App 的设置
Object.assign(app.locals, parent.locals);
});
// let mhbs = hbs.create({
// extname: '.hbs',
... ... @@ -31,14 +31,14 @@ app.on('mount', function(parent) {
// helpers: global.yoho.helpers
// });
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [`${partials}/partial`, `${doraemon}/partial`],
helpers: global.yoho.helpers
}));
app.set('views', path.join(__dirname, 'views/action'));
app.engine('.hbs', hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [`${partials}/partial`, `${doraemon}/partial`],
helpers: global.yoho.helpers
}));
// register helper
// var helpersDir = path.join(__dirname, 'helpers');
... ... @@ -47,12 +47,12 @@ app.engine('.hbs', hbs({
// require(file);
// })
// require('./helpers/include')(app, mhbs);
require('./helpers/json');
require('./helpers/page');
require('./helpers/tpl');
require('./helpers/json');
require('./helpers/page');
require('./helpers/tpl');
// router
app.use(require('./router'));
app.use(require('./router'));
module.exports = app;
module.exports = app;
... ...
... ... @@ -39,14 +39,14 @@ const getGenderByCookie = (req) => {
/**
* 获取客户端唯一标识
*
*
* @return string
*/
const getUdid = (req) => {
let udid = req.cookies.suid;
let realIp;
/*if (!udid) {
/* if (!udid) {
$realIP = $this->_request->getServer('HTTP_X_REAL_IP');
if ($realIP) {
$udid = md5($realIP);
... ... @@ -58,7 +58,7 @@ const getUdid = (req) => {
}*/
return udid;
}
};
module.exports = {
... ...
... ... @@ -6,36 +6,36 @@
'use strict';
const _ = require('lodash');
const moment = require('moment');
// const dataMap = require('../../../config/data-map');
const helpers = global.yoho.helpers;
const serviceApi = global.yoho.ServiceAPI;
const searchApi = global.yoho.SearchAPI;
const cache = global.yoho.cache;
const KEY_WEB_GUANG_BANNER_DATA = 'key_web_guang_banner_data';//逛的首页banner
const KEY_WEB_GUANG_ADS_DATA = 'key_web_guang_ads_data';//逛的首页ads
const KEY_WEB_GUANG_BANNER_DATA = 'key_web_guang_banner_data';// 逛的首页banner
const KEY_WEB_GUANG_ADS_DATA = 'key_web_guang_ads_data';// 逛的首页ads
const URL_OPERATIONS_RESOURCE_GET = 'operations/api/v5/resource/get';
// const headerModel = require('../../../doraemon/models/header');
//guang banner code
// guang banner code
const BANNER_CODE = {
'boys': '15a288635c2ed9f6c807417be90f5d2d',
'girls': 'e14e12e35af8626650979f7af8a0de2b',
'lifestyle': '1d398e899f759c6d88971be680521a6f',
'kids': 'ad14ee01ad048ce308aa3ca416133d2a'
}
};
//逛 ads code
// 逛 ads code
const ADS_CODE = {
'boys': '41777aa7ac86347692c5aa0d394b2f59',
'girls': '722253573823ebb994e313e71b0a4fb9',
'lifestyle': '02568b6042510e4be739cc688dc7d6ae',
'kids': '1ffdd6ea22c58af52ee6408cd353c2d5'
}
};
/**
* 获取首页频道nav
... ... @@ -89,19 +89,19 @@ const getPathNav = (channelType, query) => {
}]
);
return query ? _.concat(path, [{ name : query, pathTitle : query}]) : path;
}
return query ? _.concat(path, [{ name: query, pathTitle: query}]) : path;
};
const _formatTag = (tagData, isApp, uid) => {
return {
tag : tagData['name'],
url : helpers.urlFormat('/tags/index', { query : tagData['name']}, 'guang') //urlencode(tagData['name'])
}
}
tag: tagData['name'],
url: helpers.urlFormat('/tags/index', { query: tagData['name']}, 'guang') // urlencode(tagData['name'])
};
};
/**
* 格式化资讯文章
*
*
* @param array $articleData 需要格式化的资讯数据
* @param bool $showTag 是否显示左上角标签
* @param mixed $isApp 是否显示分享,在APP客户端里嵌入需要传url链接
... ... @@ -111,11 +111,11 @@ const _formatTag = (tagData, isApp, uid) => {
*/
const _formatArticle = (articleData, showTag, isApp, showAuthor, uid) => {
if(showTag !== false) {
if (showTag !== false) {
showTag = true;
}
if(showAuthor !== false) {
if (showAuthor !== false) {
showAuthor = true;
}
... ... @@ -127,41 +127,41 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid) => {
let width, height, isSquareImage = true, tags = [];
width = height = 360;
if(articleData['conver_image_type'] === 2) {
if (articleData['conver_image_type'] === 2) {
width = 360;
height = 240;
isSquareImage = false;
}
let result = {
id : articleData.id,
classification :articleData.category_name,
isReco : articleData.is_recommended ? true : false,
url : isApp ? articleData.url : helpers.urlFormat(`/${articleData.id}.html`, null, 'guang'),
img : helpers.image(articleData.src, width, height, 1),
isSquareImg : isSquareImage,
title : articleData.title,
pTime : articleData['publish_time'],
pView : articleData['views_num'],
content : articleData['intro'],
showTags : showTag,
comment : articleData['comment_num']
}
id: articleData.id,
classification: articleData.category_name,
isReco: articleData.is_recommended ? true : false,
url: isApp ? articleData.url : helpers.urlFormat(`/${articleData.id}.html`, null, 'guang'),
img: helpers.image(articleData.src, width, height, 1),
isSquareImg: isSquareImage,
title: articleData.title,
pTime: articleData['publish_time'],
pView: articleData['views_num'],
content: articleData['intro'],
showTags: showTag,
comment: articleData['comment_num']
};
if(!articleData['author']){
if (!articleData['author']) {
articleData['author'] = {
name : '',
avatar : ''
}
name: '',
avatar: ''
};
}
result['author'] = articleData.author.name;
if (articleData['author']['author_id']) {
let author_id = articleData['author']['author_id'];
result['editorUrl'] = helpers.urlFormat('/Index/editor', {'author_id' : author_id}, 'guang');
result['editorUrl'] = helpers.urlFormat('/Index/editor', {'author_id': author_id}, 'guang');
}
if (articleData['tags']) {
for(let tag of articleData['tags']) {
for (let tag of articleData['tags']) {
tags.push(_formatTag(tag, isApp));
}
}
... ... @@ -170,9 +170,9 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid) => {
// 收藏
if (isApp) {
result['collect'] = {
isCollected : articleData['isFavor'] && articleData['isFavor'] === 'Y',
url : uid ? 'javascript:;' : articleData['url'].replace('"islogin":"N"', '"islogin":"Y"')
}
isCollected: articleData['isFavor'] && articleData['isFavor'] === 'Y',
url: uid ? 'javascript:;' : articleData['url'].replace('"islogin":"N"', '"islogin":"Y"')
};
} else { // 点赞
result['like'] = articleData['praise_num'];
result['liked'] = articleData['isPraise'] && articleData['isPraise'] === 'Y';
... ... @@ -184,7 +184,7 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid) => {
// 判断是否显示作者信息
if (showAuthor && articleData['author']) {
if (!isApp) {
articleData['author']['url'] = articleData['author']['url'];//Helpers::getFilterUrl($articleData['author']['url']);
articleData['author']['url'] = articleData['author']['url'];// Helpers::getFilterUrl($articleData['author']['url']);
}
result['author'] = articleData['author'];
}
... ... @@ -211,17 +211,17 @@ const _formatArticle = (articleData, showTag, isApp, showAuthor, uid) => {
}
}
return result;
}
};
const _formatAd = (adData, isApp, uid ) => {
const _formatAd = (adData, isApp, uid) => {
return {
img : helpers.image(adData['src'], 640, 640),
url : isApp ? adData['url'] : helpers.urlFormat('/info/index', { 'id' : adData['id'] }, 'guang'),
title : adData['title'],
bgColor : adData['bgColor']
}
}
img: helpers.image(adData['src'], 640, 640),
url: isApp ? adData['url'] : helpers.urlFormat('/info/index', { 'id': adData['id'] }, 'guang'),
title: adData['title'],
bgColor: adData['bgColor']
};
};
/**
* 获取页文章数据
... ... @@ -236,17 +236,17 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u
useCache = useCache || false;
let param = {
gender : gender,
page : page,
uid : uid,
udid : udid,
client_type : "web"
}
gender: gender,
page: page,
uid: uid,
udid: udid,
client_type: 'web'
};
// $param['private_key'] = Yohobuy::$privateKeyList['web'];
//param['client_secret'] =
// param['client_secret'] =
if(sortId) {
if (sortId) {
param.sort_id = sortId;
}
... ... @@ -254,49 +254,49 @@ const getArticleList = (gender, sortId, uid, udid, page, tag, authorId, limit, u
param.tag = tag;
}
if(_.isNumber(authorId)) {
if (_.isNumber(authorId)) {
param.author_id = authorId;
}
if(limit) {
if (limit) {
param.limit = limit;
}
let cache = useCache ? 300 : false;
return serviceApi.get('guang/api/v2/article/getList', param, {
cache : cache
cache: cache
}).then(res => {
if(res && res.data) {
if (res && res.data) {
let artList, adsList, total = 0;
if(res.data.total) {
if (res.data.total) {
total = _.parseInt(res.data.total);
}
if(res.data.list) {
if (res.data.list) {
let list = res.data.list;
if(list.artList) {
if (list.artList) {
artList = _.map(list.artList, it => {
return _formatArticle(it, true, false, false, uid);
});
}
}
if(list.adlist) {
if (list.adlist) {
adsList = _.map(list.artList, it => {
return _formatAd(it, true, false, false, uid);
});
}
}
}
return {
msgs : artList,
ads : adsList,
total : total
}
msgs: artList,
ads: adsList,
total: total
};
}
})
});
};
/**
... ... @@ -320,7 +320,7 @@ const getHotTags = (page, limit) => {
return _.map(tags, it => {
return {
tagName: it.tag_name,
url: helpers.urlFormat('/tags/index', { query : it.tag_name}, 'guang')
url: helpers.urlFormat('/tags/index', { query: it.tag_name}, 'guang')
};
});
});
... ... @@ -332,34 +332,34 @@ const getHotTags = (page, limit) => {
* @return {Object}
*/
const getAds = channelType => {
let contentCode = ADS_CODE[channelType] || ADS_CODE.boys;
let ckey = KEY_WEB_GUANG_ADS_DATA + '_' + contentCode;
//$data = Cache::get($key);
//if(empty($data)) {
//$resource = IndexData::getResourceData($contentCode);
return serviceApi.get(URL_OPERATIONS_RESOURCE_GET, {
content_code : contentCode
}).then(res => {
// $data = Cache::get($key);
// if(empty($data)) {
// $resource = IndexData::getResourceData($contentCode);
return serviceApi.get(URL_OPERATIONS_RESOURCE_GET, {
content_code: contentCode
}).then(res => {
let list = [];
if(res && res['code'] === 200 && res['data'] && res['data'][0] && res['data'][0]['data']) {
list = _.map(res['data'][0]['data'], (it) => {
return {
img : helpers.image(it.src, 640, 640, 1), //Images::getImageUrl($val['src'], 830, 327, 1),
url : it.url //Helpers::getUrlSafe($val['url']));
}
});
}
let list = [];
if (res && res['code'] === 200 && res['data'] && res['data'][0] && res['data'][0]['data']) {
list = _.map(res['data'][0]['data'], (it) => {
return {
img: helpers.image(it.src, 640, 640, 1), // Images::getImageUrl($val['src'], 830, 327, 1),
url: it.url // Helpers::getUrlSafe($val['url']));
};
});
}
//格式化数据
//Cache::set($key, $data, 1800);
return list.length > 5 ? list.slice(0, 4) : list;
});
//}
//master没有数据,资源位没有数据, 取二层缓存
// 格式化数据
// Cache::set($key, $data, 1800);
return list.length > 5 ? list.slice(0, 4) : list;
});
// }
// master没有数据,资源位没有数据, 取二层缓存
// if(empty($data)) {
// $data = Cache::get($key, 'slave');
// }
... ... @@ -375,29 +375,30 @@ const getBanner = channelType => {
let contentCode = BANNER_CODE[channelType] || BANNER_CODE.boys;
let ckey = KEY_WEB_GUANG_BANNER_DATA + '_' + contentCode;
//return cache.get(ckey).then((data) => {
// return cache.get(ckey).then((data) => {
// if(!data) {
return serviceApi.get(URL_OPERATIONS_RESOURCE_GET, {
content_code : contentCode
}).then(res => {
return serviceApi.get(URL_OPERATIONS_RESOURCE_GET, {
content_code: contentCode
}).then(res => {
let list = [];
if(res && res['code'] === 200 && res['data'] && res['data'][0] && res['data'][0]['data']) {
let list = [];
if (res && res['code'] === 200 && res['data'] && res['data'][0] && res['data'][0]['data']) {
list = _.map(res['data'][0]['data'], (it) => {
return {
img : helpers.image(it.src, 830, 327, 1), //Images::getImageUrl($val['src'], 830, 327, 1),
url : it.url //Helpers::getUrlSafe($val['url']));
}
});
list = _.map(res['data'][0]['data'], (it) => {
return {
img: helpers.image(it.src, 830, 327, 1), // Images::getImageUrl($val['src'], 830, 327, 1),
url: it.url // Helpers::getUrlSafe($val['url']));
};
});
// cache.set(); //Cache::set($key, $data, 3600);
}
return list;
});
//cache.set(); //Cache::set($key, $data, 3600);
}
return list;
})
// }
// return data;
//});
// });
};
const getCategory = currentSortId => {
... ... @@ -405,17 +406,17 @@ const getCategory = currentSortId => {
currentSortId = currentSortId || 0;
return serviceApi.get('guang/api/v1/category/get', {}).then(res => {
let list = [];
if(res && res.code === 200 && res.data) {
for(let cat of res.data) {
if(cat.name === '专题') {
if (res && res.code === 200 && res.data) {
for (let cat of res.data) {
if (cat.name === '专题') {
continue;
}
list.push({
typeId : cat.id,
type : cat.name,
isActive : cat.id == currentSortId,
navUrl : helpers.urlFormat('/index/index', { type : cat.id }, 'guang')
typeId: cat.id,
type: cat.name,
isActive: cat.id == currentSortId,
navUrl: helpers.urlFormat('/index/index', { type: cat.id }, 'guang')
});
}
}
... ... @@ -424,26 +425,29 @@ const getCategory = currentSortId => {
});
};
const getExcellectRecos = (gender, page, limit) => {
/**
* 得到推荐文章
*/
const getTjArticles = (gender, page, limit) => {
return serviceApi.get('guang/api/v2/article/getArticleByViewsNum', {
gender : gender,
page : page,
limit : limit
gender: gender,
page: page,
limit: limit
}).then(res => {
let list = [];
if(res && res['data']) {
for(let it of res['data']) {
if (res && res['data']) {
for (let it of res['data']) {
let reco = {
url : helpers.urlFormat(`/${it.id}.html`, {}, 'guang'), // Helpers::url('/'.$article['id'].'.html', '', 'guang'),
title : it['title']
url: helpers.urlFormat(`/${it.id}.html`, {}, 'guang'), // Helpers::url('/'.$article['id'].'.html', '', 'guang'),
title: it['title']
};
if(it['src']) {
reco['img'] = helpers.image(it.src, 90, 60, 1);//Images::getImageUrl($article['src'], 90, 60, 1);
if (it['src']) {
reco['img'] = helpers.image(it.src, 90, 60, 1);// Images::getImageUrl($article['src'], 90, 60, 1);
}
list.push(reco);
... ... @@ -452,33 +456,364 @@ const getExcellectRecos = (gender, page, limit) => {
return list;
});
}
};
/**
* 获取作者信息
*/
const getAuthor = authorId => {
return serviceApi.get('guang/service/v1/author/getAuthor', {
author_id : authorId
author_id: authorId
}, {
cache : 3600
cache: 3600
}).then(res => {
if(res && res['data']) {
if (res && res.data) {
let d = res.data;
return {
avatar : res['data']['avatar'],
name : res['data']['name'],
intro : res['data']['author_desc']
authorId : authorId,
avatar: d.avatar,
name: d.name,
intro: d.author_desc,
authorUrl : d.name ? helpers.urlFormat('/Index/editor', { 'author_id' : authorId }, 'guang') : ''
};
}
});
};
/**
* 获取文章基本信息,文章标题(不含内容)
*/
const getArticleInfo = aid => {
return serviceApi.get('guang/service/v2/article/getArticle', {
article_id : aid
}).then(res => {
if(res && res.code === 200 && res.data) {
let d = res.data;
let tags = [];
if (d.tags) {
for(let t of d.tags) {
tags.push(_formatTag(t));
}
}
return {
title : d.article_title,
time : moment(d.publish_time).format('YYYY年MM月DD HH:mm'), //date('Y年m月d日 H:i', $article['publish_time']),
click : d.pageViews,
shareImg : helpers.image(d.cover_image, 600, 600),
desc : d.article_summary,
weixinUrl : d.url,
tags : tags,
shareImg : 'http:' + helpers.image(d.cover_image, 600, 600)
}
}
});
}
const _articleContentFormat = {
goods : goods => {
let result = [],
productSkn = [],
arr = {}
_.forEach(goods, (val, key) => {
productSkn.push(val.id);
arr[val.id] = val.src;
})
if (productSkn.length > 0) {
return null; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// return searchApi.get('', {
// query : productSkn.join(',')
// }).then(products => {
// if (isset($product['data']['product_list'])) {
// $result = self::formatProduct($product['data']['product_list'], $arr);
// }
// return {};
// });
//$product = SearchData::searchElasticByCondition(array({'query' : productSkn.join(',')}));
} else {
return null;
}
},
goodsGroup : goodsGroup => {
$result = $groupSkn = array();
let result = {}, groupSkn = {};
_.forEach(goodsGroup, (val, key) => {
if(val && val.list) {
let productSkn = [];
let arr = {};
groupSkn[key] = [];
for(let it of val.list) {
groupSkn[key].push(it.id);
productSkn.push(it.id);
arr[it.id]=it.src;
}
if(productSkn.length) {
return null; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// $product = SearchData::searchElasticByCondition(array('query' => implode(',', $productSkn)));
// if (isset($product['data']['product_list'])) {
// $result[$key]['recos'] = array_slice(self::formatProduct($product['data']['product_list'], $arr), 0, 4);
// }
}
}
});
return result;
},
text : data => {
return data;
},
singleImage : data => {
if(data && data[0] && data[0]['src']) {
return {
pic : helpers.image(data[0]['src'], 640, 640)
}
}
return null;
},
smallPic : data => {
let result = { smallPic : [] };
_.forEach(data, (it, key) => {
if(key < 2) {
result.smallPic.push(helpers.image(it.src, 600, 600));
}
});
return result;
},
link : data => {
return {};
}
}
/**
* 获取文章内容详情
*/
const getArticleContent = aid => {
let result = {
content : []
},
index = 0;
return serviceApi.get('guang/service/v2/article/getArticleContent', {
article_id : aid
}).then(res => { //内容内推荐的商品
let gpromises = [], ggpromises = [];
if(res && res.contents) {
for(let cnt of res.contents) {
_.forEach(cnt, (it, key) => {
if(key === 'goods') {
//goods.push(_articleContentFormat.goods(it.data));
gpromises.push(_articleContentFormat.goods(it.data));
} else if(key === 'goodsGroup') {
for(let gg of it.data) {
ggpromises.push(_articleContentFormat.goodsGroup(gg.recos));
//goodsGroup.push(_articleContentFormat.goodsGroup(gg.recos));
}
} else {
let other = _.isFunction(_articleContentFormat[key]) ? _articleContentFormat[key](it.data) : '';
result.content.push(other);
}
})
}
}
index = gpromises.length;
return Promise.all(gpromises.concat(ggpromises)).then(ret => {
return ret;
});
}).then(res => {
let goodsResult,
goodsGroupResult;
let goods = [], goodsGroup = [];
goodsResult = res.slice(0, index);
goodsGroupResult = res.slice(index);
if(goods.length > 0) {
result.content['relatedReco'] = {
recos : goods
}
}
if(goodsGroup.length > 0) {
result.content['relatedReco'] = {
recos : goodsGroup
}
}
return result;
});
}
/**
* 判断用户是否收藏文章地址,应该是文章与用户关联的信息
* @param $articleId
* @param $uid
* @param $udid
* @param bool $onlyUrl
* @return mixed
*/
const getArticleBaseInfo = (aId, uid, udid) => {
return serviceApi.get('guang/api/v1/article/getArticleBaseInfo', {
id : aid,
uid : uid,
udid : udid
}).then(res => {
return {
isLike : res && res.isPraise === 'Y',
likeNum : res.praise_num || 0,
isCollected : res && res.isFavor === 'Y'
}
});
}
/**
* 文章相关品牌
* @param $articleId
* @param bool $onlyUrl
* @return mixed
*/
const getArticleRelateBrand = aid => {
return serviceApi.get('guang/service/v2/article/getBrand', {
article_id : aid
}).then(res => {
return _.map(res, it => {
return {
thumb : it.thumb, //Helpers::getUrlSafe($val['thumb']);
url : it.url //Helpers::getUrlSafe($val['url']);
}
});
});
}
/**
* 相关文章列表
* @param $articleId
* @param $tag
* @param int $limit
* @param bool $onlyUrl
* @return mixed
*/
const getRelateArticleList = (aId, tag, size) => {
size = size || 3;
return serviceApi.get('guang/service/v2/article/getOtherArticle', {
article_id : aid,
tags : tag,
limit : size
}).then(res => {
return res;
if(res && res.relate) {
return _.map(res.relate, it => {
return {
id : it.id,
title : it.title,
thumb : helpers.image(it.thumb, 264, 173, 1),
url : helpers.urlFormat(`/${it.id}.html`, null, 'guang')
}
});
}
});
}
/**
* 获取文章评论数据
*/
const getArticleComments = (aid, page, pageSize) => {
let result = {};
page = page || 1;
pageSize = pageSize || 20;
return serviceApi.get('guang/api/v1/comments/getList', {
article_id : aid,
page : page,
pageSize : pageSize
}).then(res => {
if(res && res.code === 200) {
result = {
commentNum : (res['data'] && res['data']['total']) || 0
}
let list = [];
if(result.commentNum > 0 && res['data']['list']) {
for(let it of res['data']['list']) {
list.push({
avatar : helpers.image(it.avator, 100, 100),
name : it.username,
content : it.content,
time : it.create_time
});
}
}
result.list = list;
return result;
}
});
}
/**
* 收藏文章
* @param $id
* @param $uid
* @return mixed
*/
const collectArticle = (aid, uid) => {
return serviceApi.get('guang/api/v1/favorite/setFavorite', {
article_id : aid,
uid : uid
}).then(res => {
return res;
})
}
module.exports = {
getArticleList: getArticleList,
getArticleList: getArticleList,
getHotTags: getHotTags,
getAds: getAds,
getBanner: getBanner,
getCategory: getCategory,
getExcellectRecos: getExcellectRecos,
getTjArticles: getTjArticles,
getPathNav: getPathNav,
getAuthor : getAuthor
getAuthor: getAuthor,
getArticleComments : getArticleComments,
collectArticle : collectArticle,
getArticleInfo : getArticleInfo,
getArticleContent : getArticleContent,
getArticleBaseInfo : getArticleBaseInfo,
getArticleRelateBrand : getArticleRelateBrand,
getRelateArticleList : getRelateArticleList,
getArticleComments : getArticleComments
};
... ...
... ... @@ -13,7 +13,7 @@ const guangController = require(`${cRoot}/index`);
router.get('/', guangController.index);
router.get('/index/index', guangController.index);
router.get('/detail/:id', guangController.detail); //guang/info/index
router.get('/detail/:id', guangController.detail); // guang/info/index
router.get('/tags/index', guangController.tags);
router.get('/Index/editor', guangController.editor);
... ...
<div class="home-page yoho-page {{pageType}}" data-page="{{pageType}}">
{{detailId}}<br/>
{{include "sub-tpl" name="LCY"}}
<div class="guang-detail-page guang-page yoho-page clearfix">
{{# guang}}
{{> common/path-nav}}
<div class="left-side detail-body" data-id="{{id}}">
{{# header}}
<div class="detail-title">{{title}}</div>
<div class="article-info clearfix">
<div class="article-author">
<div class="author-avatar">
<a href="{{authorUrl}}" target="_blank">
<img src="{{avatar}}">
</a>
</div>
</div>
<div class="author-info">
<a class="author-name" href="{{authorUrl}}">{{name}}</a>
</div>
<div class="article-status clearfix">
<span class="article-time">{{time}}</span>
<span class="article-click">点击:{{click}}</span>
<a href="#comment-info" id="article-comment" class="article-comment"><em class="comment-num">{{commentNum}}</em>条评论</a>
</div>
</div>
{{/ header}}
<div class="article-main">
{{# content}}
{{# pic}}
<div class="article-pic block">
<img class="lazy" data-original="{{.}}">
</div>
{{/ pic}}
{{# text}}
<div class="article-text block">
<p>{{{.}}}</p>
</div>
{{/ text}}
{{#if smallPic}}
<div class="article-small-pic block clearfix">
{{# smallPic}}
<img class="lazy" data-original="{{.}}">
{{/ smallPic}}
</div>
{{/if}}
{{# relatedReco}}
<div class="related-reco block clearfix">
<div class="block-header">
相关推荐
{{# moreReco}}
<a class="more-reco" href="{{.}}">MORE ></a>
{{/ moreReco}}
</div>
<div class="recos clearfix">
{{# recos}}
{{> product/good}}
{{/ recos}}
</div>
</div>
{{/ relatedReco}}
{{/ content}}
</div>
{{#if brands}}
<div class="related-brand block clearfix">
<div class="block-header">相关品牌</div>
<div class="brands">
{{# brands}}
<div class="brand">
<a class="thumb" href="{{url}}" target="_blank">
<img class="lazy" data-original="{{thumb}}">
</a>
<p class="brand-name">{{name}}</p>
</div>
{{/ brands}}
</div>
</div>
{{/if}}
{{# userInfo}}
<div class="user-handle">
<ul class="clearfix">
<li id="prise-btn" class="like-status{{#isLike}} liked{{/isLike}}">
<a href="javascript:;">
<i class="iconfont">&#xe626;</i>
<span class="like-num">{{likeNum}}</span>
</a>
</li>
<li id="collect-btn" class="sort-collect{{#isCollected}} collected{{/isCollected}}">
<a href="javascript:;">
<i class="iconfont">&#xe616;</i>
<span>收藏</span>
<span class="cancel-collect">取消收藏</span>
</a>
</li>
</ul>
</div>
{{/ userInfo}}
<div class="article-bottom-info clearfix">
{{#if tag}}
<div class="article-tag clearfix">
<i class="tag-icon iconfont">&#xe624;</i>
<ul class="clearfix">
{{# tag}}
<li>
<a href="{{url}}" target="_blank">{{name}}</a>
</li>
{{/ tag}}
</ul>
</div>
{{/if}}
<div class="article-share">
<span class="title pull-left">分享至:</span>
{{> share}}
</div>
</div>
{{#if relatedPost}}
<div class="detail-related-posts">
<ul class="clearfix">
{{# relatedPost}}
<li>
<a href="{{url}}" target="_blank">
<span class="bg-img">
<img src="{{thumb}}" alt="">
</span>
<div class="post-title">
<h2>{{title}}</h2>
</div>
</a>
</li>
{{/ relatedPost}}
</ul>
</div>
{{/if}}
<div id="comment-area" class="comment-area">
<div class="comment-textarea">
<textarea id="comment-info" placeholder="我有话要说。。。">{{commentInfo}}</textarea>
</div>
<div class="comment-publish clearfix">
<span id="word-count-tip" class="word-count-tip"></span>
<a id="comment-btn" class="publish-btn disable">评论</a>
</div>
<div id="pjax-container" class="comments-wrap">
{{> comment}}
</div>
</div>
</div>
<div class="right-side detail-side">
{{> right-side}}
</div>
{{/ guang}}
</div>
\ No newline at end of file
... ...
... ... @@ -18,6 +18,6 @@
</li>
{{/ list}}
</ul>
<div class="comment-pager pager">{{{commentPager}}}</div>
<div class="comment-pager pager">{{pager totalRecords=commentNum page=page type="ellipsis" theme="msg-pager"}}</div>
</div>
{{/ comment}}
... ...
*{margin: 0;padding: 0;list-style: none;}
/*
KISSY CSS Reset
理念:1. reset 的目的不是清除浏览器的默认样式,这仅是部分工作。清除和重置是紧密不可分的。
2. reset 的目的不是让默认样式在所有浏览器下一致,而是减少默认样式有可能带来的问题。
3. reset 期望提供一套普适通用的基础样式。但没有银弹,推荐根据具体需求,裁剪和修改后再使用。
特色:1. 适应中文;2. 基于最新主流浏览器。
维护:玉伯<lifesinger@gmail.com>, 正淳<ragecarrier@gmail.com>
*/
/** 清除内外边距 **/
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, /* structural elements 结构元素 */
dl, dt, dd, ul, ol, li, /* list elements 列表元素 */
pre, /* text formatting elements 文本格式元素 */
form, fieldset, legend, button, input, textarea, /* form elements 表单元素 */
th, td /* table elements 表格元素 */ {
margin: 0;
padding: 0;
}
/** 设置默认字体 **/
body,
button, input, select, textarea /* for ie */ {
font: 12px/1.5 tahoma, arial, \5b8b\4f53, sans-serif;
}
h1, h2, h3, h4, h5, h6 { font-size: 100%; }
address, cite, dfn, em, var { font-style: normal; } /* 将斜体扶正 */
code, kbd, pre, samp { font-family: courier new, courier, monospace; } /* 统一等宽字体 */
small { font-size: 12px; } /* 小于 12px 的中文很难阅读,让 small 正常化 */
/** 重置列表元素 **/
ul, ol { list-style: none; }
/** 重置文本格式元素 **/
a { text-decoration: none; }
a:hover { text-decoration: underline; }
/** 重置表单元素 **/
legend { color: #000; } /* for ie6 */
fieldset, img { border: 0; } /* img 搭车:让链接里的 img 无边框 */
button, input, select, textarea { font-size: 100%; } /* 使得表单元素在 ie 下能继承字体大小 */
/* 注:optgroup 无法扶正 */
/** 重置表格元素 **/
table { border-collapse: collapse; border-spacing: 0; }
/* 清除浮动 */
.ks-clear:after, .clear:after {
content: '\20';
display: block;
height: 0;
clear: both;
}
.ks-clear, .clear {
*zoom: 1;
}
.main {padding: 30px 100px;}
.main h1{font-size:36px; color:#333; text-align:left;margin-bottom:30px; border-bottom: 1px solid #eee;}
.helps{margin-top:40px;}
.helps pre{
padding:20px;
margin:10px 0;
border:solid 1px #e7e1cd;
background-color: #fffdef;
overflow: auto;
}
.icon_lists li{
float:left;
width: 100px;
height:180px;
text-align: center;
}
.icon_lists .icon{
font-size: 42px;
line-height: 100px;
margin: 10px 0;
color:#333;
-webkit-transition: font-size 0.25s ease-out 0s;
-moz-transition: font-size 0.25s ease-out 0s;
transition: font-size 0.25s ease-out 0s;
}
.icon_lists .icon:hover{
font-size: 100px;
}
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>IconFont</title>
<link rel="stylesheet" href="demo.css">
<link rel="stylesheet" href="iconfont.css">
</head>
<body>
<div class="main">
<h1>IconFont 图标</h1>
<ul class="icon_lists clear">
<li>
<i class="icon iconfont">&#xe624;</i>
<div class="name">评论</div>
<div class="code">&amp;#xe624;</div>
<div class="fontclass">.pinglun</div>
</li>
<li>
<i class="icon iconfont">&#xe618;</i>
<div class="name">左三角</div>
<div class="code">&amp;#xe618;</div>
<div class="fontclass">.zuosanjiao</div>
</li>
<li>
<i class="icon iconfont">&#xe619;</i>
<div class="name">右三角</div>
<div class="code">&amp;#xe619;</div>
<div class="fontclass">.yousanjiao</div>
</li>
<li>
<i class="icon iconfont">&#xe60b;</i>
<div class="name">向下</div>
<div class="code">&amp;#xe60b;</div>
<div class="fontclass">.chevron-down</div>
</li>
<li>
<i class="icon iconfont">&#xe60c;</i>
<div class="name">向右</div>
<div class="code">&amp;#xe60c;</div>
<div class="fontclass">.chevron-right</div>
</li>
<li>
<i class="icon iconfont">&#xe605;</i>
<div class="name">对号</div>
<div class="code">&amp;#xe605;</div>
<div class="fontclass">.duihao</div>
</li>
<li>
<i class="icon iconfont">&#xe61b;</i>
<div class="name">购物车</div>
<div class="code">&amp;#xe61b;</div>
<div class="fontclass">.gouwuche</div>
</li>
<li>
<i class="icon iconfont">&#xe60d;</i>
<div class="name"></div>
<div class="code">&amp;#xe60d;</div>
<div class="fontclass">.cha</div>
</li>
<li>
<i class="icon iconfont">&#xe61c;</i>
<div class="name">forbid</div>
<div class="code">&amp;#xe61c;</div>
<div class="fontclass">.forbid</div>
</li>
<li>
<i class="icon iconfont">&#xe60e;</i>
<div class="name">left</div>
<div class="code">&amp;#xe60e;</div>
<div class="fontclass">.left</div>
</li>
<li>
<i class="icon iconfont">&#xe614;</i>
<div class="name">sort</div>
<div class="code">&amp;#xe614;</div>
<div class="fontclass">.sort</div>
</li>
<li>
<i class="icon iconfont">&#xe625;</i>
<div class="name">时间</div>
<div class="code">&amp;#xe625;</div>
<div class="fontclass">.iconsj</div>
</li>
<li>
<i class="icon iconfont">&#xe60f;</i>
<div class="name">search</div>
<div class="code">&amp;#xe60f;</div>
<div class="fontclass">.search</div>
</li>
<li>
<i class="icon iconfont">&#xe615;</i>
<div class="name">三角2</div>
<div class="code">&amp;#xe615;</div>
<div class="fontclass">.sanjiao2</div>
</li>
<li>
<i class="icon iconfont">&#xe610;</i>
<div class="name">三角1</div>
<div class="code">&amp;#xe610;</div>
<div class="fontclass">.sanjiao1</div>
</li>
<li>
<i class="icon iconfont">&#xe608;</i>
<div class="name">向右</div>
<div class="code">&amp;#xe608;</div>
<div class="fontclass">.xiangyou</div>
</li>
<li>
<i class="icon iconfont">&#xe609;</i>
<div class="name">向左</div>
<div class="code">&amp;#xe609;</div>
<div class="fontclass">.xiangzuo</div>
</li>
<li>
<i class="icon iconfont">&#xe620;</i>
<div class="name">问号</div>
<div class="code">&amp;#xe620;</div>
<div class="fontclass">.wenhao</div>
</li>
<li>
<i class="icon iconfont">&#xe61d;</i>
<div class="name">向下</div>
<div class="code">&amp;#xe61d;</div>
<div class="fontclass">.xiangxia</div>
</li>
<li>
<i class="icon iconfont">&#xe621;</i>
<div class="name">电话</div>
<div class="code">&amp;#xe621;</div>
<div class="fontclass">.dianhua</div>
</li>
<li>
<i class="icon iconfont">&#xe60a;</i>
<div class="name">time</div>
<div class="code">&amp;#xe60a;</div>
<div class="fontclass">.time</div>
</li>
<li>
<i class="icon iconfont">&#xe626;</i>
<div class="name"></div>
<div class="code">&amp;#xe626;</div>
<div class="fontclass">.zan</div>
</li>
<li>
<i class="icon iconfont">&#xe607;</i>
<div class="name">up</div>
<div class="code">&amp;#xe607;</div>
<div class="fontclass">.up</div>
</li>
<li>
<i class="icon iconfont">&#xe611;</i>
<div class="name">Heart</div>
<div class="code">&amp;#xe611;</div>
<div class="fontclass">.heart</div>
</li>
<li>
<i class="icon iconfont">&#xe616;</i>
<div class="name">login_check_button1</div>
<div class="code">&amp;#xe616;</div>
<div class="fontclass">.logincheckbutton1</div>
</li>
<li>
<i class="icon iconfont">&#xe601;</i>
<div class="name">mail</div>
<div class="code">&amp;#xe601;</div>
<div class="fontclass">.aaa</div>
</li>
<li>
<i class="icon iconfont">&#xe61e;</i>
<div class="name">评论</div>
<div class="code">&amp;#xe61e;</div>
<div class="fontclass">.pinglun1</div>
</li>
<li>
<i class="icon iconfont">&#xe622;</i>
<div class="name">正确</div>
<div class="code">&amp;#xe622;</div>
<div class="fontclass">.zhengque</div>
</li>
<li>
<i class="icon iconfont">&#xe606;</i>
<div class="name">circle</div>
<div class="code">&amp;#xe606;</div>
<div class="fontclass">.circle</div>
</li>
<li>
<i class="icon iconfont">&#xe627;</i>
<div class="name">eye</div>
<div class="code">&amp;#xe627;</div>
<div class="fontclass">.eye</div>
</li>
<li>
<i class="icon iconfont">&#xe61f;</i>
<div class="name">03-叹号</div>
<div class="code">&amp;#xe61f;</div>
<div class="fontclass">.03tanhao</div>
</li>
<li>
<i class="icon iconfont">&#xe61a;</i>
<div class="name">home</div>
<div class="code">&amp;#xe61a;</div>
<div class="fontclass">.home</div>
</li>
<li>
<i class="icon iconfont">&#xe600;</i>
<div class="name">shopping-card</div>
<div class="code">&amp;#xe600;</div>
<div class="fontclass">.shoppingcard</div>
</li>
<li>
<i class="icon iconfont">&#xe617;</i>
<div class="name">checkbox-checked</div>
<div class="code">&amp;#xe617;</div>
<div class="fontclass">.checkboxchecked</div>
</li>
<li>
<i class="icon iconfont">&#xe623;</i>
<div class="name">五角星</div>
<div class="code">&amp;#xe623;</div>
<div class="fontclass">.wujiaoxing</div>
</li>
<li>
<i class="icon iconfont">&#xe612;</i>
<div class="name">select</div>
<div class="code">&amp;#xe612;</div>
<div class="fontclass">.zhengchang</div>
</li>
<li>
<i class="icon iconfont">&#xe613;</i>
<div class="name">selected</div>
<div class="code">&amp;#xe613;</div>
<div class="fontclass">.weibiaoti7</div>
</li>
<li>
<i class="icon iconfont">&#xe602;</i>
<div class="name">sya</div>
<div class="code">&amp;#xe602;</div>
<div class="fontclass">.say1</div>
</li>
<li>
<i class="icon iconfont">&#xe603;</i>
<div class="name">7days</div>
<div class="code">&amp;#xe603;</div>
<div class="fontclass">.7t11</div>
</li>
<li>
<i class="icon iconfont">&#xe604;</i>
<div class="name">zheng</div>
<div class="code">&amp;#xe604;</div>
<div class="fontclass">.z</div>
</li>
</ul>
<div class="helps">
第一步:使用font-face声明字体
<pre>
@font-face {font-family: 'iconfont';
src: url('iconfont.eot'); /* IE9*/
src: url('iconfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('iconfont.woff') format('woff'), /* chrome、firefox */
url('iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
url('iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */
}
</pre>
第二步:定义使用iconfont的样式
<pre>
.iconfont{
font-family:"iconfont" !important;
font-size:16px;font-style:normal;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;}
</pre>
第三步:挑选相应图标并获取字体编码,应用于页面
<pre>
&lt;i class="iconfont"&gt;&amp;#x33;&lt;/i&gt;
</pre>
</div>
</div>
</body>
</html>
... ...
... ... @@ -16,7 +16,7 @@ function shareBase(options) {
desc: '',
channel: ''
};
var shareChannels = ['weibo', 'tweibo', 'qzone', 'renren', 'qq', 'douban','weixin'];
var shareChannels = ['weibo', 'tweibo', 'qzone', 'renren', 'qq', 'douban', 'weixin'];
var sharebox;
var shareCon = '<em><i></i></em>';
... ...
... ... @@ -11,8 +11,8 @@ var $ = require('yoho-jquery'),
var $commentList = $commentArea.find('.comments-wrap'),
$commentNum = $('#article-comment > .comment-num'),
commenting = false, //评论请求尚未返回变量
locating = false, //评论页面正在跳转
commenting = false, // 评论请求尚未返回变量
locating = false, // 评论页面正在跳转
$commentBtn = $('#comment-btn'),
MAX_COMMENTS_WORDS = 100,
$wordCountTip = $('#word-count-tip');
... ... @@ -22,21 +22,21 @@ require('./img-blink');
require('../common/share');
//Pjax
// Pjax
require('yoho-jquery-pjax');
lazyLoad({
failure_limit: 50
});
//点击评论滑到评论区
// 点击评论滑到评论区
// $('#article-comment').click(function() {
// $('html, body').animate({
// scrollTop: $commentArea.offset().top - 20
// }, 800);
// });
//文章点赞与取消点赞
// 文章点赞与取消点赞
$('#prise-btn').click(function() {
var prising = false,
url,
... ... @@ -48,11 +48,11 @@ $('#prise-btn').click(function() {
$this.toggleClass('liked');
if ($this.hasClass('liked')) {
//点赞
// 点赞
url = '/guang/info/praise';
} else {
//取消点赞
// 取消点赞
url = '/guang/info/cancelPraise';
}
prising = true;
... ... @@ -72,7 +72,7 @@ $('#prise-btn').click(function() {
$(this).toggleClass('hover');
});
//文章收藏与取消收藏
// 文章收藏与取消收藏
$('#collect-btn').click(function() {
var collecting = false,
url,
... ... @@ -84,12 +84,12 @@ $('#collect-btn').click(function() {
}
if ($this.hasClass('collected')) {
//取消收藏
// 取消收藏
url = '/guang/info/cancelcollect';
col = 0;
} else {
//收藏
// 收藏
url = '/guang/info/collect';
col = 1;
}
... ... @@ -106,7 +106,7 @@ $('#collect-btn').click(function() {
switch (data.code) {
case 401:
//防止从已有col的页面再次进行跳转后出错的情况
// 防止从已有col的页面再次进行跳转后出错的情况
if (/\?col=(1|0)/.test(location.href)) {
hrefUrl = location.href.replace(/\?col=(1|0)/, '?col=' + col);
} else {
... ... @@ -121,7 +121,7 @@ $('#collect-btn').click(function() {
case 200:
if (/\?col=(1|0)/.test(location.href)) {
//如果页面url中含有col,为了防止页面刷新时收藏或者取消收藏会根据col来的问题,进行页面跳转拿掉参数
// 如果页面url中含有col,为了防止页面刷新时收藏或者取消收藏会根据col来的问题,进行页面跳转拿掉参数
location.href = location.href.replace(/\?col=(1|0)/, '');
} else {
$this.toggleClass('collected');
... ... @@ -147,7 +147,7 @@ function showComment() {
}
showComment();
//评论
// 评论
function comment(id) {
var commentInfo = $('#comment-info').val();
... ... @@ -179,7 +179,7 @@ function comment(id) {
$commentNum.html(data.data.count);
showComment();
//clear comment-text
// clear comment-text
$('#comment-info').val('').keyup();
}
break;
... ... @@ -191,12 +191,12 @@ function comment(id) {
$commentBtn.click(function(e) {
//页面正在跳转或者正在AJAX请求时评论无效
// 页面正在跳转或者正在AJAX请求时评论无效
if (locating || commenting) {
return false;
}
//字数不符合要求
// 字数不符合要求
if ($('#comment-info').val().length - MAX_COMMENTS_WORDS > 0) {
return;
}
... ... @@ -205,12 +205,12 @@ $commentBtn.click(function(e) {
});
//comment pager pjax
// comment pager pjax
$(document).pjax('.comment-pager a', '#pjax-container', {
timeout: 5000
});
//分页后移动到评论框的位置
// 分页后移动到评论框的位置
$(document).on('pjax:end', function() {
showComment();
$('html,body').scrollTop($('#comment-info').offset().top);
... ... @@ -235,5 +235,5 @@ $('#comment-info').keyup(function() {
$wordCountTip.html(showTxt);
});
//init
// init
$('#comment-info').trigger('keyup');
... ...
... ... @@ -6,4 +6,4 @@
require('./msg');
require('./img-blink');
require('./right-side');
\ No newline at end of file
require('./right-side');
... ...
... ... @@ -15,7 +15,7 @@ require('./img-blink');
require('./right-side');
$('#slider').slider(); //初始化slider
$('#slider').slider(); // 初始化slider
$(document).pjax('.pjax-link, .msg-pager a', '#pjax-container', {
timeout: 2000
... ... @@ -23,4 +23,4 @@ $(document).pjax('.pjax-link, .msg-pager a', '#pjax-container', {
$(document).on('pjax:end', function() {
msg.dotLazy();
});
\ No newline at end of file
});
... ...
... ... @@ -9,7 +9,7 @@ var $ = require('yoho-jquery');
$('.guang-page').on('mouseover', 'a img, a .bg-img', function(e) {
var $el = $(e.target);
//slider中的图片不做此效果
// slider中的图片不做此效果
if ($el.closest('.slider').length > 0) {
return;
}
... ...
... ... @@ -5,25 +5,25 @@ var prising;
require('yoho-jquery-dotdotdot');
//资讯文字截取和lazyload
// 资讯文字截取和lazyload
function dotLazy() {
//文字截取
// 文字截取
$('.msg-title, .msg-content .content').dotdotdot({
wrap: 'letter'
});
//Lazyload
// Lazyload
lazyLoad($('#msg-list img.lazy'));
}
//资讯点赞
// 资讯点赞
$('.guang-page').on('click', '.like-icon', function() {
var $this = $(this),
msgId = $this.closest('.msg-content').data('id'),
url;
//同一资讯多次点击归一处理
// 同一资讯多次点击归一处理
if (prising === msgId) {
return;
}
... ... @@ -32,7 +32,7 @@ $('.guang-page').on('click', '.like-icon', function() {
$this.toggleClass('liked');
//点赞或取消点赞
// 点赞或取消点赞
if ($this.hasClass('liked')) {
url = '/guang/info/praise';
} else {
... ... @@ -48,7 +48,7 @@ $('.guang-page').on('click', '.like-icon', function() {
}).then(function(data) {
if (data.code === 200) {
if (data.data * 1 === 0) {
$this.next('b').addClass('num-0').children('.num').html('0'); //隐藏数字显示
$this.next('b').addClass('num-0').children('.num').html('0'); // 隐藏数字显示
} else {
$this.next('b').removeClass('num-0').children('.num').html(data.data);
}
... ...
... ... @@ -10,4 +10,4 @@ $('.ex-reco-context').dotdotdot({
wrap: 'letter'
});
lazyLoad($('.ads img.lazy'));
\ No newline at end of file
lazyLoad($('.ads img.lazy'));
... ...
... ... @@ -6,4 +6,4 @@
require('./msg');
require('./img-blink');
require('./right-side');
\ No newline at end of file
require('./right-side');
... ...