wj.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>{$info['title']}</title>
  8. <link rel="stylesheet" href="/static/mobile/css/weui.min.css">
  9. <link rel="stylesheet" href="/static/mobile/css/weuix.css">
  10. <style>
  11. body{
  12. background-color: #f2f2f2;
  13. }
  14. .main{
  15. max-width: 750px;
  16. margin: 0 auto;
  17. background-color: #ffffff;
  18. }
  19. .page-bd{
  20. padding-bottom: 30px;
  21. }
  22. .weui-form{
  23. padding-top: 0px;
  24. }
  25. .main-title{
  26. text-align: center;
  27. padding: 20px 0 10px 0;
  28. }
  29. .main-desc{
  30. text-indent: 30px;
  31. font-size: 15px;
  32. }
  33. @media only screen and (min-width: 750px){
  34. html {
  35. font-size: 16.6px !important;
  36. }
  37. }
  38. input, textarea {
  39. border: 1px solid #efefef !important;
  40. caret-color: #03aced !important;
  41. caret-color: var(--weui-BLUE) !important;
  42. }
  43. input:focus, textarea:focus {
  44. border: 1px solid #03aced !important;
  45. caret-color: #03aced !important;
  46. caret-color: var(--weui-BLUE) !important;
  47. }
  48. .weui-form-checkbox[type="radio"]:checked + label .weui-icon-radio {
  49. background-color: #03aced;
  50. border: 1px solid #03aced;
  51. }
  52. .weui-form-checkbox[type="checkbox"]:checked + label .weui-icon-checkbox {
  53. background-color: #03aced;
  54. border: 1px solid #03aced;
  55. }
  56. .weui-btn_primary {
  57. background-color: #03aced !important;
  58. /*background-color: var(--weui-BRAND);*/
  59. }
  60. .max-limit {
  61. color: rgba(0,0,0,.5);
  62. color: var(--weui-FG-1);
  63. font-size: 14px;
  64. line-height: 1.4;
  65. }
  66. .weui-input{
  67. padding: 5px;
  68. }
  69. </style>
  70. </head>
  71. <body>
  72. <div class="main">
  73. <h2 class="main-title">{$info['title']}</h2>
  74. <div class="main-desc">
  75. {$info['description']}
  76. </div>
  77. <form id="myform">
  78. <input type="hidden" name="id" value="{$info['id']}">
  79. <div class="page-bd" id="vueapp">
  80. <div v-for="(item,index) in question" :key="index">
  81. <div v-if="item.required" class="weui-cells__title weui-start"> {{index + 1}} . {{item.title}}</div>
  82. <div v-if="!item.required" class="weui-cells__title"> {{index + 1}} . {{item.title}}</div>
  83. <div v-if="item.remark" class="weui-cells__title" style="text-indent: 30px;">{{item.remark}}</div>
  84. <div class="weui-form" v-if="item.type === 'radio'">
  85. <div v-for="(item2,index2) in item.options" :key="index2" class="weui-form-li">
  86. <input class="weui-form-checkbox" :name="`answer[${item.id}]`" :id="`answer${item.id}f${item2.id}`" :value="item2.id" type="radio">
  87. <label :for="`answer${item.id}f${item2.id}`"><i class="weui-icon-radio"></i>
  88. <div class="weui-form-text"><p>{{item2.text}}</p></div>
  89. </label>
  90. </div>
  91. </div>
  92. <div class="weui-form" v-if="item.type === 'checkbox'">
  93. <div v-for="(item2,index2) in item.options" :key="index2" class="weui-form-li">
  94. <input class="weui-form-checkbox" :name="`answer[${item.id}][]`" :id="`answer${item.id}f${item2.id}`" :value="item2.id" type="checkbox">
  95. <label :for="`answer${item.id}f${item2.id}`"><i class="weui-icon-checkbox"></i>
  96. <div class="weui-form-text"><p>{{item2.text}}</p></div>
  97. </label>
  98. </div>
  99. </div>
  100. <div class="weui-form" v-if="item.type === 'text'">
  101. <div class="weui-form-li">
  102. <input type="text" :name="`answer[${item.id}]`" class="weui-input" :placeholder="`最多填写${item.limit}字`">
  103. <!-- <span class="max-limit">最多填写{{item.limit}}字</span>-->
  104. </div>
  105. </div>
  106. <div class="weui-form" v-if="item.type === 'textarea'">
  107. <div class="weui-form-li">
  108. <textarea class="weui-form-area" :name="`answer[${item.id}]`" rows="3" :placeholder="`最多填写${item.limit}字`"></textarea>
  109. <!-- <span class="max-limit">最多填写{{item.limit}}字</span>-->
  110. </div>
  111. </div>
  112. <div class="weui-form" v-if="item.type === 'star'">
  113. <div class="weui-form-li">
  114. <div>
  115. <span>{{item.star_min_text}}</span>
  116. <span style="float: right;">{{item.star_max_text}}</span>
  117. </div>
  118. <table border="0">
  119. <tr>
  120. <td v-for="n in item.star_val_max" :key="n">
  121. <input class="weui-form-checkbox" :name="`answer[${item.id}]`" :id="`answer${item.id}star${n}`" :value="n" type="radio">
  122. <label :for="`answer${item.id}star${n}`">
  123. <i class="weui-icon-radio"></i>
  124. <div class="weui-form-text">
  125. <p>{{n}}</p>
  126. </div>
  127. </label>
  128. </td>
  129. </tr>
  130. </table>
  131. </div>
  132. </div>
  133. </div>
  134. <a href="javascript:" onclick="submitbtn(this)" class="weui-btn weui-btn_primary" style="margin-top: 30px;">
  135. 提交问卷
  136. </a>
  137. </div>
  138. </form>
  139. </div>
  140. <script src="/static/jquery-1.11.3.min.js"></script>
  141. <script src="/static/layer3.2.0/layer.js"></script>
  142. <script type="text/javascript" src="/static/vuejs/require.js"></script>
  143. <script>
  144. var question = {:json_encode($info['questions'])};
  145. var question = JSON.parse(question);
  146. function submitbtn(_self) {
  147. var param2 = $('#myform').serializeArray();
  148. console.log(param2);
  149. var flag = $(_self).attr('data-flag');
  150. if(flag == 1){
  151. return false;
  152. }
  153. $(_self).attr('data-flag',1).html('保 存...');
  154. var url = "answer";
  155. $.ajax({
  156. type: "POST",
  157. url: url,
  158. data:param2,
  159. success: function (res) {
  160. if(res.code == 1){
  161. window.location.href = "wjsuccess";
  162. }else{
  163. layer.msg(res.msg);
  164. }
  165. $(_self).attr('data-flag',0).html('保 存')
  166. },
  167. error:function (e) {
  168. layer.msg('请求失败');
  169. $(_self).attr('data-flag',0).html('保 存')
  170. }
  171. });
  172. }
  173. require.config({
  174. urlArgs: "ver=1.0_0",
  175. paths:{
  176. "vue":'/static/vuejs/vue.min2'
  177. },
  178. shim:{
  179. 'vue':{
  180. exports:'vue'
  181. }
  182. }
  183. });
  184. require(['vue'],function(Vue,draggable){
  185. var vm = new Vue({
  186. el: '#vueapp',
  187. data: {
  188. question: question
  189. },
  190. computed: {
  191. resoptions: function () {
  192. console.log(this.question);
  193. return JSON.parse(JSON.stringify(this.question));
  194. }
  195. },
  196. watch: {
  197. resoptions: function (newval, oldval) {
  198. this.formatData();
  199. },
  200. },
  201. created: function () {
  202. this.question.forEach((item) => {
  203. const info = item;
  204. info.answer = '';
  205. });
  206. console.log(this.question);
  207. this.formatData();
  208. },
  209. methods: {
  210. formatData(){
  211. console.log(this.question);
  212. },
  213. }
  214. })
  215. });
  216. </script>
  217. </body>
  218. </html>