compare.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. {extend name="default/base/base_home" /}
  2. {block name="mall_main"}
  3. <div class="w1200">
  4. <div class="dsh-container mt10 mb10">
  5. <div class="dsh-compare-title">{$Think.lang.comparison_basic_information}</div>
  6. {if $compare_list}
  7. <table class="dsh-compare-table">
  8. {foreach name="compare_list" item="v"}
  9. <!-- 显示商品图片及名称 -->
  10. {if $v.key == 'goodsinfo'}
  11. <tr id="comparetr_{$key}" class="goods_tr">
  12. <th>{$v.name}</th>
  13. {for start="0" end="$maxnum"}
  14. {if $v[$i]}
  15. <td>
  16. <dl class="goods-info">
  17. <dt class="goods-pic"><a href="{:url('Goods/index',['goods_id'=>$v[$i]['goods_id']])}" target="_blank"><img src="{:goods_cthumb($v[$i]['goods_image'],240,$v[$i]['store_id'])}"></a></dt>
  18. <dd class="goods-name"><a href="{:url('Goods/index',['goods_id'=>$v[$i]['goods_id']])}" target="_blank">{$v[$i]['goods_name']}</a></dd>
  19. {if $i>0}
  20. <dd class="del" onclick="javascript:delCompare({$v[$i]['goods_id']},'info');"><i class="iconfont">&#xe725;</i>{$Think.lang.compare_delete}</dd>
  21. {/if}
  22. </dl>
  23. </td>
  24. {else /}
  25. <td><div class="no-compare">
  26. <h3>{$Think.lang.no_comparison_term}</h3>
  27. <a href="{:url('Search/index',['cate_id'=>$cate_id])}" title="" target="_blank">{$Think.lang.compare_add}</a></div></td>
  28. {/if}
  29. {/for}
  30. </tr>
  31. {/if}
  32. <!-- 显示商品价格 -->
  33. {if $v.key == 'goodsprice'}
  34. <tr id="comparetr_{$key}">
  35. <th>{$v.name}</th>
  36. {for start="0" end="$maxnum"}
  37. <td><div class="goods-price">{$v[$i]?$Think.lang.currency.$v[$i]:''}&nbsp;</div></td>
  38. {/for}
  39. </tr>
  40. {/if}
  41. <!-- 显示品牌 -->
  42. {if $v.key == 'brand'}
  43. <tr id="comparetr_{$key}">
  44. <th>{$v.name}</th>
  45. {for start="0" end="$maxnum"}
  46. <td>{if is_array($v[$i])}{$v[$i]['brand_name']}{else/}{$v[$i]}{/if}&nbsp;</td>
  47. {/for}
  48. </tr>
  49. {/if}
  50. <!-- 显示普通文字项 -->
  51. {if !$v.key}
  52. <tr id="comparetr_{$key}">
  53. <th>{$v.name}
  54. <input type="hidden" name="isdiff[]" value="{$key}|{$v.isdiff}" /></th>
  55. {for start="0" end="$maxnum"}
  56. <td>{$v[$i]}&nbsp;</td>
  57. {/for}
  58. </tr>
  59. {/if}
  60. {/foreach}
  61. </table>
  62. <div class="dsh-compare-bottom"> <a href="javascript:void(0);" ds_type="comparediff" data-param='{"type":"light"}'><i class="iconfont">&#xe748;</i>{$Think.lang.highlight_different_items}</a> <a href="javascript:void(0);" ds_type="comparediff" data-param='{"type":"cancel"}' style="display: none;"><i class="iconfont">&#xe789;</i>{$Think.lang.unhighlight_different_items}</a> <a href="javascript:void(0);" ds_type="comparesame" data-param='{"type":"hide"}'><i class="iconfont">&#xe749;</i>{$Think.lang.hide_same_item}</a> <a href="javascript:void(0);" ds_type="comparesame" data-param='{"type":"show"}' style="display: none;"><i class="iconfont">&#xe7b0;</i>{$Think.lang.show_same_item}</a> <a href="javascript:void(0);" class="delall" onclick="javascript:delCompare('all','info');"><i class="iconfont">&#xe699;</i>{$Think.lang.empty_contrast_bar}</a></div>
  63. {else /}
  64. <table class="dsh-compare-table">
  65. <tbody>
  66. <tr>
  67. <td class="dsh-compare-null"><p> <i class="iconfont">&#xe718;</i>{$Think.lang.uncorrelated_goods}</p></td>
  68. </tr>
  69. </tbody>
  70. </table>
  71. {/if}
  72. </div>
  73. </div>
  74. <script type="text/javascript">
  75. /* 当鼠标移到表格上是,当前一行背景变色 */
  76. $(document).ready(function(){
  77. $(".dsh-compare-table tr td").mouseover(function(){
  78. $(this).parent().find("td").css("background-color","#F5F5F5");
  79. $(this).parent().find("th").css("background-color","#F5F5F5");
  80. });
  81. })
  82. /* 当鼠标在表格上移动时,离开的那一行背景恢复 */
  83. $(document).ready(function(){
  84. $(".dsh-compare-table tr td").mouseout(function(){
  85. var bgc = $(this).parent().attr("bg");
  86. $(this).parent().find("td").css("background-color","#FFFFFF");
  87. $(this).parent().find("th").css("background-color","#FFFFFF");
  88. });
  89. })
  90. $(function(){
  91. //高亮显示和取消高亮不同项
  92. $("[ds_type='comparediff']").click(function(){
  93. //处理参数
  94. var data_str = '';
  95. eval('data_str =' + $(this).attr('data-param'));
  96. var type = data_str.type;
  97. $("[ds_type='comparediff']").show();
  98. $(this).hide();
  99. $("[name='isdiff[]']").each(function(){
  100. var itemval = $(this).val();
  101. if(itemval){
  102. itemval = itemval.split("|");
  103. if(type == 'light'){
  104. itemval[1] == 1?$("#comparetr_"+itemval[0]).addClass('diffrow'):'';
  105. } else {
  106. itemval[1] == 1?$("#comparetr_"+itemval[0]).removeClass('diffrow'):'';
  107. }
  108. }
  109. });
  110. });
  111. //隐藏和显示相同项
  112. $("[ds_type='comparesame']").click(function(){
  113. //处理参数
  114. var data_str = '';
  115. eval('data_str =' + $(this).attr('data-param'));
  116. var type = data_str.type;
  117. $("[ds_type='comparesame']").show();
  118. $(this).hide();
  119. $("[name='isdiff[]']").each(function(){
  120. var itemval = $(this).val();
  121. if(itemval){
  122. itemval = itemval.split("|");
  123. if(type == 'show'){
  124. itemval[1] == 0?$("#comparetr_"+itemval[0]).show():'';
  125. } else {
  126. itemval[1] == 0?$("#comparetr_"+itemval[0]).hide():'';
  127. }
  128. }
  129. });
  130. });
  131. });
  132. </script>
  133. {/block}