IT-KIMI_SHI\SINOIT.KIMI
2018-06-01 64c40fb427bff513f575f11e4c1e7bd9a1bfe3e3
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
<!DOCTYPE html>
<html>
<head>
<title>新增话题</title>
<meta charset="utf-8" />
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="viewport"content="user-scalable=no, initial-scale=1, width=device-width, height=device-height" />
 
<link rel="stylesheet" href="../../css/aui.css" />
 
<script src="../../js/jquery-1.7.2.min.js"></script>
<script src="../../js/foundation-2.0.js"></script>
<script src="../../js/toast.js"></script>
 
<style type="text/css">
        
</style>
    
 
<script type="text/javascript"> 
    var headertitle, headerroot, titleroot, contentroot, content, platfromtitle;
    var user, type, id, toast;
    
    function initele() {
        user =  getLocalData("user");
        headertitle = $("#headertitle");
        headerroot = $("#headerroot");
        contentroot = $("#contentroot");
        titleroot = $("#titleroot");
        content = $("#content");
        
        if(platfromtitle) {
            titleroot.val(platfromtitle);
            titleroot.attr("readonly",true);
        }
    }
    
    function initTitle() {
        if(type == "comment") {
            contentroot.show();
            headerroot.text("添加评论");
            headertitle.text("添加评论");
        }
    }
    
    function getVal() {
        var topic = {
                createduserid: user.id,
                title: titleroot.val(),
                typecode: "common"
            };
        if(type == "comment") {
            topic.content = content.val();
            topic.platformid = id;
        }
        
        return     topic;
    }
    
    function checkVal(topic) {
        if(type == "comment" && topic.content == "") {
            return false;
        }
        
        if(topic.title != "" && topic.createduserid != "") {
            return true;
        }
        alert("必填数据未填写完整");
        return false;
    }
    
    function commit() {
        var topic = getVal();        
        var success = checkVal(topic);
        var url = "root/data/platform";
        if(success) {
            if(id) {
                url = "root/data/comment";
            }
            
            Server.saveData(url, topic, function(result){
                if(result){
                    showDefault('success');
                    history.go(-1);
                }else{
                    showDefault('fail');
                }
            });
        }        
    }
 
    $(document).ready(function() {
        var params = getURLParams(window.location.href);
        type = params.type;
        id = params.id;
        platfromtitle = params.title;
        
        initele();
        initTitle();
    });
     
</script> 
</head>
 
<body>
    <header class="aui-bar aui-bar-nav">
        <a class="aui-pull-left aui-btn" onclick="history.go(-1);">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div id="headerroot" class="aui-title">添加话题</div>
    </header>
        <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-form-list">
            <li id="headertitle" class="aui-list-header">添加话题</li>
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" >
                            标题:
                    </div>
                    <div class="aui-list-item-input">
                        <input id="titleroot" type="text" placeholder="请输入标题(必填)">
                    </div>
                </div>
            </li>
            
            <li id="contentroot" class="aui-list-item" style="display: none;">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label">
                            内容:    
                    </div>
                    <div class="aui-list-item-input">
                        <textarea id="content" placeholder="请输入内容(选填)"></textarea>
                    </div>
                </div>
            </li>
            <li id="btn" class="aui-list-item">
                <div class="aui-list-item-inner aui-list-item-center aui-list-item-btn">
                    <div class="aui-btn aui-btn-info aui-margin-r-5" onclick="commit()">提交</div>
                    <div class="aui-btn aui-btn-danger aui-margin-l-5" onclick="history.go(-1);">取消</div>
                </div>
            </li>
        </ul>
    </div>
</body>
</html>