interactive_code.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <{include file="./admin/header.html"}>
  2. <{include file="./admin/left.html"}>
  3. <{include file="./admin/nav.html"}>
  4. <{include file="get_kindeditor.html"}>
  5. <style>
  6. .set-nav {
  7. margin: 0 auto;
  8. }
  9. .set-nav-hr {
  10. background-color: #ddd;
  11. height: 1px;
  12. position: relative;
  13. }
  14. .form-group label {
  15. font-weight: 600;
  16. }
  17. .checkbox-inline, .radio-inline {
  18. font-weight: 400!important;
  19. }
  20. .rowlabel {
  21. font-weight: 300!important;
  22. }
  23. .music_play_hide {
  24. display:none;
  25. }
  26. </style>
  27. <div id="activity_container">
  28. <form id="activity_form">
  29. <div class="activity_center">
  30. <{include file="./admin/activity/common_nav.html"}>
  31. <input name="events_id" type="hidden" value="<{$events_Data.events.id}>">
  32. <div class="panel panel-default">
  33. <div class="panel-body">
  34. <div class="form-group">
  35. <label>券名称:</label>
  36. <input name="code_name" type="text" class="form-control" value="<{$events_Data.events.code_name}>">
  37. </div>
  38. <div class="form-group">
  39. <label>券图片:</label>
  40. <div>
  41. <img id="img_url_tag" src="<{if $events_Data.events.code_img_url}><{$events_Data.events.code_img_url}><{else}>http://placehold.it/100&text=100x100<{/if}>" style="width:100px;" class="img-thumbnail">
  42. <input id="img_url_input" name="code_img_url" type="hidden" value="<{$events_Data.events.code_img_url}>">
  43. <input id="image_upload" type="button" value="选择图片" >
  44. </div>
  45. </div>
  46. <div class="form-group">
  47. <label>券数量:</label>
  48. <div>
  49. <{assign var=num value=$codeDataNum-$useCodeDataNum}>
  50. 总数: <{$codeDataNum}>&nbsp;&nbsp;已发放: <{$useCodeDataNum}>&nbsp;&nbsp;剩余: <{$num}>&nbsp;&nbsp;
  51. <a href="<{$web_cfg.domain}>/?c=Admin_Activity_SetInteractive&a=ReqShowEventCode&events_id=<{$events_Data.events.id}>">查看</a>
  52. </div>
  53. </div>
  54. <div class="form-group">
  55. <label>添加新券: <small class="text-danger">每次不超过200条,换行分割</small></label>
  56. <div>
  57. <textarea name="code_data" rows="2" class="form-control" style="width:220px;"></textarea>
  58. </div>
  59. </div>
  60. <div class="form-group">
  61. <label>设置表单:</label>
  62. <div>
  63. <table class="custom_from_table table table-condensed">
  64. <thead>
  65. <tr>
  66. <th>名称</th>
  67. <th>类型</th>
  68. <th>最小长度</th>
  69. <th>验证规则</th>
  70. <th>是否必填</th>
  71. </tr>
  72. </thead>
  73. <tbody>
  74. <{if !$events_Data.events.forms}>
  75. <tr class="not_input">
  76. <td colspan='6' align="center">没有设置表单</td>
  77. </tr>
  78. <{else}>
  79. <{foreach from=$events_Data.events.forms item=form}>
  80. <{if $form.type == 'text'}>
  81. <tr>
  82. <td><input name="f[0][name]" type="text" value="<{$form.name}>" class="form-control" /></td>
  83. <td>
  84. <select class="form-control form_select" name="f[0][type]">
  85. <option value="text" selected>单行文本框</option>
  86. <option value="textarea">多行文本框</option>
  87. <option value="select">下拉菜单</option>
  88. </select>
  89. </td>
  90. <td><input name="f[0][rule][size]" type="text" value="<{$form.rule.size}>" class="form-control" /></td>
  91. <td>
  92. <select class="form-control" name="f[0][rule][regularid]">
  93. <option value="">无规则</option>
  94. <option value="1" <{if $form.rule.regularid == 1}>selected<{/if}>>手机验证</option>
  95. <option value="2" <{if $form.rule.regularid == 2}>selected<{/if}>>邮箱验证</option>
  96. </select>
  97. </td>
  98. <td>
  99. <input name="f[0][required]" type="checkbox" value="1" <{if $form.required}>checked<{/if}>/>
  100. </td>
  101. </tr>
  102. <{/if}>
  103. <{if $form.type == 'select'}>
  104. <tr>
  105. <td><input name="f[0][name]" type="text" value="<{$form.name}>" class="form-control"/></td>
  106. <td>
  107. <select class="form_select form-control" name="f[0][type]">
  108. <option value="text">单行文本框</option>
  109. <option value="textarea">多行文本框</option>
  110. <option value="select" selected>下拉菜单</option>
  111. </select>
  112. </td>
  113. <td>
  114. <textarea name="f[0][options]" class="form-control" placeholder=""><{$form.options}></textarea>
  115. </td>
  116. <td>多个选项换行分隔</td>
  117. <td><input name="f[0][required]" type="checkbox" value="1" <{if $form.required}>checked<{/if}>/></td>
  118. </tr>
  119. <{/if}>
  120. <{if $form.type == 'textarea'}>
  121. <tr>
  122. <td><input name="f[0][name]" type="text" value="<{$form.name}>" class="form-control"/></td>
  123. <td>
  124. <select class="form_select form-control" name="f[0][type]">
  125. <option value="text">单行文本框</option>
  126. <option value="textarea" selected>多行文本框</option>
  127. <option value="select">下拉菜单</option>
  128. </select>
  129. </td>
  130. <td><input name="f[0][rule][size]" type="text" value="<{$form.rule.size}>" class="form-control"/></td>
  131. <td>
  132. <select name="f[0][rule][regularid]" class="form-control">
  133. <option value="">无规则</option>
  134. <option value="1" <{if $form.rule.regularid == 1}>selected<{/if}>>手机验证</option>
  135. <option value="2" <{if $form.rule.regularid == 2}>selected<{/if}>>邮箱验证</option>
  136. </select>
  137. </td>
  138. <td><input name="f[0][required]" type="checkbox" value="1" <{if $form.required}>checked<{/if}>/> </td>
  139. </tr>
  140. <{/if}>
  141. <{/foreach}>
  142. <{/if}>
  143. </tbody>
  144. </table>
  145. <a href="javascript:;" class="addRule js_add_prize" data-stat="show"><i class="fa fa-plus"></i> 添加表单字段</a>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. <a id="activity_submit" href="javascript:;" class="button button-3d button-primary button-rounded"><i class="fa fa-refresh fa-spin" style="display:none;"></i> 保存设置</a>
  151. </div>
  152. <{include file="./admin/activity/common_right.html"}>
  153. <div style="clear:both;"></div>
  154. </form>
  155. </div>
  156. <div class="form_select_template" style="display:none;">
  157. <table>
  158. <tr>
  159. <td><input name="f[0][name]" type="text" value="" class="form-control"/></td>
  160. <td>
  161. <select class="form_select form-control" name="f[0][type]">
  162. <option value="text">单行文本框</option>
  163. <option value="textarea">多行文本框</option>
  164. <option value="select" selected>下拉菜单</option>
  165. </select>
  166. </td>
  167. <td>
  168. <textarea name="f[0][options]" class="form-control" placeholder=""></textarea>
  169. </td>
  170. <td>多个选项换行分隔</td>
  171. <td><input name="f[0][required]" type="checkbox" value="1"/></td>
  172. </tr>
  173. </table>
  174. </div>
  175. <div class="form_text_template" style="display:none;">
  176. <table>
  177. <tr>
  178. <td><input name="f[0][name]" type="text" value="" class="form-control"/></td>
  179. <td>
  180. <select class="form_select form-control" name="f[0][type]">
  181. <option value="text" selected>单行文本框</option>
  182. <option value="textarea">多行文本框</option>
  183. <option value="select">下拉菜单</option>
  184. </select>
  185. </td>
  186. <td><input name="f[0][rule][size]" type="text" value="" class="form-control"/></td>
  187. <td>
  188. <select name="f[0][rule][regularid]" class="form-control">
  189. <option value="">无规则</option>
  190. <option value="1">手机验证</option>
  191. <option value="2">邮箱验证</option>
  192. </select>
  193. </td>
  194. <td><input name="f[0][required]" type="checkbox" value="1"/></td>
  195. </tr>
  196. </table>
  197. </div>
  198. <div class="form_textarea_template" style="display:none;">
  199. <table>
  200. <tr>
  201. <td><input name="f[0][name]" type="text" value="" class="form-control"/></td>
  202. <td>
  203. <select class="form_select form-control" name="f[0][type]">
  204. <option value="text">单行文本框</option>
  205. <option value="textarea" selected>多行文本框</option>
  206. <option value="select">下拉菜单</option>
  207. </select>
  208. </td>
  209. <td><input name="f[0][rule][size]" type="text" value="" class="form-control"/></td>
  210. <td>
  211. <select name="f[0][rule][regularid]" class="form-control">
  212. <option value="">无规则</option>
  213. <option value="1">手机验证</option>
  214. <option value="2">邮箱验证</option>
  215. </select>
  216. </td>
  217. <td><input name="f[0][required]" type="checkbox" value="1"/> </td>
  218. </tr>
  219. </table>
  220. </div>
  221. <script>
  222. KISSY.use('node, io, event, jquery', function (S, Node, IO, Event, jQuery) {
  223. var $ = S.all;
  224. $('.addRule').on('click', function () {
  225. $(".not_input").hide();
  226. var form_text_template = $('.form_text_template table tbody').last().clone(true, true, true);
  227. $('.custom_from_table tbody').last().after(form_text_template);
  228. });
  229. Event.delegate(document,'change','.form_select',function(e){
  230. var formType = e.target.value;
  231. if (formType == 'select') {
  232. var form_select_template = $('.form_select_template table tbody').last().clone(true, true, true);
  233. $(e.target).parent('tr').replaceWith(form_select_template);
  234. }
  235. if (formType == 'text') {
  236. var form_text_template = $('.form_text_template table tbody').last().clone(true, true, true);
  237. $(e.target).parent('tr').replaceWith(form_text_template);
  238. }
  239. if (formType == 'textarea') {
  240. var form_textarea_template = $('.form_textarea_template table tbody').last().clone(true, true, true);
  241. $(e.target).parent('tr').replaceWith(form_textarea_template);
  242. }
  243. });
  244. var activity_submit_status = false; //按钮状态
  245. function submit_button_active() {
  246. activity_submit_status = true;
  247. $("#activity_submit").addClass('active').all('i').show();
  248. }
  249. function submit_button_default() {
  250. activity_submit_status = false;
  251. $("#activity_submit").removeClass('active').all('i').hide();
  252. }
  253. $("#activity_submit").on('click', function () {
  254. if (activity_submit_status) {
  255. return false;
  256. }
  257. submit_button_active();
  258. jQuery('.custom_from_table tr').each(function (i, item) {
  259. jQuery(item).find('input,select,checkbox,textarea').each(function (j, input) {
  260. input.name = input.name.replace(/\[\d+\]/, '['+ i +']');
  261. });
  262. });
  263. formData = IO.serialize("#activity_form");
  264. new IO({
  265. type: "post"
  266. , url: VG.conf.root_domain + '/?c=Admin_Activity_SetInteractive&a=ReqUpCode'
  267. , data: formData
  268. , success: function (data) {
  269. if (data.ok) { //ok
  270. location.href = location.href;
  271. } else {
  272. alert('操作失败,原因:'+data.msg);
  273. location.href = location.href;
  274. }
  275. return false;
  276. }
  277. , error: function (NULL, textStatus) {
  278. alert("请求服务器失败,原因:"+textStatus);
  279. }
  280. , dataType: "json"
  281. });
  282. });
  283. });
  284. //列表默认图
  285. KindEditor.ready(function(K) {
  286. var uploadbutton = K.uploadbutton({
  287. button : K('#image_upload')[0],
  288. fieldName : 'imgFile',
  289. url : VG.conf.root_domain + '/?c=kindeditor&a=updateJson&dir=image',
  290. afterUpload : function(data) {
  291. if (data.error === 0) {
  292. var url = K.formatUrl(data.url, 'absolute');
  293. K('#img_url_input').val(data.url);
  294. K('#img_url_tag').attr('src', data.url);
  295. } else {
  296. alert(data.message);
  297. }
  298. },
  299. afterError : function(str) {
  300. alert('自定义错误信息: ' + str);
  301. }
  302. });
  303. uploadbutton.fileBox.change(function(e) {
  304. uploadbutton.submit();
  305. });
  306. });
  307. </script>
  308. <{include file="./admin/bottom.html"}>