index.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. {extend name="default/base/base_seller" /}
  2. {block name="seller_main"}
  3. <div class="alert mt15 mb5"><strong>{$Think.lang.operating_instructions}:</strong>
  4. <ul>
  5. <li>{$Think.lang.sellerspec_tip1}</li>
  6. <li>{$Think.lang.sellerspec_tip2}<font color="red">{$Think.lang.sellerspec_tip3}</font>{$Think.lang.sellerspec_tip4}</li>
  7. <li>{$Think.lang.sellerspec_tip5}</li>
  8. </ul>
  9. </div>
  10. <table class="search-form">
  11. <tr>
  12. <td class="w20">&nbsp;</td>
  13. <td class="w120"><strong>{$Think.lang.select_business_category}</strong></td>
  14. <td>
  15. <span dstype="gc1">
  16. {notempty name="gc_list"}
  17. <select dstype="gc" data-param="{deep:1}">
  18. <option>{$Think.lang.ds_please_choose}</option>
  19. {foreach name="gc_list" item="val"}
  20. <option value="{$val.gc_id}">{$val.gc_name}</option>
  21. {/foreach}
  22. </select>
  23. {/notempty}
  24. </span>
  25. <span dstype="gc2"></span>
  26. <span dstype="gc3"></span>
  27. </td>
  28. <td>&nbsp;</td>
  29. </tr>
  30. </table>
  31. <div dstype="class_spec" class="dssc-goods-spec">
  32. <div dstype="spec_ul" class="spec-tabmenu"></div>
  33. <div dstype="spec_iframe" class="spec-iframe">
  34. <div class="norecord tc">
  35. <div class="warning-option"><i class="iconfont">&#xe64c;</i><span>{$Think.lang.no_record}</span>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <!--<script src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js"></script>
  41. <script>
  42. $(function () {
  43. gcategoryInit("gcategory");
  44. });
  45. </script>-->
  46. <script>
  47. $(function() {
  48. // 查询下级分类,分类不存在显示当前分类绑定的规格
  49. $('select[dstype="gc"]').change(function() {
  50. $(this).parents('td:first').nextAll().html('');
  51. $('div[dstype="spec_ul"]').html('');
  52. $('div[dstype="spec_iframe"]').html('');
  53. getClassSpec($(this));
  54. });
  55. });
  56. // ajax选择商品分类
  57. function getClassSpec($this) {
  58. var id = parseInt($this.val());
  59. var data_str = '';
  60. eval('data_str =' + $this.attr('data-param'));
  61. var deep = data_str.deep;
  62. if (isNaN(id)) {
  63. // 清理分类
  64. clearClassHtml(parseInt(deep) + 1);
  65. }
  66. $.getJSON('ajax_class?id=' + id + '&deep=' + deep, function(data) {
  67. $('div[dstype="spec_iframe"]').empty();
  68. $('div[dstype="spec_ul"]').empty();
  69. if (data) {
  70. if (data.type == 'class') {
  71. nextClass(data.data, data.deep);
  72. } else if (data.type == 'spec') {
  73. specList(data.data, data.deep, data.gcid);
  74. }
  75. }
  76. });
  77. }
  78. // 下一级商品分类
  79. function nextClass(data, deep) {
  80. $('span[dstype="gc' + deep + '"]').html('').append('<select data-param="{deep:' + deep + '}"></select>')
  81. .find('select').change(function() {
  82. getClassSpec($(this));
  83. }).append('<option>{$Think.lang.ds_please_choose}</option>');
  84. $.each(data, function(i, n) {
  85. if (n != null) {
  86. $('span[dstype="gc' + deep + '"] > select').append('<option value="' + n.gc_id + '">' + n.gc_name + '</option>');
  87. }
  88. });
  89. // 清理分类
  90. clearClassHtml(parseInt(deep) + 1);
  91. }
  92. // 列出规格信息
  93. function specList(data, deep, gcid) {
  94. if (typeof(data) != 'undefined' && data != '') {
  95. var $_ul = $('<ul></ul>');
  96. $.each(data, function(i, n) {
  97. $_ul.append('<li><a href="javascript:void(0);" dstype="editSpec" data-param="{spid:' + n.sp_id + ',gcid:' + gcid + '}">{$Think.lang.ds_edit}' + n.sp_name + '{$Think.lang.specifications}</a></li>');
  98. });
  99. $_ul.find('a').click(function() {
  100. $_ul.find('li').removeClass('selected');
  101. $(this).parents('li:first').addClass('selected');
  102. editSpecvalue($(this));
  103. });
  104. $_ul.find('a:first').click();
  105. $('div[dstype="spec_ul"]').append($_ul);
  106. } else {
  107. $('div[dstype="spec_ul"]').append('<div class="warning-option"><i class="iconfont">&#xe64c;</i><span>{$Think.lang.category_cannot_add_specifications}</span></div>');
  108. }
  109. // 清理分类
  110. clearClassHtml(deep);
  111. }
  112. // 清理二级分类信息
  113. function clearClassHtml(deep) {
  114. switch (deep) {
  115. case 2:
  116. $('span[dstype="gc2"]').empty();
  117. case 3:
  118. $('span[dstype="gc3"]').empty();
  119. break;
  120. }
  121. }
  122. // ajax编辑规格值
  123. function editSpecvalue(o) {
  124. $('div[dstype="spec_iframe"]').html('');
  125. var data_str = '';
  126. eval('data_str =' + o.attr('data-param'));
  127. $_iframe = $('<iframe id="iframepage" name="iframepage" frameBorder=0 scrolling=no width="100%" height="630px" ' + 'src="{:url('Sellerspec/add_spec')}?spid=' + data_str.spid + '&gcid=' + data_str.gcid + '" ></iframe>'
  128. )
  129. ;
  130. $('div[dstype="spec_iframe"]').append($_iframe);
  131. }
  132. </script>
  133. {/block}