interactive_prize.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. .add_virtual_data_box {
  27. background-color: #f5f5f5;
  28. display:none;
  29. }
  30. </style>
  31. <div id="activity_container">
  32. <div class="activity_center">
  33. <{include file="./admin/activity/common_nav.html"}>
  34. <!-- <form method="post" action="<{$web_cfg.domain}>?c=Admin_Activity_SetInteractive&a=ReqUp"> -->
  35. <input name="events_id" type="hidden" value="<{$events_Data.events.id}>">
  36. <div class="panel panel-default">
  37. <div class="panel-heading"><h3 class="panel-title" id="panel-title">奖项设置</h3></div>
  38. <div class="panel-body">
  39. <div class="form-group">
  40. <div>
  41. <table class="table table-hover">
  42. <thead>
  43. <tr>
  44. <th>奖品名称</th>
  45. <th>奖品类型</th>
  46. <th>奖品数量</th>
  47. <th>中奖时间段(时)</th>
  48. <th>(当天)下次中奖时间</th>
  49. <th>状态</th>
  50. <th>编辑</th>
  51. </tr>
  52. </thead>
  53. <tbody>
  54. <{foreach from=$events_Data.prize item=prize}>
  55. <tr>
  56. <td><{$prize.prize_name}></td>
  57. <td><{$prizeType[$prize.type].desc}></td>
  58. <{assign var=num value=$prize.prize_num-$prize.prize_winning_num}>
  59. <td>总数:<{$prize.prize_num}>
  60. <{if $prize.type == 1}>
  61. <a class="incr_prize_num" data-prize-id="<{$prize.id}>" href="javascript:;">[添加]</a>
  62. <a class="decr_prize_num" data-prize-id="<{$prize.id}>" href="javascript:;">[减少]</a>
  63. <{/if}>
  64. <{if $prize.type == 2}>
  65. <a class="add_virtual_data" data-prize-id="<{$prize.id}>" href="javascript:;">[添加]</a>
  66. <a class="" data-prize-id="<{$prize.id}>" href="<{$web_cfg.domain}>/?c=Admin_Activity_SetInteractive&a=PageVirtualDataList&prize_id=<{$prize.id}>">[查看]</a>
  67. <{/if}>
  68. 抽中:<{$prize.prize_winning_num}> 剩余:<{$num}>
  69. </td>
  70. <td><{$prize.begin_hour}> - <{$prize.end_hour}></td>
  71. <td><{$prize.nextTime|date_format:'%Y-%m-%d %H:%M:%S'}></td>
  72. <td class="<{if $prize.display == 0}>text-danger<{else}>text-success<{/if}>"><{$eventsDisplayStatus[$prize.display].desc}></td>
  73. <td><a href="<{$web_cfg.domain}>/?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>&prize_id=<{$prize.id}>&edit=1">编辑</a></td>
  74. </tr>
  75. <{if $prize.type == 2}>
  76. <tr class="add_virtual_data_box box_<{$prize.id}>">
  77. <td colspan="7">
  78. <form method="post" action="<{$web_cfg.domain}>/?c=Admin_Activity_SetInteractive&a=ReqAddPrizeNum&noajax=1">
  79. <input name="events_id" type="hidden" value="<{$events_Data.events.id}>">
  80. <input name="prize_id" type="hidden" value="<{$prize.id}>">
  81. <div class="form-group">
  82. <label class="control-label">添加[<{$prize.prize_name}>]奖项数据: </label>
  83. <textarea name="virtual_data" class="form-control" rows="3" style="width:300px;"></textarea>
  84. <div class="note">多条数据换行分隔</div>
  85. <button class="add_virtual_data_submit button-primary button-raised button-small">添加</button>
  86. </div>
  87. </form>
  88. </td>
  89. </tr>
  90. <{/if}>
  91. <{/foreach}>
  92. </tbody>
  93. </table>
  94. <a href="javascript:;" class="js_add_prize" data-stat="show"><i class="fa fa-plus"></i> 添加奖项</a>
  95. </div>
  96. <div class="add_prize_form well" style="display: none;"></div>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. <{include file="./admin/activity/common_right.html"}>
  102. <div style="clear:both;"></div>
  103. </div>
  104. <div class="add_prize_template" style="display:none;">
  105. <div class="row">
  106. <div class="col-md-4">
  107. <div class="form-group">
  108. <label class="control-label rowlabel">奖项名称: </label>
  109. <div>
  110. <input name="prize_name" type="text" class="form-control" value="">
  111. </div>
  112. </div>
  113. <div class="form-group">
  114. <label class="control-label rowlabel">奖项图片: </label>
  115. <div>
  116. <img id="prize_image_tag" src="http://placehold.it/100&text=100x100" style="width:100px;" class="img-thumbnail">
  117. <input id="prize_image_input" name="prize_image_url" type="hidden" value="" />
  118. <input id="prize_image_upload" type="button" value="选择图片" />
  119. </div>
  120. </div>
  121. </div>
  122. <div class="col-md-3">
  123. <div class="form-inline form-group">
  124. <label class="control-label rowlabel">发奖时间段: </label>
  125. <div>
  126. <input name="begin_hour" type="text" class="form-control" value="0" style="width:50px;"> -
  127. <input name="end_hour" type="text" class="form-control" value="24" style="width:50px;">
  128. </div>
  129. </div>
  130. <div class="form-group">
  131. <label class="control-label rowlabel">是否需要快递: </label>
  132. <div>
  133. <select name="express" class="form-control">
  134. <option value="1">需要</option>
  135. <option value="2">不需要</option>
  136. </select>
  137. </div>
  138. </div>
  139. <div class="form-group">
  140. <label class="control-label rowlabel">属性: </label>
  141. <div>
  142. <select name="prize_type" class="form-control">
  143. <option value="0">选择</option>
  144. <option value="1">实物</option>
  145. <option value="2">虚拟</option>
  146. </select>
  147. </div>
  148. </div>
  149. <div class="prize_num" class="form-group" style="display:none;">
  150. <label class="control-label rowlabel">数量: </label>
  151. <div>
  152. <input name="prize_num" type="text" class="form-control" value="0" style="width:50px;">
  153. </div>
  154. </div>
  155. <div class="virtual_data" class="form-group" style="display:none;">
  156. <label class="control-label rowlabel">虚拟数据:<small class="text-danger">(换行分割)</small></label>
  157. <div>
  158. <textarea name="virtual_data_x" class="form-control" rows="2"></textarea>
  159. </div>
  160. </div>
  161. </div>
  162. <div class="col-md-3">
  163. <div class="form-group">
  164. <label class="control-label rowlabel">白名单:"换行"分割UID</label>
  165. <div>
  166. <textarea name="white_list" class="form-control" rows="3"></textarea>
  167. </div>
  168. </div>
  169. <div class="form-group">
  170. <label class="control-label rowlabel">100%中奖名单:"换行"分割UID</label>
  171. <div>
  172. <textarea name="hundred_percent_list" class="form-control" rows="3"></textarea>
  173. </div>
  174. </div>
  175. <div class="form-group">
  176. <label class="control-label rowlabel">黑名单:"换行"分割UID </label>
  177. <div>
  178. <textarea name="black_list" class="form-control" rows="3"></textarea>
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. <a href="javascript:;" class="ajax_add_prize_from button button-primary button-raised button-tiny" >添加</a>
  184. </div>
  185. <script>
  186. KISSY.use('node, io, event, dom', function (S, Node, IO, Event, DOM) {
  187. var $ = S.all;
  188. /* $('#activity_submit').on('click',function(){
  189. var events_id = $("input[name=events_id]").val();
  190. location = VG.conf.root_domain + '/?c=Admin_Activity_SetPage&a=PageShow&events_id='+events_id
  191. }); */
  192. $(".incr_prize_num").on('click', function() {
  193. var events_id = $("input[name=events_id]").val();
  194. var prize_id = $(this).attr('data-prize-id');
  195. var prize_num = prompt('请输入增加奖品的数量');
  196. if (!prize_num) {
  197. return false;
  198. }
  199. new IO({
  200. type: "post"
  201. , url: VG.conf.root_domain + '/?c=Admin_Activity_SetInteractive&a=ReqAddPrizeNum'
  202. , data: {'prize_id':prize_id, 'prize_num':prize_num, 'events_id':events_id}
  203. , success: function (data) {
  204. if (data.ok) { //ok
  205. alert('操作成功');
  206. location.reload();
  207. } else {
  208. alert('操作失败,原因:'+data.msg);
  209. }
  210. return false;
  211. }
  212. , error: function (NULL, textStatus) {
  213. alert("请求服务器失败,原因:"+textStatus);
  214. }
  215. , dataType: "json"
  216. });
  217. });
  218. $(".decr_prize_num").on('click', function() {
  219. var events_id = $("input[name=events_id]").val();
  220. var prize_id = $(this).attr('data-prize-id');
  221. var prize_num = prompt('请输入减少奖品的数量');
  222. if (!prize_num) {
  223. return false;
  224. }
  225. new IO({
  226. type: "post"
  227. , url: VG.conf.root_domain + '/?c=Admin_Activity_SetInteractive&a=ReqMinusPrizeNum'
  228. , data: {'prize_id':prize_id, 'num':prize_num}
  229. , success: function (data) {
  230. if (data.ok) { //ok
  231. alert('操作成功');
  232. location.reload();
  233. } else {
  234. alert('操作失败,原因:'+data.msg);
  235. }
  236. return false;
  237. }
  238. , error: function (NULL, textStatus) {
  239. alert("请求服务器失败,原因:"+textStatus);
  240. }
  241. , dataType: "json"
  242. });
  243. });
  244. //添加奖项
  245. $(".js_add_prize").on('click', function () {
  246. var add_prize_form = $('.add_prize_form');
  247. var add_prize_template = $('.add_prize_template').html();
  248. if ($(this).attr('data-stat') == 'show') {
  249. add_prize_form.html(add_prize_template).show();
  250. $(this).attr('data-stat', 'hide');
  251. //奖品图
  252. var K = KindEditor;
  253. var uploadbutton = K.uploadbutton({
  254. button : K('#prize_image_upload')[0],
  255. fieldName : 'imgFile',
  256. url : VG.conf.root_domain + '/?c=kindeditor&a=updateJson&dir=image',
  257. afterUpload : function(data) {
  258. if (data.error === 0) {
  259. var url = K.formatUrl(data.url, 'absolute');
  260. K('#prize_image_input').val(data.url);
  261. K('#prize_image_tag').attr('src', data.url);
  262. } else {
  263. alert(data.message);
  264. }
  265. },
  266. afterError : function(str) {
  267. alert('自定义错误信息: ' + str);
  268. }
  269. });
  270. uploadbutton.fileBox.change(function(e) {
  271. uploadbutton.submit();
  272. });
  273. //提交表单
  274. ajax_add_prize_from();
  275. //选择奖项类型
  276. select_prize_type();
  277. } else {
  278. add_prize_form.html('').hide();
  279. $(this).attr('data-stat', 'show');
  280. }
  281. });
  282. //Event.delegate(document, 'change', 'select[name=prize_type]', function (e) {});
  283. $(".add_virtual_data").on('click', function () {
  284. var prize_id = $(this).attr('data-prize-id');
  285. DOM.toggle(".box_"+prize_id);
  286. });
  287. $(".add_virtual_data_submit").on('click', function () {
  288. if (!confirm('确认添加?')) {
  289. return false;
  290. }
  291. });
  292. function select_prize_type() {
  293. $("select[name=prize_type]").on('change', function () {
  294. var type = $(this).val();
  295. if (type == 0) {
  296. $(".prize_num").hide().all('input').val(0);
  297. $(".virtual_data").hide().all('textarea').val('');
  298. }
  299. if (type == 1) {
  300. $(".prize_num").show();
  301. $(".virtual_data").hide().all('textarea').val('');
  302. }
  303. if (type == 2) {
  304. $(".prize_num").hide().all('input').val('');
  305. $(".virtual_data").show();
  306. }
  307. });
  308. }
  309. function ajax_add_prize_from() {
  310. $(".ajax_add_prize_from").on('click', function () {
  311. var events_id = $("input[name=events_id]").val();
  312. var post_data = {};
  313. post_data.events_id = events_id;
  314. post_data.prize_name = $('input[name=prize_name]').val();
  315. post_data.prize_image_url = $("input[name=prize_image_url]").val();
  316. post_data.begin_hour = $("input[name=begin_hour]").val();
  317. post_data.end_hour = $("input[name=end_hour]").val();
  318. post_data.express = $("select[name=express]").val();
  319. post_data.prize_type = $("select[name=prize_type]").val();
  320. post_data.white_list = $("textarea[name=white_list]").val();
  321. post_data.hundred_percent_list = $("textarea[name=hundred_percent_list]").val();
  322. post_data.black_list = $("textarea[name=black_list]").val();
  323. post_data.prize_num = $("input[name=prize_num]").val();
  324. post_data.virtual_data = $("textarea[name=virtual_data_x]").val();
  325. new IO({
  326. type: "post"
  327. , url: VG.conf.root_domain + '/?c=Admin_Activity_SetInteractive&a=ReqAddPrize&events_id='+events_id
  328. , data: post_data
  329. , success: function (data) {
  330. if (data.ok) { //ok
  331. alert('操作成功');
  332. location.reload();
  333. } else {
  334. alert('操作失败,原因:'+data.msg);
  335. }
  336. return false;
  337. }
  338. , error: function (NULL, textStatus) {
  339. alert("请求服务器失败,原因:"+textStatus);
  340. }
  341. , dataType: "json"
  342. });
  343. });
  344. }
  345. });
  346. </script>
  347. <{include file="./admin/bottom.html"}>