网站
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

483 linhas
19 KiB

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