Authored by lijing

秒杀详情动态数据

  1 +/**
  2 + * 动态获取活动的分享数据
  3 + * Created by yoho on 2016/10/19.
  4 + */
  5 +'use strict';
  6 +const mRoot = '../models';
  7 +const share = require(`${mRoot}/share`);
  8 +
  9 +exports.getShareContent = (req, res, next) => {
  10 + if (!req.query.shareId) {
  11 + return res.jsonp({
  12 + code: 400,
  13 + message: 'shareId is null'
  14 + });
  15 + }
  16 +
  17 + share.getShareContent({
  18 + shareId: req.query.shareId
  19 + }).then(result => {
  20 + res.jsonp(result);
  21 + }).catch(next);
  22 +};
  1 +'use strict';
  2 +
  3 +const shopModel = require('../models/shopCollect'),
  4 + headerModel = require('../../../doraemon/models/header');
  5 +
  6 +const shopIndex = (req, res) => {
  7 + let isApp = req.query.app_version || req.query.appVersion || false;
  8 +
  9 + // let uid = req.user.uid;
  10 + let parameter = {};
  11 +
  12 + if (!isApp) {
  13 + parameter = {
  14 + pageHeader: headerModel.setNav({
  15 + navTitle: '店铺收藏'
  16 + })
  17 + };
  18 + }
  19 +
  20 + shopModel.banner().then((result) => {
  21 + res.render('shop-collect/index', Object.assign({
  22 + module: 'activity',
  23 + page: 'shop-collect',
  24 + wechatShare: true,
  25 + title: '店铺收藏',
  26 + shopCollect: {
  27 + bannerTop: result
  28 + }
  29 + }, parameter));
  30 + });
  31 +};
  32 +
  33 +const shopNav = (req, res, next) => {
  34 +
  35 + shopModel.shopNav().then((result) => {
  36 + res.json(result);
  37 + }).catch(next);
  38 +};
  39 +
  40 +
  41 +const shopList = (req, res, next) => {
  42 + let uid = req.user.uid;
  43 + let tabName = req.query.tabName;
  44 +
  45 + shopModel.shopList(uid, tabName).then((result) => {
  46 + res.json(result);
  47 + }).catch(next);
  48 +};
  49 +
  50 +module.exports = {
  51 + shopIndex,
  52 + shopList,
  53 + shopNav
  54 +};
  1 +/**
  2 + * Created by yoho on 2016/10/19.
  3 + */
  4 +'use strict';
  5 +const serviceApi = global.yoho.ServiceAPI;
  6 +
  7 +/**
  8 + * 从接口获取 share 内容
  9 + * @returns {*|Promise.<TResult>}
  10 + */
  11 +const getShareContent = (params) => {
  12 + return serviceApi.get('operations/api/v5/webshare/getShare', {
  13 + share_id: params.shareId
  14 + }).then(result => {
  15 + return result;
  16 + });
  17 +};
  18 +
  19 +module.exports = {
  20 + getShareContent
  21 +};
  1 +/**
  2 + * 店铺收藏
  3 + * @author: zxr<xiaoru.zhang@yoho.cn>
  4 + * @date: 2016/10/17
  5 + */
  6 +'use strict';
  7 +const api = global.yoho.API;
  8 +const _ = require('lodash');
  9 +const logger = global.yoho.logger;
  10 +const service = global.yoho.ServiceAPI;
  11 +
  12 +const shopList = (uid, tabName) => {
  13 + return api.get('', {
  14 + method: 'app.shops.promote',
  15 + uid: uid,
  16 + tab_name: tabName
  17 + }).then((result) => {
  18 +
  19 + if (result && result.code === 200) {
  20 + _.forEach(result.data, function(data) {
  21 + data.isFavorite = data.isFavorite === 'Y';
  22 + });
  23 + return result.data;
  24 + } else {
  25 + logger.error('shop list data return code is not 200');
  26 + return {};
  27 + }
  28 + });
  29 +};
  30 +
  31 +const shopNav = () => {
  32 + return api.get('', {
  33 + method: 'app.shops.promoteTabNameList'
  34 + }).then((result) => {
  35 + if (result && result.code === 200) {
  36 + return result.data;
  37 + }
  38 + });
  39 +};
  40 +
  41 +const banner = () => {
  42 + return service.get('operations/api/v5/resource/get', {
  43 + content_code: 'c0acf0296a3c329678fb45da958d9951'
  44 + }, {
  45 + cache: true
  46 + }).then((result) => {
  47 + if (result && result.code === 200) {
  48 + return result.data[0];
  49 + }
  50 + });
  51 +};
  52 +
  53 +module.exports = {
  54 + shopList,
  55 + shopNav,
  56 + banner
  57 +};
@@ -20,6 +20,8 @@ const auth = require('../../doraemon/middleware/auth'); @@ -20,6 +20,8 @@ const auth = require('../../doraemon/middleware/auth');
20 const vipDay = require(`${cRoot}/vipDay`); 20 const vipDay = require(`${cRoot}/vipDay`);
21 const market = require(`${cRoot}/market`); 21 const market = require(`${cRoot}/market`);
22 const coin = require(`${cRoot}/coin`); 22 const coin = require(`${cRoot}/coin`);
  23 +const shopCollect = require(`${cRoot}/shopCollect`);
  24 +const share = require(`${cRoot}/share`);
23 25
24 // routers 26 // routers
25 27
@@ -88,5 +90,9 @@ router.post('/vip-day/msg/save.json', vipDay.beforeIn, vipDay.saveMsg); @@ -88,5 +90,9 @@ router.post('/vip-day/msg/save.json', vipDay.beforeIn, vipDay.saveMsg);
88 router.get('/vip-day/msg/fetch.json', vipDay.fetchMsg); 90 router.get('/vip-day/msg/fetch.json', vipDay.fetchMsg);
89 91
90 router.get('/coin/sendCoin', coin.sendCoin); 92 router.get('/coin/sendCoin', coin.sendCoin);
  93 +router.get('/shopCollect', shopCollect.shopIndex);// 店铺收藏
  94 +router.get('/shopList', shopCollect.shopList);// 店铺收藏列表
  95 +router.get('/shopNav', shopCollect.shopNav);// 店铺收藏导航
  96 +router.get('/share', share.getShareContent);
91 97
92 module.exports = router; 98 module.exports = router;
  1 +<div class="shop-collect yoho-page">
  2 +{{# shopCollect}}
  3 + {{# bannerTop}}
  4 + {{> resources/banner-top}}
  5 + {{/ bannerTop}}
  6 +
  7 + <div class="shop-nav nav">
  8 + </div>
  9 +
  10 + <div class="shop-list">
  11 +
  12 + </div>
  13 +{{/ shopCollect}}
  14 +</div>
@@ -22,8 +22,11 @@ module.exports = { @@ -22,8 +22,11 @@ module.exports = {
22 singleApi: 'http://single.yoho.cn/' 22 singleApi: 'http://single.yoho.cn/'
23 23
24 // service: 'http://service-test1.yohops.com:9999/', 24 // service: 'http://service-test1.yohops.com:9999/',
25 - // liveApi: 'http://testapi.live.yohops.com:9999/',  
26 - // singleApi: 'http://api-test1.yohops.com:9999/' 25 +
  26 + // api: 'http://api.yoho.cn/',
  27 + // service: 'http://service.yoho.cn/',
  28 + // liveApi: 'http://api.live.yoho.cn/',
  29 + // singleApi: 'http://single.yoho.cn/',
27 }, 30 },
28 subDomains: { 31 subDomains: {
29 host: '.m.yohobuy.com', 32 host: '.m.yohobuy.com',
@@ -70,6 +70,10 @@ @@ -70,6 +70,10 @@
70 <input class="query-param" type="hidden" data-attr="productPool" value="{{productPool}}"> 70 <input class="query-param" type="hidden" data-attr="productPool" value="{{productPool}}">
71 {{/if}} 71 {{/if}}
72 72
  73 +{{#if filter_poolId}}
  74 + <input class="query-param" type="hidden" data-attr="filter_poolId" value="{{filter_poolId}}">
  75 +{{/if}}
  76 +
73 {{#if saleType}} 77 {{#if saleType}}
74 <input class="query-param" type="hidden" data-attr="saleType" value="{{saleType}}"> 78 <input class="query-param" type="hidden" data-attr="saleType" value="{{saleType}}">
75 {{/if}} 79 {{/if}}
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 <li> 7 <li>
8 <a href="{{url}}"> 8 <a href="{{url}}">
9 <div class="img-box"> 9 <div class="img-box">
10 - <img class="lazy" data-original="{{image src 180 320}}" alt=""> 10 + <img class="lazy" data-original="{{image src 320 154}}" alt="">
11 </div> 11 </div>
12 </a> 12 </a>
13 </li> 13 </li>
  1 + {{# shopList}}
  2 + <div class="shop-info" data-id="{{shopsId}}">
  3 + <div class="info-title">
  4 + <div class="collect">
  5 + <span class="fans">粉丝{{collectionNum}}</span>
  6 + <i class="iconfont collect-btn {{#if isFavorite}}already-collect{{/ if}}">&#xe605;</i>
  7 + </div>
  8 +
  9 + <div class="shop-tile">
  10 + <img src="{{logoUrl}}"></img>
  11 + <p>
  12 + <span class="shop-name">{{shopName}}</span><br>
  13 + <span class="giving">{{words}}</span>
  14 + </p>
  15 + </div>
  16 + </div>
  17 +
  18 + <div class="info-content">
  19 + <img class="content" src="{{bannerUrl}}"></img>
  20 + </div>
  21 + </div>
  22 +{{/ shopList}}
  1 +<ul class="swiper-wrapper clearfix">
  2 + {{# navList}}
  3 + <li class="swiper-slide" data-type={{.}}>{{.}}</li>
  4 + {{/ navList}}
  5 +</ul>
  1 +/**
  2 + * 店铺收藏页
  3 + */
  4 +
  5 +var $ = require('yoho-jquery'),
  6 + Swiper = require('yoho-swiper'),
  7 + tip = require('../plugin/tip');
  8 +
  9 +var searching,
  10 + shopId,
  11 + stoping,
  12 + navSwiper,
  13 + navType;
  14 +
  15 +var shopNav = require('shopCollect/shop-nav.hbs'),
  16 + shopList = require('shopCollect/shop-list.hbs');
  17 +
  18 +require('../common');
  19 +require('../common/share');
  20 +
  21 +navType = window.queryString;
  22 +
  23 +// 店铺列表数据
  24 +function shopListData(tabName, stoping) {
  25 +
  26 + if (stoping) {
  27 + return;
  28 + }
  29 +
  30 + $.ajax({
  31 + method: 'get',
  32 + url: '/activity/shopList',
  33 + data: {
  34 + tabName: tabName
  35 + },
  36 + success: function(data) {
  37 +
  38 + var list = shopList({
  39 + shopList: data
  40 + });
  41 +
  42 + $('.shop-list').html(list);
  43 +
  44 + stoping = false;
  45 +
  46 + // 店铺收藏
  47 + $('.collect-btn').on('click', function() {
  48 + var opt,
  49 + $this = $(this);
  50 +
  51 + shopId = $this.parents('.shop-info').data('id');
  52 +
  53 + if (searching) {
  54 + return;
  55 + }
  56 + searching = true;
  57 +
  58 + if ($this.hasClass('already-collect')) {
  59 + opt = 'cancel';
  60 + } else {
  61 + opt = 'ok';
  62 + }
  63 +
  64 + $.ajax({
  65 + method: 'get',
  66 + url: location.protocol + '//m.yohobuy.com' + '/product/opt/favoriteBrand',
  67 + data: {
  68 + id: shopId,
  69 + opt: opt,
  70 + type: 'shop',
  71 + },
  72 + xhrFields: {
  73 + withCredentials: true
  74 + },
  75 + success: function(list) {
  76 + var url;
  77 +
  78 + if (list.code === 200) {
  79 + if ($this.hasClass('already-collect')) {
  80 + $this.removeClass('already-collect');
  81 + tip.show('店铺取消收藏成功');
  82 + } else {
  83 + $this.addClass('already-collect');
  84 + tip.show('店铺收藏成功');
  85 + }
  86 + }
  87 +
  88 + if (list.code === 400) {
  89 +
  90 + url = list.data;
  91 + if ($('#jump-login').length <= 0) {
  92 + $('body').append('<a href=\'' + url + '\'><span id="jump-login"><span></a>');
  93 + }
  94 + $('#jump-login').click();
  95 + }
  96 + searching = false;
  97 + },
  98 + error: function() {
  99 + tip.show('网络断开连接了~');
  100 + searching = false;
  101 + }
  102 + });
  103 + });
  104 + },
  105 + error: function() {
  106 + tip.show('网络断开连接了~');
  107 + stoping = false;
  108 + }
  109 + });
  110 +}
  111 +
  112 +// 导航数据
  113 +function shopNavData() {
  114 + $.ajax({
  115 + method: 'get',
  116 + url: '/activity/shopNav',
  117 +
  118 + success: function(data) {
  119 +
  120 + var navString = shopNav({
  121 + navList: data
  122 + });
  123 +
  124 + $('.shop-nav').html(navString);
  125 +
  126 + // 导航滑动效果
  127 + navSwiper = new Swiper('.shop-nav', {
  128 + grabCursor: true,
  129 + slidesPerView: 'auto',
  130 + slideElement: 'li'
  131 + });
  132 +
  133 + // 加载第一页数据
  134 + if (navType.id) {
  135 + $('.shop-nav').find('li').each(function() {
  136 + if (navType.id === $(this).data('type')) {
  137 + $(this).addClass('active');
  138 + shopListData($(this).data('type'));
  139 + }
  140 + });
  141 + } else {
  142 + $('.shop-nav').find('li').eq(0).addClass('active');
  143 + shopListData($('.shop-nav').find('li').eq(0).data('type'));
  144 + }
  145 +
  146 + // 导航点击事件
  147 + $('.shop-nav').find('li').on('click', function() {
  148 + var $this = $(this),
  149 + tabName = $this.data('type');
  150 +
  151 + if ($this.hasClass('active')) {
  152 + stoping = true;
  153 + } else {
  154 + stoping = false;
  155 + }
  156 +
  157 + shopListData(tabName, stoping);
  158 +
  159 + $this.addClass('active').siblings().removeClass('active');
  160 + });
  161 +
  162 + },
  163 + error: function() {
  164 + // tip.show('网络断开连接了~');
  165 + $('.shop-nav').hide();
  166 + $('.shop-list').hide();
  167 + }
  168 + });
  169 +}
  170 +
  171 +$(function() {
  172 + shopNavData();
  173 +
  174 + if ($('.banner-swiper').find('li').size() > 1) {
  175 + bannerSwiper = new Swiper('.banner-swiper', {
  176 + lazyLoading: true,
  177 + lazyLoadingInPrevNext: true,
  178 + loop: true,
  179 + autoplay: 3000,
  180 + autoplayDisableOnInteraction: false,
  181 + paginationClickable: true,
  182 + slideElement: 'li',
  183 + pagination: '.banner-top .pagination-inner'
  184 + });
  185 + }
  186 +
  187 +
  188 +});
@@ -4,6 +4,9 @@ @@ -4,6 +4,9 @@
4 * Date: 2016/7/29 4 * Date: 2016/7/29
5 * Time: 16:55 5 * Time: 16:55
6 */ 6 */
  7 +
  8 +var qs = window.queryString;
  9 +
7 var jsApiList = [ 10 var jsApiList = [
8 'checkJsApi', 11 'checkJsApi',
9 'onMenuShareTimeline', 12 'onMenuShareTimeline',
@@ -20,7 +23,6 @@ var shareData = { @@ -20,7 +23,6 @@ var shareData = {
20 }; 23 };
21 24
22 if (/QQ/i.test(navigator.userAgent)) { 25 if (/QQ/i.test(navigator.userAgent)) {
23 - console.log('hi');  
24 $.ajax({ 26 $.ajax({
25 url: '//qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js', 27 url: '//qzonestyle.gtimg.cn/qzone/qzact/common/share/share.js',
26 dataType: 'script', 28 dataType: 'script',
@@ -70,6 +72,25 @@ if (/MicroMessenger/i.test(navigator.userAgent)) { @@ -70,6 +72,25 @@ if (/MicroMessenger/i.test(navigator.userAgent)) {
70 } 72 }
71 }); 73 });
72 } 74 }
  75 +
  76 +if (qs && qs.shareId) {
  77 + $.ajax({
  78 + method: 'GET',
  79 + url: location.protocol + '//m.yohobuy.com/activity/share',
  80 + data: {
  81 + shareId: qs.shareId
  82 + },
  83 + dataType: 'jsonp',
  84 + success: function(res) {
  85 + if (res && res.code === 200 && res.data) {
  86 + shareData.desc = res.data.content;
  87 + shareData.imgUrl = res.data.pic;
  88 + shareData.title = res.data.title;
  89 + }
  90 + }
  91 + });
  92 +}
  93 +
73 module.exports = function(data) { 94 module.exports = function(data) {
74 shareData = data; 95 shareData = data;
75 96
@@ -187,9 +187,9 @@ function initFilter(opt) { @@ -187,9 +187,9 @@ function initFilter(opt) {
187 var limit = height - $(this).parent().height(); 187 var limit = height - $(this).parent().height();
188 y = y + deltaY; 188 y = y + deltaY;
189 if (y < limit * -1) 189 if (y < limit * -1)
190 - y = limit * -1; 190 + { y = limit * -1; }
191 if (y > 0) 191 if (y > 0)
192 - y = 0; 192 + { y = 0; }
193 var translate = 'translate3d(0,' + y + 'px,0)'; 193 var translate = 'translate3d(0,' + y + 'px,0)';
194 $(this).css({ 194 $(this).css({
195 '-moz-transform': translate, 195 '-moz-transform': translate,
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 @import "vip_day/index"; 2 @import "vip_day/index";
3 @import "student"; 3 @import "student";
4 @import "market/index"; 4 @import "market/index";
  5 +@import "shop-collect/shop-collect";
5 6
6 .receive-coupon-page { 7 .receive-coupon-page {
7 * { 8 * {
  1 +.shop-collect {
  2 + .nav {
  3 + height: 90px;
  4 + background: #fff;
  5 + box-sizing: border-box;
  6 + overflow: hidden;
  7 + background: #fff;
  8 + border-bottom: 1px solid #e0e0e0;
  9 +
  10 + li {
  11 + float: left;
  12 + width: 160.5px;
  13 + display: block;
  14 + height: 40px;
  15 + line-height: 40px;
  16 + text-align: center;
  17 + margin: 25px 0;
  18 + border-right: 1px solid #e0e0e0;
  19 + font-size: 24px;
  20 + color: #666;
  21 + }
  22 +
  23 + li:last-child {
  24 + border-right: none;
  25 + }
  26 +
  27 + .active {
  28 + color: #000;
  29 + font-weight: bold;
  30 + }
  31 + }
  32 +
  33 + .shop-list {
  34 + width: 100%;
  35 + background: #f0f0f0;
  36 + padding-top: 30px;
  37 +
  38 + .shop-info {
  39 + background: #fff;
  40 + border-top: 1px solid #e0e0e0;
  41 + border-bottom: 1px solid #e0e0e0;
  42 + margin-bottom: 30px;
  43 + }
  44 +
  45 + .info-title {
  46 + height: 100px;
  47 + padding: 15px 0 15px 30px;
  48 + }
  49 +
  50 + .collect {
  51 + float: right;
  52 + margin-right: 30px;
  53 + line-height: 70px;
  54 + height: 70px;
  55 +
  56 + .fans {
  57 + margin-right: 30px;
  58 + }
  59 +
  60 + .collect-btn {
  61 + color: #b0b0b0;
  62 + }
  63 +
  64 + .already-collect {
  65 + color: #d0021b;
  66 + }
  67 + }
  68 +
  69 + .shop-tile {
  70 + width: 335px;
  71 +
  72 + img {
  73 + width: 110px;
  74 + height: 70px;
  75 + float: left;
  76 + }
  77 +
  78 + p {
  79 + float: left;
  80 + margin-left: 25px;
  81 + font-size: 22px;
  82 + }
  83 +
  84 + span {
  85 + height: 35px;
  86 + line-height: 35px;
  87 + }
  88 +
  89 + .shop-name {
  90 + font-weight: bold;
  91 + font-size: 24px;
  92 + }
  93 +
  94 + .giving {
  95 + color: #b0b0b0;
  96 + }
  97 + }
  98 +
  99 + .info-content {
  100 + height: 235px;
  101 + padding: 30px;
  102 + border-top: 1px solid #e0e0e0;
  103 +
  104 + .content {
  105 + width: 690px;
  106 + height: 175px;
  107 + }
  108 + }
  109 + }
  110 +}
1 .six-lines-floor li { 1 .six-lines-floor li {
2 - height: 180px; 2 + height: 154px;
3 width: 50%; 3 width: 50%;
4 float: left; 4 float: left;
5 5
6 img { 6 img {
7 - height: 180px; 7 + height: 154px;
8 width: 100%; 8 width: 100%;
9 } 9 }
10 } 10 }
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 } 43 }
44 } 44 }
45 45
46 -.deal-main { 46 +.deal_main {
47 margin: 0.5rem 3%; 47 margin: 0.5rem 3%;
48 font-size: 14.4PX; 48 font-size: 14.4PX;
49 width: 94%; 49 width: 94%;