Write.cshtml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. 
  2. @{
  3. ViewBag.Title = "盐中校友会——留言";
  4. var nickName = string.IsNullOrEmpty(ViewBag.NickName) ? "" : ViewBag.NickName;
  5. var avatar = string.IsNullOrEmpty(ViewBag.Avatar) ? "" : ViewBag.Avatar;
  6. var gender = string.IsNullOrEmpty(ViewBag.Gender) ? "" : ViewBag.Gender;
  7. var openId = string.IsNullOrEmpty(ViewBag.OpenId) ? "" : ViewBag.OpenId;
  8. }
  9. <!DOCTYPE html>
  10. <html>
  11. <head>
  12. <meta charset="utf-8">
  13. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  14. <meta name="renderer" content="webkit">
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  16. <meta http-equiv="Cache-Control" content="no-siteapp" />
  17. <title>@ViewBag.Title</title>
  18. <meta name="keywords" content="盐城中学,盐中校友会,校友会,盐中">
  19. <meta name="description" content="">
  20. <link href="~/Content/css/bootstrap.min.css" rel="stylesheet" />
  21. <link href="~/Content/css/font-awesome.min.css" rel="stylesheet" />
  22. <link href="~/Content/css/animate.min.css" rel="stylesheet" />
  23. <link href="~/Content/css/style.min.css" rel="stylesheet" />
  24. <link href="~/Content/css/plugins/toastr/toastr.min.css" rel="stylesheet" />
  25. <script src="~/Content/js/jquery.min.js"></script>
  26. <script src="~/Content/js/bootstrap.min.js"></script>
  27. <script src="~/Content/js/plugins/toastr/toastr.min.js"></script>
  28. <script src="~/Content/js/content.min.js"></script>
  29. <script src="~/Content/js/plugins/validate/jquery.validate.min.js"></script>
  30. <script src="~/Content/js/plugins/validate/messages_zh.min.js"></script>
  31. <script src="~/Content/js/jquery.unobtrusive-ajax.min.js"></script>
  32. <script>
  33. //if (window.top !== window.self) { window.top.location = window.location };
  34. </script>
  35. <link href="~/Content/css/YZXYH.css" rel="stylesheet" />
  36. <style>
  37. .toast-center-center {
  38. top: 50%;
  39. left: 50%;
  40. margin-top: -30px;
  41. margin-left: -150px;
  42. }
  43. .count-info label {
  44. display: none;
  45. }
  46. body {
  47. background: linear-gradient(180deg, #3bb3c3, #3bb3c3);
  48. min-height: 100vh;
  49. overflow: hidden;
  50. padding-top: 15px;
  51. margin: 0 auto;
  52. width: 100vw;
  53. }
  54. form {
  55. margin-top: 5vh;
  56. }
  57. form .form-group {
  58. margin-bottom: 10px;
  59. }
  60. form label {
  61. color: #fff;
  62. }
  63. form .form-control {
  64. border-radius: 4px;
  65. }
  66. form textarea.form-control {
  67. min-height: 100px;
  68. height: 20vh;
  69. }
  70. form .checkbox, form .radio {
  71. position: relative;
  72. display: block;
  73. margin-top: 0px;
  74. margin-bottom: 10px;
  75. }
  76. #Save {
  77. background-color: #02569c;
  78. border-color: #02569c;
  79. color: #eee;
  80. transition: all .5s linear;
  81. }
  82. #Save.help {
  83. background-color: #ed5565;
  84. border-color: #ed5565;
  85. font-weight: 600;
  86. }
  87. #Save:hover {
  88. color: #fff;
  89. }
  90. .help-link {
  91. text-align: center;
  92. color: #ddd;
  93. margin-top: 5px;
  94. }
  95. .help-link a {
  96. padding: 10px 15px 5px;
  97. color: inherit;
  98. display: inline-block;
  99. }
  100. .help-link a:hover {
  101. color: #fff;
  102. }
  103. </style>
  104. </head>
  105. <body>
  106. <section class="hidden">
  107. <input id="hid_MemberPage" type="hidden" value="2" autocomplete="off" />
  108. </section>
  109. <div id="Home" style="">
  110. <div class="container">
  111. <form id="form" enctype="multipart/form-data">
  112. <h3 style="text-align: center; color: #fff;">愿望墙留言</h3>
  113. <div class="form-group">
  114. <label for="msgContent">想说的话</label>
  115. <textarea class="form-control required" id="msgContent" placeholder="请输入您想说的话..." autocomplete="off"></textarea>
  116. </div>
  117. <div class="checkbox ">
  118. @*<label>
  119. <input type="checkbox" id="isHide" style="margin-top: 0px;" autocomplete="off"> 匿名留言
  120. </label>*@
  121. <label style=" margin-left: 20px; color: #fff; font-weight: 600;">
  122. <input type="checkbox" id="isHelp" style="margin-top: 0px" autocomplete="off"> 我要求助
  123. </label>
  124. </div>
  125. <div class="form-group mobile" style="display: none">
  126. <label for="mobile">手机号码</label>
  127. <input type="text" class="form-control" placeholder="请留下联系方式" id="mobile" name="mobile" autocomplete="off" value="@(ViewBag.Mobile)">
  128. </div>
  129. <div class="form-group ">
  130. <label for="mobile">上传图片</label>
  131. <input type="file" class="form-control" placeholder="上传图片" id="image" name="image" autocomplete="off" value=" " accept="image/*" />
  132. </div>
  133. <div class="form-group nickName">
  134. <label for="nickName">留言昵称</label>
  135. <input type="text" class="form-control" placeholder="留言昵称" id="nickName" nickName="nickName" value="@(nickName)" autocomplete="off">
  136. </div>
  137. <button id="Save" type="button" class="btn " style="width: 100%">发布留言</button>
  138. </form>
  139. <div class="help-link">
  140. <a href="@Url.Action("Reply","MessageWall")">求助信息</a>
  141. |
  142. <a href="@Url.Action("ReplyDetail","MessageWall")">我的求助</a>
  143. </div>
  144. </div>
  145. </div>
  146. <script src="~/Content/js/content.min.js"></script>
  147. <script>
  148. var nickName = "@(nickName)",msgType=0;
  149. $(function() {
  150. $('#isHide').on("change",function() {
  151. if ($(this).is(':checked')) {
  152. $('#nickName').val(nickName);
  153. $('.nickName').hide();
  154. } else {
  155. $('.nickName').show();
  156. }
  157. });
  158. $('#isHelp').on("change",function() {
  159. if ($(this).is(':checked')) {
  160. $('#Save').text("发布求助信息").addClass('help');
  161. $('#mobile').addClass('required');
  162. $('.mobile').show();
  163. msgType = 1;
  164. } else {
  165. $('#Save').text("留言").removeClass('help');
  166. $('#mobile').removeClass('required');
  167. $('.mobile').hide();
  168. msgType = 0;
  169. }
  170. });
  171. $('#Save').on('click', WriteMsg);
  172. $('#form .form-control').keypress(function(e) {
  173. if (e.keyCode === 13) {
  174. WriteMsg();
  175. }
  176. });
  177. });
  178. var toastrOptions={
  179. "closeButton": true,
  180. "progressBar": true,
  181. "positionClass": "toast-center-center",
  182. "showDuration": "400",
  183. "hideDuration": "1000",
  184. "timeOut": "5000",
  185. "extendedTimeOut": "1000",
  186. "showEasing": "swing",
  187. "hideEasing": "linear",
  188. "showMethod": "fadeIn",
  189. "hideMethod": "fadeOut"
  190. }
  191. function WriteMsg() {
  192. $('#Save').prop("disabled", true);
  193. var formData= new FormData();
  194. formData.append('MsgContent' , $('#msgContent').val());
  195. formData.append('Mobile' , $('#mobile').val());
  196. formData.append('NickName' , $('#nickName').val());
  197. formData.append('OpenId' , '@(openId)');
  198. formData.append('Avatar' , '@(avatar)');
  199. formData.append('Gender' , '@(gender)');
  200. formData.append('Image',$('#image')[0].files[0]);
  201. formData.append('MsgType' , msgType);
  202. $.ajax({
  203. url: "@Url.Action("WriteMsg", "MessageWall")",
  204. type: "post",
  205. processData: false,
  206. contentType: false,
  207. beforeSend: function () {
  208. var form = $("#form");
  209. form.validate({
  210. errorPlacement: function (error, element) {
  211. element.parent().after(error);
  212. }
  213. });
  214. return form.valid();
  215. },
  216. data:formData,
  217. success: function (msg) {
  218. window.toastr.options = toastrOptions;
  219. if (msg && msg.Success) {
  220. $("#form")[0].reset();
  221. window.toastr["success"]("留言成功");
  222. } else {
  223. if (msg.Msg) {
  224. window.toastr["error"]("留言失败:" + msg.Msg);
  225. } else {
  226. window.toastr["error"]("留言失败");
  227. }
  228. }
  229. },
  230. error: function (xmlHttpRequest, errMsg) {
  231. window.toastr["error"]("留言失败");
  232. }
  233. });
  234. var delay = 10;
  235. var timer = setInterval(function df() {
  236. delay--;
  237. $('#Save').html("等待 " +delay+ "s")
  238. if (delay == 0) {
  239. $('#Save').html("发布留言")
  240. $('#Save').prop("disabled", false);
  241. clearInterval(timer);
  242. }
  243. }, 1000)
  244. }
  245. </script>
  246. </body>
  247. </html>