人人商城

post.html 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. {php $no_left =true;}
  2. {template '_header'}
  3. <script type="text/javascript" src="../addons/ewei_shopv2/static/js/dist/area/cascade.js"></script>
  4. <style type='text/css'>
  5. .tabs-container .form-group {overflow: hidden;}
  6. .tabs-container .tabs-left > .nav-tabs {width: 120px;}
  7. .tabs-container .tabs-left .panel-body {margin-left: 120px; width: 880px; text-align: left;}
  8. .tab-goods .nav li {width: 120px; text-align: right;}
  9. .spec_item_thumb {position: relative; width: 30px; height: 20px; padding: 0; border-left: none;}
  10. .spec_item_thumb i {position: absolute; top: -5px; right: -5px;}
  11. {if $item['type']==4}
  12. .type-4 {display: none;}
  13. {/if}
  14. </style>
  15. <div class="page-heading">
  16. <span class='pull-right'>
  17. {ifp 'goods.add'}
  18. <a class="btn btn-primary btn-sm" href="{php echo webUrl('goods/add')}" >添加商品</a>
  19. {/if}
  20. <a class="btn btn-default btn-sm" href="{php echo webUrl('goods',array('goodsfrom'=>$_GPC['goodsfrom'], 'page'=>$_GPC['page']))}">返回列表</a>
  21. </span>
  22. <h2>{if !empty($item['id'])}编辑{else}添加{/if}商品 <small>{if !empty($item['id'])}修改【<span class="text-info">{$item['title']}</span>】{/if}{if !empty($merch_user['merchname'])}商户名称:【<span class="text-info">{$merch_user['merchname']}</span>】{/if}</small></h2>
  23. </div>
  24. <form {ife 'goods' $item}action="" method="post"{/if} class="form-horizontal form-validate" enctype="multipart/form-data">
  25. <input type="hidden" id="tab" name="tab" value="#tab_basic" />
  26. <div class="tabs-container tab-goods">
  27. <div class="tabs-left">
  28. <ul class="nav nav-tabs" id="myTab">
  29. <li {if empty($_GPC['tab']) || $_GPC['tab']=='basic'}class="active"{/if}><a href="#tab_basic">基本</a></li>
  30. <li {if $_GPC['tab']=='option'}class="active"{/if} ><a href="#tab_option">库存/规格</a></li>
  31. <li {if $_GPC['tab']=='param'}class="active"{/if} ><a href="#tab_param">参数</a></li>
  32. <li {if $_GPC['tab']=='des'}class="active"{/if} ><a href="#tab_des">详情</a></li>
  33. <li {if $_GPC['tab']=='buy'}class="active"{/if} ><a href="#tab_buy">购买权限</a></li>
  34. <li {if $_GPC['tab']=='sale'}class="active"{/if} ><a href="#tab_sale">营销</a></li>
  35. <li {if $_GPC['tab']=='discount'}class="active"{/if} ><a href="#tab_discount">会员折扣</a></li>
  36. <li {if $_GPC['tab']=='share'}class="active"{/if} ><a href="#tab_share">分享关注</a></li>
  37. <li {if $_GPC['tab']=='notice'}class="active"{/if} ><a href="#tab_notice">卖家通知</a></li>
  38. {if !empty($com_set['level'])}
  39. <li {if $_GPC['tab']=='sell'}class="active"{/if}><a href="#tab_sell" id="a_sell">分销</a></li>
  40. {/if}
  41. {if $merchid == 0 }
  42. <li {if $_GPC['tab']=='verify'}class="active"{/if} id="tab_nav_verify" {if $item['type']==3||$item['type']==5||($item['type']==2&&!empty($item['virtualsend']))}style="display:none;"{/if}><a href="#tab_verify">线下核销</a></li>
  43. {/if}
  44. {if p('diyform')}
  45. <li {if $_GPC['tab']=='diyform'}class="active"{/if}><a href="#tab_diyform">自定义表单</a></li>
  46. {/if}
  47. {if $merchid == 0}
  48. <li {if $_GPC['tab']=='detaildiy'}class="active"{/if}><a href="#tab_detaildiy">店铺信息</a></li>
  49. {/if}
  50. {if p('diypage')}
  51. <li {if $_GPC['tab']=='diypage'}class="active"{/if}><a href="#tab_diypage">自定义模板</a></li>
  52. {/if}
  53. <li {if $item['type'] != 5}style="display:none;"{/if} class="showverifygoods" {if $_GPC['tab']=='verifygoods'}class="active"{/if} ><a href="#tab_verifygoods"><span style="color: #666;">核销设置</span></a></li>
  54. {if com('wxcard')}
  55. <li {if $item['type'] != 5}style="display:none;"{/if} class="showverifygoodscard" {if $_GPC['tab']=='verifygoodscard'}class="active"{/if} ><a href="#tab_verifygoodscard"><span style="color: #666;">微信会员卡设置</span></a></li>
  56. {/if}
  57. </ul>
  58. <div class="tab-content ">
  59. <div class="tab-pane {if empty($_GPC['tab']) || $_GPC['tab']=='basic'}active{/if}" id="tab_basic"><div class="panel-body">{template 'goods/tab/basic'}</div></div>
  60. <div class="tab-pane {if $_GPC['tab']=='option'}active{/if}" id="tab_option"> <div class="panel-body">{template 'goods/tab/option'}</div></div>
  61. <div class="tab-pane {if $_GPC['tab']=='param'}active{/if}" id="tab_param"> <div class="panel-body">{template 'goods/tab/param'}</div></div>
  62. <div class="tab-pane {if $_GPC['tab']=='des'}active{/if}" id="tab_des"> <div class="panel-body" style='padding:0;'>{template 'goods/tab/des'}</div></div>
  63. <div class="tab-pane {if $_GPC['tab']=='buy'}active{/if}" id="tab_buy"> <div class="panel-body">{template 'goods/tab/buy'}</div></div>
  64. <div class="tab-pane {if $_GPC['tab']=='sale'}active{/if}" id="tab_sale"> <div class="panel-body">{template 'goods/tab/sale'}</div></div>
  65. <div class="tab-pane {if $_GPC['tab']=='discount'}active{/if}" id="tab_discount"> <div class="panel-body">{template 'goods/tab/discount'}</div></div>
  66. <div class="tab-pane {if $_GPC['tab']=='share'}active{/if}" id="tab_share"> <div class="panel-body">{template 'goods/tab/share'}</div></div>
  67. <div class="tab-pane {if $_GPC['tab']=='notice'}active{/if}" id="tab_notice"> <div class="panel-body">{template 'goods/tab/notice'}</div></div>
  68. <div class="tab-pane {if $_GPC['tab']=='verifygoods'}active{/if}" id="tab_verifygoods"> <div class="panel-body">{template 'goods/tab/verifygoods'}</div></div>
  69. {if com('wxcard')}
  70. <div class="tab-pane {if $_GPC['tab']=='verifygoodscard'}active{/if}" id="tab_verifygoodscard"> <div class="panel-body">{template 'goods/tab/verifygoodscard'}</div></div>
  71. {/if}
  72. {if p('commission') && !empty($com_set['level'])}
  73. <div class="tab-pane {if $_GPC['tab']=='sell'}active{/if}" id="tab_sell">
  74. <div class="panel-body">
  75. {template 'commission/goods'}
  76. </div>
  77. </div>
  78. {/if}
  79. {if $merchid == 0}
  80. <div class="tab-pane {if $_GPC['tab']=='verify'}active{/if}" id="tab_verify" {if $item['type']==3||($item['type']==2&&!empty($item['virtualsend']))}style="display:none;"{/if}> <div class="panel-body">{template 'goods/tab/verify'}</div></div>
  81. {/if}
  82. {if p('diyform')}
  83. <div class="tab-pane {if $_GPC['tab']=='diyform'}active{/if}" id="tab_diyform"> <div class="panel-body">{template 'diyform/goods'}</div></div>
  84. {/if}
  85. {if $merchid == 0}
  86. <div class="tab-pane {if $_GPC['tab']=='detaildiy'}active{/if}" id="tab_detaildiy"> <div class="panel-body">{template 'goods/tab/detaildiy'}</div></div>
  87. {/if}
  88. {if p('diypage')}
  89. <div class="tab-pane {if $_GPC['tab']=='diypage'}active{/if}" id="tab_diypage"> <div class="panel-body">{template 'diypage/invoke/goods'}</div></div>
  90. {/if}
  91. </div>
  92. </div>
  93. </div>
  94. <div class='panel-body' style='position:fixed;bottom:0;width:1000px; text-align: right;z-index:10; '>
  95. {ife 'goods' $item}
  96. <input type="submit" value="保存商品" class="btn btn-primary"/>
  97. {/if}
  98. </div>
  99. </form>
  100. <script type="text/javascript">
  101. window.type = "{$item['type']}";
  102. window.virtual = "{$item['virtual']}";
  103. require(['bootstrap'], function () {
  104. $('#myTab a').click(function (e) {
  105. $('#tab').val( $(this).attr('href'));
  106. e.preventDefault();
  107. $(this).tab('show');
  108. })
  109. });
  110. $(function () {
  111. $(':radio[name=isverify]').click(function () {
  112. window.type = $("input[name='isverify']:checked").val();
  113. if (window.type == '2') {
  114. $(':checkbox[name=cash]').attr("checked",false);
  115. $(':checkbox[name=cash]').parent().hide();
  116. } else {
  117. $(':checkbox[name=cash]').parent().show();
  118. }
  119. });
  120. $(':radio[name=ispresell]').click(function () {
  121. window.ispresell = $("input[name='ispresell']:checked").val();
  122. if(window.ispresell==0){
  123. $(".presell_info").hide();
  124. }else{
  125. $(".presell_info").show();
  126. }
  127. });
  128. $(':radio[name=type]').click(function () {
  129. window.type = $("input[name='type']:checked").val();
  130. window.virtual = $("#virtual").val();
  131. if(window.type=='1'||window.type=='4'){
  132. $('.dispatch_info').show();
  133. } else {
  134. $('.dispatch_info').hide();
  135. }
  136. if (window.type == '2') {
  137. $('.send-group').show();
  138. } else {
  139. $('.send-group').hide();
  140. }
  141. if (window.type == '3') {
  142. if ($('#virtual').val() == '0') {
  143. $('.choosetemp').show();
  144. }
  145. // 商品类型如果为虚拟卡密则不允许修改库存
  146. $('#weight').attr('readonly',true);
  147. $('#total').attr('readonly',true);
  148. }
  149. if (window.type == '2' || window.type == '3'|| window.type == '5') {
  150. $(':checkbox[name=cash]').attr("checked",false);
  151. $(':checkbox[name=cash]').parent().hide();
  152. } else {
  153. $(':checkbox[name=cash]').parent().show();
  154. }
  155. if(window.type=='4'){
  156. $('.type-4').hide();
  157. }else{
  158. $('.type-4').show();
  159. }
  160. })
  161. $(":checkbox[name='buyshow']").click(function () {
  162. if ($(this).prop('checked')) {
  163. $(".bcontent").show();
  164. }
  165. else {
  166. $(".bcontent").hide();
  167. }
  168. })
  169. $(':radio[name=buyshow]').click(function () {
  170. window.buyshow = $("input[name='buyshow']:checked").val();
  171. if(window.buyshow=='1'){
  172. $('.bcontent').show();
  173. } else {
  174. $('.bcontent').hide();
  175. }
  176. })
  177. })
  178. window.optionchanged = false;
  179. $('form').submit(function(){
  180. var check = true;
  181. $(".tp_title,.tp_name").each(function(){
  182. var val = $(this).val();
  183. if(!val){
  184. $('#myTab a[href="#tab_diyform"]').tab('show');
  185. $(this).focus(),$('form').attr('stop',1),tip.msgbox.err('自定义表单字段名称不能为空!');
  186. check =false;
  187. return false;
  188. }
  189. });
  190. var diyformtype = $(':radio[name=diyformtype]:checked').val();
  191. if (diyformtype == 2) {
  192. if(kw == 0) {
  193. $('#myTab a[href="#tab_diyform"]').tab('show');
  194. $(this).focus(),$('form').attr('stop',1),tip.msgbox.err('请先添加自定义表单字段再提交!');
  195. check =false;
  196. return false;
  197. }
  198. }
  199. if(!check){return false;}
  200. window.type = $("input[name='type']:checked").val();
  201. window.virtual = $("#virtual").val();
  202. if ($("#goodsname").isEmpty()) {
  203. $('#myTab a[href="#tab_basic"]').tab('show');
  204. $('form').attr('stop',1);
  205. $(this).focus(),$('form').attr('stop',1),tip.msgbox.err('请填写商品名称!');
  206. return false;
  207. }
  208. var inum = 0;
  209. $('.gimgs').find('.img-thumbnail').each(function(){
  210. inum++;
  211. });
  212. if(inum == 0){
  213. $('#myTab a[href="#tab_basic"]').tab('show');
  214. $('form').attr('stop',1),tip.msgbox.err('请上传商品图片!');
  215. return false;
  216. }
  217. var full = true;
  218. if (window.type == '3') {
  219. if (window.virtual != '0') { //如果单规格,不能有规格
  220. if ($('#hasoption').get(0).checked) {
  221. $('form').attr('stop',1),tip.msgbox.err('您的商品类型为:虚拟物品(卡密)的单规格形式,需要关闭商品规格!');
  222. return false;
  223. }
  224. }
  225. else {
  226. var has = false;
  227. $('.spec_item_virtual').each(function () {
  228. has = true;
  229. if ($(this).val() == '' || $(this).val() == '0') {
  230. $('#myTab a[href="#tab_option"]').tab('show');
  231. $(this).next().focus();
  232. $('form').attr('stop',1),tip.msgbox.err('请选择虚拟物品模板!');
  233. full = false;
  234. return false;
  235. }
  236. });
  237. if (!has) {
  238. $('#myTab a[href="#tab_option"]').tab('show');
  239. $('form').attr('stop',1),tip.msgbox.err('您的商品类型为:虚拟物品(卡密)的多规格形式,请添加规格!');
  240. return false;
  241. }
  242. }
  243. }
  244. else if (window.type == '5') {
  245. if ($('#hasoption').get(0).checked) {
  246. $('form').attr('stop',1),tip.msgbox.err('您的商品类型为:核销产品,无法设置多商品规格!');
  247. return false;
  248. }
  249. }
  250. else if(window.type=='10'){
  251. var spec_itemlen = $(".spec_item").length;
  252. if (!$('#hasoption').get(0).checked || spec_itemlen<1) {
  253. $('#myTab a[href="#tab_option"]').tab('show');
  254. $('form').attr('stop',1),tip.msgbox.err('您的商品类型为:话费流量充值,需要开启并设置商品规格!');
  255. return false;
  256. }
  257. if(spec_itemlen>1){
  258. $('#myTab a[href="#tab_option"]').tab('show');
  259. $('form').attr('stop',1),tip.msgbox.err('您的商品类型为:话费流量充值,只可添加一个规格!');
  260. return false;
  261. }
  262. }
  263. if (!full) {
  264. return false;
  265. }
  266. full = checkoption();
  267. if (!full) {
  268. $('form').attr('stop',1),tip.msgbox.err('请输入规格名称!');
  269. return false;
  270. }
  271. if (optionchanged) {
  272. $('#myTab a[href="#tab_option"]').tab('show');
  273. $('form').attr('stop',1),tip.msgbox.err('规格数据有变动,请重新点击 [刷新规格项目表] 按钮!');
  274. return false;
  275. }
  276. var spec_item_title = 1;
  277. $(".spec_item").each(function (i) {
  278. var _this = this;
  279. if($(_this).find(".spec_item_title").length == 0){
  280. spec_item_title = 0;
  281. }
  282. });
  283. if(spec_item_title == 0){
  284. $('form').attr('stop',1),tip.msgbox.err('详细规格没有填写,请填写详细规格!');
  285. return false;
  286. }
  287. $('form').attr('stop',1);
  288. //处理规格
  289. optionArray();
  290. isdiscountDiscountsArray();
  291. discountArray();
  292. commissionArray();
  293. $('form').removeAttr('stop');
  294. return true;
  295. });
  296. function optionArray()
  297. {
  298. var option_stock = new Array();
  299. $('.option_stock').each(function (index,item) {
  300. option_stock.push($(item).val());
  301. });
  302. var option_id = new Array();
  303. $('.option_id').each(function (index,item) {
  304. option_id.push($(item).val());
  305. });
  306. var option_ids = new Array();
  307. $('.option_ids').each(function (index,item) {
  308. option_ids.push($(item).val());
  309. });
  310. var option_title = new Array();
  311. $('.option_title').each(function (index,item) {
  312. option_title.push($(item).val());
  313. });
  314. var option_virtual = new Array();
  315. $('.option_virtual').each(function (index,item) {
  316. option_virtual.push($(item).val());
  317. });
  318. var option_marketprice = new Array();
  319. $('.option_marketprice').each(function (index,item) {
  320. option_marketprice.push($(item).val());
  321. });
  322. var option_presellprice = new Array();
  323. $('.option_presell').each(function (index,item) {
  324. option_presellprice.push($(item).val());
  325. });
  326. var option_productprice = new Array();
  327. $('.option_productprice').each(function (index,item) {
  328. option_productprice.push($(item).val());
  329. });
  330. var option_costprice = new Array();
  331. $('.option_costprice').each(function (index,item) {
  332. option_costprice.push($(item).val());
  333. });
  334. var option_goodssn = new Array();
  335. $('.option_goodssn').each(function (index,item) {
  336. option_goodssn.push($(item).val());
  337. });
  338. var option_productsn = new Array();
  339. $('.option_productsn').each(function (index,item) {
  340. option_productsn.push($(item).val());
  341. });
  342. var option_weight = new Array();
  343. $('.option_weight').each(function (index,item) {
  344. option_weight.push($(item).val());
  345. });
  346. var options = {
  347. option_stock : option_stock,
  348. option_id : option_id,
  349. option_ids : option_ids,
  350. option_title : option_title,
  351. option_presellprice : option_presellprice,
  352. option_marketprice : option_marketprice,
  353. option_productprice : option_productprice,
  354. option_costprice : option_costprice,
  355. option_goodssn : option_goodssn,
  356. option_productsn : option_productsn,
  357. option_weight : option_weight,
  358. option_virtual : option_virtual
  359. };
  360. $("input[name='optionArray']").val(JSON.stringify(options));
  361. }
  362. function isdiscountDiscountsArray()
  363. {
  364. {loop $levels $level}
  365. var isdiscount_discounts_{$level['key']} = new Array();
  366. $(".isdiscount_discounts_{$level['key']}").each(function (index,item) {
  367. isdiscount_discounts_{$level['key']}.push($(item).val());
  368. });
  369. {/loop}
  370. var isdiscount_discounts_id = new Array();
  371. $('.isdiscount_discounts_id').each(function (index,item) {
  372. isdiscount_discounts_id.push($(item).val());
  373. });
  374. var isdiscount_discounts_ids = new Array();
  375. $('.isdiscount_discounts_ids').each(function (index,item) {
  376. isdiscount_discounts_ids.push($(item).val());
  377. });
  378. var isdiscount_discounts_title = new Array();
  379. $('.isdiscount_discounts_title').each(function (index,item) {
  380. isdiscount_discounts_title.push($(item).val());
  381. });
  382. var isdiscount_discounts_virtual = new Array();
  383. $('.isdiscount_discounts_virtual').each(function (index,item) {
  384. isdiscount_discounts_virtual.push($(item).val());
  385. });
  386. var options = {
  387. {loop $levels $level}
  388. isdiscount_discounts_{$level['key']} : isdiscount_discounts_{$level['key']},
  389. {/loop}
  390. isdiscount_discounts_id : isdiscount_discounts_id,
  391. isdiscount_discounts_ids : isdiscount_discounts_ids,
  392. isdiscount_discounts_title : isdiscount_discounts_title,
  393. isdiscount_discounts_virtual : isdiscount_discounts_virtual
  394. };
  395. $("input[name='isdiscountDiscountsArray']").val(JSON.stringify(options));
  396. }
  397. function discountArray()
  398. {
  399. {loop $levels $level}
  400. var discount_{$level['key']} = new Array();
  401. $(".discount_{$level['key']}").each(function (index,item) {
  402. discount_{$level['key']}.push($(item).val());
  403. });
  404. {/loop}
  405. var discount_id = new Array();
  406. $('.discount_id').each(function (index,item) {
  407. discount_id.push($(item).val());
  408. });
  409. var discount_ids = new Array();
  410. $('.discount_ids').each(function (index,item) {
  411. discount_ids.push($(item).val());
  412. });
  413. var discount_title = new Array();
  414. $('.discount_title').each(function (index,item) {
  415. discount_title.push($(item).val());
  416. });
  417. var discount_virtual = new Array();
  418. $('.discount_virtual').each(function (index,item) {
  419. discount_virtual.push($(item).val());
  420. });
  421. var options = {
  422. {loop $levels $level}
  423. discount_{$level['key']} : discount_{$level['key']},
  424. {/loop}
  425. discount_id : discount_id,
  426. discount_ids : discount_ids,
  427. discount_title : discount_title,
  428. discount_virtual : discount_virtual
  429. };
  430. $("input[name='discountArray']").val(JSON.stringify(options));
  431. }
  432. function commissionArray()
  433. {
  434. var specs = [];
  435. $(".spec_item").each(function (i) {
  436. var _this = $(this);
  437. var spec = {
  438. id: _this.find(".spec_id").val(),
  439. title: _this.find(".spec_title").val()
  440. };
  441. var items = [];
  442. _this.find(".spec_item_item").each(function () {
  443. var __this = $(this);
  444. var item = {
  445. id: __this.find(".spec_item_id").val(),
  446. title: __this.find(".spec_item_title").val(),
  447. virtual: __this.find(".spec_item_virtual").val(),
  448. show: __this.find(".spec_item_show").get(0).checked ? "1" : "0"
  449. }
  450. items.push(item);
  451. });
  452. spec.items = items;
  453. specs.push(spec);
  454. });
  455. specs.sort(function (x, y) {
  456. if (x.items.length > y.items.length) {
  457. return 1;
  458. }
  459. if (x.items.length < y.items.length) {
  460. return -1;
  461. }
  462. });
  463. var len = specs.length;
  464. var newlen = 1;
  465. var h = new Array(len);
  466. var rowspans = new Array(len);
  467. for (var i = 0; i < len; i++) {
  468. var itemlen = specs[i].items.length;
  469. if (itemlen <= 0) {
  470. itemlen = 1
  471. }
  472. newlen *= itemlen;
  473. h[i] = new Array(newlen);
  474. for (var j = 0; j < newlen; j++) {
  475. h[i][j] = new Array();
  476. }
  477. var l = specs[i].items.length;
  478. rowspans[i] = 1;
  479. for (j = i + 1; j < len; j++) {
  480. rowspans[i] *= specs[j].items.length;
  481. }
  482. }
  483. for (var m = 0; m < len; m++) {
  484. var k = 0, kid = 0, n = 0;
  485. for (var j = 0; j < newlen; j++) {
  486. var rowspan = rowspans[m];
  487. if (j % rowspan == 0) {
  488. h[m][j] = {
  489. title: specs[m].items[kid].title,
  490. virtual: specs[m].items[kid].virtual,
  491. id: specs[m].items[kid].id
  492. };
  493. }
  494. else {
  495. h[m][j] = {
  496. title: specs[m].items[kid].title,
  497. virtual: specs[m].items[kid].virtual,
  498. id: specs[m].items[kid].id
  499. };
  500. }
  501. n++;
  502. if (n == rowspan) {
  503. kid++;
  504. if (kid > specs[m].items.length - 1) {
  505. kid = 0;
  506. }
  507. n = 0;
  508. }
  509. }
  510. }
  511. var commission = {};
  512. var commission_level = {php echo json_encode($commission_level)};
  513. for (var i = 0; i < newlen; i++) {
  514. var ids = [];
  515. for (var j = 0; j < len; j++) {
  516. ids.push(h[j][i].id);
  517. }
  518. ids = ids.join('_');
  519. $.each(commission_level,function (key,val) {
  520. if(val.key == 'default')
  521. {
  522. var kkk = "commission_level_"+val.key+"_"+ids;
  523. commission[kkk] = {};
  524. $("input[data-name=commission_level_"+val.key+"_"+ids+"]").each(function (k,v) {
  525. commission[kkk][k] = $(v).val();
  526. });
  527. }
  528. else
  529. {
  530. var kkk = "commission_level_"+val.id+"_"+ids;
  531. commission[kkk] = {};
  532. $("input[data-name=commission_level_"+val.id+"_"+ids+"]").each(function (k,v) {
  533. commission[kkk][k] = $(v).val();
  534. });
  535. var kkk = "commission_level_"+val.id+"_"+ids;
  536. commission[kkk] = {};
  537. $("input[data-name=commission_level_"+val.id+"_"+ids+"]").each(function (k,v) {
  538. commission[kkk][k] = $(v).val();
  539. });
  540. }
  541. })
  542. }
  543. var commission_id = new Array();
  544. $('.commission_id').each(function (index,item) {
  545. commission_id.push($(item).val());
  546. });
  547. var commission_ids = new Array();
  548. $('.commission_ids').each(function (index,item) {
  549. commission_ids.push($(item).val());
  550. });
  551. var commission_title = new Array();
  552. $('.commission_title').each(function (index,item) {
  553. commission_title.push($(item).val());
  554. });
  555. var commission_virtual = new Array();
  556. $('.commission_virtual').each(function (index,item) {
  557. commission_virtual.push($(item).val());
  558. });
  559. var options = {
  560. commission : commission,
  561. commission_id : commission_id,
  562. commission_ids : commission_ids,
  563. commission_title : commission_title,
  564. commission_virtual : commission_virtual
  565. };
  566. $("input[name='commissionArray']").val(JSON.stringify(options));
  567. }
  568. function checkoption() {
  569. var full = true;
  570. var $spec_title = $(".spec_title");
  571. var $spec_item_title = $(".spec_item_title");
  572. if ($("#hasoption").get(0).checked) {
  573. if($spec_title.length==0){
  574. $('#myTab a[href="#tab_option"]').tab('show');
  575. full = false;
  576. }
  577. if($spec_item_title.length==0){
  578. $('#myTab a[href="#tab_option"]').tab('show');
  579. full = false;
  580. }
  581. }
  582. if (!full) {
  583. return false;
  584. }
  585. return full;
  586. }
  587. function type_change(type) {
  588. if(type == 4) {
  589. $(".interval").show();
  590. $(".price").hide();
  591. $(".minbuy").hide();
  592. $(".wholesalewarning").show();
  593. }else{
  594. $(".interval").hide();
  595. $(".price").show();
  596. $(".minbuy").show();
  597. $(".wholesalewarning").hide();
  598. }
  599. if(type == 5) {
  600. $(".showverifygoods").show();
  601. $(".showverifygoodscard").show();
  602. $('#product').hide();
  603. $('#type_virtual').hide();
  604. $("#tab_nav_verify").hide();
  605. $("[for|='totalcnf2']").show();
  606. $("[for|='totalcnf3']").show();
  607. }else
  608. {
  609. $(".showverifygoods").hide();
  610. $(".showverifygoodscard").hide();
  611. }
  612. if(type == 1||type == 4) {
  613. $('#product').show();
  614. $('#type_virtual').hide();
  615. $('.entity').show();
  616. $("#tab_nav_verify").show();
  617. $("[for|='totalcnf2']").show();
  618. $("[for|='totalcnf3']").show();
  619. } else if(type == 2) {
  620. $('#product').hide();
  621. $('#type_virtual').hide();
  622. $('.entity').hide();
  623. if($("input[name='virtualsend']:checked").val()==1) {
  624. $("#tab_nav_verify").hide();
  625. }else{
  626. $("#tab_nav_verify").show();
  627. }
  628. $("[for|='totalcnf2']").show();
  629. $("[for|='totalcnf3']").show();
  630. } else if(type == 3) {
  631. $('#type_virtual').show();
  632. $('.entity').hide();
  633. $("#tab_nav_verify").hide();
  634. $("[for|='totalcnf2']").hide();
  635. $("[for|='totalcnf3']").hide();
  636. }else if(type == 10) {
  637. $('#type_virtual').hide();
  638. $('#product').hide();
  639. $('.entity').hide();
  640. $("#tab_nav_verify").hide();
  641. $("[for|='totalcnf2']").show();
  642. $("[for|='totalcnf3']").show();
  643. }
  644. }
  645. </script>
  646. {template '_footer'}