网站
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.
 
 
 

387 lines
14 KiB

  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "biddingApi", "itemsApi", "paging",'dateTime', 'swiper'], function ($, template, Tools ) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. //焦点图数据
  9. focusListTop: [],
  10. //标的物类型
  11. deptTypeList:[],
  12. //标的物所在地
  13. deptLocationList:[],
  14. //竞价大厅列表
  15. biddingInformationList:'',
  16. //页码
  17. pageNum: 1,
  18. //页码集合
  19. pageList: [],
  20. //每页数量
  21. pageSize: 20,
  22. //总页数
  23. pageCount:0,
  24. //标的物选中项id
  25. deptId:'100',
  26. //标的所在地选中
  27. secondDeptId:'',
  28. //标的物类型ID
  29. projectNumber:'',
  30. //项目状态
  31. projectShowStatus:'',
  32. //报名开始时间
  33. signupStartTime:'',
  34. //报名结束时间
  35. signupStopTime:'',
  36. //竞价开始时间
  37. biddingStartTime:'',
  38. //竞价结束时间
  39. biddingStopTime:'',
  40. form:{
  41. deptId:100,
  42. projectNumber:'',
  43. projectShowStatus:'',
  44. // signupStartTime:'',
  45. // signupStopTime:'',
  46. // biddingStartTime:'',
  47. // biddingStopTime:'',
  48. }
  49. },
  50. };
  51. var tools = new Tools();
  52. module.init = function (page) {
  53. //获取焦点图信息
  54. //tools.doGet(websitePicture, {picType:1,status:0,orderByColumn:'picSort',isAsc:'desc'}, module.focusNewsTop , true);
  55. //底部友情链接
  56. tools.doGet(friendsLinks, {}, module.bottomFriendsLinks, true);
  57. //新闻资讯
  58. tools.doGet(biddingList, {
  59. deptId:100,
  60. pageNum:module.data.pageNum,
  61. pageSize:module.data.pageSize,
  62. }, module.biddingList,true);
  63. //标的物类型
  64. tools.doGet(webDeptType+"/project_type", {}, module.deptType,true);
  65. //标的物所在地
  66. tools.doGet(webDept, {deptId:''}, module.deptLocation, true);
  67. //网站配置信息(网站名称 底部联系方式 公安备案号 网站备案号)
  68. tools.getWebConfig();
  69. $("#signStartTimeStr").datetime({
  70. type: "date",
  71. value: [new Date().getFullYear(),new Date().getMonth()+1,new Date().getDate()],
  72. success: function (res) {
  73. console.log(res)
  74. }
  75. })
  76. $("#signEndTimeStr").datetime({
  77. type: "date",
  78. value: [new Date().getFullYear(),new Date().getMonth()+1,new Date().getDate()],
  79. success: function (res) {
  80. console.log(res)
  81. }
  82. })
  83. $("#auctionStartTimeStr").datetime({
  84. type: "date",
  85. value: [new Date().getFullYear(),new Date().getMonth()+1,new Date().getDate()],
  86. success: function (res) {
  87. console.log(res)
  88. }
  89. })
  90. $("#endTimeStr").datetime({
  91. type: "date",
  92. value: [new Date().getFullYear(),new Date().getMonth()+1,new Date().getDate()],
  93. success: function (res) {
  94. console.log(res)
  95. }
  96. })
  97. setTimeout(function(){
  98. //主题图片切换
  99. module.switchTheme();
  100. },500)
  101. };
  102. //焦点图数据
  103. module.focusNewsTop = function (data) {
  104. if (data.code == 200) {
  105. let focusArray = [];
  106. if(data.data.length<1){
  107. focusArray.push({
  108. picUrl:'../../../static/images/banner1.png'
  109. },{
  110. picUrl:'../../../static/images/banner2.png'
  111. },{
  112. picUrl:'../../../static/images/banner3.png'
  113. })
  114. }else{
  115. data.data.forEach(res=>{
  116. focusArray.push({
  117. picUrl:'/api'+res.picUrl
  118. })
  119. })
  120. }
  121. module.data.focusListTop = focusArray;
  122. var bannerFocusDataTop = template('bannerFocusDataTop', module.data);
  123. $("#bannerFocusTopContent").html(bannerFocusDataTop);
  124. new Swiper('#bannerFocusWrapTop', {
  125. paginationClickable: true,
  126. autoplay : 4000,
  127. loop:true
  128. })
  129. }
  130. }
  131. //主题图片切换
  132. module.switchTheme = function(){
  133. if(themeColor == 'red'){
  134. document.getElementById('bannerBottom').src = '../../static/images/bannerBottom_red.jpg'
  135. }else if(themeColor == 'green'){
  136. document.getElementById('bannerBottom').src = '../../static/images/bannerBottom.jpg'
  137. }
  138. }
  139. //交易项目列表
  140. module.biddingList = function (data) {
  141. if (data.code == 200) {
  142. console.log(data)
  143. var content = data.rows;
  144. var pageCount = (data.total/module.data.pageSize).toFixed(0);
  145. if (pageCount < 1){
  146. pageCount = 1;
  147. }
  148. if(module.data.biddingInformationList == ''){
  149. // 初始化 分页器
  150. var page_s1=createPage('.page_s1');
  151. // 设置分页
  152. setPage(page_s1,{
  153. pageTotal: data.total, // 数据总条数
  154. pageSize: module.data.pageSize, // 每页显示条数
  155. pageCurrent: 1, // 当前页
  156. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  157. })
  158. $('#page_s1').html('共'+pageCount+'页')
  159. }
  160. module.data.pageCount = pageCount;
  161. for(var i = 0 ; i < content.length ; i++){
  162. if(content[i].biddingStopTime == null || content[i].biddingStartTime == null){continue;}
  163. var endTimes=content[i].biddingStopTime.substring(0,10).split('-');
  164. var biddingStopTime=endTimes[1]+'/'+endTimes[2]+'/'+endTimes[0]+' '+content[i].biddingStopTime.substring(10,19);
  165. var startTimes=content[i].biddingStartTime.substring(0,10).split('-');
  166. var biddingStartTime=startTimes[1]+'/'+startTimes[2]+'/'+startTimes[0]+' '+content[i].biddingStartTime.substring(10,19);
  167. var nowTime = Date.parse(new Date());
  168. var leftTime = Date.parse(biddingStopTime)-nowTime;
  169. var rightTime = Date.parse(biddingStartTime)-nowTime;
  170. console.log(biddingStopTime)
  171. console.log(leftTime)
  172. if(leftTime>0){
  173. console.log('进行中')
  174. content[i].timeType = '进行中'
  175. }
  176. if(leftTime<0){
  177. console.log('已结束')
  178. content[i].timeType = '已结束'
  179. }
  180. if(rightTime>0){
  181. console.log('未开始')
  182. content[i].timeType = '未开始'
  183. }
  184. }
  185. module.data.biddingInformationList = content;
  186. var biddingInformationData = template('biddingInformationData', module.data);
  187. $("#biddingInformationContent").html(biddingInformationData);
  188. }
  189. }
  190. //标的物类型
  191. module.deptType = function (data) {
  192. console.log(data)
  193. if (data.code == 200) {
  194. var content = data.data ;
  195. module.data.deptTypeList = content;
  196. var deptTypeData = template('deptTypeData', module.data);
  197. $("#deptTypeContent").html(deptTypeData);
  198. }
  199. }
  200. //标的物所在地
  201. module.deptLocation = function (data) {
  202. if (data.code == 200) {
  203. var content = data.data ;
  204. module.data.deptLocationList = content;
  205. var deptLocationData = template('deptLocationData', module.data);
  206. $("#deptLocationContent").html(deptLocationData);
  207. }
  208. }
  209. //标的物所在地(二级)
  210. module.deptSecondLocation = function (data) {
  211. if ( data.data.length == 0){
  212. document.getElementById('secondDept').style.display = 'none';
  213. return;
  214. }else{
  215. document.getElementById('secondDept').style.display = 'block';
  216. }
  217. if (data.code == 200) {
  218. console.log(data)
  219. var content = data.data;
  220. module.data.deptSecondLocationList = content;
  221. var deptSecondLocationData = template('deptSecondLocationData', module.data);
  222. $("#secondDept").html(deptSecondLocationData);
  223. console.log(module.data.deptId)
  224. }
  225. }
  226. tabCheck = function (deptId) {
  227. module.data.deptId = deptId;
  228. $('#locInfoall').attr("class","auction_hall_table_tab auction_loc");
  229. $("#deptLocationContent div").attr("class","auction_hall_table_tab auction_loc");
  230. if(deptId == ''){
  231. $('#locInfoall').addClass('auction_hall_table_tab_select');
  232. document.getElementById('secondDept').style.display = 'none';
  233. }else{
  234. $('#locInfoall'+deptId).addClass('auction_hall_table_tab_select');
  235. tools.doGet(webDept, {deptId:deptId}, module.deptSecondLocation, true);
  236. }
  237. }
  238. secondCheck = function(id,secondDeptId){
  239. $('#locInfoSecondall').attr("class","auction_hall_table_tab auction_loc");
  240. $("#secondDept div").attr("class","auction_hall_table_tab auction_loc");
  241. if(id == '' && secondDeptId == ''){
  242. $('#locInfoSecondall').addClass('auction_hall_table_tab_select');
  243. module.data.deptId = $('#deptLocationContent div.auction_hall_table_tab_select').attr("data");
  244. }else{
  245. $('#locInfoall'+id).addClass('auction_hall_table_tab_select');
  246. module.data.deptId = secondDeptId;
  247. }
  248. }
  249. allDept = function (){
  250. module.data.deptSize = 30
  251. document.getElementById('allDept').innerHTML = "<i class='sanjiao-top'></i>";
  252. document.getElementById('allDept').onclick = upDept;
  253. tools.doGet(webDept + '/0', {}, module.deptLocation, true);
  254. }
  255. turnThePage = function (pageNum) {
  256. module.data.pageNum = pageNum ;
  257. tools.doGet(biddingList, {deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.biddingList,true);
  258. }
  259. typeCheck = function(id,projectNumber){
  260. if(projectNumber==undefined){
  261. // projectNumber为undefined时,置空(直接传递给后台接口导致搜索问题)
  262. projectNumber = "";
  263. }
  264. module.data.projectNumber = projectNumber;//标的物类型ID
  265. document.getElementById('standardTypeAll').className = 'auction_hall_table_tab';
  266. if(id == ''){
  267. id = 'All';
  268. }
  269. if(projectNumber == undefined){
  270. module.data.projectNumber = '';
  271. }
  272. for (var i = 0 ; i < module.data.deptTypeList.length ; i++){
  273. document.getElementById('standardType'+(i+1)).className = 'auction_hall_table_tab';
  274. }
  275. document.getElementById('standardType'+id).className = 'auction_hall_table_tab auction_hall_table_tab_select';
  276. }
  277. selectedStatus = function(id,projectShowStatus){
  278. module.data.projectShowStatus = projectShowStatus;
  279. document.getElementById('statusall').className = 'auction_hall_table_tab'
  280. for (var i = 0 ; i < 5 ; i++){
  281. document.getElementById('status'+(1+i)).className = 'auction_hall_table_tab'
  282. }
  283. document.getElementById('status'+id).className = 'auction_hall_table_tab auction_hall_table_tab_select'
  284. }
  285. //底部友情链接
  286. module.bottomFriendsLinks = function (data) {
  287. if (data.code == 200) {
  288. var content = data.data;
  289. console.log(content)
  290. module.data.friendsLinksList = content;
  291. var friendsLinksData = template('friendsLinksData', module.data);
  292. $("#friendsLinksContent").html(friendsLinksData);
  293. }
  294. }
  295. goSearchClear = function(){
  296. selectedStatus('all');
  297. tabCheck('');
  298. typeCheck('');
  299. $('#signStartTimeStr').val('')
  300. $('#signEndTimeStr').val('')
  301. $('#auctionStartTimeStr').val('')
  302. $('#endTimeStr').val('')
  303. goSearch();
  304. }
  305. goSearch = function(){
  306. module.data.itemsInformationList = '';
  307. module.data.biddingInformationList = [];
  308. $('.page_s1').html('')
  309. $('#page_s1').html('')
  310. module.data.form.deptId = module.data.deptId;
  311. module.data.form.projectNumber = module.data.projectNumber;
  312. module.data.form.projectShowStatus= module.data.projectShowStatus;
  313. // module.data.form.signupStartTime= $('#signStartTimeStr').val();
  314. // module.data.form.signupStopTime= $('#signEndTimeStr').val();
  315. // module.data.form.biddingStartTime= $('#auctionStartTimeStr').val();
  316. // module.data.form.biddingStopTime= $('#endTimeStr').val();
  317. module.data.form.pageNum= module.data.pageNum;
  318. module.data.form.pageSize= module.data.pageSize;
  319. if (module.data.form.signupStartTime){
  320. delete module.data.form.signupStartTime;
  321. }
  322. if (module.data.form.signupStopTime){
  323. delete module.data.form.signupStopTime;
  324. }
  325. if (module.data.form.biddingStartTime){
  326. delete module.data.form.biddingStartTime;
  327. }
  328. if (module.data.form.biddingStopTime){
  329. delete module.data.form.biddingStopTime;
  330. }
  331. if ($('#signStartTimeStr').val()!=''){
  332. module.data.form.signupStartTime = $('#signStartTimeStr').val();
  333. }
  334. if ($('#signEndTimeStr').val()!=''){
  335. module.data.form.signupStopTime = $('#signEndTimeStr').val();
  336. }
  337. if ($('#auctionStartTimeStr').val()!=''){
  338. module.data.form.biddingStartTime = $('#auctionStartTimeStr').val();
  339. }
  340. if ($('#endTimeStr').val()!=''){
  341. module.data.form.biddingStopTime = $('#endTimeStr').val();
  342. }
  343. console.log(module.data.form)
  344. tools.doGet(biddingList, module.data.form, module.biddingList, true);
  345. }
  346. goDetail = function (id) {
  347. tools.skip('../listingItems/itemsDetail.html?id='+id);
  348. }
  349. return module;
  350. });