Authored by xuqi

submit consult of good detail

@@ -136,7 +136,7 @@ @@ -136,7 +136,7 @@
136 {{/each}} 136 {{/each}}
137 <span class="size-ruler"></span> 137 <span class="size-ruler"></span>
138 138
139 - <span class="size-warn hide"> 139 + <span class="size-warn warn-tip hide">
140 <i class="iconfont">&#xe62c;</i> 140 <i class="iconfont">&#xe62c;</i>
141 请选择尺码 141 请选择尺码
142 </span> 142 </span>
@@ -153,7 +153,7 @@ @@ -153,7 +153,7 @@
153 <i id="plus-num" class="plus iconfont">&#xe610;</i> 153 <i id="plus-num" class="plus iconfont">&#xe610;</i>
154 <i id="minus-num" class="minus iconfont">&#xe600;</i> 154 <i id="minus-num" class="minus iconfont">&#xe600;</i>
155 </span> 155 </span>
156 - <span id="num-warn" class="num-warn hide"> 156 + <span id="num-warn" class="num-warn warn-tip hide">
157 <i class="iconfont">&#xe62c;</i> 157 <i class="iconfont">&#xe62c;</i>
158 库存不足 158 库存不足
159 </span> 159 </span>
@@ -361,7 +361,7 @@ @@ -361,7 +361,7 @@
361 <span class="sep">|</span> 361 <span class="sep">|</span>
362 <span class="title cur">购买评价({{commentNum}})</span> 362 <span class="title cur">购买评价({{commentNum}})</span>
363 </p> 363 </p>
364 - <div class="comments content"> 364 + <div class="comments cc-content">
365 <h2>购买评价({{commentNum}})</h2> 365 <h2>购买评价({{commentNum}})</h2>
366 <ul id="comments-ul"> 366 <ul id="comments-ul">
367 {{# comments}} 367 {{# comments}}
@@ -395,7 +395,7 @@ @@ -395,7 +395,7 @@
395 </p> 395 </p>
396 </div> 396 </div>
397 397
398 - <div class="consults content"> 398 + <div class="consults cc-content">
399 <h2>顾客咨询({{consultNum}})</h2> 399 <h2>顾客咨询({{consultNum}})</h2>
400 <ul id="consults-ul"> 400 <ul id="consults-ul">
401 {{# consults}} 401 {{# consults}}
@@ -428,20 +428,27 @@ @@ -428,20 +428,27 @@
428 </p> 428 </p>
429 <div class="new-consult hide"> 429 <div class="new-consult hide">
430 <textarea class="my-consult"></textarea> 430 <textarea class="my-consult"></textarea>
431 - <span class="warn-tip"> 431 + <span class="consult-warn warn-tip hide">
432 <i class="iconfont">&#xe62c;</i> 432 <i class="iconfont">&#xe62c;</i>
433 请输入咨询内容 433 请输入咨询内容
434 </span> 434 </span>
435 <div class="captcha-row"> 435 <div class="captcha-row">
436 <input class="captcha" type="text"> 436 <input class="captcha" type="text">
437 <img class="captcha-img" src="http://www.yohobuy.com/passport/images?g=consult"> 437 <img class="captcha-img" src="http://www.yohobuy.com/passport/images?g=consult">
438 - <span class="warn-tip"> 438 + <span class="captcha-warn warn-tip hide">
439 <i class="iconfont">&#xe62c;</i> 439 <i class="iconfont">&#xe62c;</i>
440 - 请输入验证码 440 + <em>请输入验证码</em>
441 </span> 441 </span>
442 </div> 442 </div>
443 <span id="submit-consult" class="btn submit-consult">提交咨询</span> 443 <span id="submit-consult" class="btn submit-consult">提交咨询</span>
444 </div> 444 </div>
  445 +
  446 + <div class="consult-success hide">
  447 + <p>
  448 + <span class="iconfont">&#xe61a;</span>
  449 + 咨询成功,请等待客服回复
  450 + </p>
  451 + </div>
445 </div> 452 </div>
446 </div> 453 </div>
447 {{/ consultComment}} 454 {{/ consultComment}}
@@ -339,7 +339,79 @@ $('.consult-comment').on('click', '.title', function() { @@ -339,7 +339,79 @@ $('.consult-comment').on('click', '.title', function() {
339 339
340 //我要咨询 340 //我要咨询
341 $('#consults-btn').click(function() { 341 $('#consults-btn').click(function() {
  342 +
  343 + //TODO:点击我要资讯的时候更新验证码显示
342 $('.new-consult').removeClass('hide'); 344 $('.new-consult').removeClass('hide');
  345 + $('.consult-success').addClass('hide');
  346 +});
  347 +
  348 +//提交咨询
  349 +$('#submit-consult').click(function() {
  350 + var $this = $(this),
  351 + $parent = $this.closest('.new-consult'),
  352 + $textarea = $parent.find('.my-consult'),
  353 + $captcha = $parent.find('.captcha'),
  354 + content = $.trim($textarea.val()),
  355 + captcha = $.trim($captcha.val());
  356 +
  357 + var $consultWarn = $parent.find('.consult-warn'),
  358 + $captchaWarn = $parent.find('.captcha-warn');
  359 +
  360 + var pass = true;
  361 +
  362 + if (content === '') {
  363 + $textarea.addClass('error');
  364 + $consultWarn.removeClass('hide');
  365 +
  366 + pass = false;
  367 + } else {
  368 + $textarea.removeClass('error');
  369 + $consultWarn.addClass('hide');
  370 + }
  371 +
  372 + if (captcha === '') {
  373 + $captcha.addClass('error');
  374 + $captchaWarn.removeClass('hide').children('em').text('请输入验证码');
  375 +
  376 + pass = false;
  377 + } else {
  378 + $captcha.removeClass('error');
  379 + $captchaWarn.addClass('hide');
  380 + }
  381 +
  382 + if (pass === false) {
  383 + return;
  384 + }
  385 +
  386 + $.ajax({
  387 + type: 'GET',
  388 + url: '/product/item/consult',
  389 + data: {
  390 + content: content,
  391 + captcha: captcha
  392 + }
  393 + }).then(function(data) {
  394 + var code = data.code;
  395 +
  396 + if (code === 200) {
  397 + $parent.addClass('hide');
  398 +
  399 + $parent.siblings('.consult-success').removeClass('hide');
  400 +
  401 + //清空输入
  402 + $textarea.val('');
  403 + $captcha.val('');
  404 + } else if (code === 400) {
  405 +
  406 + //跳转登录页
  407 + location.href = data.href;
  408 + } else if (code === 401) {
  409 +
  410 + //验证码错误
  411 + $captcha.addClass('error');
  412 + $captchaWarn.removeClass('hide').children('em').text('验证码错误');
  413 + }
  414 + });
343 }); 415 });
344 416
345 //售后服务 417 //售后服务
@@ -251,16 +251,8 @@ @@ -251,16 +251,8 @@
251 } 251 }
252 252
253 .size-warn, .num-warn { 253 .size-warn, .num-warn {
254 - display: inline-block;  
255 height: 24px; 254 height: 24px;
256 line-height: 24px; 255 line-height: 24px;
257 - color: #e01;  
258 - margin-left: 7px;  
259 - font-size: 12px;  
260 -  
261 - i {  
262 - font-size: 14px;  
263 - }  
264 } 256 }
265 257
266 .color-size-tip { 258 .color-size-tip {
@@ -583,7 +575,7 @@ @@ -583,7 +575,7 @@
583 } 575 }
584 } 576 }
585 577
586 - .consult-comment .content { 578 + .cc-content {
587 background: #f5f7f6; 579 background: #f5f7f6;
588 padding: 20px 20px 0 20px; 580 padding: 20px 20px 0 20px;
589 font-size: 12px; 581 font-size: 12px;
@@ -670,47 +662,69 @@ @@ -670,47 +662,69 @@
670 .consults { 662 .consults {
671 display: none; 663 display: none;
672 } 664 }
  665 + }
673 666
674 - .new-consult {  
675 - padding: 20px 0;  
676 - border-top: 1px solid #eaeceb; 667 + .new-consult {
  668 + padding: 20px 0;
  669 + border-top: 1px solid #eaeceb;
677 670
678 - textarea {  
679 - width: 590px;  
680 - height: 80px;  
681 - margin-top: 8px;  
682 - padding: 5px;  
683 - color: #ccc;  
684 - } 671 + textarea {
  672 + width: 590px;
  673 + height: 80px;
  674 + margin-top: 8px;
  675 + padding: 5px;
  676 + outline: none;
  677 + }
685 678
686 - .captcha-row {  
687 - margin: 10px 0;  
688 - } 679 + .captcha-row {
  680 + margin: 10px 0;
  681 + }
689 682
690 - .captcha {  
691 - width: 70px;  
692 - height: 20px;  
693 - line-height: 20px;  
694 - border: 1px solid #ccc;  
695 - margin-right: 5px;  
696 - padding: 5px;  
697 - color: #ccc;  
698 - } 683 + .captcha {
  684 + width: 70px;
  685 + height: 20px;
  686 + line-height: 20px;
  687 + border: 1px solid #ccc;
  688 + margin-right: 5px;
  689 + padding: 5px;
  690 + outline: none;
  691 + }
699 692
700 - .captcha-img {  
701 - border: 0;  
702 - height: 32px;  
703 - width: 96px;  
704 - vertical-align: middle;  
705 - } 693 + .captcha-img {
  694 + border: 0;
  695 + height: 32px;
  696 + width: 96px;
  697 + vertical-align: middle;
  698 + }
706 699
707 - .submit-consult {  
708 - display: block;  
709 - width: 140px;  
710 - height: 32px;  
711 - line-height: 32px;  
712 - margin: 0;  
713 - } 700 + .submit-consult {
  701 + display: block;
  702 + width: 140px;
  703 + height: 32px;
  704 + line-height: 32px;
  705 + margin: 0;
  706 + }
  707 +
  708 + .error {
  709 + border-color: #e01;
  710 + }
  711 + }
  712 +
  713 + .consult-success {
  714 + border-top: 1px solid #eaeceb;
  715 + margin-top: 30px;
  716 + text-align: center;
  717 + padding: 20px 0;
  718 +
  719 + p {
  720 + width: 295px;
  721 + height: 55px;
  722 + line-height: 55px;
  723 + margin: 0 auto;
  724 + border: 2px solid #222;
  725 + display: block;
  726 + color: #222;
  727 + font-weight: bold;
714 } 728 }
715 } 729 }
716 730
@@ -728,6 +742,7 @@ @@ -728,6 +742,7 @@
728 background: #eaeceb; 742 background: #eaeceb;
729 text-align: center; 743 text-align: center;
730 font-size: 12px; 744 font-size: 12px;
  745 + cursor: pointer;
731 746
732 .iconfont { 747 .iconfont {
733 font-size: 12px; 748 font-size: 12px;
@@ -823,4 +838,15 @@ @@ -823,4 +838,15 @@
823 color: #999; 838 color: #999;
824 } 839 }
825 } 840 }
  841 +
  842 + .warn-tip {
  843 + display: inline-block;
  844 + color: #e01;
  845 + margin-left: 7px;
  846 + font-size: 12px;
  847 +
  848 + i {
  849 + font-size: 14px;
  850 + }
  851 + }
826 } 852 }
@@ -374,4 +374,13 @@ class ItemController extends AbstractAction @@ -374,4 +374,13 @@ class ItemController extends AbstractAction
374 { 374 {
375 echo(' '); 375 echo(' ');
376 } 376 }
  377 +
  378 + public function consultAction()
  379 + {
  380 + $this->echoJson(
  381 + array(
  382 + 'code' => 200
  383 + )
  384 + );
  385 + }
377 } 386 }