网站
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

484 rivejä
19 KiB

  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "user", "paging","cupload","kindeditor"], function ($, template, Tools ) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. userInformationDetail:[],
  9. userSupplyInformationList:'',
  10. consultingInformationList:'',
  11. biddingInformationList:'',
  12. //页码
  13. pageNum: 1,
  14. //页码集合
  15. pageList: [],
  16. //每页数量
  17. pageSize: 5,
  18. //总页数
  19. pageCount:0,
  20. //用户ID
  21. memberId:0,
  22. //用户资料form
  23. form:{
  24. }
  25. },
  26. };
  27. var tools = new Tools();
  28. module.init = function (page) {
  29. //用户资料
  30. tools.doGet(userData, {}, module.userData);
  31. //用户资料
  32. //tools.doPut(userData, {id:}, module.userData,true);
  33. //个人中心选项卡鼠标悬浮
  34. module.userListHover();
  35. //网站配置信息(网站名称 底部联系方式 公安备案号 网站备案号)
  36. tools.getWebConfig();
  37. window.KindEditor.create('#editor_id')
  38. };
  39. //个人中心用户信息
  40. module.userData = function(data){
  41. if (data.code == 200) {
  42. var content = data.user;
  43. console.log(content)
  44. tools.doGet(userMember + '/' + content.userId, {}, module.userMember);//memberType 1个人 2单位
  45. }
  46. }
  47. //个人中心用户资料
  48. module.userMember = function(data){
  49. if (data.code == 200) {
  50. var content = data.data;
  51. console.log(data)
  52. module.data.userInformationDetail = content;
  53. module.data.memberType = content.memberType;
  54. if(content.memberType == '1'){
  55. document.getElementById('companyInformationContent').style.display = 'none';
  56. document.getElementById('userInformationContent').style.display = 'block';
  57. var userInformationData = template('userInformationData', module.data);
  58. $("#userInformationContent").html(userInformationData);
  59. var cupload2 = new Cupload ({
  60. ele: '#cupload-3',
  61. num: 5,
  62. });
  63. }else{
  64. document.getElementById('companyInformationContent').style.display = 'block';
  65. document.getElementById('userInformationContent').style.display = 'none';
  66. var companyInformationData = template('companyInformationData', module.data);
  67. $("#companyInformationContent").html(companyInformationData);
  68. var cupload2 = new Cupload ({
  69. ele: '#cupload-2',
  70. num: 5,
  71. });
  72. }
  73. document.getElementById('bankAddress').value = content.bankAddress;
  74. document.getElementById('bankCardName').value = content.bankCardName;
  75. document.getElementById('bankCardNum').value = content.bankCardNum;
  76. document.getElementById('phone').innerHTML = content.phone;
  77. module.data.memberId = content.id;
  78. console.log(content.memberType)
  79. //我的供求
  80. tools.doGet(userSupply, {memberId:content.id,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.userSupply);
  81. //我的咨询
  82. tools.doGet(userConsulting, {memberId:content.id,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.consulting);
  83. //我的竞价
  84. tools.doGet(userBidding, {memberId:content.id,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.bidding);
  85. //个人资料提交
  86. $('#supplyAction').on('click', module.supplyAction)
  87. $('#releaseAction').on('click', module.releaseAction)
  88. //获取附件的值
  89. $('#upLoadBtn').on('click',module.upLoadAction)
  90. //document.getElementById('userAction').addEventListener('click',module.formAction);
  91. }
  92. }
  93. //获取上传图片list
  94. module.upLoadAction = function(){
  95. var upLoadList = [];
  96. $('#cupload-3').find('input').each(function() {
  97. if($(this).val()!=''){
  98. upLoadList.push($(this).val())
  99. }
  100. })
  101. console.log(upLoadList)
  102. }
  103. //删除供求
  104. deleteUserSupply = function(ids){
  105. tools.doDelete(deleteSupply, {ids:ids}, module.Tips);
  106. }
  107. //个人中心我的供求
  108. module.userSupply = function(data){
  109. console.log(data)
  110. if (data.code == 200) {
  111. var content = data.rows;
  112. console.log(data)
  113. var pageCount = (data.total/module.data.pageSize).toFixed(0);
  114. if (pageCount < 1){
  115. pageCount = 1;
  116. }
  117. if(module.data.userSupplyInformationList == '') {
  118. // 初始化 分页器
  119. var page_s1 = createPage('.page_s1');
  120. // 设置分页
  121. setPage(page_s1, {
  122. pageTotal: data.total, // 数据总条数
  123. pageSize: module.data.pageSize, // 每页显示条数
  124. pageCurrent: 1, // 当前页
  125. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  126. })
  127. $('#page_s1').html('共' + pageCount + '页')
  128. }
  129. module.data.userSupplyInformationList = content;
  130. var userSupplyInformationData = template('userSupplyInformationData', module.data);
  131. $("#userSupplyInformationContent").html(userSupplyInformationData);
  132. }
  133. }
  134. //个人中心我的咨询
  135. module.consulting = function(data){
  136. if (data.code == 200) {
  137. var content = data.rows;
  138. var pageCount = (data.total/module.data.pageSize).toFixed(0);
  139. if (pageCount < 1){
  140. pageCount = 1;
  141. }
  142. if(module.data.consultingInformationList == '') {
  143. // 初始化 分页器
  144. var page_s1 = createPage('.page_s2');
  145. // 设置分页
  146. setPage(page_s1, {
  147. pageTotal: data.total, // 数据总条数
  148. pageSize: module.data.pageSize, // 每页显示条数
  149. pageCurrent: 1, // 当前页
  150. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  151. })
  152. }
  153. module.data.consultingInformationList = content;
  154. $('#page_s2').html('共'+pageCount+'页')
  155. var consultingInformationData = template('consultingInformationData', module.data);
  156. $("#consultingInformationContent").html(consultingInformationData);
  157. }
  158. }
  159. //个人中心我的竞价
  160. module.bidding = function(data){
  161. if (data.code == 200) {
  162. var content = data.rows;
  163. console.log(content)
  164. var pageCount = (data.total/module.data.pageSize).toFixed(0);
  165. if (pageCount < 1){
  166. pageCount = 1;
  167. }
  168. if(module.data.biddingInformationList == '') {
  169. // 初始化 分页器
  170. var page_s1=createPage('.page_s3');
  171. // 设置分页
  172. setPage(page_s1, {
  173. pageTotal: data.total, // 数据总条数
  174. pageSize: module.data.pageSize, // 每页显示条数
  175. pageCurrent: 1, // 当前页
  176. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  177. })
  178. $('#page_s3').html('共' + pageCount + '页')
  179. }
  180. module.data.biddingInformationList = content;
  181. var biddingInformationData = template('biddingInformationData', module.data);
  182. $("#biddingInformationContent").html(biddingInformationData);
  183. }
  184. }
  185. tabCheck = function(type){
  186. document.getElementById('user').className = '';
  187. document.getElementById('bank').className = '';
  188. document.getElementById(type).className = 'active';
  189. console.log(type)
  190. document.getElementById('userInformationContent').style.display = 'none';
  191. document.getElementById('companyInformationContent').style.display = 'none';
  192. document.getElementById('bankInformationContent').style.display = 'none';
  193. document.getElementById('phoneInformationContent').style.display = 'none';
  194. if (module.data.memberType == '2' && type == 'user'){
  195. document.getElementById('companyInformationContent').style.display = 'block';
  196. }else if (module.data.memberType == '1' && type == 'user'){
  197. document.getElementById('userInformationContent').style.display = 'block';
  198. }else{
  199. document.getElementById(type+'InformationContent').style.display = 'block';
  200. }
  201. }
  202. phoneUpdate = function(type){
  203. document.getElementById(type+'InformationContent').style.display = 'none';
  204. document.getElementById('phoneInformationContent').style.display = 'block';
  205. }
  206. tabLeftCheck = function(type){
  207. for (var i = 1 ; i < 5 ; i++){
  208. document.getElementById('icon-list'+i).className = '';
  209. }
  210. document.getElementById(type).className = 'active';
  211. document.getElementById('userInformation').style.display = 'none';
  212. document.getElementById('supplyInformation').style.display = 'none';
  213. document.getElementById('consultingInformation').style.display = 'none';
  214. document.getElementById('biddingInformation').style.display = 'none';
  215. document.getElementById('releaseSupply').style.display = 'none';
  216. document.getElementById('release').style.display = 'none';
  217. if(type == 'icon-list1'){
  218. document.getElementById('userInformation').style.display = 'block';
  219. }
  220. if(type == 'icon-list2'){
  221. document.getElementById('supplyInformation').style.display = 'block';
  222. module.data.clickType = 'supply';
  223. }
  224. if(type == 'icon-list3'){
  225. document.getElementById('consultingInformation').style.display = 'block';
  226. module.data.clickType = 'consulting';
  227. }
  228. if(type == 'icon-list4'){
  229. document.getElementById('biddingInformation').style.display = 'block';
  230. module.data.clickType = 'bidding';
  231. }
  232. module.data.pageNum = 1 ;
  233. }
  234. goSupply = function(){
  235. document.getElementById('supplyInformation').style.display = "none";
  236. document.getElementById('releaseSupply').style.display = "block";
  237. }
  238. gosupplyTable = function(){
  239. document.getElementById('supplyInformation').style.display = "block";
  240. document.getElementById('releaseSupply').style.display = "none";
  241. }
  242. goRelease = function(){
  243. document.getElementById('consultingInformation').style.display = "none";
  244. document.getElementById('release').style.display = "block";
  245. }
  246. goReleaseTable = function(){
  247. document.getElementById('consultingInformation').style.display = "block";
  248. document.getElementById('release').style.display = "none";
  249. }
  250. //翻页
  251. turnThePage = function (pageNum) {
  252. module.data.pageNum = pageNum ;
  253. if(module.data.clickType == 'supply'){
  254. tools.doGet(userSupply, {memberId:module.data.memberId,pageNum:pageNum,pageSize:module.data.pageSize}, module.userSupply);
  255. }
  256. if(module.data.clickType == 'consulting'){
  257. tools.doGet(userConsulting, {memberId:module.data.memberId,pageNum:pageNum,pageSize:module.data.pageSize}, module.consulting);
  258. }
  259. if(module.data.clickType == 'bidding'){
  260. tools.doGet(userBidding, {memberId:module.data.memberId,pageNum:pageNum,pageSize:module.data.pageSize}, module.bidding);
  261. }
  262. }
  263. //个人用户资料修改
  264. formAction = function (type){
  265. var data = {};
  266. //var password = $('#password').val();
  267. module.data.userFormType = type ;
  268. if(type == 'company'){
  269. //公司用户信息
  270. var companyName = $('#companyName').val();
  271. var idCardNum = $('#idCardNum').val();
  272. var realname = $('#realname').val();
  273. var companyCode = $('#companyCode').val();
  274. var companyNature = $('#companyNature').val();
  275. var companyScope = $('#companyScope').val();
  276. var companyTimeLimit = $('#companyTimeLimit').val();
  277. var companySetupTime = $('#companySetupTime').val();
  278. var companyCapital = $('#companyCapital').val();
  279. var companyLicense = $('#companyLicense').val();
  280. var address = $('#address').val();
  281. data['companyName'] = companyName;
  282. data['idCardNum'] = idCardNum;
  283. data['realname'] = realname;
  284. data['companyCode'] = companyCode;
  285. data['companyName'] = companyName;
  286. data['companyNature'] = companyNature;
  287. data['companyScope'] = companyScope;
  288. data['companyTimeLimit'] = companyTimeLimit;
  289. data['companySetupTime'] = companySetupTime;
  290. data['companyCapital'] = companyCapital;
  291. data['companyLicense'] = companyLicense;
  292. data['address'] = address;
  293. tools.setCookie('userName',realname,24 * 60 * 60)
  294. tools.setCookie('idCardNum',idCardNum,24 * 60 * 60)
  295. tools.setCookie('address',address,24 * 60 * 60)
  296. }
  297. if(type == 'user'){
  298. //个人用户信息
  299. var userFormRealName = $('#userFormRealName').val();
  300. var userFormIdCard = $('#userFormIdCard').val();
  301. var userFormAddress = $('#userFormAddress').val();
  302. data['idCardNum'] = userFormIdCard;
  303. data['realname'] = userFormRealName;
  304. data['address'] = userFormAddress;
  305. tools.setCookie('userName',userFormRealName,24 * 60 * 60)
  306. tools.setCookie('idCardNum',userFormIdCard,24 * 60 * 60)
  307. tools.setCookie('address',userFormAddress,24 * 60 * 60)
  308. }
  309. if(type == 'bank'){
  310. //银行卡信息
  311. var bankCardName = $('#bankCardName').val();
  312. var bankCardNum = $('#bankCardNum').val();
  313. var bankAddress = $('#bankAddress').val();
  314. data['bankCardName'] = bankCardName;
  315. data['bankCardNum'] = bankCardNum;
  316. data['bankAddress'] = bankAddress;
  317. tools.setCookie('bankCardName',bankCardName,24 * 60 * 60)
  318. tools.setCookie('bankCardNum',bankCardNum,24 * 60 * 60)
  319. tools.setCookie('bankAddress',bankAddress,24 * 60 * 60)
  320. }
  321. //data['password'] = password;
  322. data['id'] = module.data.memberId;
  323. tools.doPut(userUpdate, data, module.Tips)
  324. }
  325. //发布供求
  326. module.supplyAction = function (){
  327. var data = {};
  328. //供求信息
  329. var demandType = $('#demandType').val();
  330. var projectName = $('#projectName').val();
  331. var location = $('#location').val();
  332. var projectRealName = $('#projectRealName').val();
  333. var projectPhone = $('#projectPhone').val();
  334. var projectContent = $('#projectContent').val();
  335. var logintime = tools.getNowFormatDate();
  336. console.log(demandType);
  337. data['projectName'] = projectName;
  338. data['location'] = location;
  339. data['realname'] = projectRealName;
  340. data['phone'] = projectPhone;
  341. data['projectContent'] = projectContent;
  342. data['logintime'] = logintime;
  343. data['supplyDemandType'] = demandType;
  344. data['deptId'] = 100;
  345. data['memberId'] = module.data.memberId;
  346. tools.doPost(userDemand, data, module.Tips)
  347. }
  348. //发布咨询
  349. module.releaseAction = function (){
  350. var data = {};
  351. //供求信息
  352. var title = $('#title').val();
  353. var releaseContent = $('#releaseContent').val();
  354. var releaseRealName = $('#releaseRealName').val();
  355. var releasePhone = $('#releasePhone').val();
  356. var logintime = tools.getNowFormatDate();
  357. data['title'] = title;
  358. data['content'] = releaseContent;
  359. data['realname'] = releaseRealName;
  360. data['phone'] = releasePhone;
  361. data['logintime'] = logintime;
  362. data['deptId'] = 100;
  363. data['memberId'] = module.data.memberId;
  364. tools.doPost(userCommunicate, data, module.Tips)
  365. }
  366. module.Tips = function(data){
  367. tools.initError(data.msg);
  368. }
  369. //手动验证表单
  370. module.check = function () {
  371. var usernameVal = $('#username').val();
  372. var passwordVal = $('#password').val();
  373. var codeVal = $('#code').val();
  374. /* 手机号 */
  375. if (usernameVal == '') {
  376. $('#username')[0].focus()
  377. tools.initTips('请输入用户名', 'right', $('#username')[0], 2000)
  378. return false;
  379. }
  380. /* 密码 */
  381. if (passwordVal == '') {
  382. $('#password')[0].focus()
  383. tools.initTips('请输入密码', 'right', $('#password')[0], 2000)
  384. return false;
  385. } else if (parseInt(passwordVal.length) < 6 || parseInt(passwordVal.length) > 18) {
  386. $('#password')[0].focus()
  387. tools.initTips('请输入正确格式密码', 'right', $('#password')[0], 2000)
  388. return false;
  389. }
  390. /*图形验证码*/
  391. if (module.uuid == '' || codeVal == '') {
  392. $('#code')[0].focus()
  393. tools.initTips('请输入图形验证码', 'right', $('#code')[0], 2000)
  394. return false;
  395. }
  396. return true;
  397. }
  398. //个人中心选项卡鼠标悬浮
  399. module.userListHover = function(){
  400. document.getElementById('icon-list1').onmouseout = function(){
  401. document.getElementById('icon1').src = '../../static/images/user_index_icon1.png'
  402. }
  403. document.getElementById('icon-list1').onmouseover = function(){
  404. document.getElementById('icon1').src = '../../static/images/user_index_icon5.png'
  405. }
  406. document.getElementById('icon-list2').onmouseout = function(){
  407. document.getElementById('icon2').src = '../../static/images/user_index_icon2.png'
  408. }
  409. document.getElementById('icon-list2').onmouseover = function(){
  410. document.getElementById('icon2').src = '../../static/images/user_index_icon6.png'
  411. }
  412. document.getElementById('icon-list3').onmouseout = function(){
  413. document.getElementById('icon3').src = '../../static/images/user_index_icon3.png'
  414. }
  415. document.getElementById('icon-list3').onmouseover = function(){
  416. document.getElementById('icon3').src = '../../static/images/user_index_icon7.png'
  417. }
  418. document.getElementById('icon-list4').onmouseout = function(){
  419. document.getElementById('icon4').src = '../../static/images/user_index_icon4.png'
  420. }
  421. document.getElementById('icon-list4').onmouseover = function(){
  422. document.getElementById('icon4').src = '../../static/images/user_index_icon8.png'
  423. }
  424. }
  425. goSearch = function () {
  426. var searchTitle = $('#searchTitle').val();
  427. var searchContent = $('#searchContent').val();
  428. console.log(searchTitle)
  429. tools.doGet(userConsulting, {title:searchTitle,content:searchContent,memberId:module.data.memberId,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.interactInformation);
  430. }
  431. return module;
  432. });