Authored by zhangxiaoru

shopcollect

/**
* 动态获取活动的分享数据
* Created by yoho on 2016/10/19.
*/
'use strict';
const mRoot = '../models';
const share = require(`${mRoot}/share`);
exports.getShareContent = (req, res, next) => {
if (!req.query.shareId) {
return res.jsonp({
code: 400,
message: 'shareId is null'
});
}
share.getShareContent({
shareId: req.query.shareId
}).then(result => {
res.jsonp(result);
}).catch(next);
};
... ...
'use strict';
const shopModel = require('../models/shopCollect'),
headerModel = require('../../../doraemon/models/header');
const shopIndex = (req, res) => {
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));
});
};
const shopNav = (req, res, next) => {
shopModel.shopNav().then((result) => {
res.json(result);
}).catch(next);
};
const shopList = (req, res, next) => {
let uid = req.user.uid;
let tabName = req.query.tabName;
shopModel.shopList(uid, tabName).then((result) => {
res.json(result);
}).catch(next);
};
module.exports = {
shopIndex,
shopList,
shopNav
};
... ...
/**
* Created by yoho on 2016/10/19.
*/
'use strict';
const serviceApi = global.yoho.ServiceAPI;
/**
* 从接口获取 share 内容
* @returns {*|Promise.<TResult>}
*/
const getShareContent = (params) => {
return serviceApi.get('operations/api/v5/webshare/getShare', {
share_id: params.shareId
}).then(result => {
return result;
});
};
module.exports = {
getShareContent
};
... ...
/**
* 店铺收藏
* @author: zxr<xiaoru.zhang@yoho.cn>
* @date: 2016/10/17
*/
'use strict';
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('', {
method: 'app.shops.promote',
uid: uid,
tab_name: tabName
}).then((result) => {
if (result && result.code === 200) {
_.forEach(result.data, function(data) {
data.isFavorite = data.isFavorite === 'Y';
});
return result.data;
} else {
logger.error('shop list data return code is not 200');
return {};
}
});
};
const shopNav = () => {
return api.get('', {
method: 'app.shops.promoteTabNameList'
}).then((result) => {
if (result && result.code === 200) {
return result.data;
}
});
};
const banner = () => {
return service.get('operations/api/v5/resource/get', {
content_code: 'c0acf0296a3c329678fb45da958d9951'
}, {
cache: true
}).then((result) => {
if (result && result.code === 200) {
return result.data[0];
}
});
};
module.exports = {
shopList,
shopNav,
banner
};
... ...
... ... @@ -20,6 +20,8 @@ const auth = require('../../doraemon/middleware/auth');
const vipDay = require(`${cRoot}/vipDay`);
const market = require(`${cRoot}/market`);
const coin = require(`${cRoot}/coin`);
const shopCollect = require(`${cRoot}/shopCollect`);
const share = require(`${cRoot}/share`);
// routers
... ... @@ -88,5 +90,9 @@ router.post('/vip-day/msg/save.json', vipDay.beforeIn, vipDay.saveMsg);
router.get('/vip-day/msg/fetch.json', vipDay.fetchMsg);
router.get('/coin/sendCoin', coin.sendCoin);
router.get('/shopCollect', shopCollect.shopIndex);// 店铺收藏
router.get('/shopList', shopCollect.shopList);// 店铺收藏列表
router.get('/shopNav', shopCollect.shopNav);// 店铺收藏导航
router.get('/share', share.getShareContent);
module.exports = router;
... ...
<div class="shop-collect yoho-page">
{{# shopCollect}}
{{# bannerTop}}
{{> resources/banner-top}}
{{/ bannerTop}}
<div class="shop-nav nav">
</div>
<div class="shop-list">
</div>
{{/ shopCollect}}
</div>
\ No newline at end of file
... ...
... ... @@ -20,10 +20,12 @@ module.exports = {
service: 'http://service.yoho.cn/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
// service: 'http://service-test1.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test1.yohops.com:9999/'
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/',
},
subDomains: {
host: '.m.yohobuy.com',
... ...
... ... @@ -70,6 +70,10 @@
<input class="query-param" type="hidden" data-attr="productPool" value="{{productPool}}">
{{/if}}
{{#if filter_poolId}}
<input class="query-param" type="hidden" data-attr="filter_poolId" value="{{filter_poolId}}">
{{/if}}
{{#if saleType}}
<input class="query-param" type="hidden" data-attr="saleType" value="{{saleType}}">
{{/if}}
... ...
... ... @@ -7,7 +7,7 @@
<li>
<a href="{{url}}">
<div class="img-box">
<img class="lazy" data-original="{{image src 180 320}}" alt="">
<img class="lazy" data-original="{{image src 320 154}}" alt="">
</div>
</a>
</li>
... ...
{{# shopList}}
<div class="shop-info" data-id="{{shopsId}}">
<div class="info-title">
<div class="collect">
<span class="fans">粉丝{{collectionNum}}</span>
<i class="iconfont collect-btn {{#if isFavorite}}already-collect{{/ if}}">&#xe605;</i>
</div>
<div class="shop-tile">
<img src="{{logoUrl}}"></img>
<p>
<span class="shop-name">{{shopName}}</span><br>
<span class="giving">{{words}}</span>
</p>
</div>
</div>
<div class="info-content">
<img class="content" src="{{bannerUrl}}"></img>
</div>
</div>
{{/ shopList}}
\ No newline at end of file
... ...
<ul class="swiper-wrapper clearfix">
{{# navList}}
<li class="swiper-slide" data-type={{.}}>{{.}}</li>
{{/ navList}}
</ul>
\ No newline at end of file
... ...
/**
* 店铺收藏页
*/
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
tip = require('../plugin/tip');
var searching,
shopId,
stoping,
navSwiper,
navType;
var shopNav = require('shopCollect/shop-nav.hbs'),
shopList = require('shopCollect/shop-list.hbs');
require('../common');
require('../common/share');
navType = window.queryString;
// 店铺列表数据
function shopListData(tabName, stoping) {
if (stoping) {
return;
}
$.ajax({
method: 'get',
url: '/activity/shopList',
data: {
tabName: tabName
},
success: function(data) {
var list = shopList({
shopList: data
});
$('.shop-list').html(list);
stoping = false;
// 店铺收藏
$('.collect-btn').on('click', function() {
var opt,
$this = $(this);
shopId = $this.parents('.shop-info').data('id');
if (searching) {
return;
}
searching = true;
if ($this.hasClass('already-collect')) {
opt = 'cancel';
} else {
opt = 'ok';
}
$.ajax({
method: 'get',
url: location.protocol + '//m.yohobuy.com' + '/product/opt/favoriteBrand',
data: {
id: shopId,
opt: opt,
type: 'shop',
},
xhrFields: {
withCredentials: true
},
success: function(list) {
var url;
if (list.code === 200) {
if ($this.hasClass('already-collect')) {
$this.removeClass('already-collect');
tip.show('店铺取消收藏成功');
} else {
$this.addClass('already-collect');
tip.show('店铺收藏成功');
}
}
if (list.code === 400) {
url = list.data;
if ($('#jump-login').length <= 0) {
$('body').append('<a href=\'' + url + '\'><span id="jump-login"><span></a>');
}
$('#jump-login').click();
}
searching = false;
},
error: function() {
tip.show('网络断开连接了~');
searching = false;
}
});
});
},
error: function() {
tip.show('网络断开连接了~');
stoping = false;
}
});
}
// 导航数据
function shopNavData() {
$.ajax({
method: 'get',
url: '/activity/shopNav',
success: function(data) {
var navString = shopNav({
navList: data
});
$('.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')) {
$(this).addClass('active');
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');
if ($this.hasClass('active')) {
stoping = true;
} else {
stoping = false;
}
shopListData(tabName, stoping);
$this.addClass('active').siblings().removeClass('active');
});
},
error: function() {
// tip.show('网络断开连接了~');
$('.shop-nav').hide();
$('.shop-list').hide();
}
});
}
$(function() {
shopNavData();
if ($('.banner-swiper').find('li').size() > 1) {
bannerSwiper = new Swiper('.banner-swiper', {
lazyLoading: true,
lazyLoadingInPrevNext: true,
loop: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
paginationClickable: true,
slideElement: 'li',
pagination: '.banner-top .pagination-inner'
});
}
});
... ...
... ... @@ -4,6 +4,9 @@
* Date: 2016/7/29
* Time: 16:55
*/
var qs = window.queryString;
var jsApiList = [
'checkJsApi',
'onMenuShareTimeline',
... ... @@ -20,7 +23,6 @@ var shareData = {
};
if (/QQ/i.test(navigator.userAgent)) {
console.log('hi');
$.ajax({
url: '//qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js',
dataType: 'script',
... ... @@ -70,6 +72,25 @@ if (/MicroMessenger/i.test(navigator.userAgent)) {
}
});
}
if (qs && qs.shareId) {
$.ajax({
method: 'GET',
url: location.protocol + '//m.yohobuy.com/activity/share',
data: {
shareId: qs.shareId
},
dataType: 'jsonp',
success: function(res) {
if (res && res.code === 200 && res.data) {
shareData.desc = res.data.content;
shareData.imgUrl = res.data.pic;
shareData.title = res.data.title;
}
}
});
}
module.exports = function(data) {
shareData = data;
... ...
... ... @@ -187,9 +187,9 @@ function initFilter(opt) {
var limit = height - $(this).parent().height();
y = y + deltaY;
if (y < limit * -1)
y = limit * -1;
{ y = limit * -1; }
if (y > 0)
y = 0;
{ y = 0; }
var translate = 'translate3d(0,' + y + 'px,0)';
$(this).css({
'-moz-transform': translate,
... ...
... ... @@ -2,6 +2,7 @@
@import "vip_day/index";
@import "student";
@import "market/index";
@import "shop-collect/shop-collect";
.receive-coupon-page {
* {
... ...
.shop-collect {
.nav {
height: 90px;
background: #fff;
box-sizing: border-box;
overflow: hidden;
background: #fff;
border-bottom: 1px solid #e0e0e0;
li {
float: left;
width: 160.5px;
display: block;
height: 40px;
line-height: 40px;
text-align: center;
margin: 25px 0;
border-right: 1px solid #e0e0e0;
font-size: 24px;
color: #666;
}
li:last-child {
border-right: none;
}
.active {
color: #000;
font-weight: bold;
}
}
.shop-list {
width: 100%;
background: #f0f0f0;
padding-top: 30px;
.shop-info {
background: #fff;
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
margin-bottom: 30px;
}
.info-title {
height: 100px;
padding: 15px 0 15px 30px;
}
.collect {
float: right;
margin-right: 30px;
line-height: 70px;
height: 70px;
.fans {
margin-right: 30px;
}
.collect-btn {
color: #b0b0b0;
}
.already-collect {
color: #d0021b;
}
}
.shop-tile {
width: 335px;
img {
width: 110px;
height: 70px;
float: left;
}
p {
float: left;
margin-left: 25px;
font-size: 22px;
}
span {
height: 35px;
line-height: 35px;
}
.shop-name {
font-weight: bold;
font-size: 24px;
}
.giving {
color: #b0b0b0;
}
}
.info-content {
height: 235px;
padding: 30px;
border-top: 1px solid #e0e0e0;
.content {
width: 690px;
height: 175px;
}
}
}
}
... ...
.six-lines-floor li {
height: 180px;
height: 154px;
width: 50%;
float: left;
img {
height: 180px;
height: 154px;
width: 100%;
}
}
... ...
... ... @@ -43,7 +43,7 @@
}
}
.deal-main {
.deal_main {
margin: 0.5rem 3%;
font-size: 14.4PX;
width: 94%;
... ...