<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>紫光云引擎</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css" />
</head>

<body>
    <!-- <section class="aui-content" id="subheader">
        <div style="background-color:#3F73AD;">
            <div class="aui-text-right aui-margin-r-10" onclick="doReadall()" style="color:white;"><b><u>全部已阅</u></b></div>
            <div style="height:2px;"></div>
        </div>
    </section> -->
    <section class="aui-content" id="subheader">
        <div class="aui-grid aui-bg-info">
            <div class="aui-text-right sub-title aui-margin-r-5" onclick="doReadall()"><b><u data-i18n="6660136"></b></u>
            </div>
        </div>
        <div class="aui-tab" id="tab">
            <div class="aui-tab-item" data-i18n="6660057"></div>
            <div class="aui-tab-item" data-i18n="6660058"></div>
        </div>
    </section>
    <section class="aui-content container aui-margin-b-10">
        <div class="aui-grid">
            <!-- 标签页一 -->
            <div class="aui-row tab-content  aui-padding-t-15 tab1" id="test">

                <div class="aui-content aui-margin-b-15">
                    <ul class="aui-list " id="reasoncon">
                        <script id="DotTemplate" type="text/x-dot-template">
                            {{~it.data:value:index}}
                            <li class="aui-list-item msgitem" data-id="{{= value.id}}">
                                <div style="width:100%;">
                                    <div class="ctime" style="color:{{ if(value.read_sign=='0'){ }}#585858{{ }else{ }}#ccc{{ } }};text-align:center;width:100%;">{{= value.yeartime}}</div>

                                    <div class="aui-list-item-inner" style="width:100%;font-size: 0.7rem;{{ if(value.read_sign=='0'){ }}font-weight:600;{{ }else{ }}color:#ccc;{{ } }}">
                                        ● {{= value.content}}
                                    </div>
                                </div>
                            </li>

                            {{~}}
                        </script>

                    </ul>
                </div>

            </div>
            <!-- 标签页二 -->
            <div class="aui-row tab-content  tab2" style="display: none;">

                <div class="aui-content aui-margin-b-15">
                    <ul class="aui-list " id="reasoncon2">
                        <script id="DotTemplate2" type="text/x-dot-template">
                            {{~it.data:value:index}}
                            <li class="aui-list-item msgitem" data-id="{{= value.id}}">
                                <div style="width:100%;">
                                    <div class="ctime" style="color:{{ if(value.read_sign=='0'){ }}#585858{{ }else{ }}#ccc{{ } }};text-align:center;width:100%;">{{= value.yeartime}}</div>

                                    <div class="aui-list-item-inner" style="width:100%;font-size: 0.7rem;{{ if(value.read_sign=='0'){ }}font-weight:600;{{ }else{ }}color:#ccc;{{ } }}">
                                        ● {{= value.content}}
                                    </div>
                                </div>
                            </li>
                            {{~}}
                        </script>

                    </ul>
                </div>

            </div>

        </div>
    </section>



</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/md5.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/swipe.js"></script>
<script type="text/javascript" src="../script/SHA1.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/remotedb.js"></script>
<script type="text/javascript" src="../script/list.js"></script>
<script type="text/javascript" src="../script/aui-tab.js"></script>
<script type="text/javascript" src="../script/aui-toast.js"></script>
<script type="text/javascript" src="../script/aui-selectbox.js"></script>
<script type="text/javascript" src="../script/aui-popup-new.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/jquery.min.js"></script>
<script type="text/javascript" src="../script/CryptoJS/core.js"></script>
<script type="text/javascript" src="../script/CryptoJS/cipher-core.js"></script>
<script type="text/javascript" src="../script/CryptoJS/mode-ecb.js"></script>
<script type="text/javascript" src="../script/CryptoJS/aes.js"></script>
<script type="text/javascript" src="../script/aui-collapse.js"></script>

<script type="text/javascript" src="../script/i18next-12.0.0.min.js"></script>
<script type="text/javascript" src="../script/i18nextLocizeBackend.min.js"></script>
<script type="text/javascript" src="../script/jquery-i18next.min.js"></script>
<script type="text/javascript" src="../script/jquery.cookie.js"></script>
<script type="text/javascript" src="../script/i18n-app.js"></script>

<script type="text/javascript">
    var host, timeTemplate, timeTemplate2, mytab;
    apiready = function() {
        fnReady();
        ajaxsetup();
        timeTemplate = doT.template($("#DotTemplate").text());
        timeTemplate2 = doT.template($("#DotTemplate2").text());
        api.parseTapmode();
        host = $api.getStorage('host');
        api.addEventListener({
            name: 'showtopframe1'
        }, function(ret, err) {
            if (ret) {
                load_i18n(function(t, i18n) {
                    lang = t;
                    i18next = i18n;
                    ajaxsetup();
                    host = $api.getStorage('host');
                    if ($api.getStorage('projectmodules').indexOf('tpm') > -1) {
                        getreasonList();
                        getreasonList2();
                    }
                    try {
                        var datartn = eval('(' + JSON.stringify(ret) + ')');
                        var rtnLst = datartn['value'];
                        var ptabindex = datartn['value']['ptabindex'];
                        if (ptabindex) {
                            mytab.setActive(ptabindex);
                            $('.tab-content').hide();
                            $('.tab' + ptabindex).show();
                        }
                    } catch (e) {

                    } finally {

                    }
                });
            }
        });
        load_i18n(function(t, i18n) {
            lang = t;
            i18next = i18n;
            if ($api.getStorage('projectmodules').indexOf('tpm') > -1) {
                getreasonList();
                getreasonList2();
            }
            mytab = new auiTab({
                element: document.getElementById("tab"),
                index: api.pageParam.ptabindex ? api.pageParam.ptabindex : 1,
            }, function(ret) {
                // console.log('ddddd ' + JSON.stringify(ret));
                if (1 == ret.index) {
                    if ($api.getStorage('projectmodules').indexOf('tpm') > -1) {
                        getreasonList();
                    }
                } else if (2 == ret.index) {
                    if ($api.getStorage('projectmodules').indexOf('tpm') > -1) {
                        getreasonList2();
                    }
                }
                $('.tab-content').hide();
                $('.tab' + ret.index).show();
            });
            $('.tab-content').hide();
            $('.tab' + (api.pageParam.ptabindex ? api.pageParam.ptabindex : 1)).show();
        });
        doRefreshEvent();
        $('.container').css('margin-top', headerHeight + subheaderHeight);
    };

    function doRefreshEvent() {
        api.setCustomRefreshHeaderInfo({
            bgColor: '#f0f0f0',
            image: {
                pull: 'widget://image/loading/pull.png',
                transform: [
                    'widget://image/loading/00.png',
                    'widget://image/loading/01.png',
                    'widget://image/loading/02.png',
                    'widget://image/loading/03.png',
                    'widget://image/loading/04.png',
                    'widget://image/loading/05.png',
                    'widget://image/loading/06.png'
                ],
                load: [
                    'widget://image/loading/00.png',
                    'widget://image/loading/01.png',
                    'widget://image/loading/02.png',
                    'widget://image/loading/03.png',
                    'widget://image/loading/04.png',
                    'widget://image/loading/05.png',
                    'widget://image/loading/06.png'
                ]
            },
            switchTime: 0.2
        }, function() {
            //下拉刷新被触发，自动进入加载状态，使用 api.refreshHeaderLoadDone() 手动结束加载中状态
            setTimeout(function() {
                api.refreshHeaderLoadDone();
                if ($api.getStorage('projectmodules').indexOf('tpm') > -1) {
                    getreasonList();
                    getreasonList2();
                }
            }, 500);
        });
    }

    // function fnRefreshHeaderLoading() {
    //     api.refreshHeaderLoading();
    // };

    // $('.tab-content').hide();
    // $('.tab1').show();



    // var host='http://61.177.28.246:8100';
    //     getHost();
    //     ajaxsetup();
    //     autologin();
    //     getreasonList();
    //     getreasonList2();

    function getreasonList() {
        $.ajax({
            url: host + "/tpm/AppMsg/MsgList",
            data: JSON.stringify({
                "type": 1
            }),
            dataType: 'json',
            　contentType: 'application/json',
            type: 'POST',
            success: function(result) {
                // customToast(lang[result.msg], 2000);
                // console.log(JSON.stringify(result));
                // var timeTemplate = doT.template($("#DotTemplate").text());
                $("#reasoncon").html(timeTemplate(result));
                listen_rowclick();
            }
        })
    }

    function getreasonList2() {
        $.ajax({
            url: host + "/tpm/AppMsg/MsgList",
            data: JSON.stringify({
                "type": 2
            }),
            dataType: 'json',
            　contentType: 'application/json',
            type: 'POST',
            success: function(result) {
                // customToast(lang[result.msg], 2000);
                // console.log(JSON.stringify(result));
                // var timeTemplate = doT.template($("#DotTemplate2").text());
                $("#reasoncon2").html(timeTemplate2(result));
                listen_rowclick();
            }
        })
    }

    function listen_rowclick() {
        $(".msgitem").click(function() {
            var _this = $(this);
            var id = _this.attr('data-id');


            $.ajax({
                url: host + "/tpm/AppMsg/ReadMsgById",
                data: JSON.stringify({
                    "msgid": parseInt(id)
                }),
                dataType: 'json',
                　　　contentType: 'application/json',
                type: 'POST',
                success: function(result) {
                    // console.log(_this.html());
                    console.log(JSON.stringify(result));
                    if (result.ret == 1) {
                        _this.css('color', '#ccc');
                        _this.find('.ctime').css('color', '#ccc');
                        api.execScript({
                            name: 'root',
                            script: 'loadunread();'
                        });
                    } else {
                        customToast(lang(result.msg), 2000);
                    }
                }
            })

        });
    }

    function doReadall() {
        if ($api.getStorage('projectmodules').indexOf('tpm') < 0) {
            return;
        }
        var msgids = [];
        var _this;
        $(".msgitem").each(function(index, item) {
            _this = $(this);
            if ('rgb(33, 33, 33)' == _this.css('color')) {
                msgids.push(parseInt(_this.attr('data-id')));
            }
        });
        if (msgids.length < 1) {
            customToast(lang('6660138'), 2000);
            return;
        }
        // console.log(JSON.stringify({
        //     "msgarr": msgids
        // }));
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: lang('6660106'),
            text: lang('6660137'),
            modal: true
        });
        $.ajax({
            url: host + "/tpm/AppMsg/ReadMsgById",
            data: JSON.stringify({
                "msgarr": msgids
            }),
            dataType: 'json',
            contentType: 'application/json',
            type: 'POST',
            success: function(result) {
                api.hideProgress();
                console.log(JSON.stringify(result));
                if (result.ret == 1) {
                    $(".msgitem").each(function(index, item) {
                        _this = $(this);
                        _this.css('color', '#ccc');
                        _this.find('.ctime').css('color', '#ccc');
                    });
                    api.execScript({
                        name: 'root',
                        script: 'loadunread();'
                    });
                } else {
                    customToast(lang(result.msg), 2000);
                }
            }
        })
    }

    function reloadMe() {
        console.log('reloadMe');
        location.reload();
        window.location.reload();
    }
</script>

</html>
