...
|
...
|
@@ -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('');
|
|
|
$discountFolder.slideDown();
|
|
|
} else {
|
|
|
$discountFirstItem.addClass('short-text');
|
|
|
$discountArrow.removeClass('icon-up').addClass('icon-down').html('');
|
|
|
$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(); |
|
|
|
...
|
...
|
|