<!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>
|