网站
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

index.js 22 KiB

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