interactive_question.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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-heading"><h3 class="panel-title" id="panel-title">设置问题</h3></div>
  34. <div class="panel-body" style="padding: 10px; display: none;" id="show_div">
  35. <div style="margin: 10px; display: none;" >排序: &nbsp; &nbsp; &nbsp; <font id="f_sort"></font></div>
  36. <input type="hidden" value="<{$nextSort}>" id="f_sort_h" name="f_sort_h">
  37. <div style="margin: 10px;">问题: &nbsp; &nbsp; &nbsp; <font id="f_question"></font></div>
  38. <input type="hidden" value="" id="f_question_h" name="f_question_h">
  39. <div style="margin: 10px;">选项类型: &nbsp; &nbsp; &nbsp; <font id="f_type"></font></div>
  40. <div style="margin: 10px;">选项规则: &nbsp; &nbsp; &nbsp; <font id="f_choice"></font></div>
  41. <input type="hidden" value="" id="f_type_h" name="f_type_h">
  42. <input type="hidden" value="" id="f_num_h" name="f_num_h">
  43. <input type="hidden" value="" id="f_choice_h" name="f_choice_h">
  44. <div style="clear:both;"></div>
  45. <div id="show_html">
  46. </div>
  47. <div style="clear:both;"></div>
  48. <div style="margin: 10px; text-align: left: ;">
  49. <a href="javascript:;" id="add_but" class="button button-3d button-primary button-rounded">点击保存</a>
  50. <div style="text-align: right;"><a href="?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>&typ=question" style="text-align: right;"><<返回上一级</a></div>
  51. </div>
  52. </div>
  53. <div id="img_html" style="display:none;">
  54. <div class="panel panel-default" style="padding:10px 10px 0px 10px;">
  55. <div class="form-group">
  56. <div>
  57. <img id="img_url_tag" src="http://placehold.it/200&text=290x(>290)" style="width:100px;" class="img-thumbnail">
  58. <input id="img_url_input" name="img_url" type="hidden" value="">
  59. <input id="image_upload" type="button" value="选择图片" >
  60. </div>
  61. </div>
  62. <p> 答案: <input type="text" name="img_url_answer"></p>
  63. </div>
  64. </div>
  65. <div id="txt_html" style="display:none;">
  66. <div class="panel panel-default" style="padding:10px 10px 0px 10px;">
  67. <p>答案: <input type="text" name="txt" id="txt"></p>
  68. </div>
  69. </div>
  70. <div class="panel-body" id="add_div" >
  71. <div class="form-group">
  72. <p style="display: none;">顺序:<input type="text" id="sort" size="2" value="<{$nextSort}>" ></p>
  73. <p>问题:<input type="text" id="question" size="50" ></p>
  74. <p>选项:<input type="text" id ="num" value="0" size="2" >个</p>
  75. <p>选项类型:<select name="type" id="type">
  76. <option value="img">图片</option>
  77. <option value="txt">文字</option>
  78. </select>
  79. </p>
  80. <p>选项规则:<select name="choice" id="choice">
  81. <option value="0">单选</option>
  82. <option value="1">多选</option>
  83. </select>
  84. </p>
  85. <div>
  86. <p style="margin-top: 20px;"><a href="javascript:;" id="add"><i class="fa fa-plus"></i> 点击创建问题</a></p>
  87. <div style="text-align: right;"><a href="?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>" style="text-align: right;"><<返回上一级</a></div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. <{include file="./admin/activity/common_right.html"}>
  94. <div style="clear:both;"></div>
  95. </form>
  96. </div>
  97. <script>
  98. KISSY.use('node, io, event, jquery', function (S, Node, IO, Event, jQuery) {
  99. var $ = S.all;
  100. $("#add").on('click', function () {
  101. var tyepData = {'img':'图片','txt':'文字'};
  102. var choiceData = {'1':'多选','0':'单选'};
  103. var question = $('#question').val();
  104. var sort = $('#sort').val();
  105. var num = $('#num').val();
  106. var type = $('#type').val();
  107. var choice = $('#choice').val();
  108. $('#f_sort').html(sort);
  109. $('#f_question').html(question);
  110. $('#f_type').html(tyepData[type]);
  111. $('#f_choice').html(choiceData[choice]);
  112. $('#f_sort_h').val(sort);
  113. $('#f_question_h').val(question);
  114. $('#f_type_h').val(type);
  115. $('#f_choice_h').val(choice);
  116. $('#f_num_h').val(num);
  117. $('#add_div').hide();
  118. $('#show_div').show();
  119. if(type == 'img'){
  120. var inHtml = '';
  121. for (var i=1;i<=num;i++){
  122. var html = $('#img_html').html();
  123. html = html.replace("img_url_tag", "img_url_tag_"+i);
  124. html = html.replace("img_url_input", "img_url_input_"+i);
  125. html = html.replace("image_upload", "image_upload_"+i);
  126. html = html.replace("name=\"img_url", "name=\"img_url_"+i);
  127. html = html.replace("img_url_answer", "img_url_answer_"+i);
  128. inHtml+=html;
  129. }
  130. $('#show_html').html(inHtml);
  131. for (var i=1;i<=num;i++){
  132. runImg('image_upload_'+i,'img_url_input_'+i,'img_url_tag_'+i);
  133. }
  134. return ;
  135. }
  136. if(type=='txt'){
  137. var inHtml = '';
  138. for (var i=1;i<=num;i++){
  139. var html = $('#txt_html').html();
  140. html = html.replace("\"txt\"", '"txt_'+i+'"');
  141. html = html.replace("\"txt\"", '"txt_'+i+'"');
  142. inHtml+=html;
  143. }
  144. $('#show_html').html(inHtml);
  145. return ;
  146. }
  147. });
  148. $("#add_but").on('click', function () {
  149. var formData = IO.serialize("#activity_form");
  150. new IO({
  151. type: "post"
  152. , url: VG.conf.root_domain + '/?c=Admin_Activity_SetInteractive&a=ReqAddSurveyQuestion'
  153. , data: formData
  154. , success: function (data) {
  155. if (data.ok) { //ok
  156. location.href = VG.conf.root_domain + '?c=Admin_Activity_SetInteractive&a=PageShow&events_id=<{$events_Data.events.id}>';
  157. } else {
  158. alert('操作失败,原因:'+data.msg);
  159. }
  160. return false;
  161. }
  162. , error: function (NULL, textStatus) {
  163. alert("请求服务器失败,原因:"+textStatus);
  164. }
  165. , dataType: "json"
  166. });
  167. });
  168. //图片上传
  169. function runImg(image_upload,img_url_input,img_url_tag){
  170. var K = KindEditor;
  171. var uploadbutton = K.uploadbutton({
  172. button : K('#'+image_upload)[0],
  173. fieldName : 'imgFile',
  174. url : VG.conf.root_domain + '/?c=kindeditor&a=updateJson&dir=image',
  175. afterUpload : function(data) {
  176. if (data.error === 0) {
  177. var url = K.formatUrl(data.url, 'absolute');
  178. K('#'+img_url_input).val(data.url);
  179. K('#'+img_url_tag).attr('src', data.url);
  180. } else {
  181. alert(data.message);
  182. }
  183. },
  184. afterError : function(str) {
  185. alert('自定义错误信息: ' + str);
  186. }
  187. });
  188. uploadbutton.fileBox.change(function(e) {
  189. uploadbutton.submit();
  190. });
  191. }
  192. });
  193. </script>
  194. <{include file="./admin/bottom.html"}>