addActivityForm.jsp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <%@ page contentType="text/html;charset=UTF-8" %>
  2. <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
  3. <%@ page import="java.util.*"%>
  4. <%@ page import="java.text.*"%>
  5. <%
  6. String datetime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); //获取系统时间
  7. request.setAttribute("currentTime",datetime);
  8. %>
  9. <html>
  10. <head>
  11. <title>推荐专区添加</title>
  12. <meta name="decorator" content="default"/>
  13. <script type="text/javascript">
  14. $(document).ready(function() {
  15. //$("#name").focus();
  16. $("#inputForm").validate({
  17. submitHandler: function(form){
  18. var isSubMitFlag = true;
  19. if ($("#productIds").val() == '') {
  20. alertx("请先选择商品");
  21. isSubMitFlag = false;
  22. return false;
  23. }
  24. var actType = $("input[name='actType']:checked").val();
  25. if (actType == null || actType == '') {
  26. alertx("请选择推荐类型");
  27. isSubMitFlag = false;
  28. return false;
  29. }
  30. if (isSubMitFlag) {
  31. loading('正在提交,请稍等...');
  32. form.submit();
  33. }
  34. },
  35. errorContainer: "#messageBox",
  36. errorPlacement: function(error, element) {
  37. $("#messageBox").text("输入有误,请先更正。");
  38. if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
  39. error.appendTo(element.parent().parent());
  40. } else {
  41. error.insertAfter(element);
  42. }
  43. }
  44. });
  45. });
  46. //选择商品
  47. function showSelect() {
  48. var productIds = $("#productIds").val();
  49. var url = '${ctx}/newhome/newActivity/findProductPage?productIds='+productIds;
  50. var title = "选择商品";
  51. top.$.jBox("iframe:"+url, {
  52. iframeScrolling: 'yes',
  53. width: $(top.document).width() - 400,
  54. height: $(top.document).height() - 160,
  55. persistent: true,
  56. title: title,
  57. buttons: {"确定": '1', "关闭": '-1'},
  58. submit: function (v, h, f) {
  59. //确定
  60. var $jboxFrame = top.$('#jbox-iframe');
  61. var $mainFrame = top.$('#mainFrame');
  62. if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
  63. var item = $jboxFrame[0].contentWindow.getCheckedItems(0);
  64. if (item.length > 0) {
  65. //添加数据
  66. $.post("${ctx}/product/activity/saveTemp", function (data) {
  67. if (true == data.success) {
  68. var productID = item;
  69. var actType = $("input[name='actType']:checked").val();
  70. var actSort = $("#actSort").val();
  71. window.location.href = "${ctx}/newhome/newActivity/addActivityForm?id=" + productID + "&actType=" + actType + "&actSort=" + actSort+"&productIds="+productID;
  72. $.jBox.tip(data.msg, 'info');
  73. } else {
  74. $.jBox.tip(data.msg, 'error');
  75. }
  76. }, "JSON");//这里返回的类型有:json,html,xml,text
  77. return true;
  78. } else {
  79. top.$.jBox.tip("请先勾选商品...");
  80. return false;
  81. }
  82. }
  83. return true;
  84. }
  85. });
  86. }
  87. </script>
  88. </head>
  89. <body>
  90. <ul class="nav nav-tabs">
  91. <li><a href="${ctx}/newhome/newActivity/">推荐专区</a></li>
  92. <li class="active"><a href="${ctx}/newhome/newActivity/addActivityForm">推荐专区添加</a></li>
  93. </ul><br/>
  94. <form:form id="inputForm" modelAttribute="product" action="${ctx}/newhome/newActivity/addActivity" method="post" class="form-horizontal">
  95. <form:hidden path="productIds"/>
  96. <form:hidden path="productID"/>
  97. <sys:message content="${message}"/>
  98. <div class="control-group">
  99. <label><label style="color: red">*</label>商品:</label>
  100. <label><a href="JavaScript:;" onclick="showSelect()">${product == null?'请先选择商品':product.productID == null or ''?'请先选择商品':'更换商品'}</a></label>
  101. <c:if test="${product !=null and product.productID>0}">
  102. <table id="contentTable" border="0" style="border:1px solid#000000;">
  103. <tbody id="contentTbody">
  104. <tr>
  105. <td>
  106. <label>商品ID:</label>
  107. </td>
  108. <td>
  109. <label>${product.productID}</label>
  110. </td>
  111. </tr>
  112. <tr>
  113. <td>商品名称:</td>
  114. <td>${product.name}</td>
  115. </tr>
  116. <tr>
  117. <td align="top">商品图片:</td>
  118. <td><img src="${product.mainImage}" width="80px" height="80px"></td>
  119. </tr>
  120. <tr>
  121. <td>供应商名称:</td>
  122. <td>${product.shopName}</td>
  123. </tr>
  124. </tbody>
  125. </table>
  126. </c:if>
  127. </div>
  128. <div class="control-group" id="promotionType">
  129. <label><label style="color: red">*</label>推荐类型:</label>
  130. <input type="radio" id="actType1" name="actType" value="1" ${product.actType == null ? "checked" : product.actType == "1"?"checked":""} />热销
  131. <input type="radio" id="actType2" name="actType" value="2" ${product.actType == "2" ? "checked" : ""} />上新
  132. <input type="radio" id="actType3" name="actType" value="4" ${product.actType == "4" ? "checked" : ""} />无
  133. </div>
  134. <div class="control-group">
  135. <label style="display: inline">排序:</label>
  136. <form:input path="actSort" id="actSort" htmlEscape="false" maxlength="11" class="input-xlarge "/>
  137. </div>
  138. <div class="form-actions">
  139. <input id="btnSubmit" class="btn btn-primary" type="submit" value="确 定"/>
  140. <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
  141. </div>
  142. </form:form>
  143. <script type="text/javascript">
  144. $(function () {
  145. })
  146. //促销方式修改
  147. $("input:radio[name='mode']").click(function () {
  148. var promotionType = $("input[name='mode']:checked").val();
  149. if ("1" == promotionType) {
  150. $("#discountContent1").attr("style","display:inline");
  151. $("#discountContent2").attr("style","display:none");
  152. $("#discountContent3").attr("style","display:none");
  153. }else if ("2" == promotionType) {
  154. $("#discountContent1").attr("style","display:none");
  155. $("#discountContent2").attr("style","display:inline");
  156. $("#discountContent3").attr("style","display:none");
  157. } else {
  158. $("#discountContent1").attr("style","display:none");
  159. $("#discountContent2").attr("style","display:none");
  160. $("#discountContent3").attr("style","display:inline");
  161. }
  162. })
  163. //促销时效修改
  164. $("input:radio[name='status']").click(function () {
  165. var promotionStatus = $("input[name='status']:checked").val();
  166. var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
  167. if ("1" == promotionStatus) {
  168. $("#begin").attr("style","display:none");
  169. $("#end").attr("style","display:none");
  170. if (null == promotiondelFlag1) {
  171. $("#promotionStatus").text("进行中");
  172. $("#promotionStatus").attr("style", "display: inline;color:green");
  173. }
  174. }else if ("2" == promotionStatus) {
  175. $("#begin").attr("style","");
  176. $("#end").attr("style","");
  177. if (null == promotiondelFlag1) {
  178. updateStatus();
  179. }
  180. }
  181. })
  182. //促销日期修改
  183. $("#beginTime").blur(function () {
  184. var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
  185. if (null == promotiondelFlag1) updateStatus()
  186. });
  187. $("#endTime").blur(function () {
  188. var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
  189. if (null == promotiondelFlag1) updateStatus()
  190. });
  191. //促销状态修改
  192. $("input:checkbox[name='delFlag1']").click(function () {
  193. var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
  194. if (promotiondelFlag1 != null) {
  195. $("#promotionStatus").text("已关闭");
  196. $("#promotionStatus").attr("style", "display: inline;color:red");
  197. }else {
  198. var promotionStatus = $("input[name='status']:checked").val();
  199. if ("1" == promotionStatus) {
  200. $("#promotionStatus").text("进行中");
  201. $("#promotionStatus").attr("style", "display: inline;color:green");
  202. } else updateStatus()
  203. }
  204. })
  205. function updateStatus() {
  206. var beginTime = $("#beginTime").val();
  207. var beginMs = new Date(beginTime).getTime();
  208. var endTime = $("#endTime").val();
  209. var endMs = new Date(endTime).getTime();
  210. var nowMs = new Date().getTime();
  211. if (nowMs < beginMs) {
  212. $("#promotionStatus").text("未开始");
  213. $("#promotionStatus").attr("style", "display: inline;color:purple");
  214. } else if (nowMs > endMs) {
  215. $("#promotionStatus").text("已结束");
  216. $("#promotionStatus").attr("style", "display: inline;color:orange");
  217. } else {
  218. $("#promotionStatus").text("进行中");
  219. $("#promotionStatus").attr("style", "display: inline;color:green");
  220. }
  221. }
  222. </script>
  223. </body>
  224. </html>