Authored by zhangxiaoru

shop

... ... @@ -4,23 +4,28 @@ const shopModel = require('../models/shopCollect'),
headerModel = require('../../../doraemon/models/header');
const shopIndex = (req, res) => {
res.render('shop-collect/index', {
module: 'activity',
page: 'shop-collect',
wechatShare: true,
title: '店铺收藏',
pageHeader: headerModel.setNav({
navTitle: '店铺收藏'
}),
shopCollect: {
bannerTop: {
data: [
{src: '//img10.static.yhbimg.com/yhb-img01/2016/10/10/15/01a6351f91fe38304d268db009c9126bd4.jpg?imageView2/2/w/640/h/240/q/70'},
{src: '//img11.static.yhbimg.com/yhb-img01/2016/10/12/17/0168982b53cefca01ff3b2c5b91e606714.jpg?imageView2/2/w/640/h/240/q/70'}
]
let isApp = req.query.app_version || req.query.appVersion || false;
let uid = req.user.uid;
let parameter = {};
if (!isApp) {
parameter = {
pageHeader: headerModel.setNav({
navTitle: '店铺收藏'
})
};
}
shopModel.banner().then((result) => {
res.render('shop-collect/index', Object.assign({
module: 'activity',
page: 'shop-collect',
wechatShare: true,
title: '店铺收藏',
shopCollect: {
bannerTop: result
}
}
}, parameter));
});
};
... ...
... ... @@ -4,11 +4,10 @@
* @date: 2016/10/17
*/
'use strict';
// const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const logger = global.yoho.logger;
const service = global.yoho.ServiceAPI;
const shopList = (uid, tabName) => {
return api.get('', {
... ... @@ -37,7 +36,18 @@ const shopNav = () => {
});
};
const banner = () => {
return service.get('operations/api/v5/resource/get', {
content_code: 'c0acf0296a3c329678fb45da958d9951'
}, {
cache: true
}).then((result) => {
return result.data[0];
});
};
module.exports = {
shopList,
shopNav
shopNav,
banner
};
... ...
... ... @@ -6,21 +6,18 @@ var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
tip = require('../plugin/tip');
// Handlebars = require('yoho-handlebars');
var searching,
shopId,
navSwiper,
stoping;
stoping,
navType;
var shopNav = require('template/shopCollect/shop-nav.hbs'),
shopList = require('template/shopCollect/shop-list.hbs');
require('../common');
require('../common/share')
var navType = window.queryString;
require('../common');
navType = window.queryString;
// 店铺列表数据
function shopListData(tabName, stoping) {
... ... @@ -45,6 +42,7 @@ function shopListData(tabName, stoping) {
stoping = false;
//店铺收藏
$('.collect-btn').on('click', function() {
var opt,
$this = $(this);
... ... @@ -86,7 +84,12 @@ function shopListData(tabName, stoping) {
}
if (data.code === 400) {
window.location.href = 'http://www.yohobuy.com/passport/login';
url = data.data;
if ($('#jump-login').length <= 0) {
$('body').append('<a href=\'' + url + '\'><span id="jump-login"><span></a>');
}
$('#jump-login').click();
}
searching = false;
},
... ... @@ -104,7 +107,6 @@ function shopListData(tabName, stoping) {
});
}
// 导航数据
function shopNavData() {
$.ajax({
... ... @@ -119,6 +121,14 @@ function shopNavData() {
$('.shop-nav').html(navString);
//导航滑动效果
navSwiper = new Swiper('.shop-nav', {
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li'
});
//加载第一页数据
if (navType.id) {
$('.shop-nav').find('li').each(function() {
if (navType.id === $(this).data('type')) {
... ... @@ -126,12 +136,12 @@ function shopNavData() {
shopListData($(this).data('type'));
}
});
} else {
$('.shop-nav').find('li').eq(0).addClass('active');
shopListData($('.shop-nav').find('li').eq(0).data('type'));
}
//导航点击事件
$('.shop-nav').find('li').on('click', function() {
var $this = $(this),
tabName = $this.data('type');
... ... @@ -149,19 +159,15 @@ function shopNavData() {
},
error: function() {
tip.show('网络断开连接了~');
//tip.show('网络断开连接了~');
$('.shop-nav').hide();
$('.shop-list').hide();
}
});
}
$(function() {
navSwiper = new Swiper('.shop-nav', {
grabCursor: true,
slidesPerView: 'auto',
slideElement: 'li'
});
shopNavData();
if ($('.banner-swiper').find('li').size() > 1) {
bannerSwiper = new Swiper('.banner-swiper', {
... ... @@ -176,5 +182,5 @@ $(function() {
});
}
shopNavData();
});
... ...
... ... @@ -88,6 +88,7 @@
.shop-name {
font-weight: bold;
font-size: 24px;
}
.giving {
... ...