index_alone.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. {extend name="public/container"}
  2. {block name="head"}
  3. <link href="{__FRAME_PATH}css/plugins/iCheck/custom.css" rel="stylesheet">
  4. <script src="{__ADMIN_PATH}plug/validate/jquery.validate.js"></script>
  5. <script src="{__ADMIN_PATH}frame/js/plugins/iCheck/icheck.min.js"></script>
  6. <script src="{__ADMIN_PATH}frame/js/ajaxfileupload.js"></script>
  7. <style>
  8. label.error{
  9. color: #a94442;
  10. margin-bottom: 0;
  11. display: inline-block;
  12. font: normal normal normal 14px/1 FontAwesome;
  13. font-size: inherit;
  14. text-rendering: auto;
  15. -webkit-font-smoothing: antialiased;
  16. -moz-osx-font-smoothing: grayscale;
  17. transform: translate(0, 0);
  18. }
  19. </style>
  20. {/block}
  21. {block name="content"}
  22. <div class="row">
  23. <div class="col-sm-12">
  24. <div class="ibox-title">
  25. <h5>配置</h5>
  26. </div>
  27. <div class="ibox float-e-margins">
  28. <div class="ibox-content">
  29. <form method="post" class="form-horizontal" id="signupForm" action="{:Url('save_basics',array('tab_id'=>$tab_id))}">
  30. <input type="hidden" value="{$tab_id}" name="tab_id"/>
  31. {volist name="list" id="vo"}
  32. {eq name="$vo['config_tab_id']" value="$tab_id"}
  33. <div class="form-group">
  34. <label class="col-sm-2 control-label" {eq name="$vo['type']" value="radio"}style="padding-top: 0;"{/eq}>{$vo.info}</label>
  35. <div class="col-sm-10">
  36. <div class="row">
  37. <div class="col-md-6">
  38. {switch name="$vo['type']" }
  39. {case value="text" break="1"}<!-- 文本框-->
  40. <input type="{$vo.type}" class="form-control" name="{$vo.menu_name}" value="{$vo.value}" validate="{$vo['required']}" style="width: {$vo.width}%"/>
  41. {/case}
  42. {case value="textarea" break="1"}<!--多行文本框-->
  43. <textarea name="{$vo.menu_name}" cols="{$vo.width}" rows="{$vo.high}" class="form-control" style="width: {$vo.width}%">{$vo.value}</textarea>
  44. {/case}
  45. {case value="checkbox" break="1"}<!--多选框-->
  46. <?php
  47. $parameter = array();
  48. $option = array();
  49. if($vo['parameter']){
  50. $parameter = explode("\n",$vo['parameter']);
  51. foreach ($parameter as $k=>$v){
  52. $option[$k] = explode('=>',$v);
  53. }
  54. // dump($option);
  55. // exit();
  56. }
  57. $checkbox_value = $vo['value'];
  58. if(!is_array($checkbox_value)) $checkbox_value = explode("\n",$checkbox_value);
  59. // dump($checkbox_value);
  60. // exit();
  61. ?>
  62. {volist name="option" id="son" key="k"}
  63. {if condition="in_array($son[0],$checkbox_value)"}
  64. <label class="checkbox-inline i-checks">
  65. <input type="checkbox" value="{$son.0}" name="{$vo.menu_name}[]" checked="checked">{$son.1}</label>
  66. {else/}
  67. <label class="checkbox-inline i-checks">
  68. <input type="checkbox" value="{$son.0}" name="{$vo.menu_name}[]">{$son.1}</label>
  69. {/if}
  70. {/volist}
  71. {/case}
  72. {case value="radio" break="1"}<!--单选按钮-->
  73. <?php
  74. $parameter = array();
  75. $option = array();
  76. if($vo['parameter']){
  77. $parameter = explode("\n",$vo['parameter']);
  78. foreach ($parameter as $k=>$v){
  79. $option[$k] = explode('=>',$v);
  80. }
  81. }
  82. ?>
  83. {volist name="option" id="son"}
  84. {if condition="$son[0] eq $vo['value']"}
  85. <div class="radio i-checks checked" style="display:inline">
  86. <label class="" style="padding-left: 0;">
  87. <div class="iradio_square-green " style="position: relative;">
  88. <input type="radio" checked="checked" value="{$son.0}" name="{$vo.menu_name}" style="position: absolute; opacity: 0;">
  89. </div>
  90. <i></i> {$son.1}
  91. </label>
  92. </div>
  93. {else /}
  94. <div class="radio i-checks" style="display:inline">
  95. <label class="" style="padding-left: 0;">
  96. <div class="iradio_square-green" style="position: relative;">
  97. <input type="radio" value="{$son.0}" name="{$vo.menu_name}" style="position: absolute; opacity: 0;">
  98. </div>
  99. <i></i> {$son.1}
  100. </label>
  101. </div>
  102. {/if}
  103. {/volist}
  104. {/case}
  105. {case value="upload" break="1"}<!--文件上传-->
  106. <?php
  107. $img_image = $vo['value'];
  108. $num_img = 0;
  109. if(!empty($img_image)){
  110. $num_img = 1;
  111. }
  112. ?>
  113. <!--文件-->{if condition="$vo['upload_type'] EQ 3"}
  114. <div style="display: inline-flex;">
  115. <input type="file" class="{$vo.menu_name}_1" name="{$vo.menu_name}" style="display: none;" data-name="{$vo.menu_name}" id="{$vo.menu_name}" data-type = "{$vo.upload_type}" />
  116. <span class="flag" style="margin-top: 5px;width: 86px;height: 27px;border-radius: 6px;cursor:pointer;padding: .5rem;background-color: #18a689;color: #fff;text-align: center;" data-name="{$vo.menu_name}" >点击上传</span>
  117. {if condition="$num_img < 1"}
  118. <div class="file-box">
  119. <div class="file {$vo.menu_name}">
  120. </div>
  121. </div>
  122. {else/}
  123. {volist name="$vo['value']" id="img"}
  124. <div class="file-box">
  125. <div class="file {$vo.menu_name}" style="position: relative;">
  126. <a href="http://<?php echo $_SERVER['SERVER_NAME'].$img;?>" target="_blank">
  127. <span class="corner"></span>
  128. <div class="icon">
  129. <i class="fa fa-file"></i>
  130. </div>
  131. <div class="file-name">
  132. <?php
  133. //显示带有文件扩展名的文件名
  134. echo basename($img);
  135. ?>
  136. </div>
  137. </a>
  138. <div data-name="{$vo.menu_name}" style="position: absolute;right: 4%;top: 2%;cursor: pointer" onclick="delPic(this)">删除</div>
  139. <input type="hidden" name="{$vo.menu_name}[]" value="{$img}">
  140. </div>
  141. </div>
  142. {/volist}
  143. {/if}
  144. <div class="clearfix"></div>
  145. </div>
  146. <!--多图-->{elseif condition="$vo['upload_type'] EQ 2"/}
  147. <div style="margin-top: 20px;">
  148. <input type="file" class="{$vo.menu_name}_1" name="{$vo.menu_name}" style="display: none;" data-name="{$vo.menu_name}" id="{$vo.menu_name}" data-type = "{$vo.upload_type}" />
  149. <span class="flag" style="margin-top: 5px;width: 86px;height: 27px;border-radius: 6px;cursor:pointer;padding: .5rem 1rem;background-color: #18a689;color: #fff;text-align: center;" data-name="{$vo.menu_name}" >点击上传</span>
  150. <div class="attachment upload_image_{$vo.menu_name}" style="display:block;margin:20px 0 5px -44px">
  151. {volist name="$vo['value']" id="img"}
  152. <div class="file-box">
  153. <div class="file {$vo.menu_name}" style="position: relative;">
  154. <a href="http://<?php echo $_SERVER['SERVER_NAME'].$img;?>" target="_blank">
  155. <span class="corner"></span>
  156. <div class="image">
  157. <img alt="image" class="img-responsive" src="{$img}">
  158. </div>
  159. <div class="file-name">
  160. <?php
  161. //显示带有文件扩展名的文件名
  162. echo basename($img);
  163. ?>
  164. </div>
  165. </a>
  166. <div data-name="{$vo.menu_name}" style="position: absolute;right: 4%;top: 2%;cursor: pointer" onclick="delPic(this)">删除</div>
  167. <input type="hidden" name="{$vo.menu_name}[]" value="{$img}">
  168. </div>
  169. </div>
  170. {/volist}
  171. <div class="clearfix"></div>
  172. </div>
  173. </div>
  174. <!--单图-->{else/}
  175. <div style="display: inline-flex;">
  176. <input type="file" class="{$vo.menu_name}_1" name="{$vo.menu_name}" style="display: none;" data-name="{$vo.menu_name}" id="{$vo.menu_name}" data-type = "{$vo.upload_type}" />
  177. <div class="flag" style="width: 100px;height: 80px;background-image:url('{__MODULE_PATH}wechat/news/images/image.png');cursor: pointer" data-name="{$vo.menu_name}" >
  178. </div>
  179. {if condition="$num_img LT 1"}
  180. <div class="file-box">
  181. <div class="{$vo.menu_name}">
  182. </div>
  183. </div>
  184. {else/}
  185. {volist name="$vo['value']" id="img"}
  186. <div class="file-box">
  187. <div class="{$vo.menu_name}">
  188. <div style="position: relative;" class="file">
  189. <a href="http://<?php echo $_SERVER['SERVER_NAME'].$img;?>" target="_blank">
  190. <span class="corner"></span>
  191. <div class="image">
  192. <img alt="image" class="img-responsive" src="{$img}" style="width: 100%;height: 100%">
  193. </div>
  194. <div class="file-name">
  195. <?php
  196. //显示带有文件扩展名的文件名
  197. echo basename($img);
  198. ?>
  199. </div>
  200. </a>
  201. <div data-name="{$vo.menu_name}" style="position: absolute;right: 4%;top: 2%;cursor: pointer" onclick="delPic(this)">删除</div>
  202. <input type="hidden" name="{$vo.menu_name}[]" value="{$img}">
  203. </div>
  204. </div>
  205. </div>
  206. {/volist}
  207. <div class="clearfix"></div>
  208. {/if}
  209. </div>
  210. {/if}
  211. {/case}
  212. {/switch}
  213. </div>
  214. <div class="col-md-2">
  215. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> {$vo.desc}</span>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. <div class="hr-line-dashed"></div>
  221. {/eq}
  222. {/volist}
  223. <div class="form-group" style="text-align: center;">
  224. <div class="col-sm-4 col-sm-offset-2">
  225. <button class="btn btn-primary" type="submit">提交</button>
  226. </div>
  227. </div>
  228. </form>
  229. </div>
  230. </div>
  231. </div>
  232. </div>
  233. {/block}
  234. {block name="script"}
  235. <script>
  236. $eb = parent._mpApi;
  237. $().ready(function() {
  238. $("#signupForm").validate();
  239. $('.i-checks').iCheck({
  240. checkboxClass: 'icheckbox_square-green',
  241. radioClass: 'iradio_square-green',
  242. });
  243. $('.flag').on('click',function(){
  244. $('.'+$(this).data('name')+'_1').trigger('click');
  245. change_upload($(this).data('name'));
  246. });
  247. function change_upload(_this_name) {
  248. $('.'+_this_name+'_1').on('change',function(){
  249. ajaxFileUpload(this);
  250. });
  251. }
  252. });
  253. /**
  254. * 添加文件
  255. * */
  256. function getHtmlFlie(menu_name,html_src) {
  257. html_file = '';
  258. if(html_src.length < 1){
  259. return html_file;
  260. }
  261. html_file += '<a href="http://'+window.location.host+html_src+'" target="_blank">';
  262. html_file += '<span class="corner"></span>';
  263. html_file += '<div class="icon">';
  264. html_file += '<i class="fa fa-file"></i>';
  265. html_file += '</div>';
  266. html_file += '<div class="file-name">';
  267. $.ajax({
  268. url:"{:url('getImageName')}",
  269. data:'src='+html_src,
  270. type:'post',
  271. async:false,
  272. dataType:'json',
  273. success:function (re) {
  274. html_file += re.name;
  275. }
  276. })
  277. html_file += '</div>';
  278. html_file += '</a>';
  279. html_file += '<div data-name="'+menu_name+'" style="position: absolute;right: 4%;top: 2%;cursor: pointer" onclick="delPic(this)">删除</div>';
  280. html_file += '<input type="hidden" name="'+menu_name+'[]" value="'+html_src+'">';
  281. return html_file;
  282. }
  283. /**
  284. * 多图上传html 处理
  285. * */
  286. function getHtmlOrthe(menu_name,html_src) {
  287. html_order = '';
  288. if(html_src.length < 1){
  289. return html_order;
  290. }
  291. html_order += '<div class="file-box">';
  292. html_order += '<div class="file '+menu_name+'" style="position: relative">';
  293. html_order += '<a href="http://'+window.location.host+html_src+'" target="_blank">';
  294. html_order += '<span class="corner"></span>';
  295. html_order += '<div class="image">';
  296. html_order += '<img alt="image" class="img-responsive" src="'+html_src+'">';
  297. html_order += '</div>';
  298. html_order += '<div class="file-name">';
  299. $.ajax({
  300. url:"{:url('getImageName')}",
  301. data:'src='+html_src,
  302. type:'post',
  303. async:false,
  304. dataType:'json',
  305. success:function (re) {
  306. html_order += re.name;
  307. }
  308. })
  309. html_order += '</div>';
  310. html_order += '</a>';
  311. html_order += '<div data-name="'+menu_name+'" style="position: absolute;right: 4%;top: 2%;cursor: pointer" onclick="delPic(this)">删除</div>';
  312. html_order += '<input type="hidden" name="'+menu_name+'[]" value="'+html_src+'">';
  313. html_order += '</div>';
  314. html_order += '</div>';
  315. return html_order;
  316. }
  317. /**
  318. * 单图上传html处理
  319. * */
  320. function getHtml(menu_name,html_src) {
  321. html_one = '';
  322. if(html_src.length < 1){
  323. return html_one;
  324. }
  325. html_one += '<div style="position: relative;" class="file">'
  326. html_one += '<a href="http://'+window.location.host+html_src+'" target="_blank">';
  327. html_one += '<span class="corner"></span>';
  328. html_one += '<div class="image">';
  329. html_one += '<img alt="image" class="img-responsive" src="'+html_src+'">';
  330. html_one += '</div>';
  331. html_one += '<div class="file-name">';
  332. $.ajax({
  333. url:"{:url('getImageName')}",
  334. data:'src='+html_src,
  335. type:'post',
  336. async:false,
  337. dataType:'json',
  338. success:function (re) {
  339. html_one += re.name;
  340. }
  341. })
  342. html_one += '</div>';
  343. html_one += '</a>';
  344. html_one += '<div data-name="'+menu_name+'" style="position: absolute;right: 4%;top: 2%;cursor: pointer" onclick="delPic(this)">删除</div>';
  345. html_one += '<input type="hidden" name="'+menu_name+'[]" value="'+html_src+'">';
  346. html_one += '</div>'
  347. return html_one;
  348. }
  349. function ajaxFileUpload(is) {
  350. bool_upload_num = $(is).data('type');
  351. $.ajaxFileUpload({
  352. url: "{:url('view_upload')}",
  353. data:{file: $(is).data('name'),type:bool_upload_num},
  354. type: 'post',
  355. secureuri: false, //一般设置为false
  356. fileElementId: $(is).data('name'), // 上传文件的id、name属性名
  357. dataType: 'json', //返回值类型,一般设置为json、application/json
  358. success: function(data, status, e){
  359. if(data.code == 200){
  360. if(bool_upload_num == 2){
  361. getHtmlOrthe($(is).data('name'),data.data.url);
  362. $('.upload_image_'+$(is).data('name')).append(html_order);
  363. }else if(bool_upload_num == 1){
  364. getHtml($(is).data('name'),data.data.url);
  365. $('.'+$(is).data('name')).empty();
  366. $('.'+$(is).data('name')).append(html_one);
  367. }else if(bool_upload_num == 3){
  368. getHtmlFlie($(is).data('name'),data.data.url);
  369. $('.'+$(is).data('name')).empty();
  370. $('.'+$(is).data('name')).append(html_file);
  371. }else{}
  372. $eb.message('success',data.msg);
  373. }else{
  374. $eb.message('error',data.msg);
  375. }
  376. $('.'+$(is).data('name')).on('change',function(){ ajaxFileUpload(this);})
  377. },
  378. error: function(data, status, e){
  379. $('.'+$(is).data('name')).on('change',function(){ ajaxFileUpload(this);})
  380. }
  381. });
  382. }
  383. $('.del_upload_one')
  384. function delPic(_this) {
  385. if(!confirm('确认删除?')) return false;
  386. p = $(_this).parents('.'+$(_this).data('name'));
  387. p.empty();
  388. }
  389. </script>
  390. {/block}