inquiry.html 35.9 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 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918
<!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">
    <title>我要问诊</title>
    <script src="__TMPL__/public/assets/js/fontsize.js"></script>
    <link rel="stylesheet" href="__TMPL__/public/assets/css/init.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/css/swiper-3.4.2.min.css">
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_793738_tlxymah92x.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/css/weui.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/css/myweui.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/css/referralModule.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/css/comment.css">
</head>
<body>
<div class="container">
    <div class="inquary_box">
        <div class="content_item">
            <!--<div class="tab_title">接诊信息(同意转诊时需要填写此表单)</div>-->
            <div class="info_box">
                <div class="info_item inquiry_type">
                    <div class="title">
                        <text>疾病分类</text>
                    </div>

                    <div class="info_input"><input class="inquiry_value" type="text" placeholder="请选择基本种类" readonly="" onfocus="this.focus()">
                        <text class="iconfont icon-xiala"></text>
                    </div>
                </div>
                <div class="info_item expert">
                    <div class="title">
                        <text>问诊专家</text>
                    </div>

                    <div class="info_input"><input class="expert_value" type="text" placeholder="推荐专家" readonly="" onfocus="this.focus()">
                        <text class="iconfont icon-xiala"></text>
                    </div>
                </div>
                <div class="hint_info">提示:您可以选择推荐专家,平台会为您匹配对应专家;您也可以
                    选择其他专家。
                </div>
                <div class="info_item">
                    <div class="title" data-id="1">
                        <text>病人主述</text>
                        <text class="iconfont icon-huatong voice_btn"></text>
                        <text class="iconfont icon-tianxie"></text>
                    </div>
                    <div class="textarea_box">
                        <textarea class="area textarea1" type="text"   placeholder="请输入临床表现" maxlength="1000"></textarea>
                        <p class="text_num"><span class="text-count">0</span>/1000</p>
                    </div>
                    <div id="voice_module" class="voice_module" video-id="1">
                        <div class="voice_list" voiceitemid="1">
                            <div class="voice_box voice_third">
                                <div class="voice_item">
                                    <text class="iconfont icon-luyin voice_icon"></text>
                                    <text class="voice_font luyin">点击图标可播放 时长:<span class="timeLength">0</span></text>
                                </div>
                                <div class="voice_btn_box">
                                    <text class="iconfont icon-quxiao cancle_voice"></text>
                                    <text class="iconfont icon-tianjia add_voice"></text>
                                </div>
                            </div>
                            <div class="voice_box voice_first" voiceid="1">
                                <div class="voice_item">
                                    <text class="iconfont icon-huatong mike voice_icon"></text>
                                    <text class="voice_font huatong">点击图标开始语音语音最长60秒</text>
                                </div>
                                <div class="voice_btn_box">
                                    <text class="iconfont icon-quxiao icon_cancle"></text>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="info_item">
                    <div class="title" data-id="3">
                        <text>初步诊断</text>
                        <text class="iconfont icon-huatong voice_btn voice_btn3"></text>
                        <text class="iconfont icon-tianxie"></text>
                    </div>
                    <div class="textarea_box">
                        <textarea class="area textarea3" type="text"  placeholder="请输入初步诊断" maxlength="1000"></textarea>
                        <p class="text_num"><span class="text-count">0</span>/1000</p>
                    </div>
                    <div id="voice_module3" class="voice_module" video-id="3">
                        <div class="voice_list" voiceitemid="3">
                            <div class="voice_box voice_third">
                                <div class="voice_item">
                                    <text class="iconfont icon-luyin voice_icon"></text>
                                    <text class="voice_font luyin">点击图标可播放 时长:<span class="timeLength">0</span></text>
                                </div>
                                <div class="voice_btn_box">
                                    <text class="iconfont icon-quxiao cancle_voice"></text>
                                    <text class="iconfont icon-tianjia add_voice"></text>
                                </div>
                            </div>
                            <!--<div class="voice_box voice_second">-->
                            <!--<div class="voice_item">-->
                            <!--<text class="iconfont icon-luying_ongoing voice_icon"></text>-->
                            <!--<text class="voice_font luying_ongoing">正在播放 <span class="timeLength">0</span>秒/60秒</text>-->
                            <!--</div>-->
                            <!--</div>-->
                            <div class="voice_box voice_first">
                                <div class="voice_item">
                                    <text class="iconfont icon-huatong mike voice_icon"></text>
                                    <text class="voice_font huatong">点击图标开始语音语音最长60秒</text>
                                </div>
                                <div class="voice_btn_box">
                                    <text class="iconfont icon-quxiao icon_cancle cancle_voice"></text>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="info_item">
                    <div class="title" data-id="2">
                        <text>你的困惑</text>
                        <text class="iconfont icon-huatong voice_btn voice_btn2"></text>
                        <text class="iconfont icon-tianxie"></text>
                    </div>
                    <div class="textarea_box">
                        <textarea class="area textarea2" type="text"  placeholder="请输入你的困惑" maxlength="1000"></textarea>
                        <p class="text_num"><span class="text-count">0</span>/1000</p>
                    </div>
                    <div id="voice_module2" class="voice_module" video-id="2">
                        <div class="voice_list" voiceitemid="2">
                            <div class="voice_box voice_third">
                                <div class="voice_item">
                                    <text class="iconfont icon-luyin voice_icon"></text>
                                    <text class="voice_font luyin">点击图标可播放 时长:<span class="timeLength">0</span></text>
                                </div>
                                <div class="voice_btn_box">
                                    <text class="iconfont icon-quxiao cancle_voice"></text>
                                    <text class="iconfont icon-tianjia add_voice"></text>
                                </div>
                            </div>
                            <!--<div class="voice_box voice_second">-->
                            <!--<div class="voice_item">-->
                            <!--<text class="iconfont icon-luying_ongoing voice_icon"></text>-->
                            <!--<text class="voice_font luying_ongoing">正在播放 <span class="timeLength">0</span>秒/60秒</text>-->
                            <!--</div>-->
                            <!--</div>-->
                            <div class="voice_box voice_first">
                                <div class="voice_item">
                                    <text class="iconfont icon-huatong mike voice_icon"></text>
                                    <text class="voice_font huatong">点击图标开始语音语音最长60秒</text>
                                </div>
                                <div class="voice_btn_box">
                                    <text class="iconfont icon-quxiao icon_cancle cancle_voice"></text>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="upload_box">
                <div class="weui-uploader__hd">
                    <p class="title">报告单(最多上传9张)</p>
                </div>
                <div class="weui-uploader__bd">
                    <ul class="weui-uploader__files" id="uploaderFiles">
                    </ul>
                    <div class="weui-uploader__input-box addpic">
                        <!--<input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*"-->
                               <!--multiple/>-->
                    </div>
                </div>
            </div>
            <div class="agree_btn submit">提交</div>
        </div>
    </div>

    <!--录音弹窗-->
    <div class="mask_box first" hidden>
        <div class="popup_box">
            <div class="popup_title">录制语音</div>
            <div class="popup_time">
                <div class="time-item">
                    <!--<span id="day_show">0天</span>-->
                    <strong id="hour_show"><text id="h"></text>00:</strong>
                    <strong id="minute_show"><text></text>01:</strong>
                    <strong id="second_show"><text></text>00</strong>
                </div>
                <div class="popup_info">还可以录制 <span id="second_test">60</span></div>
            </div>
            <div class="popup_btn_box">
                <div class="popup_item start ">
                    <img class="popup_icon" src="__TMPL__/public/assets/images/eicon09@2x.png" alt="">
                    <div>开始</div>
                </div>
                <div class="popup_item pause" hidden>
                    <img class="popup_icon" src="__TMPL__/public/assets/images/eicon13@2x.png" alt="">
                    <div>暂停</div>
                </div>
                <div class="popup_item stop" hidden>
                    <img class="popup_icon" src="__TMPL__/public/assets/images/eicon14@2x.png" alt="">
                    <div>已停止</div>
                </div>
                <div class="popup_center play start">
                    <img class="" src="__TMPL__/public/assets/images/eicon11@2x.png" alt="">
                </div>
                <div class="popup_center stopping" hidden>
                    <img class="" src="__TMPL__/public/assets/images/eicon12@2x.png" alt="">
                </div>
                <div class="popup_item next_step">
                    <img class="popup_icon"  src="__TMPL__/public/assets/images/eicon10@2x.png" alt="">
                    <div>下一步</div>
                </div>
            </div>
        </div>
    </div>

    <!---->
    <div class="mask_box second" hidden>
        <div class="popup_box">
            <div class="popup_title">录制语音</div>
            <div class="popup_time">
                <div class="popup_btn audition">点击试听</div>
                <!--<div class="popup_info">时长:4分58秒</div>-->
            </div>
            <div class="popup_btn_box">
                <div class="large_icon rerecord">
                    <img class="popup_icon " src="__TMPL__/public/assets/images/eicon15@2x.png" alt="">
                    <div>重新录制</div>
                </div>
                <div class="large_icon submit_voice">
                    <img class="popup_icon upload" src="__TMPL__/public/assets/images/eicon16@2x.png" alt="">
                    <div>我要发送</div>
                </div>
            </div>
        </div>
    </div>

    <!--弹窗-->
    <div class="box" hidden>
        <div class="public_popup_box">
            <text>提交成功!</text>
            <text>等待专家回复</text>
        </div>
    </div>
</div>

<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script>
<script src="__TMPL__/public/assets/js/weui.js"></script>
<script src="__TMPL__/public/assets/js/myweui.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<!--<script src="__TMPL__/public/assets/js/referral.js"></script>-->
<script type="application/javascript">
    var serverIds = '';
    //文本框显示字数
    wx.config({$sdk});
    $(".area").on("input propertychange", function () {

        var $this = $(this),
            _val = $this.val(),
            count = "";
        if (_val.length > 1000) {
            $this.val(_val.substring(0, 1000));
        }
        count = 1000 - $this.val().length;
        $(this).siblings(".text_num").children('.text-count').text(count);
    });

    //    疾病分类下拉
    $('.inquiry_type').click(function () {
        weui.picker([
            <volist name='platment' id='vo'>
                {label: '{$vo.name}', value: {$vo.id}},
             </volist>
            ], {
                onChange: function (res) {
                    $('.expert_value').val('')
                    $('.expert_value').data('data-id','')
                },
                onConfirm: function (res) {
                    $('.inquiry_value').val(res[0].label)
                    $('.inquiry_value').data('data-id',res[0].value)
                    /*请求接口获取推荐专家*/
                        $.ajax({
                            url:'{:url('remmoedExpert')}',
                            type:'POST',
                            data:{
                               id:res[0].value
                            },
                            success:function(res){
                                if(res.code==1){
                                    console.log(res)
                                    $('.expert_value').val(res.data.user_login)
                                    $('.expert_value').data('data-id', res.data.id)
                                }
                            }
                        })


                }
            }
        )
    })
    //    疾病分类下拉
    $('.expert').click(function () {
        var doctor = new Array()
        var platment_id = $('.inquiry_value').data('data-id');
        if (!platment_id) {
            weui.toast('请先选择疾病分类!');
            return;
        }
        $.ajax({
            url: "{:url('getExportByPlatment')}",
            data: {
                platment_id: platment_id
            },
            type: 'POST',
            success: function (res) {
                console.log(res);

                if(res.data.length>0){
                    for (key in res.data) {
                        var info = new Object();
                        info.label = res.data[key].user_login;
                        info.value = res.data[key].id;
                        doctor[key] = info
                    }
                }else{
                    weui.toast('暂无专家!');
                    return;
                }

                console.log(doctor);
                var doctor1 = new Array();
                weui.picker(doctor, {
                        onChange: function (res) {
                            console.log(res)
                        },
                        onConfirm: function (res) {
                            $('.expert_value').val(res[0].label)
                            $('.expert_value').data('data-id', res[0].value)
                        }
                    }
                )
            }
        })
    })
    //  性别分类
    $('.sex_type').click(function () {
        weui.picker([
                {label: '男', value: 1},
                {label: '女', value: 2}
            ], {
                onChange: function (res) {
                    console.log(res)
                },
                onConfirm: function (res) {
                    $('.sex_value').val(res[0].label)
                }
            }
        )
    })
    //  性别分类
    $('.unit_type').click(function () {
        weui.picker([
                {label: '国企', value: 0},
                {label: '私企', value: 1}
            ], {
                onChange: function (res) {
                    console.log(res)
                },
                onConfirm: function (res) {
                    $('.unit_value').val(res[0].label)
                }
            }
        )
    })

    var title_id = ''

    //语音模块
    // $('.icon-tianxie').hide()
    // $('.voice_first').hide()
    // $('.voice_second').hide()
    $('.voice_third').hide()
    $('.icon_cancle').hide()


    //点击
    $('.info_item').on('click','.title',function () {
        $(this).parent().toggleClass('voice')
    })

    //点击正在播放按钮
    $('.icon-luying_ongoing').click(function () {
        var videolist = $(".voice_module");
        for (var i = 0; i < videolist.length; i++) {
            var videoid = $(videolist[i]).attr("video-id");
            if (videoid == title_id) {
                $(videolist[i]).show();
                $(videolist[i]).children('.voice_second').hide()
                $(videolist[i]).children('.voice_third').show();
            }
          }
    })

    //倒计时
    var times = "60";//倒计时总秒数量
    var time="";
    var timeLength=0;
    function countDown(times) {
        var timer = null;
        timer = setInterval(function () {
            var day = 0,
                hour = 0,
                minute = 0,
                second = 0;//时间默认值
            if (times > 0) {
                day = Math.floor(times / (60 * 60 * 24));
                hour = Math.floor(times / (60 * 60)) - (day * 24);
                minute = Math.floor(times / 60) - (day * 24 * 60) - (hour * 60);
                second = Math.floor(times) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
            }
            if (day <= 9) day = '0' + day;
            if (hour <= 9) hour = '0' + hour;
            if (minute <= 9) minute = '0' + minute;
            if (second <= 9) second = '0' + second;

            $('#hour_show').html('<text id="h"></text>' + hour + ':');
            $('#minute_show').html('<text></text>' + minute + ':');
            $('#second_show').html('<text></text>' + second + '');
            $('#second_test').html('<text></text>' + second + '');

            //
            // console.log(day + "天:" + hour + "小时:" + minute + "分钟:" + second + "秒");
            times--;

        }, 1000);
        // if (times <= 0) {
        //     clearInterval(timer);
        // }

        $('.pause').click(function () {
            // timer(intDiff);
            clearInterval(timer);
            localStorage.setItem("times",times)
        })
        $('.stop').click(function () {
            clearInterval(timer);
            times=0;
        })
        $('.stopping').click(function () {
            clearInterval(timer);
            timeLength=60-times;
            console.log('录音时长:'+timeLength);
            localStorage.clear()
        })
    }
    $('.start').click(function () {
        time=localStorage.getItem("times")
        if(time==null){
            times = parseInt(60)
        }else{
            times=time;
        }
        console.log(time)
        // myTimer(intDiff);
        countDown(times);
        localStorage.setItem("times",times)
    })

    //添加一条新语音
    var num = 1;
    $('.voice_module').on('click', '.add_voice', function () {
        times=60
        // clearInterval(timer);
        var day = 0,
            hour = 0,
            minute = 0,
            second = 0;//时间默认值
        if (day <= 9) day = '0' + day;
        if (hour <= 9) hour = '0' + hour;
        if (minute <= 9) minute = '0' + minute;
        if (second <= 9) second = '0' + second;

        $('#hour_show').html('<text id="h"></text>' + hour + ':');
        $('#minute_show').html('<text></text>' + minute + ':');
        $('#second_show').html('<text></text>' + second + '');
        $('#second_test').html(60);

        num = num + 1
        var parent = $(this).parents('.voice_module')
        var html =  '<div class="voice_list" voiceitemid="'+num+'">\n' +
            '<div class="voice_box voice_third" style="display: none;">\n' +
            '           <div class="voice_item">\n' +
            '               <text class="iconfont icon-luyin voice_icon"></text>\n' +
            '               <text class="voice_font luyin">点击图标可播放 时长:<span class="timeLength">0</span>秒</text>\n' +
            '           </div>\n' +
            '           <div class="voice_btn_box">\n' +
            '               <text class="iconfont icon-quxiao cancle_voice"></text>\n' +
            // '               <text class="iconfont icon-tianjia add_voice"></text>\n' +
            '           </div>\n' +
            '    </div>\n' +
            '    <div class="voice_box voice_first">\n' +
            '      <div class="voice_item">\n' +
            '       <text class="iconfont icon-huatong mike voice_icon"></text>\n' +
            '       <text class="voice_font huatong">点击图标开始语音语音最长60秒</text>\n' +
            '      </div>\n' +
            '    <div class="voice_btn_box">\n' +
            '        <text class="iconfont icon-quxiao icon_cancle cancle_voice"></text>\n' +
            '    </div>\n' +
            '   </div>\n' +
            '</div>'


        // parent.append($('.voice_list').html());
        parent.append(html)

    })

    //显示弹窗
    var videoid=''
    //生命全局唯一 音频
    var voiceBox;
    $(document).on("click", ".mike", function () {
        $('.first').show()
        $('.play').show()
        $('.start').show()
        $('.stopping').hide()
        $('.stop').hide()
        $('.next_step').hide();
        // videoid=$(this).parents(".voice_module").attr("video-id")

        // $(this).parents(".voice_first").hide();
        // $(this).parents(".voice_first").siblings(".voice_third").show()
        //
        //     // vioceid=$(this).parents(".voice_first").attr("voiceid");
        //

        voiceBox = $(this).parents('.voice_list');

        // console.log(voiceBox)
        // $('.submit_voice').attr('videoid')
        //
        // var videolist = $(".voice_module");
        // console.log(videolist)
        // for (var i = 0; i < videolist.length; i++) {
        //     if (videoid == title_id) {
        //         $(videolist[i]).children(".voice_list").children(".voice_list").hide();
        //         $(videolist[i]).children(".voice_list").children(".voice_third").show();
        //     }
        // }

    });

    //删除语音
    $(".voice_module").on("click",".cancle_voice",function(){
        var parent=$(this).parents(".voice_list").parent();
        var leng=parent.children('.voice_list').length;
        $(this).parents(".voice_list").remove();
        if(leng==1){
            num = num + 1
            var html =  '<div class="voice_list" voiceitemid="'+num+'">\n' +
                '<div class="voice_box voice_third" style="display: none;">\n' +
                '           <div class="voice_item">\n' +
                '               <text class="iconfont icon-luyin voice_icon"></text>\n' +
                '               <text class="voice_font luyin">点击图标可播放 时长:<span class="timeLength">0</span>秒</text>\n' +
                '           </div>\n' +
                '           <div class="voice_btn_box">\n' +
                '               <text class="iconfont icon-quxiao cancle_voice"></text>\n' +

                '           </div>\n' +
                '    </div>\n' +
                '    <div class="voice_box voice_first">\n' +
                '      <div class="voice_item">\n' +
                '       <text class="iconfont icon-huatong mike voice_icon"></text>\n' +
                '       <text class="voice_font huatong">点击图标开始语音语音最长60秒</text>\n' +
                '      </div>\n' +
                '    <div class="voice_btn_box">\n' +
                '        <text class="iconfont icon-quxiao icon_cancle cancle_voice"></text>\n' +
                '               <text class="iconfont icon-tianjia add_voice"></text>\n' +
                '    </div>\n' +
                '   </div>\n' +
                '</div>';
            parent.append(html);
        }

    });



    //开始录音
    var localId;
    $('.start').click(function () {
        $('.start').hide()
        $('.stop').hide()
        $('.play').hide()
        $('.pause').show()
        $('.stopping').show()
        $('.next_step').hide()
        /*微信开始录音*/
        wx.startRecord();
    })

    //暂停
    $('.pause').click(function () {
        $('.pause').hide()
        $('.start').show()
        $('.stopping').hide()

    })

    //停止录音
    $('.stopping').click(function () {
        $('.next_step').show()
        $('.stop').show()
        $('.pause').hide()
        wx.stopRecord({
            success: function (res) {
                localId  = res.localId;
            }

        });
    })

    //下一步
    $('.next_step').click(function () {
        $('.first').hide()
        $('.second').show()

    })

    //点击试听
    $('.audition').click(function () {
        wx.onVoicePlayEnd({
            success: function (res) {
                var localId = res.localId; // 返回音频的本地ID
            }
        });
        wx.playVoice({
            localId:localId  //需要播放的音频的本地ID,由stopRecord接口获得
        });

        var videolist = $(".voice_module");
        for (var i = 0; i < videolist.length; i++) {
            var videoid = $(videolist[i]).attr("video-id");
            if (videoid == title_id) {
                $('.second').hide()
                $(videolist[i]).show();
                $(videolist[i]).children('.voice_list').hide()
                $(videolist[i]).children('.voice_third').show();
            }
        }
    })


   // 列表中点击试听
    $('.voice_third').click(
        function () {
            var tryId=$(this).attr('data-try');
            wx.playVoice({
                localId:tryId
            });
        }
    )

    //我要发送
    $('.submit_voice').click(function () {
        voiceBox.find('.voice_first').hide().siblings('.voice_third').show()
        wx.uploadVoice({localId: localId, // 需要上传的音频的本地ID,由stopRecord接口获得
            isShowProgressTips: 1, // 默认为1,显示进度提示
            success: function (res) {
                voiceBox.find('.voice_first').hide().siblings('.voice_third').attr('data-serverid',res.serverId);
            }
        });
        voiceBox.find('.voice_first').hide().siblings('.voice_third').attr('data-try',localId);
        voiceBox.find('.voice_first').hide().siblings('.voice_third').attr('data-time',timeLength);
        voiceBox.find('.timeLength').html(timeLength);
        $('.second').hide()
    })

     //确认音频
    $('.upload').click(function () {
        var videolist = $(".voice_module");
        for (var i = 0; i < videolist.length; i++) {
            var videoid = $(videolist[i]).attr("video-id");
            if (videoid == title_id) {
                $('.second').hide()
                $(videolist[i]).show();
                $(videolist[i]).children('.voice_list').hide()
                $(videolist[i]).children('.voice_third').show();
                /*上面放上 音频id和本地地址*/
                $(videolist[i]).children('.voice_third').attr('try-id',localId);
                $(videolist[i]).children('.voice_third').data('data-try',localId);
                $(videolist[i]).children('.voice_third').attr('id','audio'+videoid);
                wx.uploadVoice({
                    localId: localId, // 需要上传的音频的本地ID,由stopRecord接口获得
                    isShowProgressTips: 1, // 默认为1,显示进度提示
                    success: function (res) {
                        var serverId = res.serverId; // 返回音频的服务器端ID
                        $(videolist[i]).children('.voice_third').attr('server-id',serverId);
                        $(videolist[i]).children('.voice_third').data('data-server',serverId);
                        localId='';
                    }
                });
            }
        }
    })

    //重新录制
    $('.rerecord').click(function () {
        $('#second_test').html(60);
        $('.first').show()
        $('.second').hide()
        $('.stop').hide()
        $('.stopping').hide()
        $('.start').show()
    })

    //上传图片
    $(function () {
        var tmpl = '<li class="weui-uploader__file" style="background-image:url(#url#)"></li>',
            $gallery = $("#gallery"), $galleryImg = $("#galleryImg"),
            $uploaderInput = $("#uploaderInput"),
            $uploaderFiles = $("#uploaderFiles")
        ;
        $uploaderInput.on("change", function (e) {
            var src, url = window.URL || window.webkitURL || window.mozURL, files = e.target.files;
            for (var i = 0, len = files.length; i < len; ++i) {
                var file = files[i];

                if (url) {
                    src = url.createObjectURL(file);
                } else {
                    src = e.target.result;
                }
                $uploaderFiles.append($(tmpl.replace('#url#', src)));
            }
        });
        $uploaderFiles.on("click", "li", function () {
            $galleryImg.attr("style", this.getAttribute("style"));
            $gallery.fadeIn(100);
        });
        $gallery.on("click", function () {
            $gallery.fadeOut(100);
        });
    });

    //上传图片
    $('.addpic').on('click', function (res) {
        var length = $('.length').length;
        if (length >= 9) {
            weui.toast('不能上传了')
            $('#addpic').hide();
            return false;
        }
        wx.chooseImage({
            count: 9 - length, // 默认9
            sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
            sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
            success: function (res) {
                console.log(res.localIds);
                for (var i = 0; i < res.localIds.length; i++) {
                    // $('.addpic').before('<img style="width:100px;height:100px;" class="length" src="'+res.localIds[i]+'"/>')
                    $('.addpic').before('<li class="weui-uploader__file length" src="' + res.localIds[i] + '" style="background-image:url(' + res.localIds[i] + ')"></li>')
                }
                uploadImages(res.localIds)// 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
            }
        });
    })


    function uploadImages(localIds) {
        var localId = localIds.pop();
        wx.uploadImage({
            localId: localId,
            isShowProgressTips: 1,
            success: function (res) {
                var serverId = res.serverId; // 返回图片的服务器端ID
                console.log(serverId);
                serverIds += serverId + ',';
                if (localIds.length > 0) {
                    uploadImages(localIds);
                }
            },
            fail: function (res) {
                $modal.toast(JSON.stringify(res));
            }
        });
    }


    //提交按钮
    $('.submit').click(function () {
        /*获取疾病分类*/
        var ill_id=$('.inquiry_value').data('data-id');
        if(!ill_id){
            weui.toast('疾病分类不能为空!')
            return;
        }
        /*获取问诊专家*/
        var expert_id=$('.expert_value').data('data-id');
        if(!expert_id){
            weui.toast('问诊专家不能为空!')
            return;
        }
        /*获取病人主诉*/

        var display1=$('.voice_btn').css('display');
        //console.log(display1);
        if (display1=='none'){
            var tell='';
            /*判断发送类型*/
            var tell_type='1';
            $('#voice_module .voice_third').each(function () {
                /*拼接信息*/
                var voiceId1=$(this).attr('data-serverid');
                if (voiceId1!=undefined){
                    if (tell==''){
                        tell=voiceId1;
                    }else{
                        tell+=','+voiceId1;
                    }
                }
            })
        }else{
            var tell=$('.textarea1').val();
            var tell_type='2';
            if (!tell){
                weui.toast('病人主诉不能为空!')
                return;
            }
        }

        /*获取初步诊断*/
        var display3=$('.voice_btn3').css('display');

        if (display3=='none'){
            var diagnose_type='1';
            var diagnose='';
            $('#voice_module3 .voice_third').each(function () {
                var voiceId1=$(this).attr('data-serverid');
                console.log(voiceId1);
                if (voiceId1!=undefined){
                    if (diagnose==''){
                        diagnose=voiceId1;
                    }else{
                        diagnose+=','+voiceId1;
                    }
                }
            })
        }else{
            var diagnose=$('.textarea3').val();
            var diagnose_type='2';
            if (!diagnose){
                weui.toast('初步诊断不能为空!')
                return;
            }
        }

        /*获取你的困惑*/
        var display2=$('.voice_btn2').css('display');
        //console.log(display2);
        if (display2=='none'){
            var puzzled_type='1';
            var puzzled='';
            $('#voice_module2 .voice_third').each(function () {
                var voiceId1=$(this).attr('data-serverid');
                console.log(voiceId1);
                if (voiceId1!=undefined){
                    if (puzzled==''){
                        puzzled=voiceId1;
                    }else{
                        puzzled+=','+voiceId1;
                    }
                }
            })
        }else{
            var puzzled=$('.textarea2').val();
            var puzzled_type='2';
            if (!puzzled){
                weui.toast('你的困惑不能为空!')
                return;
            }
        }

        /*提交后台*/
        $.ajax({
            url:"{:url('inqueryPost')}",
            type:'POST',
            data:{
                ill_id:ill_id,
                expert_id:expert_id,
                patient:tell,
                patient_type:tell_type,
                diagnose:diagnose,
                diagnose_type:diagnose_type,
                problem:puzzled,
                problem_type:puzzled_type,
                photos:serverIds
            },
            success:function (res) {
                weui.toast(res.msg);
                if(res.code==1){
                    setTimeout(function () {
                        window.location.href=res.url;
                    },1500);
                }
                return false;
            },
            error:function (res) {
                alert(res);
            }
        })
    })

</script>
</body>
</html>