123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>{$info['title']}</title>
- <link rel="stylesheet" href="/static/mobile/css/weui.min.css">
- <link rel="stylesheet" href="/static/mobile/css/weuix.css">
- <style>
- body{
- background-color: #f2f2f2;
- }
- .main{
- max-width: 750px;
- margin: 0 auto;
- background-color: #ffffff;
- }
- .page-bd{
- padding-bottom: 30px;
- }
- .weui-form{
- padding-top: 0px;
- }
- .main-title{
- text-align: center;
- padding: 20px 0 10px 0;
- }
- .main-desc{
- text-indent: 30px;
- font-size: 15px;
- }
- @media only screen and (min-width: 750px){
- html {
- font-size: 16.6px !important;
- }
- }
- input, textarea {
- border: 1px solid #efefef !important;
- caret-color: #03aced !important;
- caret-color: var(--weui-BLUE) !important;
- }
- input:focus, textarea:focus {
- border: 1px solid #03aced !important;
- caret-color: #03aced !important;
- caret-color: var(--weui-BLUE) !important;
- }
- .weui-form-checkbox[type="radio"]:checked + label .weui-icon-radio {
- background-color: #03aced;
- border: 1px solid #03aced;
- }
- .weui-form-checkbox[type="checkbox"]:checked + label .weui-icon-checkbox {
- background-color: #03aced;
- border: 1px solid #03aced;
- }
- .weui-btn_primary {
- background-color: #03aced !important;
- /*background-color: var(--weui-BRAND);*/
- }
- .max-limit {
- color: rgba(0,0,0,.5);
- color: var(--weui-FG-1);
- font-size: 14px;
- line-height: 1.4;
- }
- .weui-input{
- padding: 5px;
- }
- </style>
- </head>
- <body>
- <div class="main">
- <h2 class="main-title">{$info['title']}</h2>
- <div class="main-desc">
- {$info['description']}
- </div>
- <form id="myform">
- <input type="hidden" name="id" value="{$info['id']}">
- <div class="page-bd" id="vueapp">
- <div v-for="(item,index) in question" :key="index">
- <div v-if="item.required" class="weui-cells__title weui-start"> {{index + 1}} . {{item.title}}</div>
- <div v-if="!item.required" class="weui-cells__title"> {{index + 1}} . {{item.title}}</div>
- <div v-if="item.remark" class="weui-cells__title" style="text-indent: 30px;">{{item.remark}}</div>
- <div class="weui-form" v-if="item.type === 'radio'">
- <div v-for="(item2,index2) in item.options" :key="index2" class="weui-form-li">
- <input class="weui-form-checkbox" :name="`answer[${item.id}]`" :id="`answer${item.id}f${item2.id}`" :value="item2.id" type="radio">
- <label :for="`answer${item.id}f${item2.id}`"><i class="weui-icon-radio"></i>
- <div class="weui-form-text"><p>{{item2.text}}</p></div>
- </label>
- </div>
- </div>
- <div class="weui-form" v-if="item.type === 'checkbox'">
- <div v-for="(item2,index2) in item.options" :key="index2" class="weui-form-li">
- <input class="weui-form-checkbox" :name="`answer[${item.id}][]`" :id="`answer${item.id}f${item2.id}`" :value="item2.id" type="checkbox">
- <label :for="`answer${item.id}f${item2.id}`"><i class="weui-icon-checkbox"></i>
- <div class="weui-form-text"><p>{{item2.text}}</p></div>
- </label>
- </div>
- </div>
- <div class="weui-form" v-if="item.type === 'text'">
- <div class="weui-form-li">
- <input type="text" :name="`answer[${item.id}]`" class="weui-input" :placeholder="`最多填写${item.limit}字`">
- <!-- <span class="max-limit">最多填写{{item.limit}}字</span>-->
- </div>
- </div>
- <div class="weui-form" v-if="item.type === 'textarea'">
- <div class="weui-form-li">
- <textarea class="weui-form-area" :name="`answer[${item.id}]`" rows="3" :placeholder="`最多填写${item.limit}字`"></textarea>
- <!-- <span class="max-limit">最多填写{{item.limit}}字</span>-->
- </div>
- </div>
- <div class="weui-form" v-if="item.type === 'star'">
- <div class="weui-form-li">
- <div>
- <span>{{item.star_min_text}}</span>
- <span style="float: right;">{{item.star_max_text}}</span>
- </div>
- <table border="0">
- <tr>
- <td v-for="n in item.star_val_max" :key="n">
- <input class="weui-form-checkbox" :name="`answer[${item.id}]`" :id="`answer${item.id}star${n}`" :value="n" type="radio">
- <label :for="`answer${item.id}star${n}`">
- <i class="weui-icon-radio"></i>
- <div class="weui-form-text">
- <p>{{n}}</p>
- </div>
- </label>
- </td>
- </tr>
- </table>
- </div>
- </div>
- </div>
- <a href="javascript:" onclick="submitbtn(this)" class="weui-btn weui-btn_primary" style="margin-top: 30px;">
- 提交问卷
- </a>
- </div>
- </form>
- </div>
- <script src="/static/jquery-1.11.3.min.js"></script>
- <script src="/static/layer3.2.0/layer.js"></script>
- <script type="text/javascript" src="/static/vuejs/require.js"></script>
- <script>
- var question = {:json_encode($info['questions'])};
- var question = JSON.parse(question);
- function submitbtn(_self) {
- var param2 = $('#myform').serializeArray();
- console.log(param2);
- var flag = $(_self).attr('data-flag');
- if(flag == 1){
- return false;
- }
- $(_self).attr('data-flag',1).html('保 存...');
- var url = "answer";
- $.ajax({
- type: "POST",
- url: url,
- data:param2,
- success: function (res) {
- if(res.code == 1){
- window.location.href = "wjsuccess";
- }else{
- layer.msg(res.msg);
- }
- $(_self).attr('data-flag',0).html('保 存')
- },
- error:function (e) {
- layer.msg('请求失败');
- $(_self).attr('data-flag',0).html('保 存')
- }
- });
- }
- require.config({
- urlArgs: "ver=1.0_0",
- paths:{
- "vue":'/static/vuejs/vue.min2'
- },
- shim:{
- 'vue':{
- exports:'vue'
- }
- }
- });
- require(['vue'],function(Vue,draggable){
- var vm = new Vue({
- el: '#vueapp',
- data: {
- question: question
- },
- computed: {
- resoptions: function () {
- console.log(this.question);
- return JSON.parse(JSON.stringify(this.question));
- }
- },
- watch: {
- resoptions: function (newval, oldval) {
- this.formatData();
- },
- },
- created: function () {
- this.question.forEach((item) => {
- const info = item;
- info.answer = '';
- });
- console.log(this.question);
- this.formatData();
- },
- methods: {
- formatData(){
- console.log(this.question);
- },
- }
- })
- });
- </script>
- </body>
- </html>
|