index.html 16.8 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="__TMPL__/public/assets/assets/css/weui.min.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/assets/css/swiper-3.4.2.min.css">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_970727_pul0ncci0v.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/assets/css/style.css">
    <script type="text/javascript" src="__TMPL__/public/assets/assets/js/fontsize.js"></script>
    <script type="text/javascript" src="__TMPL__/public/assets/assets/js/jquery-2.1.0.js"></script>
    <title>问卷调查</title>
</head>
<body>
<a class="agree_top" href="javascript:history.back(-1);">
    <div class="iconfont icon-xiangzuo"></div>
    <div>返回</div>
</a>
<div class="survey_item">
    <div class="survey_itemtxt">*我的姓名:</div>
    <div class="survey_input">
        <input type="text" placeholder="请正确填写姓名,否则无法正确显示结果" id="name">
    </div>
</div>
<div class="survey_item">
    <div class="survey_itemtxt">*性别:</div>
    <div class="survey_input" id="sex"></div>
    <div class="sex_itemtxt choose_sex" >请选择</div>
</div>
<div class="survey_item survey_choosetime">
    <div class="survey_itemtxt">*出生日期:</div>
    <div class="trust_iteminput survey_input">
        <div class="guanxi_toptxt guanxitxt">选择年月日显示年龄</div>
        <div class="tip_guanximiantxt huominatxt" id="age"></div>
    </div>
</div>
<div class="survey_item">
    <div class="survey_itemtxt">*所在地区:</div>
    <div class="survey_input" id="region"></div>
    <div class="sex_itemtxt region" >请选择</div>
</div>
<div class="survey_item">
    <div class="survey_itemtxt">*家庭结构:</div>
    <div class="survey_input" id="family"></div>
    <div class="sex_itemtxt family" >请选择</div>
</div>
<div class="survey_item">
    <div class="survey_itemtxt">*职业:</div>
    <div class="survey_input" id="work"></div>
    <div class="sex_itemtxt work" >请选择</div>
</div>
<div class="survey_item big_item">
    <div class="survey_itemtxt">*有无吸烟酗酒是:</div>
    <div class="survey_input" id="smoke"></div>
    <div class="sex_itemtxt smoke" >请选择</div>
</div>
<div class="survey_item">
    <div class="survey_itemtxt">*出行方式:</div>
    <div class="survey_input" id="go"></div>
    <div class="sex_itemtxt go" >请选择</div>
</div>
<div class="survey_item baoz">
    <div class="survey_itemtxt">*有无社保:</div>
    <div class="survey_input" id="baoz"></div>
    <div class="sex_itemtxt baoz" >请选择</div>
</div>
<div class="survey_item big_item">
    <div class="survey_itemtxt">*家庭年收入:</div>
    <div class="survey_input" id="income"></div>
    <div class="sex_itemtxt income" >请选择</div>
</div>
<div class="survey_item bigbig_item">
    <div class="survey_itemtxt">*是否有负债(房贷车贷):</div>
    <div class="survey_input" id="fangdai"></div>
    <div class="sex_itemtxt fangdai" >请选择</div>
</div>
<div class="survey_item big_item">
    <div class="survey_itemtxt">*个人年收入:</div>
    <div class="survey_input" id="shouru"></div>
    <div class="sex_itemtxt shouru" >请选择</div>
</div>
<div class="survey_item big_item">
    <div class="survey_itemtxt">*大约未还负债:</div>
    <div class="survey_input" id="fuzai"></div>
    <div class="sex_itemtxt fuzai" >请选择</div>
</div>
<div class="survey_item big_item">
    <div class="survey_itemtxt">*是否有家族病史:</div>
    <div class="survey_input" id="disease"></div>
    <div class="sex_itemtxt disease" >请选择</div>
</div>
<div class="survey_title">*你更关心您家人哪方面保障:<text class="survey_title_sub">(单选或多选)</text></div>
<div class="choosebox">
    <div class="choose_item">
        <div class="choose_itemcell">旅游</div>
        <div class="choose_itemcell">意外</div>
        <div class="choose_itemcell">健康</div>
    </div>
    <div class="choose_item">
        <div class="choose_itemcell">旅游</div>
        <div class="choose_itemcell">意外</div>
        <div class="choose_itemcell">健康</div>
    </div>
</div>
<div class="survey_title survey_titles">*常用的联系方式:</div>
<div class="survey_titleinput">
    <input type="text" placeholder="请输入" id="xianxi" style="height: 27px;">
</div>
<div class="regbtn survey_btn">完成问卷</div>
<div id="toast" style="display: none;">
    <div class="weui-mask_transparent"></div>
    <div class="weui-toast">
        <p class="weui-toast__content">已完成</p>
    </div>
</div>
<script type="text/javascript" src="__TMPL__/public/assets/assets/js/jquery-2.1.0.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/assets/js/swiper-3.4.2.jquery.min.js"></script>
<script type="text/javascript " src="__TMPL__/public/assets/assets/js/weui.min.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/assets/js/common.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/assets/js/Augly_Verification.js"></script>
<script type="text/javascript" src="__TMPL__/public/assets/assets/js/provinces.js"></script>
<script type="text/javascript">

    $(function () {

        var province=[];//省名数组
        provinces.forEach(function (currentValue, index, arr){
                let provinceobj={
                    label: currentValue.province_name,
                    value: currentValue.province_id
                }
            province.push(provinceobj);
        });
console.log('province',province);

$('.choose_item').on('click','div',function () {
    if($(this).hasClass('choose_active')){
        $(this).removeClass('choose_active');
    }else{
        $(this).addClass('choose_active');
    }
})
$('.regbtn').click(function () {
    var name=$('#name').val();
    var sex=$('#sex').html();
    var age=$('#age').html();
    var region=$('#region').html();
    var family=$('#family').html();
    var work=$('#work').html();
    var smoke=$('#smoke').html();
    var go=$('#go').html();
    var baoz=$('#baoz').html();
    var income=$('#income').html();
    var fangdai=$('#fangdai').html();
    var shouru=$('#shouru').attr('data-shouru');
    var fuzai=$('#fuzai').attr('data-fuzai');
    var xianxi=$('#xianxi').val();
    var disease=$('#disease').html();
    let len=$('.choose_active').length;
    var safeguard = [];
    for(var i=0;i<len;i++){
        safeguard.push($('.choose_active').eq(i).text());
    }
    if(name==''){
        toast("姓名不能为空");
    }else if(sex==''){
        toast("请选择性别")
    }else if(age==''){
        toast("请选择出生日期")
    }else if(region=='1'){
        toast('请选择所在地区')
    }else if(family==''){
        toast('请选择家庭结构')
    }else if(work==''){
        toast('请选择职业')
    }else if(smoke==''){
        toast('请选择有无吸烟酗酒史')
    }else if(go==''){
        toast('请选择出行方式')
    }else if(baoz==''){
        toast('请选择有无社保')
    }else if(income==''){
        toast('请选择家庭年收入')
    }else if(fangdai==''){
        toast('请选择负债(房贷车贷)')
    }else if(shouru==''){
        toast('请选择个人年收入')
    }else if(fuzai==''){
        toast('请选择未还负债')
    }else if(disease == ''){
        toast('请选择家族病史')
    }else if(len == 0){
        toast('请选择你更关心您家人哪方面保障')
    }else if(xianxi==''){
        toast('常用的联系方式不能为空')
    }else{
        $.ajax({
            url: "{:url('question/create_question')}",
            type: "POST",
            data: {'name':name,'sex':sex,'birthday':age,'area':region,'family_num':family,'occupation':work,'smoke_drink':smoke,'going':go,'social':baoz,'year_income':income,'liabilities':fangdai,'personage_year_income':shouru,'not_return':fuzai,'family_disease':disease,'safeguard':safeguard,'phone':xianxi},
            success: function (data) {
                var data = eval("(" + data + ")");
                if(data.code == 20000){
                    toast('提交成功');
                    setTimeout(function(){window.location.href="{:url('index/index')}"},2000)
                }else if(data.code == 40005){
                    toast('您已提交过一份了');
                }else{
                    toast('与服务器断开连接');
                }
            }
        })
    }
})
    $('.choose_sex').click(function () {
        weui.picker([{
            label: '男',
            value: '1'
        }, {
            label:  '女',
            value:  '1'
        }], {
            onChange: function(result) {
            },
            onConfirm: function(result) {

                $('#sex').html(result[0].label)
            }
        });
    })
    $('.survey_choosetime').click(function () {
        var that=$(this);

        weui.datePicker({
            start:new Date().getFullYear() - 90,
            end: new Date(),
            defaultValue: [new Date().getFullYear(), new Date().getMonth()+1, new Date().getDate()],
            onConfirm: function(result){
                let date='';
                for(var i=0;i<result.length;i++){
                    if(i==(result.length-1)){
                        date += result[i].value
                    }else{
                        date += result[i].value+'/'
                    }
                }
                var currentdate = new Date();
                var startDate = new Date(date);
                var newDate = currentdate.getTime() - startDate.getTime();
                // 向下取整  例如 10岁 20天 会计算成 10岁
                // 如果要向上取整 计算成11岁,把floor替换成 ceil
                var age = Math.ceil(newDate / 1000 / 60 / 60 / 24 /365);
                if (isNaN(age)){
                    age = "";
                }
                console.log(age);
                that.find('.guanxitxt').hide(date);
                that.find('.tip_guanximiantxt').html(age-1)
            },
        });
    })
//省市选项
    $('.region').click(function () {
        var that=this;
        weui.picker(province, {
            onChange: function(result) {
            },
            onConfirm: function(result) {
                console.log('result',result);
                // 二级调用:时间
                $('.weui-picker').on('animationend webkitAnimationEnd', function() {
                    getcity(result[0].label,result[0].value);
                });
            }
        })
    })

       function getcity(provincename,provinceid){

            var that=this;
            var  city=[];
           citys.forEach(function (currentValue, index, arr){
               if(currentValue.province_id==provinceid){
                   let cityobj={
                       label: currentValue.city_name,
                       value: currentValue.city_id
                   }
                   city.push(cityobj);
               }
           });
           weui.picker(city, {
               onChange: function(result) {
               },
               onConfirm: function(result) {
                   $('#regiontxt').hide();
                  $('#region').html(provincename+result[0].label);


               }
           })
        }
//工作的选择
$('.work').click(function () {
    let that=this;
    weui.picker([{
        label: '职员',
        value: '职员'
    }, {
        label:  '学生',
        value:  '学生'
    },{
        label:  '自由职业',
        value:  '自由职业'
    },{
        label:  '企业高管',
        value:  '企业高管'
    },{
        label:  '其他',
        value:  '其他'
    }
    ], {
        onChange: function(result) {
        },
        onConfirm: function(result) {
            console.log($(that).find('.guanxitxt'));
            $(that).find('.guanxitxt').hide();
            $('#work').html(result[0].label)
        }
    })
})
//有无吸烟史选择
$('.smoke').click(function () {
    let that=this;
    weui.picker([{
        label: '有',
        value: '有'
    }, {
        label:  '无',
        value:  '无'
    }], {
        onChange: function(result) {
        },
        onConfirm: function(result) {
            console.log($(that).find('.guanxitxt'));
            $(that).find('.guanxitxt').hide();
            $('#smoke').html(result[0].label)
        }
    })
})
//出行方式的选择
$('.go').click(function () {
    let that=this;
    weui.picker([{
        label: '公共交通',
        value: '公共交通'
    }, {
        label:  '自驾',
        value:  '自驾'
    },{
        label:  '公共交通+自驾',
        value:  '公共交通+自驾'
    }], {
        onChange: function(result) {
        },
        onConfirm: function(result) {
            console.log($(that).find('.guanxitxt'));
            $(that).find('.guanxitxt').hide();
            $('#go').html(result[0].label)
        }
    })
})
//选择有无社保
$('.baoz').click(function () {
    let that=this;
    weui.picker([{
        label: '有',
        value: '有'
    }, {
        label:  '无',
        value:  '无'
    }], {
        onChange: function(result) {
        },
        onConfirm: function(result) {
            console.log($(that).find('.guanxitxt'));
            $(that).find('.guanxitxt').hide();
            $('#baoz').html(result[0].label)
        }
    })
})
//家庭结构选择
$('.family').click(function () {
    let that = this;
    weui.picker([{
        label: '1-2',
        value: '1-2'
    }, {
        label: '3-4',
        value: '3-4'
    }, {
        label: '5人以上',
        value: '5人以上'
    }
    ], {
        onChange: function (result) {
        },
        onConfirm: function (result) {
            console.log($(that).find('.guanxitxt'));
            $(that).find('.guanxitxt').hide();
            $('#family').html(result[0].label)
        }
    })
})
//选择家庭收入
$('.income').click(function () {
    let that=this;
    weui.picker([{
        label: '5万以下',
        value: '5万以下'
    }, {
        label:  '5-15万',
        value:  '5-15万'
    },{
        label:  '15-25万',
        value:  '15-25万'
    },{
        label:  '25-35万',
        value:  '25-35万'
    },{
        label:  '35万以上',
        value:  '35万以上'
    }], {
        onChange: function(result) {
        },
        onConfirm: function(result) {

            $(that).find('.guanxitxt').hide();
            $('#income').html(result[0].label)
        }
    })
})
//fangdai
$('.fangdai').click(function () {
    let that=this;
    weui.picker([{
        label: '有',
        value: '有'
    }, {
        label:  '无',
        value:  '无'
    }], {
        onChange: function(result) {
        },
        onConfirm: function(result) {

            $(that).find('.guanxitxt').hide();
            $('#fangdai').html(result[0].label)
        }
    })
})
//个人年收入shouru
$('.shouru').click(function () {
    let that=this;
    weui.picker([{
        label: '5万以下',
        value: '50000'
    }, {
        label:  '5-15万',
        value:  '100000'
    },{
        label:  '15-25万',
        value:  '200000'
    },{
        label:  '25-35万',
        value:  '300000'
    },{
        label:  '35万以上',
        value:  '350000'
    }], {
        onChange: function(result) {
        },
        onConfirm: function(result) {

            $(that).find('.guanxitxt').hide();
            $('#shouru').html(result[0].label)
            $('#shouru').attr('data-shouru',result[0].value)
        }
    })
})

// 大约未还负债
$('.fuzai').click(function () {
    let that=this;
    weui.picker([{
        label: '10万以下',
        value: '100000'
    }, {
        label:  '10-30万',
        value:  '150000'
    },{
        label:  '30-50万',
        value:  '400000'
    },{
        label:  '50-100万',
        value:  '750000'
    },{
        label:  '100万以上',
        value:  '1000000'
    },{
        label:  '0',
        value:  '0'
    }], {
        onChange: function(result) {
        },
        onConfirm: function(result) {
            $(that).find('.guanxitxt').hide();
            $('#fuzai').html(result[0].label);
            $('#fuzai').attr('data-fuzai',result[0].value);
        }
    })
})
    //disease
//是否有家族病史
$('.disease').click(function () {
    let that=this;
    weui.picker([{
        label: '有',
        value: '有'
    }, {
        label:  '无',
        value:  '无'
    }], {
        onChange: function(result) {
        },
        onConfirm: function(result) {
            console.log($(that).find('.guanxitxt'));
            $(that).find('.guanxitxt').hide();
            $('#disease').html(result[0].label)
        }
    })
})
    })
</script>
</body>
</html>