Authored by 周少峰

home index async

1 { 1 {
2 "extends": "yoho", 2 "extends": "yoho",
3 "parserOptions": { 3 "parserOptions": {
4 - "sourceType": "module" 4 + "sourceType": "module",
  5 + "ecmaVersion": 2017
5 } 6 }
6 } 7 }
@@ -14,8 +14,20 @@ const getCommonHeader = (req, res, next) => { @@ -14,8 +14,20 @@ const getCommonHeader = (req, res, next) => {
14 }).catch(next); 14 }).catch(next);
15 }; 15 };
16 16
  17 +const getCommonHeaderNew = (req, res, next) => {
  18 + let channel = req.query.channel;
  19 + let uid = req.user.uid;
  20 + let clientService = _.get(req.app.locals.pc, 'clientService.new', false);
  21 +
  22 + let result = req.ctx(headerModel).getHomeNavNew(uid, channel, req.originalUrl, clientService);
  23 +
  24 + _.merge(res.locals, result);
  25 + next();
  26 +};
  27 +
17 module.exports = { 28 module.exports = {
18 - getCommonHeader 29 + getCommonHeader,
  30 + getCommonHeaderNew
19 }; 31 };
20 32
21 33
1 'use strict'; 1 'use strict';
2 2
3 const indexService = require('../models/index-service'); 3 const indexService = require('../models/index-service');
  4 +const _ = require('lodash');
4 5
5 const index = (req, res, next)=>{ 6 const index = (req, res, next)=>{
6 let uid = req.user.uid; 7 let uid = req.user.uid;
@@ -8,17 +9,61 @@ const index = (req, res, next)=>{ @@ -8,17 +9,61 @@ const index = (req, res, next)=>{
8 let channel = req.yoho.channel; 9 let channel = req.yoho.channel;
9 let isStudent = req.user.isStudent; 10 let isStudent = req.user.isStudent;
10 11
11 - req.ctx(indexService).index(uid, udid, channel, isStudent).then(result => { 12 + req.ctx(indexService).indexNew(uid, udid, channel, isStudent).then(result => {
  13 + _.merge(res.locals, result.header);
12 return res.render('index', { 14 return res.render('index', {
13 module: 'home', 15 module: 'home',
14 page: 'index', 16 page: 'index',
15 meIndexPage: true, 17 meIndexPage: true,
16 - me: result 18 + me: result.content
17 }); 19 });
18 }).catch(next); 20 }).catch(next);
19 }; 21 };
20 22
  23 +// 个人中心-首页-喜欢的品牌
  24 +async function brands(req, res) {
  25 + let brandsData = await req.ctx(indexService).brands();
  26 +
  27 + res.json({brands: brandsData, more: '/brands'});
  28 +}
  29 +
  30 +// 新品上架
  31 +async function newArrive(req, res) {
  32 + let arrive = await req.ctx(indexService).newArrive();
  33 +
  34 + res.json({newArrive: arrive});
  35 +}
  36 +
  37 +// 推荐
  38 +async function recommend(req, res) {
  39 + let uid = req.user.uid;
  40 + let udid = req.user.uid + req.yoho.udid;
  41 + let channelNum = req.yoho.channelNum;
  42 +
  43 + res.json({recommend: await req.ctx(indexService).recommend(uid, udid, channelNum)});
  44 +}
  45 +
  46 +// 头像和左侧菜单我的消息
  47 +async function newsAvatar(req, res) {
  48 + let uid = req.user.uid;
  49 + let result = await req.ctx(indexService).newsAvatar(uid);
  50 +
  51 + res.json(result);
  52 +}
  53 +
  54 +async function numbers(req, res) {
  55 + let uid = req.user.uid;
  56 + let result = await req.ctx(indexService).numbers(uid);
  57 +
  58 + res.json(result);
  59 +}
  60 +
21 module.exports = { 61 module.exports = {
22 - index 62 + index,
  63 + brands,
  64 + newArrive,
  65 + recommend,
  66 + newsAvatar,
  67 + numbers
23 }; 68 };
24 69
@@ -149,6 +149,43 @@ module.exports = class extends global.yoho.BaseModel { @@ -149,6 +149,43 @@ module.exports = class extends global.yoho.BaseModel {
149 }); 149 });
150 } 150 }
151 151
  152 + getHomeNavNew(uid, channel, url, clientSwitcher) {
  153 + let navs = this._getActiveNav(url, clientSwitcher, 1);
  154 + let activeNav = navs.activeNav;
  155 + let bread = [{href: helpers.urlFormat('/'), name: 'YOHO!BUY 有货首页'}];
  156 +
  157 + if (activeNav) {
  158 + bread.push({
  159 + name: '个人中心',
  160 + href: helpers.urlFormat('/home')
  161 + });
  162 +
  163 + bread.push({
  164 + name: activeNav.name
  165 + });
  166 +
  167 + // 订单详情
  168 + if (activeNav.curHref === '/home/orders/detail') {
  169 + Object.assign(_.last(bread), {
  170 + href: helpers.urlFormat('/home/orders')
  171 + });
  172 + bread.push({
  173 + name: '订单详情'
  174 + });
  175 + }
  176 + } else {
  177 + bread.push({
  178 + name: '个人中心'
  179 + });
  180 + }
  181 +
  182 + return {
  183 + path: bread,
  184 + homeNav: navs.homeNav,
  185 + userThumb: ''
  186 + };
  187 + }
  188 +
152 getHomeNav(uid, channel, url, clientSwitcher) { 189 getHomeNav(uid, channel, url, clientSwitcher) {
153 let that = this; 190 let that = this;
154 191
@@ -38,7 +38,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -38,7 +38,7 @@ module.exports = class extends global.yoho.BaseModel {
38 method: 'web.search.favorBrand' 38 method: 'web.search.favorBrand'
39 }; 39 };
40 40
41 - return this.get({data: options}); 41 + return this.get({data: options, param: {cache: 86400}});
42 } 42 }
43 43
44 newArrival() { 44 newArrival() {
@@ -84,13 +84,13 @@ module.exports = class extends global.yoho.BaseModel { @@ -84,13 +84,13 @@ module.exports = class extends global.yoho.BaseModel {
84 * @param string $mode 84 * @param string $mode
85 * @return mixed 85 * @return mixed
86 */ 86 */
87 - getByNodeContent(node, mode) { 87 + getByNodeContent(node, mode, params) {
88 let options = { 88 let options = {
89 method: 'web.html.content', 89 method: 'web.html.content',
90 mode: mode, 90 mode: mode,
91 node: node 91 node: node
92 }; 92 };
93 93
94 - return this.get({data: options}); 94 + return this.get({data: options, param: params || {}});
95 } 95 }
96 }; 96 };
@@ -9,6 +9,20 @@ const helpers = global.yoho.helpers; @@ -9,6 +9,20 @@ const helpers = global.yoho.helpers;
9 9
10 const OrderService = require('./orders-service'); 10 const OrderService = require('./orders-service');
11 const IndexApi = require('./index-api'); 11 const IndexApi = require('./index-api');
  12 +const UserApi = require('./user-api');
  13 +const MsgApi = require('./message');
  14 +const headerModel = require('../../../doraemon/models/header');
  15 +const cache = global.yoho.cache;
  16 +const cachePreKey = 'HOME_INDEX_';
  17 +const defaultAvatar = '//img10.static.yhbimg.com/headimg/' +
  18 + '2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100';
  19 +
  20 +
  21 +const numbersKey = {
  22 + pending: 'pengding',
  23 + unread: 'unread',
  24 + needComment: 'needComment'
  25 +};
12 26
13 const CHANNEL_NUM = { 27 const CHANNEL_NUM = {
14 boys: 1, 28 boys: 1,
@@ -164,7 +178,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -164,7 +178,7 @@ module.exports = class extends global.yoho.BaseModel {
164 _footerBanner() { 178 _footerBanner() {
165 const CODE = '20110609-152143'; 179 const CODE = '20110609-152143';
166 180
167 - return new IndexApi(this.ctx).getByNodeContent(CODE).then(banner => { 181 + return new IndexApi(this.ctx).getByNodeContent(CODE, {}, {cache: 86400}).then(banner => {
168 return _.get(banner, 'data', '').replace(/http:\/\//g, '//'); 182 return _.get(banner, 'data', '').replace(/http:\/\//g, '//');
169 }); 183 });
170 } 184 }
@@ -176,6 +190,126 @@ module.exports = class extends global.yoho.BaseModel { @@ -176,6 +190,126 @@ module.exports = class extends global.yoho.BaseModel {
176 return new OrderService(this.ctx).closeReason(); 190 return new OrderService(this.ctx).closeReason();
177 } 191 }
178 192
  193 + // 个人中心首页 异步获取新品上架数据
  194 + async newArrive() {
  195 + let arriveCaceKey = `${cachePreKey}arrive`;
  196 + let arrive = await cache.get(arriveCaceKey);
  197 +
  198 + if (!arrive) {
  199 + let arriveOrigin = await new IndexApi(this.ctx).newArrival();
  200 +
  201 + arrive = this._handleProduct(_.get(arriveOrigin, 'data.product_list', []));
  202 + if (!_.isEmpty(arrive)) {
  203 + cache.set(arriveCaceKey, arrive, 3600);
  204 + }
  205 + } else {
  206 + arrive = JSON.parse(arrive);
  207 + }
  208 +
  209 + return Promise.resolve(arrive);
  210 + }
  211 +
  212 + // 推荐数据
  213 + async recommend(uid, udid, channelNum) {
  214 + let recommendCaceKey = `${cachePreKey}recommend`;
  215 + let recommend = await cache.get(recommendCaceKey);
  216 +
  217 + if (!recommend) {
  218 + let recommendOrigin = await new IndexApi(this.ctx).recommend(channelNum, uid, udid, '100004', 30);
  219 +
  220 + recommend = this._handleProduct(_.get(recommendOrigin, 'data.product_list', []));
  221 + if (!_.isEmpty(recommend)) {
  222 + cache.set(recommendCaceKey, recommend, 3600);
  223 + }
  224 + } else {
  225 + recommend = JSON.parse(recommend);
  226 + }
  227 +
  228 + return Promise.resolve(recommend);
  229 + }
  230 +
  231 + // 个人中心首页 异步获取品牌数据
  232 + async brands() {
  233 + let brandsCaceKey = `${cachePreKey}brands`;
  234 + let brand = await cache.get(brandsCaceKey);
  235 +
  236 + if (!brand) {
  237 + let brandOrigin = await new IndexApi(this.ctx).guessBrand();
  238 +
  239 + brand = this._handleBrand(_.get(brandOrigin, 'data', []), 6);
  240 + if (!_.isEmpty(brand)) {
  241 + cache.set(brandsCaceKey, brand, 86400);
  242 + }
  243 + } else {
  244 + brand = JSON.parse(brand);
  245 + }
  246 +
  247 + return Promise.resolve(brand);
  248 + }
  249 +
  250 + // 个人中心异步查询我的消息和头像
  251 + async newsAvatar(uid) {
  252 + let result = await Promise.props(
  253 + {
  254 + profile: new UserApi(this.ctx).getUserInfo(uid),
  255 + msg: new MsgApi(this.ctx).unreadTotal(uid)
  256 + }
  257 + );
  258 + let avatar = helpers.image(_.get(result, 'profile.data.head_ico', ''), 100, 100) || defaultAvatar;
  259 + let msgCount = _.get(result, 'msg.data.total', 0);
  260 +
  261 + return Promise.resolve({avatar: avatar, msg: msgCount});
  262 + }
  263 +
  264 + // 首页顶部数量
  265 + async numbers(uid, udid) {
  266 + let result = {};
  267 + let numbers = await Promise.props({
  268 + pending: new IndexApi(this.ctx).pendingOrderCount(uid), // 待处理订单
  269 + unread: new IndexApi(this.ctx).unreadMessageCount(uid, udid), // 未读消息
  270 + needComment: new IndexApi(this.ctx).needCommentCount(uid) // 待评论商品
  271 + });
  272 +
  273 + result[numbersKey.pending] = _.get(numbers, 'pending.data.count', 0);
  274 + result[numbersKey.unread] = _.get(numbers, 'unread.data.inbox_total', 0);
  275 + result[numbersKey.needComment] = _.get(numbers, 'needComment.data', 0);
  276 +
  277 + return Promise.resolve(result);
  278 + }
  279 +
  280 +
  281 + // 个人中心首页同步数据
  282 + async indexNew(uid, udid, channel, isStudent) {
  283 + let indexData = await Promise.props({
  284 + header: headerModel.requestHeaderData(channel),
  285 + recentOrder: this._recentOrder(uid),
  286 + footerBanner: this._footerBanner(),
  287 + reason: this._cancelReason()
  288 + });
  289 +
  290 + return Object.assign(
  291 + {
  292 + content: {
  293 + content: {
  294 + messages: [
  295 + {href: helpers.urlFormat('/home/orders'), name: '待处理订单', id: numbersKey.pending, count: 0},
  296 + {href: helpers.urlFormat('/home/message'), name: '未读消息', id: numbersKey.unread, count: 0},
  297 + {href: helpers.urlFormat('/home/comment'), name: '待评论商品',
  298 + id: numbersKey.needComment, count: 0}
  299 + ],
  300 + certifiedName: +isStudent ? '学生身份已验证' : '身份验证',
  301 + certifiedUrl: helpers.urlFormat('/product/students/'),
  302 + latestOrders: Object.assign(indexData.recentOrder, {cancelReason: indexData.reason})
  303 + },
  304 + banner: indexData.footerBanner
  305 + }
  306 + },
  307 + {
  308 + header: indexData.header
  309 + }
  310 + );
  311 + }
  312 +
179 index(uid, udid, channel, isStudent) { 313 index(uid, udid, channel, isStudent) {
180 let that = this; 314 let that = this;
181 315
@@ -50,9 +50,27 @@ const invoiceController = require(`${cRoot}/invoice`); @@ -50,9 +50,27 @@ const invoiceController = require(`${cRoot}/invoice`);
50 50
51 const meGiftController = require(`${cRoot}/me-gift`); 51 const meGiftController = require(`${cRoot}/me-gift`);
52 52
  53 +const checkLogin = (res, req, next) => {
  54 + if (req.user.uid) {
  55 + return next();
  56 + } else {
  57 + if (res.xhr) {
  58 + res.json({code: 401, message: '未登录!'});
  59 + } else {
  60 + res.redirect('/login.html');
  61 + }
  62 + }
  63 +};
53 64
54 // 首页 65 // 首页
55 -router.get(['/index', '/'], tabsMiddleware.getCommonHeader, indexController.index); 66 +router.get(['/index', '/'], tabsMiddleware.getCommonHeaderNew, indexController.index);
  67 +router.get('/index/brands', checkLogin, indexController.brands);
  68 +router.get('/index/newArrive', checkLogin, indexController.newArrive);
  69 +router.get('/index/recommend', checkLogin, indexController.recommend);
  70 +router.get('/index/newsAvatar', checkLogin, indexController.newsAvatar);
  71 +router.get('/index/numbers', checkLogin, indexController.numbers);
  72 +
  73 +// router.get(['/index', '/'], tabsMiddleware.getCommonHeader, indexController.index);
56 74
57 // 查看二维码 75 // 查看二维码
58 router.get('/QRcode', tabsMiddleware.getCommonHeader, personalController.QRcode); 76 router.get('/QRcode', tabsMiddleware.getCommonHeader, personalController.QRcode);
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 消息提示: 10 消息提示:
11 {{# messages}} 11 {{# messages}}
12 <a href="{{href}}">{{name}}</a> 12 <a href="{{href}}">{{name}}</a>
13 - <b>({{count}})</b> 13 + <b id="{{id}}">({{count}})</b>
14 {{/ messages}} 14 {{/ messages}}
15 15
16 {{#unless @root.pc.user.removeStudentIdentification}} 16 {{#unless @root.pc.user.removeStudentIdentification}}
@@ -36,88 +36,86 @@ @@ -36,88 +36,86 @@
36 {{> home/orders/order-block}} 36 {{> home/orders/order-block}}
37 </div> 37 </div>
38 {{/ latestOrders}} 38 {{/ latestOrders}}
39 -  
40 - {{# favBrand}}  
41 - <div class="brands block">  
42 - <h2 class="title">  
43 - <a class="more-orders more" href="{{more}}">  
44 - 更多品牌  
45 - </a>  
46 - </h2>  
47 - <ul class="clearfix">  
48 - {{# brands}}  
49 - <li>  
50 - <a href="{{href}}">  
51 - <img class="brand-logo" src="{{logo}}">  
52 - <span class="brand-name">{{name}}</span>  
53 - </a>  
54 - </li>  
55 - {{/ brands}}  
56 - </ul> 39 + <div class="brands block" id="home-brands-box">
57 </div> 40 </div>
58 - {{/ favBrand}}  
59 -  
60 - {{#if newArrival}}  
61 - <div class="new-arrival block">  
62 - <h2 class="title">  
63 - <p class="na-pager-wrap">  
64 - <span class="na-pager pre no-visible">  
65 - <i class="iconfont">&#xe618;</i>  
66 - </span>  
67 - <span class="na-pager next">  
68 - <i class="iconfont">&#xe619;</i>  
69 - </span>  
70 - </p>  
71 - </h2>  
72 - <ul class="clearfix">  
73 - {{# newArrival}}  
74 - <li>  
75 - <a href="{{href}}">  
76 - <img class="thumb" src="{{thumb}}">  
77 - <p class="name">{{name}}</p>  
78 - <span class="price">¥{{price}}</span>  
79 - </a>  
80 - </li>  
81 - {{/ newArrival}}  
82 - </ul> 41 + <div class="new-arrival block" id="home-new-box">
83 </div> 42 </div>
84 - {{/if}}  
85 -  
86 -  
87 {{/ content}} 43 {{/ content}}
88 -  
89 -  
90 </div> 44 </div>
91 <!--recommend-for-you--> 45 <!--recommend-for-you-->
92 - {{#if recommend}}  
93 - <div class="recommend block">  
94 - <h2 class="title">  
95 - <p class="na-pager-wrap">  
96 - <span class="rc-pager pre no-visible">  
97 - <i class="iconfont">&#xe618;</i>  
98 - </span>  
99 - <span class="rc-pager next">  
100 - <i class="iconfont">&#xe619;</i>  
101 - </span>  
102 - </p>  
103 - </h2>  
104 - <ul class="clearfix">  
105 - {{# recommend}}  
106 - <li>  
107 - <a href="{{href}}" data-id='{{productId}}' target="_blank">  
108 - <img class="thumb" src="{{thumb}}">  
109 - <p class="name">{{name}}</p>  
110 - <span class="price">¥{{price}}</span>  
111 - </a>  
112 - </li>  
113 - {{/ recommend}}  
114 - </ul> 46 + <div class="recommend block" id="home-recommend-box">
115 </div> 47 </div>
116 - {{/if}}  
117 <!--recommend-for-you--> 48 <!--recommend-for-you-->
118 <div class="ho-btm"> 49 <div class="ho-btm">
119 {{{banner}}} 50 {{{banner}}}
120 {{> help-us}} 51 {{> help-us}}
121 </div> 52 </div>
122 {{/ me}} 53 {{/ me}}
  54 + <script type="text/html" id="home-brands-tpl">
  55 + <h2 class="title">
  56 + <a class="more-orders more" href="\{{more}}">
  57 + 更多品牌
  58 + </a>
  59 + </h2>
  60 + <ul class="clearfix">
  61 + \{{# brands}}
  62 + <li>
  63 + <a href="\{{href}}">
  64 + <img class="brand-logo" src="\{{logo}}">
  65 + <span class="brand-name">\{{name}}</span>
  66 + </a>
  67 + </li>
  68 + \{{/ brands}}
  69 + </ul>
  70 + </script>
  71 + <script type="text/html" id="home-new-tpl">
  72 + \{{#if newArrive}}
  73 + <h2 class="title">
  74 + <p class="na-pager-wrap">
  75 + <span class="na-pager pre no-visible">
  76 + <i class="iconfont">&#xe618;</i>
  77 + </span>
  78 + <span class="na-pager next">
  79 + <i class="iconfont">&#xe619;</i>
  80 + </span>
  81 + </p>
  82 + </h2>
  83 + <ul class="clearfix">
  84 + \{{# newArrive}}
  85 + <li>
  86 + <a href="\{{href}}">
  87 + <img class="thumb" src="\{{thumb}}">
  88 + <p class="name">\{{name}}</p>
  89 + <span class="price">¥\{{price}}</span>
  90 + </a>
  91 + </li>
  92 + \{{/ newArrive}}
  93 + </ul>
  94 + \{{/if}}
  95 + </script>
  96 + <script type="text/html" id="home-recommend-tpl">
  97 + \{{#if recommend}}
  98 + <h2 class="title">
  99 + <p class="na-pager-wrap">
  100 + <span class="rc-pager pre no-visible">
  101 + <i class="iconfont">&#xe618;</i>
  102 + </span>
  103 + <span class="rc-pager next">
  104 + <i class="iconfont">&#xe619;</i>
  105 + </span>
  106 + </p>
  107 + </h2>
  108 + <ul class="clearfix">
  109 + \{{# recommend}}
  110 + <li>
  111 + <a href="\{{href}}" data-id='\{{productId}}' target="_blank">
  112 + <img class="thumb" src="\{{thumb}}">
  113 + <p class="name">\{{name}}</p>
  114 + <span class="price">¥\{{price}}</span>
  115 + </a>
  116 + </li>
  117 + \{{/ recommend}}
  118 + </ul>
  119 + \{{/if}}
  120 + </script>
123 </div> 121 </div>
@@ -2,9 +2,7 @@ @@ -2,9 +2,7 @@
2 <p class="title ucenter"></p> 2 <p class="title ucenter"></p>
3 <div class="user-thumb"> 3 <div class="user-thumb">
4 <div class="thumb-bg"> 4 <div class="thumb-bg">
5 - {{#if userThumb}}  
6 - <img id="user-thumb" src="{{image2 userThumb w=100 h=100}}">  
7 - {{/if}} 5 + <img id="user-thumb">
8 </div> 6 </div>
9 </div> 7 </div>
10 {{# homeNav}} 8 {{# homeNav}}
@@ -18,7 +16,7 @@ @@ -18,7 +16,7 @@
18 <li class="row{{#if @first}} first{{/if}}{{#if active}} active{{/if}}"> 16 <li class="row{{#if @first}} first{{/if}}{{#if active}} active{{/if}}">
19 <a href="{{href}}" target="{{#if isBlank}}_blank{{/if}}" >{{name}}</a> 17 <a href="{{href}}" target="{{#if isBlank}}_blank{{/if}}" >{{name}}</a>
20 {{#if count}} 18 {{#if count}}
21 - <span class="new-count">{{count}}</span> 19 + <span class="new-count hide" id="new-count">{{count}}</span>
22 {{/if}} 20 {{/if}}
23 </li> 21 </li>
24 {{/each}} 22 {{/each}}
@@ -4,12 +4,14 @@ @@ -4,12 +4,14 @@
4 * @date: 2016/2/17 4 * @date: 2016/2/17
5 */ 5 */
6 6
7 -var $ = require('yoho-jquery'); 7 +var $ = require('yoho-jquery'),
  8 + handlebars = require('yoho-handlebars');
8 var yas = require('../common/data-yas'); 9 var yas = require('../common/data-yas');
9 var RECID = (new Date().getTime() + '_PC_YOHOBUY_' + 10 var RECID = (new Date().getTime() + '_PC_YOHOBUY_' +
10 Math.floor(Math.random() * 1000000 + 1000000) + 11 Math.floor(Math.random() * 1000000 + 1000000) +
11 '_' + Math.floor(Math.random() * 1000000 + 1000000)); 12 '_' + Math.floor(Math.random() * 1000000 + 1000000));
12 13
  14 +
13 require('./orders/order-block'); 15 require('./orders/order-block');
14 require('../common'); 16 require('../common');
15 17
@@ -76,6 +78,13 @@ function pageChange(self, $ul, page, itemWith, curPage, num) { @@ -76,6 +78,13 @@ function pageChange(self, $ul, page, itemWith, curPage, num) {
76 rcCurPage = 1, 78 rcCurPage = 1,
77 PRDID = []; 79 PRDID = [];
78 80
  81 + var $brandsBox = $('#home-brands-box'),
  82 + $newBox = $('#home-new-box'),
  83 + $recommendBox = $('#home-recommend-box'),
  84 + $brandsTpl = $('#home-brands-tpl').html(),
  85 + $newTpl = $('#home-new-tpl').html(),
  86 + $recommendTpl = $('#home-recommend-tpl').html();
  87 +
79 $naUl.width($naUl.width() * naPage); 88 $naUl.width($naUl.width() * naPage);
80 $rcUl.width($rcUl.width() * rcPage); 89 $rcUl.width($rcUl.width() * rcPage);
81 90
@@ -167,4 +176,34 @@ function pageChange(self, $ul, page, itemWith, curPage, num) { @@ -167,4 +176,34 @@ function pageChange(self, $ul, page, itemWith, curPage, num) {
167 176
168 // 为您优选埋点 end 177 // 为您优选埋点 end
169 178
  179 +
  180 + // 我的消息、我的头像
  181 + $.getJSON('//www.yohobuy.com/home/index/newsAvatar', function(data) {
  182 + $('#user-thumb').attr('src', data.avatar);
  183 + if (+data.msg > 0) {
  184 + $('#new-count').html(data.msg).removeClass('hide');
  185 + }
  186 + });
  187 +
  188 + // 待处理订单,未读消息,待分享商品数量
  189 + $.getJSON('//www.yohobuy.com/home/index/numbers', function(numbers) {
  190 + $.each(numbers, function(key, val) {
  191 + $('#' + key).html(val);
  192 + });
  193 + });
  194 +
  195 + // 喜欢的品牌
  196 + $.getJSON('//www.yohobuy.com/home/index/brands', function(brands) {
  197 + $brandsBox.html(handlebars.compile($brandsTpl)(brands));
  198 + });
  199 +
  200 + // 新品上架
  201 + $.getJSON('//www.yohobuy.com/home/index/newArrive', function(products) {
  202 + $newBox.html(handlebars.compile($newTpl)(products));
  203 + });
  204 +
  205 + // 猜你喜欢
  206 + $.getJSON('//www.yohobuy.com/home/index/recommend', function(rec) {
  207 + $recommendBox.html(handlebars.compile($recommendTpl)(rec));
  208 + });
170 }()); 209 }());