portal html css js resource

demandModify.js 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. $(document).ready(function() {
  2. loginStatus(); //判断个人是否登录
  3. valUser();
  4. var userid = $.cookie("userid");
  5. personMess()
  6. var demandId = GetQueryString("demandId");
  7. var a = new Date();
  8. var c = a.getFullYear() + "-" + (Number(a.getMonth()) + 1) + "-" + (Number(a.getDate()) + 1);
  9. $('.dateBtn').datetimepicker({
  10. language: 'ch',
  11. weekStart: 0,
  12. todayBtn: 1,
  13. autoclose: 1,
  14. todayHighlight: 1,
  15. startView: 2,
  16. minView: 2,
  17. forceParse: 0,
  18. startDate: c,
  19. });
  20. /*联系电话*/
  21. $("#phone").bind({
  22. focus: function() {
  23. $(this).siblings().find("span").show();
  24. },
  25. blur: function() {
  26. $(this).siblings().find("span").hide();
  27. }
  28. })
  29. queryOnedemand()
  30. function queryOnedemand() {
  31. $.ajax({
  32. "url": "/ajax/demand/qo",
  33. "type": "GET",
  34. "data": {
  35. "id": demandId,
  36. },
  37. "contentType": "application/x-www-form-urlencoded",
  38. "traditional": true,
  39. "dataType": "json",
  40. "success": function(data) {
  41. if(data.success) {
  42. var $data = data.data;
  43. var demandTit =$data.title + "-科袖网";
  44. document.title = demandTit;
  45. $("#demandTitle").text($data.title);
  46. $("#publishTime").text(commenTime($data.createTime));
  47. $("#pageView").text($data.pageViews);
  48. $("#demandContent").text($data.descp);
  49. $("#oprovince").text($data.province);
  50. $("#ocity").text($data.city);
  51. $("#spendCost").val($data.cost);
  52. $("#budget").val($data.duration);
  53. $("#createTime").val(changeTime($data.invalidDay));
  54. $("#phone").val($data.contactNum);
  55. if($data.cost == 0) {
  56. $("#spendCost").css("color", "#999");
  57. }
  58. if($data.duration ==0) {
  59. $("#budget").css("color", "#999");
  60. }
  61. //省份城市颜色
  62. if($("#oprovince").text() == "请选择省/直辖市") {
  63. $("#oprovince").removeClass("mr_select");
  64. } else {
  65. $("#oprovince").addClass("mr_select");
  66. }
  67. if($("#ocity").text() == "请选择城市") {
  68. $("#ocity").removeClass("mr_select");
  69. } else {
  70. $("#ocity").addClass("mr_select");
  71. }
  72. }
  73. },
  74. "error": function() {
  75. $.MsgBox.Alert('提示', '服务器连接超时');
  76. }
  77. });
  78. }
  79. function formatDate(date) {
  80. var y = date.getFullYear();
  81. var m = date.getMonth() + 1;
  82. m = m < 10 ? '0' + m : m;
  83. var d = date.getDate();
  84. d = d < 10 ? ('0' + d) : d;
  85. return y + '-' + m + '-' + d;
  86. };
  87. function test() {
  88. if($("#oprovince").text() == "请选择省/直辖市") {
  89. $.MsgBox.Alert('提示', '请选择省/直辖市');
  90. return;
  91. }
  92. if($("#ocity").text() == "请选择城市") {
  93. $.MsgBox.Alert('提示', '请选择城市');
  94. return;
  95. }
  96. if($("#createTime").val() == "") {
  97. $.MsgBox.Alert('提示', '请选择需求有效期');
  98. return;
  99. } else {
  100. if(formatDate(a) > $("#createTime").val()) {
  101. $.MsgBox.Alert('提示', '该需求已过期,请修改有效期,若已解决请点击「需求已完成」按钮');
  102. return;
  103. }
  104. }
  105. if($("#phone").val().trim() == "") {
  106. $.MsgBox.Alert('提示', '请填写联系电话');
  107. return;
  108. } else if($("#phone").val().length > 50) {
  109. $.MsgBox.Alert('提示', '联系电话不得超过50个字');
  110. return;
  111. }
  112. return 1;
  113. }
  114. $("#modia").click(function() {
  115. if(test()) {
  116. $.MsgBox.Confirm("提示", "确认修改需求?", pDemand);
  117. }
  118. });
  119. $("#complete").click(function() {
  120. $.MsgBox.Confirm("提示", "确认需求已完成?", com);
  121. });
  122. $("#closeDemand").click(function() {
  123. $.MsgBox.Confirm("提示", "确认关闭该需求?", closeDe);
  124. });
  125. function com() {
  126. $.ajax({
  127. "url": "/ajax/demand/over",
  128. "type": "POST",
  129. "data": {
  130. "id": demandId,
  131. "uid": userid
  132. },
  133. "contentType": "application/x-www-form-urlencoded",
  134. "traditional": true,
  135. "dataType": "json",
  136. "success": function(data) {
  137. if(data.success) {
  138. location.href = "myDemand.html";
  139. }
  140. },
  141. "error": function() {
  142. $.MsgBox.Alert('提示', '服务器连接超时');
  143. }
  144. });
  145. }
  146. function closeDe() {
  147. $.ajax({
  148. "url": "/ajax/demand/close",
  149. "type": "POST",
  150. "data": {
  151. "id": demandId,
  152. "uid": userid
  153. },
  154. "contentType": "application/x-www-form-urlencoded",
  155. "traditional": true,
  156. "dataType": "json",
  157. "success": function(data) {
  158. if(data.success) {
  159. location.href = "myDemand.html";
  160. }
  161. },
  162. "error": function() {
  163. $.MsgBox.Alert('提示', '服务器连接超时');
  164. }
  165. });
  166. }
  167. /*时间转换成6位传给后台*/
  168. function st6(osr) {
  169. var tim = osr.substring(0, 4) + osr.substring(5, 7) + osr.substring(8, 10);
  170. return tim;
  171. }
  172. function pDemand() {
  173. var time=new Date(),
  174. y=time.getFullYear();
  175. m=time.getMonth()+1;
  176. if(m<10) {
  177. m="0"+m;
  178. }
  179. d=time.getDate();
  180. if(d<10) {
  181. d="0"+d;
  182. }
  183. var oTime=Number(y+""+m+""+d);
  184. var seleTime=Number(st6($("#createTime").val()));
  185. if(oTime>seleTime) {
  186. $.MsgBox.Alert('提示', '该需求已过期,请修改有效期,若已解决请点击「需求已完成」按钮');
  187. return;
  188. }
  189. $.ajax({
  190. "url": "/ajax/demand/modify",
  191. "type": "POST",
  192. "data": {
  193. "province": $("#oprovince").text(),
  194. "city": $("#ocity").text(),
  195. "cost": $("#spendCost").val() != "0" ? $("#spendCost").val() : "",
  196. "duration": $("#budget").val() != "0" ? $("#budget").val() : "",
  197. "invalidDay": st6($("#createTime").val()),
  198. "contactNum": $("#phone").val(),
  199. "modifier": userid,
  200. "id": demandId
  201. },
  202. "contentType": "application/x-www-form-urlencoded",
  203. "traditional": true,
  204. "dataType": "json",
  205. "success": function(data) {
  206. if(data.success) {
  207. location.href = "myDemand.html";
  208. }
  209. },
  210. "error": function() {
  211. $.MsgBox.Alert('提示', '服务器连接超时');
  212. }
  213. });
  214. }
  215. /*查询企业信息*/
  216. function queryOrg(orgId) {
  217. $.ajax({
  218. "url": "/ajax/org/" + orgId,
  219. "type": "GET",
  220. "traditional": true,
  221. "dataType": "json",
  222. "success": function(data) {
  223. if(data.success) {
  224. var $data = data.data;
  225. if($data.isJoin == 1) {
  226. if($data.forShort) {
  227. $("#Qname").text($data.forShort)
  228. } else {
  229. $("#Qname").text($data.name)
  230. }
  231. //$("#Qname,.qiyego").attr("href", "cmpInforShow.html?orgId=" + $data.id);
  232. if($data.authStatus == 3) {
  233. $("#QauthFlag").addClass("authicon-com-ok").attr("title", "科袖认证企业");
  234. }
  235. if($data.hasOrgLogo) {
  236. $("#companyImg").attr("src", "/images/org/" + $data.id + ".jpg");
  237. } else {
  238. $("#companyImg").attr("src", "/images/default-icon.jpg");
  239. }
  240. } else {
  241. $("#Qname").text($data.name);
  242. $("#companyImg").attr("src", "/images/default-icon.jpg");
  243. }
  244. }
  245. },
  246. "error": function() {
  247. $.MsgBox.Alert('提示', '服务器连接超时');
  248. }
  249. });
  250. }
  251. function personMess() {
  252. $.ajax({
  253. "url": "/ajax/professor/baseInfo/" + userid,
  254. "type": "GET",
  255. "traditional": true,
  256. "dataType": "json",
  257. "success": function(data) {
  258. if(data.success) {
  259. var $data = data.data;
  260. var userType = autho($data.authType, $data.orgAuth, $data.authStatus);
  261. $("#auth").attr("title", userType.title).addClass(userType.sty);
  262. $("#proName").text($data.name);
  263. if($data.hasHeadImage) {
  264. $("#proImg").attr("style", "background-image: url(/images/head/" + $data.id + "_l.jpg);");
  265. }
  266. var oT = ($data.title) ? $data.title : ($data.office ? $data.office : "");
  267. $("#brief").text(oT);
  268. queryOrg($data.orgId);
  269. }
  270. },
  271. "error": function() {
  272. $.MsgBox.Alert('提示', '服务器连接超时');
  273. }
  274. });
  275. }
  276. })