Authored by 梁志锋

Merge branch 'feature/twocolumnbrand' into develop

/**
* 我要咨询提交页面
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/12/01
*/
var $ = require('jquery'),
tip = require('../../plugin/tip'),
loading = require('../../plugin/loading');
var $consultForm = $('.consult-form'),
$submit = $('#submit'),
$content = $('#content'),
productId = $('#product_id').val(),
isSubmiting;
$submit.on('touchend', function() {
$content.blur();
$consultForm.submit();
return false;
}).on('touchstart', function() {
$(this).addClass('highlight');
}).on('touchend touchcancel', function() {
$(this).removeClass('highlight');
});
$content.on('focus', function() {
if ($content.val() === '请输入咨询内容') {
$content.val('');
}
}).on('blur', function() {
if ($content.val() === '') {
$content.val('请输入咨询内容');
}
});
// 提交表单请求
$consultForm.on('submit', function() {
var content;
if (isSubmiting) {
return false;
}
// 简单的表单校验
content = $content.val();
if (!content || content === '请输入咨询内容') {
tip.show('咨询内容不能为空');
return false;
}
isSubmiting = true;
loading.showLoadingMask();
$.ajax({
method: 'POST',
url: '/product/detail/consultsubmit',
data: {
product_id: productId,
content: content
}
}).then(function(res) {
if ($.type(res) !== 'object') {
res = {};
}
if (res.code !== 200) {
tip.show(res.message || '网络出了点问题~');
isSubmiting = false;
loading.hideLoadingMask();
} else {
window.history.go(-1);
}
}).fail(function() {
tip.show('网络出了点问题~');
isSubmiting = false;
});
return false;
});
... ...
... ... @@ -9,10 +9,9 @@ var $ = require('jquery'),
Hammer = require('yoho.hammer'),
tip = require('../../plugin/tip');
var likeHammer = new Hammer(document.getElementById('likeBtn'));
var addToCartHammer = new Hammer(document.getElementById('addtoCart'));
var productId = $('#productId').val();
var likeHammer = new Hammer(document.getElementById('likeBtn')),
addToCartHammer = new Hammer(document.getElementById('addtoCart')),
productId = $('#productId').val();
likeHammer.on('tap', function(e) {
var opt,
... ...
... ... @@ -8,4 +8,5 @@ require('./newsale/newarrival');
require('./newsale/discount');
require('./list');
require('./detail/detail');
require('./detail/desc');
\ No newline at end of file
require('./detail/loadmore');
require('./detail/consultform');
\ No newline at end of file
... ...
... ... @@ -3,7 +3,7 @@
<form class="consult-form" url="{{formUrl}}">
<textarea id="content" name="content">请输入咨询内容</textarea>
<input type="hidden" id="product_id" value="{{productId}}">
<a type="submit">提交</a>
<a type="submit" id="submit">提交</a>
</form>
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -95,7 +95,7 @@
{{else}}
<div class="nodata">
<span>暂无商品评价和咨询</span>
<a href="/product/detail/consultform" class="go-consult">我要咨询<span class="iconfont">&#xe604;</span></a>
<a href="{{link}}" class="go-consult">我要咨询<span class="iconfont">&#xe604;</span></a>
</div>
{{/if}}
{{/if}}
... ... @@ -130,10 +130,10 @@
</div>
{{/cartInfo}}
{{#if introUrl}}
<input id="introUrl" type="hidden" value={{introUrl}}>
<input id="introUrl" type="hidden" value='{{introUrl}}'>
{{/if}}
{{#if id}}
<input id="productId" type="hidden" value={{id}}>
<input id="productId" type="hidden" value='{{id}}'>
{{/if}}
</div>
... ...
<script>
seajs.use('js/common');
</script>
<script>
seajs.use('js/product/detail/consultform');
</script>
{{!-- 逛(PLUS+STAR) --}}
{{#if psList}}
<script>
... ...
... ... @@ -59,7 +59,7 @@
<span class="iconfont">&#xe63d;</span>暂无咨询
</div>
<div class="consult-content-footer">
<a href="/product/detail/consultform">
<a href="{{link}}">
我要咨询
<span class="iconfont">&#xe604;</span></a>
</div>
... ...