Authored by zhangxiaoru

shop

@@ -4,23 +4,28 @@ const shopModel = require('../models/shopCollect'), @@ -4,23 +4,28 @@ const shopModel = require('../models/shopCollect'),
4 headerModel = require('../../../doraemon/models/header'); 4 headerModel = require('../../../doraemon/models/header');
5 5
6 const shopIndex = (req, res) => { 6 const shopIndex = (req, res) => {
  7 + let isApp = req.query.app_version || req.query.appVersion || false;
  8 + let uid = req.user.uid;
  9 + let parameter = {};
  10 +
  11 + if (!isApp) {
  12 + parameter = {
  13 + pageHeader: headerModel.setNav({
  14 + navTitle: '店铺收藏'
  15 + })
  16 + };
  17 + }
7 18
8 - res.render('shop-collect/index', { 19 + shopModel.banner().then((result) => {
  20 + res.render('shop-collect/index', Object.assign({
9 module: 'activity', 21 module: 'activity',
10 page: 'shop-collect', 22 page: 'shop-collect',
11 wechatShare: true, 23 wechatShare: true,
12 title: '店铺收藏', 24 title: '店铺收藏',
13 - pageHeader: headerModel.setNav({  
14 - navTitle: '店铺收藏'  
15 - }),  
16 shopCollect: { 25 shopCollect: {
17 - bannerTop: {  
18 - data: [  
19 - {src: '//img10.static.yhbimg.com/yhb-img01/2016/10/10/15/01a6351f91fe38304d268db009c9126bd4.jpg?imageView2/2/w/640/h/240/q/70'},  
20 - {src: '//img11.static.yhbimg.com/yhb-img01/2016/10/12/17/0168982b53cefca01ff3b2c5b91e606714.jpg?imageView2/2/w/640/h/240/q/70'}  
21 - ]  
22 - } 26 + bannerTop: result
23 } 27 }
  28 + }, parameter));
24 }); 29 });
25 }; 30 };
26 31
@@ -4,11 +4,10 @@ @@ -4,11 +4,10 @@
4 * @date: 2016/10/17 4 * @date: 2016/10/17
5 */ 5 */
6 'use strict'; 6 'use strict';
7 -  
8 -// const serviceAPI = global.yoho.ServiceAPI;  
9 const api = global.yoho.API; 7 const api = global.yoho.API;
10 const _ = require('lodash'); 8 const _ = require('lodash');
11 const logger = global.yoho.logger; 9 const logger = global.yoho.logger;
  10 +const service = global.yoho.ServiceAPI;
12 11
13 const shopList = (uid, tabName) => { 12 const shopList = (uid, tabName) => {
14 return api.get('', { 13 return api.get('', {
@@ -37,7 +36,18 @@ const shopNav = () => { @@ -37,7 +36,18 @@ const shopNav = () => {
37 }); 36 });
38 }; 37 };
39 38
  39 +const banner = () => {
  40 + return service.get('operations/api/v5/resource/get', {
  41 + content_code: 'c0acf0296a3c329678fb45da958d9951'
  42 + }, {
  43 + cache: true
  44 + }).then((result) => {
  45 + return result.data[0];
  46 + });
  47 +};
  48 +
40 module.exports = { 49 module.exports = {
41 shopList, 50 shopList,
42 - shopNav 51 + shopNav,
  52 + banner
43 }; 53 };
@@ -6,21 +6,18 @@ var $ = require('yoho-jquery'), @@ -6,21 +6,18 @@ var $ = require('yoho-jquery'),
6 Swiper = require('yoho-swiper'), 6 Swiper = require('yoho-swiper'),
7 tip = require('../plugin/tip'); 7 tip = require('../plugin/tip');
8 8
9 - // Handlebars = require('yoho-handlebars');  
10 -  
11 var searching, 9 var searching,
12 shopId, 10 shopId,
13 - navSwiper,  
14 - stoping; 11 + stoping,
  12 + navType;
15 13
16 var shopNav = require('template/shopCollect/shop-nav.hbs'), 14 var shopNav = require('template/shopCollect/shop-nav.hbs'),
17 shopList = require('template/shopCollect/shop-list.hbs'); 15 shopList = require('template/shopCollect/shop-list.hbs');
18 16
19 require('../common'); 17 require('../common');
  18 +require('../common/share')
20 19
21 -var navType = window.queryString;  
22 -  
23 -require('../common'); 20 +navType = window.queryString;
24 21
25 // 店铺列表数据 22 // 店铺列表数据
26 function shopListData(tabName, stoping) { 23 function shopListData(tabName, stoping) {
@@ -45,6 +42,7 @@ function shopListData(tabName, stoping) { @@ -45,6 +42,7 @@ function shopListData(tabName, stoping) {
45 42
46 stoping = false; 43 stoping = false;
47 44
  45 + //店铺收藏
48 $('.collect-btn').on('click', function() { 46 $('.collect-btn').on('click', function() {
49 var opt, 47 var opt,
50 $this = $(this); 48 $this = $(this);
@@ -86,7 +84,12 @@ function shopListData(tabName, stoping) { @@ -86,7 +84,12 @@ function shopListData(tabName, stoping) {
86 } 84 }
87 85
88 if (data.code === 400) { 86 if (data.code === 400) {
89 - window.location.href = 'http://www.yohobuy.com/passport/login'; 87 +
  88 + url = data.data;
  89 + if ($('#jump-login').length <= 0) {
  90 + $('body').append('<a href=\'' + url + '\'><span id="jump-login"><span></a>');
  91 + }
  92 + $('#jump-login').click();
90 } 93 }
91 searching = false; 94 searching = false;
92 }, 95 },
@@ -104,7 +107,6 @@ function shopListData(tabName, stoping) { @@ -104,7 +107,6 @@ function shopListData(tabName, stoping) {
104 }); 107 });
105 } 108 }
106 109
107 -  
108 // 导航数据 110 // 导航数据
109 function shopNavData() { 111 function shopNavData() {
110 $.ajax({ 112 $.ajax({
@@ -119,6 +121,14 @@ function shopNavData() { @@ -119,6 +121,14 @@ function shopNavData() {
119 121
120 $('.shop-nav').html(navString); 122 $('.shop-nav').html(navString);
121 123
  124 + //导航滑动效果
  125 + navSwiper = new Swiper('.shop-nav', {
  126 + grabCursor: true,
  127 + slidesPerView: 'auto',
  128 + slideElement: 'li'
  129 + });
  130 +
  131 + //加载第一页数据
122 if (navType.id) { 132 if (navType.id) {
123 $('.shop-nav').find('li').each(function() { 133 $('.shop-nav').find('li').each(function() {
124 if (navType.id === $(this).data('type')) { 134 if (navType.id === $(this).data('type')) {
@@ -126,12 +136,12 @@ function shopNavData() { @@ -126,12 +136,12 @@ function shopNavData() {
126 shopListData($(this).data('type')); 136 shopListData($(this).data('type'));
127 } 137 }
128 }); 138 });
129 -  
130 } else { 139 } else {
131 $('.shop-nav').find('li').eq(0).addClass('active'); 140 $('.shop-nav').find('li').eq(0).addClass('active');
132 shopListData($('.shop-nav').find('li').eq(0).data('type')); 141 shopListData($('.shop-nav').find('li').eq(0).data('type'));
133 } 142 }
134 143
  144 + //导航点击事件
135 $('.shop-nav').find('li').on('click', function() { 145 $('.shop-nav').find('li').on('click', function() {
136 var $this = $(this), 146 var $this = $(this),
137 tabName = $this.data('type'); 147 tabName = $this.data('type');
@@ -149,19 +159,15 @@ function shopNavData() { @@ -149,19 +159,15 @@ function shopNavData() {
149 159
150 }, 160 },
151 error: function() { 161 error: function() {
152 - tip.show('网络断开连接了~');  
153 - 162 + //tip.show('网络断开连接了~');
  163 + $('.shop-nav').hide();
  164 + $('.shop-list').hide();
154 } 165 }
155 }); 166 });
156 } 167 }
157 168
158 -  
159 $(function() { 169 $(function() {
160 - navSwiper = new Swiper('.shop-nav', {  
161 - grabCursor: true,  
162 - slidesPerView: 'auto',  
163 - slideElement: 'li'  
164 - }); 170 + shopNavData();
165 171
166 if ($('.banner-swiper').find('li').size() > 1) { 172 if ($('.banner-swiper').find('li').size() > 1) {
167 bannerSwiper = new Swiper('.banner-swiper', { 173 bannerSwiper = new Swiper('.banner-swiper', {
@@ -176,5 +182,5 @@ $(function() { @@ -176,5 +182,5 @@ $(function() {
176 }); 182 });
177 } 183 }
178 184
179 - shopNavData(); 185 +
180 }); 186 });
@@ -88,6 +88,7 @@ @@ -88,6 +88,7 @@
88 88
89 .shop-name { 89 .shop-name {
90 font-weight: bold; 90 font-weight: bold;
  91 + font-size: 24px;
91 } 92 }
92 93
93 .giving { 94 .giving {