portal html css js resource

postDemand.js 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. $(document).ready(function() {
  2. loginStatus(); //判断个人是否登录
  3. valUser();
  4. var userid = $.cookie("userid");
  5. var orgId = "";
  6. /*$("body").on("click", function(event) {
  7. var event = event ? event : window.event;
  8. var obj = event.srcElement ? event.srcElement : event.target;
  9. if($('.boxHid').css("display") === "none") {
  10. if($(obj).hasClass("howbtn")) {} else {
  11. return;
  12. }
  13. }
  14. if($(obj).hasClass("closeFeed")) {} else {
  15. if($(obj).parents(".boxHid").hasClass("boxHid")) {
  16. return;
  17. }
  18. }
  19. $('.boxHid').toggle();
  20. event.stopPropagation();
  21. })*/
  22. $(".btnModel,.closeFeed").click(function(){
  23. $('.boxHid').toggle();
  24. })
  25. var a = new Date();
  26. var c = a.getFullYear() + "-" + (Number(a.getMonth()) + 1) + "-" + (Number(a.getDate()) + 1);
  27. $('.dateBtn').datetimepicker({
  28. language: 'en',
  29. weekStart: 0,
  30. todayBtn: 1,
  31. autoclose: 1,
  32. todayHighlight: 1,
  33. startView: 2,
  34. minView: 2,
  35. forceParse: 0,
  36. startDate: c,
  37. });
  38. /*需求主题*/
  39. $("#demandTitle").bind({
  40. focus: function() {
  41. $(this).siblings().find("span").show();
  42. },
  43. blur: function() {
  44. $(this).siblings().find("span").hide();
  45. }
  46. })
  47. /*需求内容*/
  48. $("#remarkContent").bind({
  49. focus: function() {
  50. $(this).parent().siblings().find(".frmconmsg").show();
  51. },
  52. blur: function() {
  53. $(this).parent().siblings().find(".frmconmsg").hide();
  54. },
  55. input: function() {
  56. $(".msgconNum").find("em").text($(this).val().length);
  57. }
  58. })
  59. /*联系电话*/
  60. $("#phone").bind({
  61. focus: function() {
  62. $(this).siblings().find("span").show();
  63. },
  64. blur: function() {
  65. $(this).siblings().find("span").hide();
  66. }
  67. })
  68. function test() {
  69. if($("#demandTitle").val().trim() == "") {
  70. $.MsgBox.Alert('提示', '请填写需求主题');
  71. return;
  72. } else if($("#demandTitle").val().length > 50) {
  73. $.MsgBox.Alert('提示', '需求主题不得超过50个字');
  74. return;
  75. }
  76. if($("#remarkContent").val().trim() == "") {
  77. $.MsgBox.Alert('提示', '请填写需求内容');
  78. return;
  79. } else if($("#remarkContent").val().length > 1000) {
  80. $.MsgBox.Alert('提示', '需求内容不得超过1000个字');
  81. return;
  82. }
  83. if($("#oprovince").text() == "请选择省/直辖市") {
  84. $.MsgBox.Alert('提示', '请选择省/直辖市');
  85. return;
  86. }
  87. if($("#ocity").text() == "请选择城市") {
  88. $.MsgBox.Alert('提示', '请选择城市');
  89. return;
  90. }
  91. if($("#createTime").val() == "") {
  92. $.MsgBox.Alert('提示', '请选择需求有效期');
  93. return;
  94. }
  95. if($("#phone").val().trim() == "") {
  96. $.MsgBox.Alert('提示', '请填写联系电话');
  97. return;
  98. } else if($("#phone").val().length > 50) {
  99. $.MsgBox.Alert('提示', '联系电话不得超过50个字');
  100. return;
  101. }
  102. return 1;
  103. }
  104. $(".posted").click(function() {
  105. if(test()) {
  106. $.MsgBox.Confirm("提示", "确认发布需求?", pDemand);
  107. }
  108. event.stopPropagation();
  109. });
  110. /*时间转换成6位传给后台*/
  111. function st6(osr) {
  112. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10);
  113. return tim;
  114. }
  115. function pDemand() {
  116. $.ajax({
  117. "url": "/ajax/demand",
  118. "type": "POST",
  119. "data": {
  120. "title": $("#demandTitle").val(),
  121. "descp": $("#remarkContent").val(),
  122. "province": $("#oprovince").text(),
  123. "city": $("#ocity").text(),
  124. "cost": $("#spendCost").val(),
  125. "duration": $("#budget").val(),
  126. "invalidDay": st6($("#createTime").val()),
  127. "contactNum": $("#phone").val(),
  128. "creator": userid,
  129. "orgId": orgId
  130. },
  131. "contentType": "application/x-www-form-urlencoded",
  132. "traditional": true,
  133. "dataType": "json",
  134. "success": function(data) {
  135. if(data.success) {
  136. location.href = "myDemand.html";
  137. }
  138. },
  139. "error": function() {
  140. $.MsgBox.Alert('提示', '服务器连接超时');
  141. }
  142. });
  143. }
  144. /*查询企业信息*/
  145. function queryOrg() {
  146. $.ajax({
  147. "url": "/ajax/org/" + orgId,
  148. "type": "GET",
  149. "traditional": true,
  150. "dataType": "json",
  151. "success": function(data) {
  152. if(data.success) {
  153. var $data = data.data;
  154. if($data.isJoin == 1) {
  155. if($data.forShort) {
  156. $("#Qname").text($data.forShort)
  157. } else {
  158. $("#Qname").text($data.name)
  159. }
  160. // $("#Qname,.qiyego").attr("href", "cmpInforShow.html?orgId=" + $data.id);
  161. if($data.authStatus == 3) {
  162. $("#QauthFlag").addClass("authicon-com-ok").attr("title", "科袖认证企业");
  163. }
  164. if($data.hasOrgLogo) {
  165. $("#companyImg").attr("src", "/images/org/" + $data.id + ".jpg");
  166. } else {
  167. $("#companyImg").attr("src", "/images/default-icon.jpg");
  168. }
  169. } else {
  170. $("#Qname").text($data.name);
  171. $("#companyImg").attr("src", "/images/default-icon.jpg");
  172. }
  173. }
  174. },
  175. "error": function() {
  176. $.MsgBox.Alert('提示', '服务器连接超时');
  177. }
  178. });
  179. }
  180. personMess()
  181. function personMess() {
  182. $.ajax({
  183. "url": "/ajax/professor/baseInfo/" + userid,
  184. "type": "GET",
  185. "traditional": true,
  186. "dataType": "json",
  187. "success": function(data) {
  188. if(data.success) {
  189. var $data = data.data;
  190. var userType = autho($data.authType, $data.orgAuth, $data.authStatus);
  191. $("#auth").attr("title", userType.title).addClass(userType.sty);
  192. $("#proName").text($data.name);
  193. if($data.hasHeadImage) {
  194. $("#proImg").attr("style", "background-image: url(/images/head/" + $data.id + "_l.jpg);");
  195. }
  196. var oT = ($data.title) ? $data.title : ($data.office ? $data.office : "");
  197. $("#brief").text(oT);
  198. if($data.province) {
  199. $("#oprovince").text($data.province)
  200. }
  201. if($data.address) {
  202. $("#ocity").text($data.address)
  203. }
  204. //省份城市颜色
  205. if($("#oprovince").text() == "请选择省/直辖市") {
  206. $("#oprovince").removeClass("mr_select");
  207. } else {
  208. $("#oprovince").addClass("mr_select");
  209. }
  210. if($("#ocity").text() == "请选择城市") {
  211. $("#ocity").removeClass("mr_select");
  212. } else {
  213. $("#ocity").addClass("mr_select");
  214. }
  215. $("#spendCost").css("color", "#999");
  216. $("#budget").css("color", "#999");
  217. if($data.phone) {
  218. $('#phone').val($data.phone)
  219. }
  220. orgId = $data.orgId;
  221. queryOrg();
  222. }
  223. },
  224. "error": function() {
  225. $.MsgBox.Alert('提示', '服务器连接超时');
  226. }
  227. });
  228. }
  229. })