owner_info.php 59.1 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 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283
<?php

use yii\helpers\Url;
use app\ht\helpers\CssFiles;
use app\ht\exts\FormatTime;
use common\helpers\ImageManager;
use common\business\RepairOrderPriceRule;
use common\business\SuspendOrder;
use domain\trade\RepairOrderAgent;
use domain\trade\RepairOrderStatus;
use domain\trade\RepairOrderType;

$this->title = '订单详情';
$this->params['breadcrumbs'][] = '订单管理';
$this->params['breadcrumbs'][] = ['label' => '订单列表', 'url' => ['/trade/order/owner-index','order_status'=>$order_status]];
$this->params['breadcrumbs'][] =  $this->title;

CssFiles::register($this, 'exts/showimg/css/showimg.css');
$markTag = false;
$is_finished_tag = 0;
if (isset($is_finished)) {
    // 如果有回访记录提交,回访完成,则标记为1,未完成,则标记为2
    $is_finished_tag = ($is_finished == 1) ? 1 : 2 ;
}
?>
<style>
    .checkout_m{float: left;margin-right: 8px !important;}
    .checkLabel{margin-right:40px}
    .actionBtn{cursor: pointer }
    .jumper{margin-left:20px}

    .content-wrap .content-edit-ready{float: right;}
    .content-wrap .content-show{width: 80%;float: left!important;}
    .content-edit-ready{width: 20%;}
    .fake-textarea{
        padding: 10px 15px;
        border: 1px solid #CCCCCC;
        color: #777777;
        font-size: 14px;
        cursor: text;
        border-radius: 4px;
        text-align: left;
        width: 49%;
    }
    .content-show-textarea{width: 80%;height: 80px;}
    textarea {border-radius: 4px;}
    .ready-editor{display: none;}
    .select-div {
        display: inline-block;
        float: left;
        margin-right: 10px;
        margin-bottom:5px;
        color: #FFFFFF;
        border-radius: 5px;
        padding: 5px 10px 5px 10px;
        /*background-color: #F4F4F4*/
    }
    .select-div:hover {
        cursor: pointer;
    }
    .select-div input {
        display: none;
    }
    .select-div span {
        text-align: center;
    }
</style>
<div class="panel panel-default">
    <div id="warning"></div>
    <input type="hidden" value="<?=$order['id'] ?>" name="order_id" id="order_id" >
    <input type="hidden" value="<?=$order['uuid'] ?>" name="order_uuid" id="order_uuid" >
    <input type="hidden" value="<?=$order['engineer_id'] ?>" name="engineer_id" id="engineer_id" >
    <div class="panel-body">
        <table class="table table-bordered">
            <tr>
                <td colspan="6" class="bg-info">订单信息</td>
            </tr>
            <tr>
                <th width="110">订单号</th>
                <td width="320"><?=$order['order_no']; ?></td>
                <th width="110">订单状态</th>
                <td width="320"><?=$orderStatusList[$order['status']]; ?></td>
                <th width="110">支付单号</th>
                <td><?=$order['pay_no']; ?></td>
            </tr>
            <tr>

                <th>支付时间</th>
                <td><?php if (!empty($order['pay_at'])) {
                        echo Yii::$app->formatter->asTime($order['pay_at'],"yyyy-MM-dd HH:mm:ss");
                        ?>

                    <?php }else{ ?>
                        暂无时间
                    <?php }?>
                </td>

                <th>报修客户端</th>
                <td><?=$order['repair_client_name']; ?></td>
                <th>报修渠道</th>
                <td><?= $channels[$order['repair_channel']] ?></td>
            </tr>
            <tr>
                <th>报修设备</th>
                <td>
                    <span><?=$order['repair_device_name']; ?></span>

                </td>
                <th>报修时间</th>
                <td><?=Yii::$app->formatter->asTime($order['created_at'],"yyyy-MM-dd HH:mm:ss"); ?></td>

                <th>帐户信息</th>
                <td><?=$order['nickname']; ?>&nbsp;&nbsp;(&nbsp;帐户手机:<?=$order['phone'] ?>&nbsp;)</td>
            </tr>
            <tr>
                <th>上门地址</th>
                <td><?=$order['title'].$order['detail']?> (<?=$order['address']; ?>)&nbsp;[<?= empty($order['longitude']) ? 0 : $order['longitude']; ?>, <?= empty($order['latitude']) ? 0 : $order['latitude']; ?>]</td>


                <th>联系信息</th>
                <td><?=empty($order['contact_name'])? '未填':$order['contact_name']; ?>&nbsp;&nbsp;(&nbsp;电话:<span id = "curr_contact_phone"><?=$order['contact_phone'] ?></span>&nbsp;)<a href="javascript:void(0)" id="changePhone">修改号码</a></td>
                <th>接单工程师</th>
                <td><?=$order['engineer_name']?$order['engineer_name'].'('.$order['engineer_phone'].')':'未接单'; ?>
                <?php if($order['owner_engineer_id'] > 0 && $order['owner_engineer_id'] == $order['engineer_id']): ?> (自己接单)<?php endif;?>
                </td>

                </tr>
            <?php if($commission):?>
                <tr>
                    <th>转单人</th><td><?=$commission['engineer_name']?></td>
                    <th>转单分成</th><td><?=$commission['type_desc']?></td>
                    <th>转单备注</th><td><?=$commission['remark']?></td>
                </tr>
            <?php endif;?>
            <tr>
                <th>二次上门时间</th>
                <td >
                    <?php
                    if (empty($order['two_door_at'])){
                        ?>
                        暂无
                    <?php }else{ ?>
                        <?= Yii::$app->formatter->asTime($order['two_door_at'],"yyyy-MM-dd HH:mm:ss");?>
                        <?php
                    }?>
                </td>
                <th>通话记录</th>
                <td>
                    <?php if (RepairOrderStatus::STATUS_WAIT_PICK != $order['status']) :?>
                        <a href="<?=Url::toRoute("/trade/order-call/index?orderId=". $order['uuid'])?>">查看历史通话记录</a>
                    <?php else:?>
                        暂无
                    <?php endif;?>
                </td>

                <th>带走设备</th>
                <td >
                    <?=$order["is_take_away_label"] ? $order["is_take_away_label"] : "" ?>
                </td>
            </tr>
            <tr>
                <th>接单距离</th>
                <td colspan="3">
                    <?=$order['pick_order_address']; ?> <span class="badge" style="background-color: #17a2b8; color: #fff;"><?=$order['pick_order_distance'] . '米' ?></span>
                </td>
                <th></th>
                <td></td>
            </tr>
            <tr>
                <th>人工操作</th>
                <td colspan="5">
                    <?php if ($isSupperRole && ($order['is_system_delete'] == 0)) :?>
                        <button type="button" class="btn btn-danger" id="delete">测试订单</button>
                    <?php endif;?>
                </td>
            </tr>

            <tr>
                <th>跟单客服</th>
                <td>
                    <?= empty($order["customerName"]) ? "无" : $order["customerName"] ?>
                </td>
                <th> </th>
                <td>
                    <!-- && $order['pay_at'] >0 && $order['pay_price'] >0 不一定线上支付了才能开票 -->

                </td>
                <th></th>
                <td>
                </td>
            </tr>
            <tr>
                <th>工程师备注</th>
                <td colspan="5"><?=empty($order['engineer_remark'])?'暂无':$order['engineer_remark'] ?></td>
            </tr>
            <?php if ($agent_id >= 0) {?>
                <tr>
                    <th>客户来源</th>
                    <td colspan="5"><?= isset(RepairOrderAgent::getLabels($agent_id)["title"]) ? RepairOrderAgent::getLabels($agent_id)["title"] : "" ?></td>
                </tr>
            <?php } ?>
	    <?php if ($call_phone) {?>
                <tr>
                    <th>当前联系人电话</th>
                    <td colspan="5"><?= $call_phone ?></td>
                </tr>
            <?php } ?>
        </table>
    </div>
    <div class="panel-body">
        <table class="table table-bordered">
            <tr>
                <td colspan="4" class="bg-info">用户故障描述</td>
            </tr>
            <tr>
                <td colspan="4">
                    <?php foreach($userSelectFault as $fault): ?>
                        <span class="btn btn-danger btn-sm"><?=$fault['name']?></span>
                    <?php endforeach; ?>
                    <?php if ($order['other_fault']){ ?>
                        <span class="btn btn-danger btn-sm"><?=$order['other_fault']?></span>
                    <?php }?>
                </td>
            </tr>
            <tr class="text-center">
                <?php if (sizeof($imgList) > 0){ ?>
                    <?php foreach($imgList as $img): ?>
                        <td width="25%"><img src="<?=ImageManager::getUrl($img['img_path']) ?>" height="200px" name="show_img" /></td>
                    <?php endforeach; ?>
                    <?php
                    $tmpSize = 4 - sizeof($imgList);
                    for($i=0;$i<$tmpSize;$i++){
                        echo "<td width=\"25%\"></td>";
                    }
                    ?>
                <?php } ?>
                <div id="img_alert" style="z-index: 999;">
                    <div class="img_content">
                        <span class="closed">x</span>
                        <img src="" />
                    </div>
                </div>
            </tr>
        </table>
    </div>

    <div class="panel-body">
        <table class="table table-bordered text-center">
            <tr>
                <td colspan="5" class="bg-info text-left">维修故障明细及报价 &nbsp;&nbsp;<a type="button" class="btn btn-success" href="<?=Url::toRoute("/trade/repair-plans-logs/owner-index?order_id=".$order['id'])?>">报价记录</a></td>
            </tr>
            <tr>
                <th class="text-center" width="25%">设备故障</th>
                <th class="text-center" width="25%">维修方案</th>
                <th class="text-center" width="20%">价格</th>
                <th class="text-center" width="5%">数量</th>
                <th class="text-center" width="20%">维修价格</th>
            </tr>
            <?php
            if ($repairOrderPlansList){
                foreach($repairOrderPlansList as $plan): ?>
                    <tr>
                        <td class="text-left"><?=$plan['fault'] ?></td>
                        <td class="text-left" data-repair-plan-id="<?=$plan['rpid'] ?>"><?=$plan['plan_name'] ?></td>
                        <td class="text-left"><?=$plan['price'] ?></td>
                        <td><?=$plan['quantity']?></td>
                        <td><?=$plan['price']  ?></td>
                    </tr>
                <?php endforeach;
            }else{
                ?>
                <tr><td colspan="5" >暂无报价</td></tr>
                <?php
            }
            ?>
            <tr>
                <td class="text-left">维修总金额</td>
                <td class="text-left" colspan="4">
                    <?php if ($repairOrderPlansList || $order['status'] == RepairOrderStatus::STATUS_WAIT_PAY || $has_pay){?>
                        <span class="text-danger"><?=$order['repair_price'] ?></span>(维修费)+ <span class="text-danger"><?=$order['door_fee'] ?></span>(上门费)= <span class="text-danger"><?=RepairOrderPriceRule::orderTotalPrice($order, true)?></span>

                        <?php if($order['cost_price'] > 0){?><span style="margin-left:3rem;">成本价格:<?=$order['cost_price'] ?></span><?php }?>
                    <?php } else{?>
                        <span class="text-danger">无</span>
                    <?php } ?>
                </td>
            </tr>

            <tr>
                <td class="text-left">实付金额</td>
                <td class="text-left" colspan="4">
                    <?php if ($order['status'] == RepairOrderStatus::STATUS_WAIT_PAY){?>
                        <span class="text-danger">等待支付</span>
                    <?php } else{?>
                        <?php if ($has_pay){?>
                            <span class="text-danger"><?=$order['pay_price'] ?></span>
                        <?php } else{?>
                            <span class="text-danger">无</span>
                        <?php } ?>
                    <?php } ?>
                </td>
            </tr>

            <tr>
                <td class="text-left">工程师收入</td>
                <td class="text-left" colspan="4">
                    <?php if ($has_pay):?>
                        <?php if(RepairOrderType::TYPE_FORWARD_TO_PLATFORM == $order['type'] || RepairOrderType::TYPE_FORWARD_TO_FRIEND == $order['type']){ ?>
                            <span>接单工程师:<?=$order['engineer_income']?> </span><span style="margin-left:3rem"> 转单工程师:<?=$order['forward_income']?></span>
                        <?php } else {?>
                            接单工程师:<?=$order['engineer_income']?>
                        <?php }?>
                    <?php else:?>
                        暂无
                    <?php endif;?>
                </td>
            </tr>


        </table>
    </div>

    <div class="panel-body">
        <table class="table table-bordered text-center">
            <?php if ($order_rate){?>
                <tr>
                    <td colspan="5" class="bg-info text-left">用户评价</td>
                </tr>
                <tr>
                    <th class="text-center" width="10%">综合评分</th>
                    <th class="text-center" width="10%">速度评分</th>
                    <th class="text-center" width="10%">态度评分</th>
                    <th class="text-center" width="10%">技能评分</th>
                    <th class="text-center" width="60%">评价内容</th>
                </tr>
                <tr>
                    <td><?=$order_rate->final_star ?></td>
                    <td> <?=$order_rate->user_speed_star ?></td>
                    <td><?=$order_rate->user_attitude_star ?> </td>
                    <td><?=$order_rate->user_skill_star ?></td>
                    <td><?=empty($order_rate->user_comment)?"暂无评论内容":$order_rate->user_comment ?></td>
                </tr>
            <?php } else{?>
                <tr><td colspan="5" >暂无评价</td></tr>
            <?php } ?>
        </table>
    </div>

    <?php if ($rate_tags){ ?>
    <div class="panel-body">
        <table class="table table-bordered text-center">
            <tr>
                <td colspan="5" class="bg-info text-left">评价标签</td>
            </tr>
            <tr>
                <?php
                if ($rate_tags){ ?>
                    <td style="text-align: left;"> <?php foreach($rate_tags as $k=>$v){ ?> <span class="btn btn-info"> <?=$v["name"] ?></span> <?php } ?></td>
                    <?php
                } else {
                    ?>
                    <td>暂无评价标签</td>
                    <?php
                }
                ?>
            </tr>
        </table>
    </div>
    <?php } ?>

    <?php if ($order['cancel_reason']){?>
    <div class="panel-body">
        <table class="table table-bordered text-center">
            <tr>
                <td colspan="5" class="bg-info text-left">用户取消理由</td>
            </tr>
            <tr>
                <td style="text-align: left;">  <span class="btn btn-danger"> <?= $order['cancel_reason'] ?></span>  </td>
            </tr>
        </table>
    </div>
    <?php } ?>
    <?php if ($questionList) { ?>
        <div class="panel-body">
            <table class="table table-bordered text-center">
                <tr>
                    <td colspan="2" class="bg-info text-left">客户回访</td>
                </tr>
                <?php foreach ($questionList as $question) {?>
                <tr>
                    <td style="text-align: right;width: 180px;"><?=$question['title'] ?> :</td>
                    <?php if (1 == $question['type']) {?>
                        <td class="text-left" name="options-td" question_id = "<?=$question['id'] ?>" question_type="1" question_title="<?=$question['title'] ?>">
                        <?php foreach ($question['options'] as $option) { ?>
                            <?php if (isset($interview_result) && $interview_result && $is_finished_tag == 1) {
                                foreach ($interview_result as $result) {
                                    if (isset($result['type']) && $result['type']==1) {
                                        if (isset($result[$question['title']]) && $result[$question['title']] == $option['content']) {
                                            echo $option['content'];
                                        }
                                    }
                                }
                            } else { ?>
                            <div class="select-div radio-div label-default">
                                <input type="radio" class="radio_option" name="radio_option_<?=$question['id'] ?>" data-id = "<?=$question['id'] ?>"
                                    <?php if (isset($interview_result) && $interview_result) {
                                        foreach ($interview_result as $result) {
                                            if (isset($result['type']) && $result['type']==1) {
                                                if (isset($result[$question['title']]) && $result[$question['title']] == $option['content']) {
                                                    echo "checked=\"checked\"";
                                                }
                                                if (isset($result[$question['title']])) {
                                                    if ($result[$question['title']]) {
                                                        // echo "disabled=\"disabled\"";
                                                    }
                                                }
                                            }
                                        }
                                    } else {
                                        if ($question['title'] == "客户来源") {
                                            if ($order["original_device_type"] == 1 && $option['content'] == "扫码") {
                                                echo "checked=\"checked\"";
                                            }
                                        }
                                    }?> value="<?=$option['content'] ?>" /><span><?=$option['content'] ?></span>
                            </div>
                            <?php } ?>
                        <?php } ?>
                        </td>
                    <?php } elseif (2 == $question['type']) { ?>
                        <td class="text-left" name="options-td" question_id = "<?=$question['id'] ?>" question_type="2"  question_title="<?=$question['title'] ?>">
                        <?php foreach ($question['options'] as $option) { ?>
                            <?php if (isset($interview_result) && $interview_result && $is_finished_tag == 1) {
                                foreach ($interview_result as $result) {
                                    if (isset($result['type']) && $result['type']==2){
                                        if (isset($result[$question['title']])) {
                                            foreach (explode(",",$result[$question['title']]) as $k=>$opch){
                                                if (!empty($opch) && $opch == $option['content']){
                                                    echo $option['content'];
                                                }
                                            }
                                        }
                                    }
                                }
                            } else { ?>
                                <div class="select-div label-primary">
                                <input type="checkbox" class="checkbox_option" name="checkbox_option_<?=$question['id'] ?>"
                                       <?php if (isset($interview_result) && $interview_result) {
                                           foreach ($interview_result as $result) {
                                               if (isset($result['type']) && $result['type']==2){
                                                   if (isset($result[$question['title']])) {
                                                       foreach (explode(",",$result[$question['title']]) as $k=>$opch){
                                                           if (!empty($opch) && $opch == $option['content']){
                                                               echo "checked=\"checked\"";
                                                           }
                                                           if (isset($opch)) {
                                                               if ($opch) {
                                                                   // echo "disabled=\"disabled\"";
                                                               }
                                                           }
                                                       }
                                                   }
                                               }
                                           }
                                       }?> data-id = "<?=$question['id'] ?>" value="<?=$option['content'] ?>" /><span><?=$option['content'] ?></span>
                                </div>
                            <?php } ?>
                        <?php } ?>
                        </td>
                    <?php } elseif (3 == $question['type']) { ?>
                        <td class="text-left" name="options-td" question_id = "<?=$question['id'] ?>" question_type="3"  question_title="<?=$question['title'] ?>">
                            <?php if (isset($interview_result) && $interview_result && $is_finished_tag == 1) {
                                foreach ($interview_result as $result) {
                                    if (isset($result['type']) && $result['type']===3){
                                        if (isset($result[$question['title']])) {
                                            echo $result[$question['title']];
                                        }
                                    }
                                }
                            } else { ?>
                                <textarea class="form-control textarea_option" name="textarea_option_<?=$question['id'] ?>" data-id = "<?=$question['id'] ?>" rows="4" style="width: 60%;resize:vertical;" placeholder="请输入<?=$question['title'] ?>" ><?php if (isset($interview_result) && $interview_result) {
                                        foreach ($interview_result as $result) {
                                            if (isset($result['type']) && $result['type']===3){
                                                if (isset($result[$question['title']])) {
                                                    echo $result[$question['title']];
                                                }
                                            }
                                        }
                                    }?></textarea>
                            <?php } ?>
                        </td>
                    <?php } else { ?>
                        <td class="text-left"  name="options-td" question_id = "<?=$question['id'] ?>"  question_type="0" question_title="<?=$question['title'] ?>">
                            <?php if (isset($interview_result) && $interview_result && $is_finished_tag == 1) {
                                foreach ($interview_result as $result) {
                                    if (isset($result['type']) && $result['type']===0){
                                        if (isset($result[$question['title']])) {
                                            echo $result[$question['title']];
                                        }
                                    }
                                }
                            } else { ?>
                                <input type="text" class="form-control input_option" name="input_option_<?=$question['id'] ?>" value="<?php if (isset($interview_result) && $interview_result) {
                                    foreach ($interview_result as $result) {
                                        if (isset($result['type']) && $result['type']===0){
                                            if (isset($result[$question['title']])) {
                                                echo $result[$question['title']];
                                                $markTag = true;
                                            }
                                        }
                                    }
                                }?>" data-id = "<?=$question['id'] ?>" style="width: 60%"  placeholder="请输入<?=$question['title'] ?>" />
                            <?php } ?>
                        </td>
                    <?php } ?>
                </tr>
                <?php } ?>
                <tr>
                    <td style="text-align: right;">回访是否完成:</td>
                    <td class="text-left">
                        <?php if ((isset($is_finished) && $is_finished == 1)) {
                            echo "是";
                        } else { ?>
                        <div class="select-div radio-div label-default">
                            <input type="radio" value="1" id="rdfinished" class="rdfinished" name="rdfinished"/>是
                        </div>
                        <div class="select-div radio-div label-default">
                            <input type="radio" value="0" id="rdfinished" class="rdfinished" <?php if ($is_finished_tag == 2) echo "checked"; ?> name="rdfinished"/>否
                        </div>
                        <?php } ?>
                    </td>
                </tr>

                <?php if (isset($interview_result) && $interview_result && $is_finished_tag == 1) { ?>

                <?php } else { ?>
                    <tr class="text-center">
                        <td colspan="2">
                            <button type="button" class="btn btn-primary" id="btn_save_interview"><?php if ($is_finished_tag == 2) echo "保存"; else echo "提交"; ?></button>
                        </td>
                    </tr>
                <?php } ?>
            </table>
        </div>
    <?php } ?>

    <?php if ($is_finished_tag > 0): ?>
    <!-- 评论功能 -->
    <div class="panel-body form-inline">
        <form>
            <table class="table table-bordered text-center table-comment">
                <tr class="comment-row">
                    <td colspan="2" class="bg-info text-left">回访评论</td>
                </tr>

                <?php if (isset($interview_comment)): ?>
                    <?php foreach ($interview_comment as $key => $commentItem): ?>
                        <tr class="comment-row comment-row-<?=$commentItem['id'] ?>">
                            <td style="text-align: right;width: 230px;">
                                <span style="font-weight: bold;"><?=$commentItem['username'] ?></span>
                                <?php
                                    $format = new FormatTime();
                                    if (time() - $commentItem['updated_at'] < 86400) {
                                        $commentItem['updated_at'] = $format->formatTime($commentItem['updated_at']);
                                    } else {
                                        $commentItem['updated_at'] = Yii::$app->formatter->asTime($commentItem['updated_at'], "yyyy-MM-dd HH:mm:ss");
                                    }
                                    echo '<span class="edit-to">';
                                    if ($commentItem['is_modified'] == 1) {
                                        echo "编辑于: ";
                                    }
                                    echo '</span>';
                                    echo $commentItem['updated_at'];
                                ?>
                            </td>
                            <td class="text-left">
                                <div class="content-wrap">
                                    <?php if ($commentItem['user_id'] == $user_id): ?>
                                        <div class="content-edit-ready">
                                            <a class="edit-comment btn btn-primary" data-id="<?=$commentItem['id'] ?>" href="javascript:void(0)">编辑</a>
                                            <a class="delete-comment btn btn-danger" data-id="<?=$commentItem['id'] ?>" href="javascript:void(0)">删除</a>
                                        </div>
                                    <?php endif; ?>
                                    <div class="content-show">
                                        <div class="edit-text">
                                            <span><?=$commentItem['content'] ?></span>
                                        </div>
                                        <div class="ready-editor">
                                            <div class="ready-editor-wrap"><textarea id="content-show-textarea-<?=$commentItem['id'] ?>" class="content-show-textarea" name="comment"><?=$commentItem['content'] ?></textarea></div>
                                            <div class="edit-old-comment" style="margin-top: 5px;">
                                                <button type="button" data-id="<?=$commentItem['id'] ?>" class="btn btn-primary btn_save_interview_old_comment btn_save_interview_old_comment_<?=$commentItem['id'] ?>">保存</button>
                                                <button type="button" data-id="<?=$commentItem['id'] ?>" class="btn btn-primary btn_cancel_interview_old_comment btn_cancel_interview_old_comment_<?=$commentItem['id'] ?>">取消</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                <?php endif; ?>

                <tr class="text-center">
                    <td colspan="2">
                        <div class="fake-textarea" data-droppable="" style="display: none;">点击发表评论</div>
                    </td>
                </tr>
                <tr class="text-center comment-submit-wrap">
                    <td colspan="2">
                        <textarea id="txt-new-comment" tabindex="1" class="comment-content" placeholder=" 填写评论内容" name="comment_content" style="display: block;width: 100%;height: 100px;margin-bottom: 3px;"></textarea>
                        <div style="margin-top: 5px;">
                            <button type="button" class="btn btn-primary" id="btn_save_interview_comment">发表评论</button>
                            <button type="button" class="btn btn-primary" id="btn_cancel_interview_comment">取消</button>
                        </div>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <?php endif; ?>

    <div class="panel-body form-inline">
        <table class="table" style="border-top:none;">
            <tr>
                <td class="col-sm-6" style="vertical-align: top">
                    <table class="table table-bordered">
                        <tr>
                            <td class="bg-info">后台备注</td>
                        </tr>
                        <tr>
                            <td width="100%"><textarea class="form-control" style="width:100%;" rows="3" id="remark" name="remark"></textarea></td>
                        </tr>
                        <tr class="text-center">
                            <td>
                                <button type="button" class="btn btn-primary ladda-button" data-style="slide-up" id="save">提交备注</button>
                            </td>
                        </tr>
                    </table>
                </td>
                <td class="col-sm-6" style="vertical-align: top">
                    <table class="table table-bordered">
                        <tr>
                            <td colspan="3" class="bg-info">操作日志</td>
                        </tr>
                        <tr>
                            <th width="112" >操作时间</th>
                            <th width="130" >操作人员</th>
                            <th >操作内容</th>
                        </tr>
                        <?php  foreach($logList as $log): ?>
                            <tr>
                                <td><?=Yii::$app->formatter->asTime($log['log_at'],"yyyy-MM-dd HH:mm:ss"); ?></td>
                                <td><?=$log['operator_user'] ?></td>
                                <td><?=$log['content'] ?></td>
                            </tr>
                        <?php endforeach; ?>

                    </table>
                </td>
            </tr>
        </table>
    </div>

</div>
<div class="modal fade" id="phoneModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">修改联系电话</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <input type="text" class="form-control" id="changePhoneNumber" placeholder="例如 1380038000">
                    </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="phoneSubmitBtn">提交</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<script type="text/javascript" src="<?=Url::toRoute('/exts/showimg/js/showimg.js')?>" ></script>
<script src="<?=Yii::$app->request->baseUrl?>/exts/base/1.0.0/ui/kindeditor/kindeditor-all-min.js"></script>
<link rel="stylesheet" href="<?=Yii::$app->request->baseUrl?>/exts//base/1.0.0/ui/kindeditor/themes/simple/simple.css" />

<script type="text/javascript">
    var editor;
    KindEditor.lang({
        gallery : '图片管理'
    });
    KindEditor.ready(function(K) {
        return;
        /*
        editor = K.create('#txt-new-comment', {
            themeType : 'simple',
            minWidth : '432px',
            filterMode: false, // 允许输入任何代码(不做过滤)
            items : [
                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',  'gallery', '|',
                'table', 'hr', 'pagebreak',
                'anchor', 'link', 'unlink'
            ],
            uploadJson : '',
            formatUploadUrl: false,
            bodyClass: 'create-comment-editor',
            baseUrl: ''
        });
        */
    });
</script>

<script type="text/javascript">
    var kinditerArry = new Array();
    function createMoreEditor(id) {
        if (kinditerArry.hasOwnProperty(id)) {
            kinditerArry[id].remove();
        }

        kinditerArry[id] = KindEditor.create('#content-show-textarea-' + id, {
            allowFileManager : true,
            themeType : 'simple',
            minWidth : '432px',
            filterMode: false, // 允许输入任何代码(不做过滤)
            items : [
                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',  'gallery', '|',
                'table', 'hr', 'pagebreak',
                'anchor', 'link', 'unlink'
            ],
            uploadJson : '<?= Url::toRoute(['/site/editor-upload']) ?>',
            formatUploadUrl: false,
            baseUrl: '<?= Yii::$app->request->baseUrl ?>'
        });
    }
</script>

<script>
    var closeOrderUrl ='<?=Url::toRoute("/trade/order/close-order")?>';
    $(document).ready(function () {

        $("#save").bind("click", function () {
            var id = $("#order_id").val();
            var remark = $("#remark").val();
            if (remark == null || remark == ""){
                alert("请填写备注内容");
                return false;
            }
            if (id == null || id == ""){
                alert("丢失标记信息,无法提交备注");
                return false;
            }
            var l = $.ladda(this);
            $.ajax({
                type: "post",
                url: "do-update-remark",
                dataType:"json",
                data: $.csrf({"id":id,"remark":remark}),
                success:function(msg){
                    alert(msg['msg']);
                    if (msg['status'] == 1){
                        location.reload();
                    }else{
                    }
                },
                beforeSend: function () {
                    // 开始显示
                    l.start();
                },
                complete: function () {
                    // 取消加载提示
                    l.stop();
                },
                error:function(msg){
                }
            });
        });



        // 系统删除订单
        $("#delete").bind("click", function () {
            var id = $("#order_id").val();
            if (id == null || id == ""){
                alert("订单ID丢失");
                return false;
            }

            if (!confirm('确定删除该订单')) {
                return false;
            }

            $.ajax({
                type: "post",
                url: "<?=Url::toRoute("/trade/order/system-delete-order")?>",
                dataType:"json",
                data: $.csrf({"id" : id}),
                success:function(msg){
                    if (msg['success']){
                        alert('删除订单成功');
                        //location.href = "<?=Url::toRoute("/trade/order/index")?>";
                        location.reload();
                    }else{
                        alert(msg['msg']);
                        location.reload();
                    }
                },
                error:function(msg){
                }
            });
        });
        // 系统还原订单
        $("#restore").bind("click", function () {
            var id = $("#order_id").val();
            if (id == null || id == ""){
                alert("订单ID丢失");
                return false;
            }
            $.ajax({
                type: "post",
                url: "<?=Url::toRoute("/trade/order/system-restore-order")?>",
                dataType:"json",
                data: $.csrf({"id" : id}),
                success:function(msg){
                    if (msg['success']){
                        alert('还原订单成功');
                        //location.href = "<?=Url::toRoute("/trade/order/index")?>";
                        location.reload();
                    }else{
                        alert(msg['msg']);
                        location.reload();
                    }
                },
                error:function(msg){
                }
            });
        });

        //删除评论
        $(".table-comment").on("click", ".delete-comment", function () {
            var msg = "您真的确定要删除吗?\n\n请确认!";
            if (confirm(msg) == false){
                return false;
            }
            //评论ID
            var id = $(this).attr('data-id');
            if (id == null || id == ""){
                alert("评论ID丢失");
                return false;
            }

            $.ajax({
                type: "post",
                url: "<?=Url::toRoute("/trade/order/ajax-comment-delete")?>",
                dataType:"json",
                data: $.csrf({"id" : id}),
                success:function(msg){
                    if (msg['success']){
                        console.log(msg);
                        $(".comment-row-" + id).remove();
                    }else{
                        alert(msg['error']);
                    }
                },
                error:function(msg){
                }
            });
        });
        //编辑评论,打开编辑器
        $(".table-comment").on("click", ".edit-comment", function () {
            //评论ID
            var id = $(this).attr('data-id');
            if (id == null || id == ""){
                alert("评论ID丢失");
                return false;
            }
            $(".comment-row-" + id + " .ready-editor").show();
            $(".comment-row-" + id + " .edit-text").hide();
            //createMoreEditor(id);
        });

        //编辑评论,取消编辑器修改
        $(".table-comment").on("click", ".btn_cancel_interview_old_comment", function () {
            //评论ID
            var id = $(this).attr('data-id');
            if (id == null || id == ""){
                alert("评论ID丢失");
                return false;
            }
            $(".comment-row-" + id + " .ready-editor").hide();
            $(".comment-row-" + id + " .edit-text").show();
        });

        //点击虚拟输入框显示editor
        $(".fake-textarea").bind("click", function () {
            $(".comment-submit-wrap").show();
            $(this).hide();
        });
        //点击取消隐藏editor
        $("#btn_cancel_interview_comment").bind("click", function () {
            hideEditor();
        });
        //隐藏editor
        function hideEditor() {
            $(".comment-submit-wrap").hide();
            $(".fake-textarea").show();
        }
        //编辑评论-执行提交
        $(".table-comment").on("click", ".btn_save_interview_old_comment", function () {
            //评论ID
            var comment_id = $(this).attr('data-id');
            var id = $("#order_id").val();
            if (comment_id == null || comment_id == ""){
                alert("评论ID丢失");
                return false;
            }

            /*
            // 取得HTML内容
            kinditerArry[comment_id].html();
            // 同步数据后可以直接取得textarea的value
            kinditerArry[comment_id].sync();
            */

            var comment_content = $("#content-show-textarea-" + comment_id).val()
            if (comment_content == null || comment_content == ""){
                alert("评论不能为空");
                return false;
            }
            $.ajax({
                type: "post",
                url: "<?=Url::toRoute("/trade/order/ajax-comment")?>",
                dataType:"json",
                data: $.csrf({"comment_id" : comment_id, "content" : comment_content, "id" : id}),
                success:function(msg){
                    if (msg['success']){
                        console.log(msg);

                        $(".comment-row-" + comment_id + " .edit-text span").html(msg.content);
                        $("#content-show-textarea-" + comment_id).val(msg.content);
                        //kinditerArry[comment_id].remove();

                        //显示内容,隐藏文本域
                        $(".comment-row-" + comment_id + " .ready-editor").hide();
                        $(".comment-row-" + comment_id + " .edit-text").show();
                        $(".comment-row-" + comment_id + " .edit-to").html(" 编辑于: ");

                        //清空编辑器内容
                    }else{
                        alert(msg['error']);
                        //location.reload();
                    }
                },
                error:function(msg){
                }
            });
        });

        //发表评论
        $("#btn_save_interview_comment").bind("click", function () {
            /*
            // 取得HTML内容
            html = editor.html();
            // 同步数据后可以直接取得textarea的value
            editor.sync();
            */

            var id = $("#order_id").val();
            var comment_content = $("#txt-new-comment").val();
            if (id == null || id == ""){
                alert("订单ID丢失");
                return false;
            }

            if (comment_content == null || comment_content == ""){
                alert("评论不能为空");
                return false;
            }

            $(this).attr("disabled", true);
            setTimeout(function(){ $("#btn_save_interview_comment").attr("disabled", false); }, 5000);
            $.ajax({
                type: "post",
                url: "<?=Url::toRoute("/trade/order/ajax-comment")?>",
                dataType:"json",
                data: $.csrf({"id" : id, "content" : comment_content}),
                success:function(msg){
                    if (msg['success']){
                        var html = '<tr class="comment-row comment-row-' + msg.interview_comment.id + '">';
                        html += '<td style="text-align: right;width: 230px;"><span style="font-weight: bold;">' + msg.interview_comment.username + '</span> <span class="edit-to"></span>' + msg.interview_comment.updated_at + '</td>';
                        html += '<td class="text-left"><div class="content-wrap"><div class="content-edit-ready"><a style="margin-right: 4px;"  class="edit-comment btn btn-primary" data-id="' + msg.interview_comment.id + '" href="javascript:void(0)">编辑</a>';
                        html += '<a class="delete-comment btn btn-danger" data-id="' + msg.interview_comment.id + '" href="javascript:void(0)">删除</a></div>';

                        html += '<div class="content-show"><div class="edit-text"><span>' + msg.interview_comment.content + '</span></div>';
                        html += '<div class="ready-editor">';
                        html += '<div><textarea id="content-show-textarea-' + msg.interview_comment.id + '" class="content-show-textarea" name="comment">' + msg.interview_comment.content + '</textarea></div>';
                        html += '<div class="edit-old-comment" style="margin-top: 5px;">';
                        html += '<button type="button" data-id="' + msg.interview_comment.id + '" class="btn btn-primary btn_save_interview_old_comment" style="margin-right: 4px;">保存</button>';
                        html += '<button type="button" data-id="' + msg.interview_comment.id + '" class="btn btn-primary btn_cancel_interview_old_comment">取消</button>';
                        html += '</div></div></div></div></td></tr>';

                        $(".comment-row:last").after(html);
                        //清空编辑器内容
                        $("#txt-new-comment").val("");

                        /*
                        KindEditor.html("#txt-new-comment","");
                        hideEditor();
                        */
                    }else{
                        alert(msg['error']);
                        //location.reload();
                    }
                    $("#btn_save_interview_comment").attr("disabled", false);
                },
                error:function(msg){
                    $("#btn_save_interview_comment").attr("disabled", false);
                }
            });
        });
        //提交问卷
        $("#btn_save_interview").bind("click", function () {
            var id = $("#order_id").val();
            var questionAnswers = "{\"answers\":[";
            try{
                $("td[name='options-td']").each(function(){
                    var questionId = $(this).attr("question_id"); //问题编号
                    var questionType = $(this).attr("question_type"); //问题类型
                    var questionTitle = $(this).attr("question_title"); //问题
                    questionAnswers += "{\""+questionTitle+"\":";
                    if (1 == questionType) {
                        var selectRadioValues = "";
                        var filterStr= "input[name='radio_option_"+questionId+"']";
                        $(filterStr).each(function(){
                            if ($(this).is(':checked')) {
                                selectRadioValues = $(this).val();
                            }
                        });
                        /*if (selectRadioValues == "") {
                            throw("请选择"+questionTitle);
                            return;
                        }*/
                        questionAnswers = questionAnswers + "\""+selectRadioValues+"\"";
                    } else if (2 == questionType) {
                        var selectCheckValues = "";
                        var filterStr= "input[name='checkbox_option_"+questionId+"']";
                        $(filterStr).each(function(){
                            if ($(this).is(':checked')) {
                                selectCheckValues += $(this).val() + ",";
                            }
                        });
                        /*if (selectCheckValues == "") {
                            throw("请选择"+questionTitle);
                            return;
                        }*/
                        questionAnswers = questionAnswers + "\""+selectCheckValues+"\"";
                    }  else if (3 == questionType) {
                        var inputValues = "";
                        var filterStr= "textarea[name='textarea_option_"+questionId+"']";
                        $(filterStr).each(function(){
                            if ($(this).val() != "") {
                                if (questionId == 8){
                                    var myDate = new Date();
                                    var year = myDate.getFullYear();    //获取完整的年份(4位,1970-????)
                                    var month = myDate.getMonth() + 1;       //获取当前月份(0-11,0代表1月)
                                    var date = myDate.getDate();        //获取当前日(1-31)
                                    var Hour = myDate.getHours();
                                    var Minutes = myDate.getMinutes();
                                    var Seconds = myDate.getSeconds();
                                    if (Minutes < 10){
                                        Minutes ="0" + Minutes
                                    }
                                    if (Seconds < 10){
                                        Seconds ="0" + Seconds
                                    }
                                    inputValues += $(this).val().replace(/\n/g,"\\n") + ' ' + year + '-' + month + '-' + date + ' ' + Hour + ':' + Minutes + ':' + Seconds + '\\r\\n';
                                }else{
                                    inputValues += $(this).val().replace(/\n/g,"\\n");
                                }

                            }
                        });
                        /*if (selectRadioValues == "") {
                            throw("请填写"+questionTitle);
                            return;
                        }*/
                        questionAnswers = questionAnswers + "\""+inputValues+"\"";
                    } else {
                        var selectRadioValues = "";
                        var filterStr= "input[name='input_option_"+questionId+"']";
                        $(filterStr).each(function(){
                            if ($(this).val() != "") {
                                selectRadioValues += $(this).val();
                            }
                        });
                        /*if (selectRadioValues == "") {
                            throw("请填写"+questionTitle);
                            return;
                        }*/
                        questionAnswers = questionAnswers + "\""+selectRadioValues+"\"";
                    }
                    questionAnswers = questionAnswers +",\"type\" : " +questionType;
                    questionAnswers += "},";
                });
                if (questionAnswers.indexOf(",") > 0) {
                    questionAnswers=questionAnswers.substring(0,questionAnswers.length-1); //去除最后一个字符
                }
            }catch(e){
                alert(e);
                return; //在这里return
            }
            questionAnswers = questionAnswers + "]}";
            if (id == null || id == "options-td"){
                alert("订单ID丢失");
                return false;
            }

            var rdFinished = $('input[name="rdfinished"]:checked').val();

            $.ajax({
                type: "post",
                url: "<?=Url::toRoute("/trade/order/submit-interview")?>",
                dataType:"json",
                data: $.csrf({"orderId" : id,"answers" : questionAnswers,"isFinished":rdFinished}),
                success:function(msg){
                    alert(msg['msg']);
                    location.reload();
                },
                error:function(msg){
                }
            });
        });


        //显示警告信息
        function alertWaringMsg(showmsg){
            var htmltext = "<div class='alert alert-warning' style='margin-bottom:0;display:block'>" +
                "        <a href='#' class='close' data-dismiss='alert'>" +
                "            &times;" +
                "        </a>" +
                " <strong>提示!</strong>"+showmsg+"。" +
                "    </div>";
            $("#warning").html(htmltext);
        }

        function isMobile(phone) {
            var  mobileRegx = "^1(3|5|6|8|4|7|9)[0-9]{9}$";
            return new RegExp(mobileRegx).test(phone);
        }
        // 弹出修改联系电话
        $('#changePhone').click(function(e){
            $('#phoneModal').modal('show');
        })

        $('#phoneSubmitBtn').click(function(e){
            var selfDom = $(this)
            var phone = $('#changePhoneNumber').val();
            if (!isMobile(phone)) {
                alert('请录入合格手机号码');
            } else {
                var uuid = $('#order_uuid').val();
                selfDom.attr('disabled', true);
                $.ajax({
                    type: "post",
                    url: "<?=Url::toRoute("/trade/order/change-contact-phone")?>",
                    dataType:"json",
                    data: $.csrf({orderId : uuid, phone: phone}),
                    success:function(res){
                        selfDom.removeAttr('disabled');
                        if (res.success) {
                            alert(res.msg);
                            $('#curr_contact_phone').html(phone);
                            $('#phoneModal').modal('hide');
                        } else {
                            alert(res.msg);
                        }
                    },
                    error:function(msg){
                    }
                });
            }
        })

        /**
         * 此方法暂时不用
         * 回访备注,当内容为空时并on focus时,自动在最前面加 年月日
         */
        $(document).on('focus',"[data-id=8]",function () {
            var return_notes = $("[data-id=8]");
            var myDate = new Date();
            var year = myDate.getFullYear();    //获取完整的年份(4位,1970-????)
            var month = myDate.getMonth() + 1;       //获取当前月份(0-11,0代表1月)
            var date = myDate.getDate();        //获取当前日(1-31)
            if (return_notes.val() == null || return_notes.val() == '') {
                //$(this).val(year + '/' + month + '/' + date + ' ');
            }
        })

        $(".select-div").each(function(){
            var isChecked = $(this).find("input").prop('checked');
            if (isChecked) {
                $(this).removeClass('label-default').addClass('label-primary')
            } else {
                $(this).removeClass('label-primary').addClass('label-default')
            }
        });

        /**
         * 模擬radio,checkbox选中
         */
        $(document).on('click', '.select-div', function () {
            var isChecked = $(this).find("input").prop('checked');
            if (isChecked) {
                $(this).find("input").prop("checked", false);
                $(this).removeClass('label-primary').addClass('label-default')
            } else {
                $(this).find("input").prop("checked", true);
                if ($(this).hasClass('radio-div')) {
                    $(this).parent('td').find(".select-div").removeClass('label-primary').addClass('label-default')
                }
                $(this).removeClass('label-default').addClass('label-primary')
            }
        })

    }); // end document ready

    // 页面太长了,这里另起一个 $(function(){ })
    var reBindPhoneURL = "<?=Url::toRoute("/trade/order/bind-user-consult")?>";
    var engineerConsultURL = "<?=Url::toRoute("/trade/order/bind-engineer-consult")?>";
    var setOrderInvalidURL = "<?=Url::toRoute("/trade/order/set-order-invalid")?>";
    var checkDoorFeeURL = "<?=Url::toRoute("/trade/order/check-door-fee")?>";
    $(function(){
        var orderId = $("#order_id").val();
        $('.bandUserConsultByHand').click(function(e){
            console.log('bandUserConsultByHand click');

            if (confirm('重新绑定之后在2小时内可继续通话')) {
                $.post(reBindPhoneURL, {orderId: orderId},function(res){
                    alert(res.error);
                },'json')
            }
        })

        $('.bandEngineerConsultByHand').click(function(e){
            console.log('bandEngineerConsultByHand click');

            if (confirm('重新绑定之后工程师在1小时内可继续通话')) {
                $.post(engineerConsultURL, {orderId: orderId},function(res){
                    alert(res.error);
                },'json')
            }
        })

        $('#setOrderInvalid').click(function(e){
            var that = $(this);
            if (!confirm('是否确认并关闭该恶意订单')) {
                return false;
            }
            $.post(setOrderInvalidURL, {orderId:orderId ,remark: '恶意下单'}, function(res){
                if (res.success) {
                    that.remove();
                } else {
                    alert(res.message);
                }
            }, 'json')
        })


    })
</script>