<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>投诉</title>
    <meta name="viewport" content="width=750,user-scalable=no,target-densitydpi=device-dpi">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="<?php echo RESOURCE_SITE_URL; ?>/mobile/ugc/css/complaint.css?<?php echo bonus_version(); ?>">
</head>
<body data-special_id="<?php echo $output['special_id'];?>">
    <div class="maincontent">
        <p class="prompt">请选择投诉原因</p>
        <div class="grup">
            <div class="cell" data-option="欺诈">欺诈</div>
            <div class="cell" data-option="色情">色情</div>
            <div class="cell" data-option="诱导行为">诱导行为</div>
            <div class="cell" data-option="不实信息">不实信息</div>
            <div class="cell" data-option="违法犯罪">违法犯罪</div>
            <div class="cell" data-option="骚扰">骚扰</div>
            <div class="cell" data-option="违规声明原创">违规声明原创</div>
            <div class="cell" data-option="未经授权的文章内容">未经授权的文章内容</div>
            <div class="cell" data-option="其他">其他</div>
        </div>
        <p class="prompt">个人/企业等民事主体被诽谤侮辱、人身权或知识产权等被侵犯请选择"侵犯"投诉。</p>
        <div class="grup">
            <div class="cell" data-option="侵犯">侵犯（冒充他人、侵犯名誉等）</div>
        </div>
        <div class="submit_btn">确定</div>
        <div class="shade">
            <div class="loading"></div>
        </div>
    </div>
    <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/bonus/js/zepto.min.js?<?php echo bonus_version(); ?>"></script>
    <script type="text/javascript" src="<?php echo RESOURCE_SITE_URL; ?>/mobile/comm/layer.js?<?php echo bonus_version(); ?>"></script>
    <script type="text/javascript">
        $(function(){

            var host = (function () {
                return window.location.protocol + "//" + window.location.host;
            })();

            var specialId = (function(){
                return special_id = $('body').attr('data-special_id');
            })();

            var Complaint = function(){
                var complaint_list = [];
                this.set_option = function(cell){
                    complaint_list.push(cell);
                };
                this.remove_option = function(cell){
                    for(var i=0; i<complaint_list.length; i++) {
                        if(complaint_list[i] == cell) {
                            complaint_list.splice(i, 1);
                            break;
                        }
                    }
                };
                this.get_options = function(){
                    return complaint_list.join(',');
                };
            };

            var complaint = new Complaint();

           $('.cell').on('touchstart',function(){
               var option = $(this).attr('data-option');
               if($(this).hasClass('active')) {
                   $(this).removeClass('active');
                   complaint.remove_option(option);
               }
               else{
                   $(this).addClass('active');
                   complaint.set_option(option);
               }
           });
           $('.submit_btn').on('touchstart',function ()
           {
               $('.shade').show();
               var options = complaint.get_options();
               if(options.length <= 0)
               {
                   $('.shade').hide();
                   alert('请选择您的投诉原因');
                   return;
               }
               var url = host + '/mobile/index.php?act=member_ugc&op=report&client_type=ajax&special_id=' + specialId + '&content=' + encodeURI(complaint.get_options());
               $.ajax({
                   type: "get",
                   async: false,
                   url: url,
                   dataType: "jsonp",
                   jsonp: "callback",
                   jsonpCallback: "flightHandler",
                   success: function(data){
                       $('.shade').hide();
                       if (data.code !== 200) {
                           alert(data.message);
                       }
                       else {
                           alert('投诉成功!');
                           window.history.go(-1);
                       }
                   }
               });
           });
        });
    </script>
</body>
</html>