<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>服务评价</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/commentstyle.css" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/mobile.css" />
    <script type="text/javascript" src="${ctxPlugin}/static/js/jquery-3.3.1.min.js"></script>
</head>

<body>
<%--<div class="returntop">
    <a href="">
        <i class="fa fa-angle-left leftarrow2"></i>
        <span class="servicetit">服务评价</span>
    </a>
</div>--%>
<div style="height:20px;"></div>
<div class="suggcontent">
    <%--<div id="starRating">
        <p class="photo">
            <span><i class="high"></i><i class="nohigh"></i></span>
            <span><i class="high"></i><i class="nohigh"></i></span>
            <span><i class="high"></i><i class="nohigh"></i></span>
            <span><i class="high"></i><i class="nohigh"></i></span>
            <span><i class="high"></i><i class="nohigh"></i></span>
        </p>
    </div>--%>
    <ul class="fuwpj">
        <li>
            <span><input type="hidden" value="1">1、是否及时上门服务</span>
            <i></i>
        </li>
        <li>
            <span><input type="hidden" value="2">2、出示上岗证，穿工作服，戴安全帽</span>
            <i></i>
        </li>
        <li>
            <span><input type="hidden" value="3">3、服务完成清洁现场</span>
            <i></i>
        </li>
        <li>
            <span><input type="hidden" value="4">4、服务完成指导用户运维电站</span>
            <i></i>
        </li>
        <li>
            <span><input type="hidden" value="5">5、服务人员服务态度满意</span>
            <i></i>
        </li>
        <li>
            <span><input type="hidden" value="6">6、服务是否专业</span>
            <i></i>
        </li>
    </ul>
    <div class="shoufei">
        <div>
            <label>是否收费：</label>
            <input type="radio" name="sex"  value="2"  checked="checked"/>否&nbsp;&nbsp;
            <input type="radio" name="sex"  value="1" />是
        </div>
        <div class="jineiner">
            <input type="text" class="jinetext" id="money" disabled>
            <span>元</span>
        </div>
    </div>
</div>
<div style="height:65px;"></div>
<input type="hidden" id="count">
<div class="pingbotton">
    <button class="pingbtn" onclick="commit()">提交评价</button>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script type="text/javascript">
    var orderId = '${orderId}';
    var userId = '${userId}';

    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form'], function(){
        //layui.use(['table','layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        table = tableExt.getLayTable();

    })
    $(".fuwpj li i").click(function(){
        $(this).toggleClass("active")
    })


    $(function () {
       /* //评分
        var starRating = 0;
        $('.photo span').on('mouseenter',function () {
            var index = $(this).index()+1;
            $(this).prevAll().find('.high').css('z-index',1)
            $(this).find('.high').css('z-index',1)
            $(this).nextAll().find('.high').css('z-index',0)
            $('.starNum').html((index*2).toFixed(1)+'分')
        })
        $('.photo').on('mouseleave',function () {
            $(this).find('.high').css('z-index',0)
            var count = starRating / 2
            if(count == 5) {
                $('.photo span').find('.high').css('z-index',1);
            } else {
                $('.photo span').eq(count).prevAll().find('.high').css('z-index',1);
            }
            $('.starNum').html(starRating.toFixed(1)+'分');
        })
        $('.photo span').on('click',function () {
            var index = $(this).index()+1;
            $(this).prevAll().find('.high').css('z-index',1)
            $(this).find('.high').css('z-index',1)
            starRating = index*2;
            $('.starNum').html(starRating.toFixed(1)+'分');
            $("#count").val(index);

        })*/
    })

    window.addEventListener('pagehide', function(e) {
        var $body = $(document.body);
        $body.children().remove();
        // 要等到回调函数完成，用户按返回才执行script标签的代码
        setTimeout(function() {
            $body.append("<script type='text/javascript'>window.location.reload();<\/script>");
        });
    });

    var phoneWidth = parseInt(window.screen.width);
    var phoneScale = phoneWidth / 750;
    var ua = navigator.userAgent;
    if(/Android (\d+\.\d+)/.test(ua)) {
        var version = parseFloat(RegExp.$1);
        if(version > 2.3) {
            document.write('<meta name="viewport" content="width=750, minimum-scale =' + phoneScale + ', maximum-scale =' + phoneScale + ', target-densitydpi=device-dpi">');
        } else {
            document.write('<meta name="viewport" content="width=750, target-densitydpi=device-dpi">');
        }
    } else {
        document.write('<meta name="viewport" content="width=750, user-scalable=no, target-densitydpi=device-dpi">');
    }

    var ifcharge;
    $("input[name=sex]").click(function(){
         ifcharge = $("input[type=radio]:checked").val();
        if (ifcharge == "2") {
            $("#money").attr("disabled", true);
        } else {
            $("#money").removeAttr("disabled");
        }
    });

    function commit() {
        ifcharge = $("input[type=radio]:checked").val();
        var superviseId = "";
        var money = $("#money").val();
        var comment = $(".active");
        comment.each(function () {
            var a = $(this).parent().find("input").val();
            if (superviseId == "") {
                superviseId = a;
            } else {
                superviseId = superviseId + "," + a;
            }
        });
        $.ajax({
            type:"POST",
            url:"${ctx}/comment/saveComment",
            data:{
                orderId:orderId,
                userId:userId,
                superviseId:superviseId,
                money:money,
                ifcharge: ifcharge
            },
            success:function(result){
                if(result.code ==200){
                    parent.layer.msg('<span style="font-size: 30px;">评价成功</span>', {icon:1,time:1000},function(){
                        parent.location.reload(); //刷新父页面
                        location.href='${ctx}/comment/commentToDetatil?orderId='+orderId;
                    });
                }else if(result.code == "505"){
                    layer.msg('<span style="font-size: 30px;">评价失败,已评价!</span>', {icon:2,time:1000},function(){
                    });
                }else{
                    layer.msg('<span style="font-size: 30px;">评价失败,数据有误!</span>', {icon:2,time:1000});
                }
            }
        });

    }





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