version.jsp 6.63 KB
<!DOCTYPE html>
<%@page import="com.weaver.formmodel.mobile.publisher.PublishManager"%>
<%@ page contentType="text/html; charset=UTF-8" isELIgnored="true"%>
<%@ include file="/mobilemode/admin/init.jsp"%>
<%
int appid = Util.getIntValue(request.getParameter("appid"));
if(appid == -1){
	out.println("未指定应用id");
	return;
}
boolean isPublish = (PublishManager.getInstance().isPublish(appid) == 1);
%>
<html>
<head>
<link type="text/css" rel="stylesheet" href="/mobilemode/admin/src/common/css/common.css">
<link type="text/css" rel="stylesheet" href="/mobilemode/admin/dep/layer/skin/default/layer.css"><%--IE9 iframe中require依赖css有问题会导致JS代码不执行 --%>
<style type="text/css">
.span-control{
	width: 48px;
}
.lang8 .span-control{
	width:120px;
}
.btn-container {
    overflow: hidden;
    margin-top: 8px;
}
.publish-btn, .unpublish-btn{
	float: right;
    font-size: 12px;
    padding: 7px 14px;
}
.unpublish-btn{
	margin-right: 10px;
	border-color: #bd2726;
    color: #bd2726;
}
.timeline {
    position: relative;
    margin-top: 12px;
    height: 450px;
    padding-top: 12px;
}
.timeline-item {
    position: relative;
    padding: 0 0 12px;
    list-style: none;
    margin: 0;
    line-height: 3;
}
.timeline-item:last-child{
	padding-bottom: 0px;
}
.timeline-item-tail {
    position: absolute;
    left: 5px;
    top: 0px;
    height: 100%;
    border-left: 2px solid #e9e9e9;
}
.timeline-item-head {
    position: absolute;
    width: 12px;
    height: 12px;
    background-color: #fff;
    border-radius: 100px;
    border: 2px solid #2db7f5;
    color: #2db7f5;
}
.timeline-item-content {
    padding: 0 0 10px 24px;
    font-size: 12px;
    position: relative;
    top: -3px;
}
.timeline-item-content h3 {
    color: #404040;
    font-weight: 400;
    font-size: 18px;
    line-height: 18px;
    margin-bottom: 6px;
}
.timeline-item-content .time {
    background: #f7f7f7;
    padding: 1px 6px;
    border-radius: 3px;
    color: #777;
    font-size: 11px;
    border: 1px solid #e9e9e9;
}
.timeline-item:last-child .timeline-item-content{
	padding-bottom: 0px;
}
</style>
</head>

<body class="lang<%=user.getLanguage()%>">
	<div style="padding: 0px 18px;" class="p-property">
	<div class="form-group">
		<div class="row">
			<span class="col-2 span-control"><%=SystemEnv.getHtmlLabelName(22186,user.getLanguage())%>:</span>
			<div class="col-m-8 required">
				<input type="text" id="serial" class="form-control" value="" placeholder="<%=SystemEnv.getHtmlLabelName(384929,user.getLanguage())%>" />
			</div>
		</div>
		<div class="row">
			<span class="col-2 span-control"><%=SystemEnv.getHtmlLabelName(433,user.getLanguage())%>:</span>
			<div class="col-m-8 required">
				<textarea id="descriptions" class="area-control" placeholder="<%=SystemEnv.getHtmlLabelName(384930,user.getLanguage())%>"></textarea>
			</div>
		</div>
		<div class="btn-container">
			
			<div class="btn publish-btn"><%if(isPublish){%><%=SystemEnv.getHtmlLabelName(511571,user.getLanguage())%><%}else{%><%=SystemEnv.getHtmlLabelName(511572,user.getLanguage())%><%}%></div>
			
			<div class="btn unpublish-btn" <%if(!isPublish){%> style="display:none;"<%}%>><%=SystemEnv.getHtmlLabelName(511574,user.getLanguage())%></div>
		</div>
		
		<ul class="timeline"></ul>
	</div>
	</div>
<script type="text/javascript">
var appid = "<%=appid%>";
define("app_version", ["modal", "jquery", "layer", "components/common", "juicer", "scroll"], function (modal) {
	var common = require("components/common");
	var layer = require("layer");
	var Scroll = require("scroll");

	new Scroll(".timeline");

	function checkRequired(selector, tip){
		var v = $.trim($(selector).val());
		if(v == ""){
			layer.tips(tip, selector, {
				tips: [3, '#3595CC'],
				time: 3000
			});
			$(selector)[0].focus();
			return false;
		}
		return v;
	}
	
	$(".publish-btn").on("click", function(){
		var $btn = $(this);
		if($btn.hasClass("disabled")){
			return;
		}
		var serial = checkRequired("#serial", "<%=SystemEnv.getHtmlLabelName(384960,user.getLanguage())%>");//请填写版本号
		if(serial === false){
			return;
		}
		var descriptions = checkRequired("#descriptions", "<%=SystemEnv.getHtmlLabelName(384961,user.getLanguage())%>");//请填写描述
		if(descriptions === false){
			return;
		}
		$btn.addClass("disabled");
		common.api("app", {
			action: "publishWithVersion",
			data:{
				"appid": appid,
				"serial": serial,
				"descriptions": descriptions,
			}
		}).done(function(data) {
			var modal = top.layer || layer;

			$btn.removeClass("disabled");
			if(data.api_status){
				$(".unpublish-btn").show();
				$(".publish-btn").html("<%=SystemEnv.getHtmlLabelName(511571,user.getLanguage())%>");
				$("#serial").val("");
				$("#descriptions").val("");
				modal.alert("<%=SystemEnv.getHtmlLabelName(33179,user.getLanguage())%>", function(index){//发布成功
					modal.close(index);
					top.closeTopDialog && top.closeTopDialog(true); // 发布状态
				});
				versionList.load();
			}
		});
	});
	
	$(".unpublish-btn").on("click", function(){
		var $btn = $(this);
		var modal = top.layer || layer;
		modal.confirm("<%=SystemEnv.getHtmlLabelName(384958,user.getLanguage())%>", function(index){
			modal.close(index);
			if($btn.hasClass("disabled")){
				return;
			}
			$btn.addClass("disabled");
  			common.api("app", {
				action: "publish",
				type: "get",
				data:{
					"appid": appid,
					"optType": 0
				}
			}).done(function(data) {
				$btn.removeClass("disabled");
				if(data.api_status){
					$btn.hide();
					$(".publish-btn").html("<%=SystemEnv.getHtmlLabelName(511572,user.getLanguage())%>");
					modal.alert("<%=SystemEnv.getHtmlLabelName(384959,user.getLanguage())%>", function(index){//已下架该应用
						modal.close(index);
						top.closeTopDialog && top.closeTopDialog(false); // 下架状态
					});
				}
			});
		});
	});
	
	var versionList = {
		load: function(){
			common.api("app", {
				action: "versions",
				type : "get",
				data:{
					"appid": appid
				}
			}).done(function(res) {
				var templateHtml = [
                   '{@each data as d}',
                       '<li class="timeline-item">',
							'<div class="timeline-item-tail"></div>',
							'<div class="timeline-item-head"></div>',
							'<div class="timeline-item-content">',
								'<h3>${d.serial}</h3>',
								'<p><span class="time">${d.createdate}</span></p>',
								'<div class="version-content">',
								'$${d.descriptions}',
								'</div>',
							'</div>',
						'</li>',
                   '{@/each}'    
				].join('');
				
				
            	var html = juicer(templateHtml, res);
            	$(".timeline").html(html);
			});
		}
	};
	
	versionList.load();
});
require(["app_version"]);
</script>
</body>
</html>