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

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