123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <%@ page contentType="text/html;charset=UTF-8" %>
- <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
- <%@ page import="java.util.*"%>
- <%@ page import="java.text.*"%>
- <%
- String datetime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); //获取系统时间
- request.setAttribute("currentTime",datetime);
- %>
- <html>
- <head>
- <title>推荐专区添加</title>
- <meta name="decorator" content="default"/>
- <script type="text/javascript">
- $(document).ready(function() {
- //$("#name").focus();
- $("#inputForm").validate({
- submitHandler: function(form){
- var isSubMitFlag = true;
- if ($("#productIds").val() == '') {
- alertx("请先选择商品");
- isSubMitFlag = false;
- return false;
- }
- var actType = $("input[name='actType']:checked").val();
- if (actType == null || actType == '') {
- alertx("请选择推荐类型");
- isSubMitFlag = false;
- return false;
- }
- if (isSubMitFlag) {
- loading('正在提交,请稍等...');
- form.submit();
- }
- },
- errorContainer: "#messageBox",
- errorPlacement: function(error, element) {
- $("#messageBox").text("输入有误,请先更正。");
- if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
- error.appendTo(element.parent().parent());
- } else {
- error.insertAfter(element);
- }
- }
- });
- });
- //选择商品
- function showSelect() {
- var productIds = $("#productIds").val();
- var url = '${ctx}/newhome/newActivity/findProductPage?productIds='+productIds;
- var title = "选择商品";
- top.$.jBox("iframe:"+url, {
- iframeScrolling: 'yes',
- width: $(top.document).width() - 400,
- height: $(top.document).height() - 160,
- persistent: true,
- title: title,
- buttons: {"确定": '1', "关闭": '-1'},
- submit: function (v, h, f) {
- //确定
- var $jboxFrame = top.$('#jbox-iframe');
- var $mainFrame = top.$('#mainFrame');
- if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
- var item = $jboxFrame[0].contentWindow.getCheckedItems(0);
- if (item.length > 0) {
- //添加数据
- $.post("${ctx}/product/activity/saveTemp", function (data) {
- if (true == data.success) {
- var productID = item;
- var actType = $("input[name='actType']:checked").val();
- var actSort = $("#actSort").val();
- window.location.href = "${ctx}/newhome/newActivity/addActivityForm?id=" + productID + "&actType=" + actType + "&actSort=" + actSort+"&productIds="+productID;
- $.jBox.tip(data.msg, 'info');
- } else {
- $.jBox.tip(data.msg, 'error');
- }
- }, "JSON");//这里返回的类型有:json,html,xml,text
- return true;
- } else {
- top.$.jBox.tip("请先勾选商品...");
- return false;
- }
- }
- return true;
- }
- });
- }
- </script>
- </head>
- <body>
- <ul class="nav nav-tabs">
- <li><a href="${ctx}/newhome/newActivity/">推荐专区</a></li>
- <li class="active"><a href="${ctx}/newhome/newActivity/addActivityForm">推荐专区添加</a></li>
- </ul><br/>
- <form:form id="inputForm" modelAttribute="product" action="${ctx}/newhome/newActivity/addActivity" method="post" class="form-horizontal">
- <form:hidden path="productIds"/>
- <form:hidden path="productID"/>
- <sys:message content="${message}"/>
- <div class="control-group">
- <label><label style="color: red">*</label>商品:</label>
- <label><a href="JavaScript:;" onclick="showSelect()">${product == null?'请先选择商品':product.productID == null or ''?'请先选择商品':'更换商品'}</a></label>
- <c:if test="${product !=null and product.productID>0}">
- <table id="contentTable" border="0" style="border:1px solid#000000;">
- <tbody id="contentTbody">
- <tr>
- <td>
- <label>商品ID:</label>
- </td>
- <td>
- <label>${product.productID}</label>
- </td>
- </tr>
- <tr>
- <td>商品名称:</td>
- <td>${product.name}</td>
- </tr>
- <tr>
- <td align="top">商品图片:</td>
- <td><img src="${product.mainImage}" width="80px" height="80px"></td>
- </tr>
- <tr>
- <td>供应商名称:</td>
- <td>${product.shopName}</td>
- </tr>
- </tbody>
- </table>
- </c:if>
- </div>
- <div class="control-group" id="promotionType">
- <label><label style="color: red">*</label>推荐类型:</label>
- <input type="radio" id="actType1" name="actType" value="1" ${product.actType == null ? "checked" : product.actType == "1"?"checked":""} />热销
- <input type="radio" id="actType2" name="actType" value="2" ${product.actType == "2" ? "checked" : ""} />上新
- <input type="radio" id="actType3" name="actType" value="4" ${product.actType == "4" ? "checked" : ""} />无
- </div>
- <div class="control-group">
- <label style="display: inline">排序:</label>
- <form:input path="actSort" id="actSort" htmlEscape="false" maxlength="11" class="input-xlarge "/>
- </div>
- <div class="form-actions">
- <input id="btnSubmit" class="btn btn-primary" type="submit" value="确 定"/>
- <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
- </div>
- </form:form>
- <script type="text/javascript">
- $(function () {
- })
- //促销方式修改
- $("input:radio[name='mode']").click(function () {
- var promotionType = $("input[name='mode']:checked").val();
- if ("1" == promotionType) {
- $("#discountContent1").attr("style","display:inline");
- $("#discountContent2").attr("style","display:none");
- $("#discountContent3").attr("style","display:none");
- }else if ("2" == promotionType) {
- $("#discountContent1").attr("style","display:none");
- $("#discountContent2").attr("style","display:inline");
- $("#discountContent3").attr("style","display:none");
- } else {
- $("#discountContent1").attr("style","display:none");
- $("#discountContent2").attr("style","display:none");
- $("#discountContent3").attr("style","display:inline");
- }
- })
- //促销时效修改
- $("input:radio[name='status']").click(function () {
- var promotionStatus = $("input[name='status']:checked").val();
- var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
- if ("1" == promotionStatus) {
- $("#begin").attr("style","display:none");
- $("#end").attr("style","display:none");
- if (null == promotiondelFlag1) {
- $("#promotionStatus").text("进行中");
- $("#promotionStatus").attr("style", "display: inline;color:green");
- }
- }else if ("2" == promotionStatus) {
- $("#begin").attr("style","");
- $("#end").attr("style","");
- if (null == promotiondelFlag1) {
- updateStatus();
- }
- }
- })
- //促销日期修改
- $("#beginTime").blur(function () {
- var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
- if (null == promotiondelFlag1) updateStatus()
- });
- $("#endTime").blur(function () {
- var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
- if (null == promotiondelFlag1) updateStatus()
- });
- //促销状态修改
- $("input:checkbox[name='delFlag1']").click(function () {
- var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
- if (promotiondelFlag1 != null) {
- $("#promotionStatus").text("已关闭");
- $("#promotionStatus").attr("style", "display: inline;color:red");
- }else {
- var promotionStatus = $("input[name='status']:checked").val();
- if ("1" == promotionStatus) {
- $("#promotionStatus").text("进行中");
- $("#promotionStatus").attr("style", "display: inline;color:green");
- } else updateStatus()
- }
- })
- function updateStatus() {
- var beginTime = $("#beginTime").val();
- var beginMs = new Date(beginTime).getTime();
- var endTime = $("#endTime").val();
- var endMs = new Date(endTime).getTime();
- var nowMs = new Date().getTime();
- if (nowMs < beginMs) {
- $("#promotionStatus").text("未开始");
- $("#promotionStatus").attr("style", "display: inline;color:purple");
- } else if (nowMs > endMs) {
- $("#promotionStatus").text("已结束");
- $("#promotionStatus").attr("style", "display: inline;color:orange");
- } else {
- $("#promotionStatus").text("进行中");
- $("#promotionStatus").attr("style", "display: inline;color:green");
- }
- }
- </script>
- </body>
- </html>
|