Authored by 陈轩

Merge branch 'feature/newDetail' of http://git.yoho.cn/fe/yohobuywap-node into feature/newDetail

... ... @@ -958,7 +958,7 @@ let _getPromotionInfo = (skn) => {
*/
let _getFavorite = (productId, uid) => {
if (!uid) {
return Promise.resolve({});
return Promise.resolve(false);
}
return singleAPI.get('favorite', {
method: 'app.favorite.isFavoriteNew',
... ... @@ -969,7 +969,7 @@ let _getFavorite = (productId, uid) => {
return result.data;
}
return {};
return false;
});
};
... ... @@ -1489,7 +1489,7 @@ const _cartCount = (uid, shoppingKey) => {
}
return count;
}
return Promise.resolve(0);
return 0;
});
};
... ...
... ... @@ -63,6 +63,8 @@
<i class="iconfont font-right pull-right">&#xe614;</i>
<i class="iconfont font-quan">&#xe900;</i><span>领取优惠券</span>
</div>
{{!--占位: 促销--}}
<div id="placeholder-promotion"></div>
{{!-- 占位: 用户反馈, 店铺入口 --}}
<div id="placeholder-feedback-store"></div>
... ...
{{# cartInfo}}
<div class="chose-panel">
<div class="main">
<div class="infos">
<div class="infos {{#if @root.tickets}} tickets-info {{/if}}">
<div class="basic-info" >
{{#each thumbs}}
{{#if @first}}
<img class="thumb" src="{{img}}">
{{/if}}
<img class="thumb {{#unless @first}}hide{{/unless}}" src="{{img}}">
{{/each}}
<div class="text-info">
<p class="name">{{name}}</p>
<p class="price">
{{#if price}}
<span class="sale-price">{{salePrice}}</span>
<span class="market-price">{{price}}</span>
{{else}}
{{# isY isSecKill}}
<span class="sale-price">{{salePrice}}</span>
<span class="market-price data-bind"></span>
<span class="market-price">{{salePrice}}</span>
{{else}}
<span class="sale-price no-price">{{salePrice}}</span>
{{/ isY}}
{{/if}}
</p>
</div>
</div>
<div class="chose-items">
<div class="color-list block-list">
<span class="name">颜色</span>
<ul id="" data-index="" class="size-row clearfix ">
<li class="block" data-num="">
</li>
<span class="name">{{#if @root.tickets}}日期{{else}}颜色{{/if}}</span>
{{#each colors}}
<ul id="{{id}}" data-index="{{@index}}" class="size-row clearfix {{#unless @first}}hide{{/unless}}">
{{#each color}}
<li class="block {{#if chosed}} chosed{{/if}} {{#unless colorNum}} zero-stock{{/unless}}" data-num="{{colorNum}}">{{name}}</li>
{{/each}}
</ul>
{{/each}}
</div>
<div class="size-list block-list">
<span class="name">尺码</span>
<ul class="size-row clearfix">
<li class="block " data-num="" data-id="" data-skuid="">
</li>
<div class="size-list block-list {{#if @root.single}} hide{{/if}}">
<span class="name">{{#if @root.tickets}}区域{{else}}尺码{{/if}}</span>
{{#each sizes}}
<ul class="size-row clearfix {{#unless @first}}hide{{/unless}}">
{{#each size}}
<li class="block {{#if chosed}} chosed{{/if}} {{#unless sizeNum}} zero-stock {{/unless}}" data-num="{{sizeNum}}" data-id="{{id}}" data-skuid="{{skuId}}">{{name}}</li>
{{/each}}
</ul>
{{/each}}
</div>
<div class="num">
<span class="name">数量</span>
<div class="clearfix">
<a class="btn btn-minus" href="javascript:void(0);">
<span class="iconfont ">&#xe625;</span>
<span class="iconfont {{#if promotionId}}disabled{{/if}}">&#xe625;</span>
</a>
<input id="good-num" class="good-num disabled" type="text" value="1" disabled="true">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="iconfont ">&#xe624;</span>
<span class="iconfont {{#if promotionId}}disabled{{/if}}">&#xe624;</span>
</a>
</div>
<span class="left-num"></span>
<input id="left-num" type="hidden" value="0">
<input id="limitNum" type="hidden" value="">
<input id="limitNum" type="hidden" value="{{limit}}">
</div>
</div>
</div>
<div class="btn-wrap">
<button id="chose-btn-sure" class="btn btn-sure"></button>
<button id="chose-btn-sure" class="btn btn-sure">{{#if @root.tickets}}立即购买{{else}}加入购物车{{/if}}</button>
</div>
</div>
<input id="promotionId" type="hidden" value="">
<input id="single" type="hidden" value="">
<input id="promotionId" type="hidden" value="{{promotionId}}">
<input id="single" type="hidden" value="{{@root.single}}">
</div>
<div class="cart-bar">
{{#unless @root.wap.common.removeCartCount}}
... ...
{{!-- 商品促销 --}}
{{#if promotion}}
<div class="goods-discount" id="goodsDiscount">
{{#each promotion}}
{{#if @first}}
<h1 class="first-item short-text tap-hightlight">{{promotionTitle}}<span class="icon-down iconfont dropdown">&#xe609;</span></h1>
{{else}}
<div class="discount-folder">
<h1 class="folder-item tap-hightlight">{{promotionTitle}}</h1>
</div>
{{/if}}
{{/each}}
</div>
{{/if}}
\ No newline at end of file
... ...
... ... @@ -178,11 +178,12 @@ function checkColorSizeNum() {
function show(html, cb) {
if (html) {
$chosePanel.html(html);
init();
}
if ($('#promotionId').val() !== '') {
disableNumEdit();
}
init();
}
$('.chose-panel').show();
$num = $('#good-num');
... ... @@ -558,7 +559,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
$chosed = $('.block-list>ul>li.chosed');
if ($chosed.length === 2 && $chosed.closest('.zero-stock').length === 0) {
isSecKills = $('.seckill-time').length;// 秒杀标记
isSecKills = $('.seckill-time').length; // 秒杀标记
productSku = $curSizeBlock.data('skuid');
promotionId = $('#promotionId').val();
... ... @@ -591,7 +592,7 @@ $yohoPage.on('touchstart', '.btn-minus', function() {
url = '/cart/index/modify';
} else if (limitProductCode) {
isSecKills = $('.seckill-time').length;// 秒杀标记
isSecKills = $('.seckill-time').length; // 秒杀标记
$(this).css('background-color', '#ccc').removeAttr('id');
// 当前面板选择的是限购商品
... ...
/**
* 判断是否是Y,应对接口经常返回Y/N做boolean
* @param string value
*/
module.exports = function(value, options) {
if (value === 'Y') {
return options.fn(this);
} else {
return options.inverse(this);
}
};
... ...
/*
商品详情页:异步获取品牌信息, 评论,
*/
'use strict';
... ... @@ -2,9 +2,9 @@ var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload'),
Swiper = require('yoho-swiper'),
tip = require('../plugin/tip'),
chosePanel = require('../common/chose-panel'),
dialog = require('../plugin/dialog'),
dbClass = 'data-bind';
dialog = require('../plugin/dialog');
var dbClass = 'data-bind';
require('../common');
... ... @@ -37,7 +37,9 @@ var infoDataHbs = require('product/detail/infodata.hbs');
var priceDataHbs = require('product/detail/pricedata.hbs');
var renderInfo = function(data) {
if (!data) { return; }
if (!data) {
return;
}
// 商品价格
if (data.goodsPrice) {
... ... @@ -69,8 +71,6 @@ var renderInfo = function(data) {
return false;
});
}, 200);
} else {
chosePanel(data);
}
};
... ... @@ -140,6 +140,8 @@ var getInfoData = function() {
rightBtnText: '打开Yoho!Buy有货APP'
}
}, function() {
var appUrl = $('input[name="limitCodeUrl"]').val();
ifr = document.createElement('iframe');
ifr.src = appUrl;
ifr.style.display = 'none';
... ... @@ -173,15 +175,16 @@ var getInfoData = function() {
/*
* 获取商品 相关数据: 1. 促销 2. feedback 3. 店铺, 并初始化
*/
+(function(skn, productId, brandId) { // eslint-disable-line
+
(function(skn, productId, brandId) { // eslint-disable-line
// 模版: 促销, feedback, 店铺
// var promotion = require('product/detail/promotion.hbs');
var promotionT = require('product/detail/promotion.hbs');
var feedbackT = require('product/detail/feedbacks.hbs');
var enterStoreT = require('product/detail/enterStore.hbs');
// placeholder
var $feedbackStore = $('#placeholder-feedback-store');
var $promotion = $('#placeholder-promotion');
/**
* 渲染 feedback, 店铺, 替换placeholder
... ... @@ -204,18 +207,67 @@ var getInfoData = function() {
}
/**
* 渲染 促销, 替换placeholder
* @param data
* {
* promotion
* }
* @param $placeholder
*/
function renderPromotion(data, $placeholder) {
var promotionHtml = promotionT({
promotion: data.promotion
});
return $placeholder.replaceWith(promotionHtml);
}
function promotionInit() {
var $goodsDiscount = $('#goodsDiscount');
var $discountFirstItem = $goodsDiscount.find('.first-item');
var $discountFolder = $goodsDiscount.find('.discount-folder');
var $discountArrow = $goodsDiscount.find('.first-item span');
// 初始化goods-discount
if ($discountFolder.children().length === 0) {
$discountFolder.css('display', 'none');
$discountArrow.html('');
}
// goods-discount下拉按钮点击事件
if ($goodsDiscount.length && $discountFolder.children().length > 0) {
$goodsDiscount.on('click', function() {
if ($discountFolder.is(':hidden')) {
$discountFirstItem.removeClass('short-text');
$discountArrow.removeClass('icon-down').addClass('icon-up').html('&#xe608;');
$discountFolder.slideDown();
} else {
$discountFirstItem.addClass('short-text');
$discountArrow.removeClass('icon-up').addClass('icon-down').html('&#xe609;');
$discountFolder.slideUp();
}
});
}
}
// boot
$.get('/product/detail/sknData.json', {
skn: skn,
productId: productId,
brandId: brandId
}).done(function(info) {
renderFeedbackStore({
feedbacks: info.feedbacks,
enterStore: info.enterStore
}, $feedbackStore);
// step1: render dom
renderFeedbackStore(info, $feedbackStore);
renderPromotion(info, $promotion);
// step2: init js
require('./detail/comments-consults');
require('./detail/consultform'); // TODO
promotionInit();
});
}(productSkn, productId, brandId));
// 初始化执行
getInfoData();
... ...