Best JavaScript code snippet using tracetest
sj_index.js
Source:sj_index.js
1function initPageMain() {2 var indexObj;3 initIndexVar();4 initIndexListener();5 initIndexView();6 function initIndexVar() {7 if(!indexObj) {8 indexObj = new Index();9 }10 }11 function initIndexListener() {12 if(indexObj) {13 indexObj.setOnIndexClickListener();14 }15 }16 function initIndexView(){17 indexObj.getAjaxForSJList();18 }19}20function Index() {21 var thisObj = this;22 var getZSFListUrl = SERVER_URL+"ex/stay/list"; //ä½å®¿è´¹23 var getGQFListUrl = SERVER_URL+"ex/bridge/list"; //è¿æ¡¥è´¹24 var getNSFFListUrl = SERVER_URL+"ex/urea/list"; //å°¿ç´ è´¹25 var getSGListUrl = SERVER_URL+"ex/hAccidentApplication/list"; //äºæ
26 var userInfo = JSON.parse(sessionStorage.getItem("user_info")); //è·åç¨æ·æ°æ®27 var jobInfo = JSON.parse(sessionStorage.getItem("user_jobInfo")); //è·åç¨æ·æ°æ®28 var state = parseInt(publicObj.getUrlParameter("state"));29 var typeNum = sessionStorage.getItem("typeNum")30 this.setOnIndexClickListener = function() {31 //顶é¨é项å¡éä¸æ ·å¼32 var $tab = $(".topTabBar").children();33 $tab.on("click", function() {34 var $this = $(this);35 $tab.removeClass("topTabBar_select");36 $this.addClass("topTabBar_select");37 });38 $(".tab2").click(function() {39 $(".tab2 i").addClass("public-iconListWhite");40 $(".tab1 i").addClass("public-iconApplyBlack");41 $(".list").show();42 $(".apply").hide();43 })44 $(".tab1").click(function() {45 $(".tab1 i").removeClass("public-iconApplyBlack");46 $(".tab2 i").removeClass("public-iconListWhite");47 $(".apply").show();48 $(".list").hide();49 })50 $(".listItem").click(function(_event){51 if($(this).attr("data-page")){52 location.href = "../html/"+$(this).attr("data-page")+"?type=-3";53 }else{54 publicObj.openDingdingPopup("该åè½è¿å¨å¼åä¸");55 }56 });57 $("#select1").change(function(){58 thisObj.getAjaxForSJList();59 });60 };61 //è·åå¸æºè®¢åå表62 this.getAjaxForSJList = function(){63 $(".listContent>.listItem:not([id])").remove();64 console.log(state)65 console.log(state, typeNum)66 switch (typeNum) {67 case "1":68 if ( state == "-9") {69 $.get(getZSFListUrl, { userId: jobInfo.structureUserId, isSend: "1,2", limit: 10000, page: 1, order: "ecs", state: "3,8" }, function (_data) {70 if(_data.data.records.length==0){71 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");72 }73 for (var i in _data.data.records) {74 var thisItem = _data.data.records[i];75 var $listItemClone = $("#listItem").clone();76 $listItemClone.removeAttr("id");77 $listItemClone.attr("data-id", thisItem.id);78 $listItemClone.find(".listName").text(thisItem.number);79 $listItemClone.find(".money").text("Â¥" + thisItem.money);80 $listItemClone.find("#sj").text(thisItem.driverName);81 $listItemClone.find("#bxdType").text("ä½å®¿è´¹æ¥éå");82 var stateText;83 switch (parseInt(thisItem.isSend)) {84 case 1:85 stateText = "æªå¯";86 break;87 case 2:88 stateText = "å·²å¯";89 break;90 default:91 break;92 }93 $listItemClone.find("#state").text(stateText);94 var thisDate = new Date();95 thisDate.setTime(thisItem.declarationTime * 1000);96 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));97 $listItemClone.click(function (_event) {98 location.href = "hotelbx.html?id=" + $(this).attr("data-id");99 });100 $(".listContent").append($listItemClone.show());101 }102 });103 break;104 }else if(state == 20 || state == "20"){105 $.get(getZSFListUrl, { userId: jobInfo.structureUserId, limit: 10000, page: 1, order: "ecs", state: "2,3,6,8" }, function (_data) {106 if(_data.data.records.length==0){107 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");108 }109 for (var i in _data.data.records) {110 var thisItem = _data.data.records[i];111 var $listItemClone = $("#listItem").clone();112 $listItemClone.removeAttr("id");113 $listItemClone.attr("data-id", thisItem.id);114 $listItemClone.find(".listName").text(thisItem.number);115 $listItemClone.find(".money").text("Â¥" + thisItem.money);116 $listItemClone.find("#sj").text(thisItem.driverName);117 $listItemClone.find("#bxdType").text("ä½å®¿è´¹æ¥éå");118 var stateText;119 switch (thisItem.state) {120 case -2:121 stateText = "æªè¿å®¡";122 break;123 case -1:124 stateText = "æªè¿å®¡";125 break;126 case 0:127 stateText = "å¾
审æ¹";128 break;129 case 1:130 stateText = "å¾
å®¡æ ¸";131 break;132 case 2:133 stateText = "å¾
æ¥é";134 break;135 case 3:136 stateText = "å¾
æ款";137 break;138 case 4:139 stateText = "å¾
å¤ç";140 break;141 case 5:142 stateText = "å¨å¤ç";143 break;144 case 6:145 stateText = "å·²å®æ";146 break;147 case 7:148 stateText = "å·²è¿å®¡æ¹";149 break;150 }151 $listItemClone.find("#state").text(stateText);152 var thisDate = new Date();153 thisDate.setTime(thisItem.declarationTime * 1000);154 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));155 $listItemClone.click(function (_event) {156 location.href = "hotelbx.html?id=" + $(this).attr("data-id");157 });158 $(".listContent").append($listItemClone.show());159 }160 });161 break;162 }else{163 console.log("åºç°äºç¶æ");164 console.log(state);165 $.get(getZSFListUrl, { userId: jobInfo.structureUserId, limit: 10000, page: 1, order: "ecs", state: state }, function (_data) {166 if(_data.data.records.length==0){167 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");168 }169 for (var i in _data.data.records) {170 var thisItem = _data.data.records[i];171 var $listItemClone = $("#listItem").clone();172 $listItemClone.removeAttr("id");173 $listItemClone.attr("data-id", thisItem.id);174 $listItemClone.find(".listName").text(thisItem.number);175 $listItemClone.find(".money").text("Â¥" + thisItem.money);176 $listItemClone.find("#sj").text(thisItem.driverName);177 $listItemClone.find("#bxdType").text("ä½å®¿è´¹æ¥éå");178 var stateText;179 switch (thisItem.state) {180 case -2:181 stateText = "æªè¿å®¡";182 break;183 case -1:184 stateText = "æªè¿å®¡";185 break;186 case 0:187 stateText = "å¾
审æ¹";188 break;189 case 1:190 stateText = "å¾
å®¡æ ¸";191 break;192 case 2:193 stateText = "å¾
æ¥é";194 break;195 case 3:196 stateText = "å¾
æ款";197 break;198 case 4:199 stateText = "å¾
å¤ç";200 break;201 case 5:202 stateText = "å¨å¤ç";203 break;204 case 6:205 stateText = "å·²å®æ";206 break;207 case 7:208 stateText = "å·²è¿å®¡æ¹";209 break;210 }211 $listItemClone.find("#state").text(stateText);212 var thisDate = new Date();213 thisDate.setTime(thisItem.declarationTime * 1000);214 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));215 $listItemClone.click(function (_event) {216 location.href = "hotelbx.html?id=" + $(this).attr("data-id");217 });218 $(".listContent").append($listItemClone.show());219 }220 });221 break;222 }223 224 case "2":225 if (state == "-9") {226 $.get(getGQFListUrl, { userId: jobInfo.structureUserId, isSend:"1,2", limit: 10000, page: 1, order: "ecs", state: "3,8" }, function (_data) {227 console.log(_data)228 if(_data.data.records.length==0){229 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");230 }231 for (var i in _data.data.records) {232 var thisItem = _data.data.records[i];233 var $listItemClone = $("#listItem").clone();234 $listItemClone.removeAttr("id");235 $listItemClone.attr("data-id", thisItem.id);236 $listItemClone.find(".listName").text(thisItem.number);237 $listItemClone.find(".money").text("Â¥" + thisItem.money);238 $listItemClone.find("#sj").text(thisItem.driverName);239 $listItemClone.find("#bxdType").text("è¿æ¡¥è´¹æ¥éå");240 var stateText;241 switch (parseInt(thisItem.isSend)) {242 case 1:243 stateText = "æªå¯";244 break;245 case 2:246 stateText = "å·²å¯";247 break;248 default:249 break;250 }251 $listItemClone.find("#state").text(stateText);252 var thisDate = new Date();253 thisDate.setTime(thisItem.declarationTime * 1000);254 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));255 $listItemClone.click(function (_event) {256 location.href = "pontage.html?id=" + $(this).attr("data-id");257 });258 $(".listContent").append($listItemClone.show());259 }260 });261 break;262 }else if(state == 20||state == "20"){ //20çæ¶ååºè¯¥æ¥è¯¢ç¶æ为2,3,6,8263 console.log("æ¯20 ");264 $.get(getGQFListUrl, { userId: jobInfo.structureUserId, limit: 10000, page: 1, order: "ecs", state: "2,3,6,8" }, function (_data) {265 console.log(_data)266 if(_data.data.records.length==0){267 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");268 }269 for (var i in _data.data.records) {270 var thisItem = _data.data.records[i];271 var $listItemClone = $("#listItem").clone();272 $listItemClone.removeAttr("id");273 $listItemClone.attr("data-id", thisItem.id);274 $listItemClone.find(".listName").text(thisItem.number);275 $listItemClone.find(".money").text("Â¥" + thisItem.money);276 $listItemClone.find("#sj").text(thisItem.driverName);277 $listItemClone.find("#bxdType").text("è¿æ¡¥è´¹æ¥éå");278 var stateText;279 switch (thisItem.state) {280 case -2:281 stateText = "æªè¿å®¡";282 break;283 case -1:284 stateText = "æªè¿å®¡";285 break;286 case 0:287 stateText = "å¾
审æ¹";288 break;289 case 1:290 stateText = "å¾
å®¡æ ¸";291 break;292 case 2:293 stateText = "å¾
æ¥é";294 break;295 case 3:296 stateText = "å¾
æ款";297 break;298 case 4:299 stateText = "å¾
å¤ç";300 break;301 case 5:302 stateText = "å¨å¤ç";303 break;304 case 6:305 stateText = "å·²å®æ";306 break;307 case 7:308 stateText = "已审æ¹";309 break;310 }311 $listItemClone.find("#state").text(stateText);312 var thisDate = new Date();313 thisDate.setTime(thisItem.declarationTime * 1000);314 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));315 $listItemClone.click(function (_event) {316 location.href = "pontage.html?id=" + $(this).attr("data-id");317 });318 $(".listContent").append($listItemClone.show());319 }320 });321 break;322 }else{323 $.get(getGQFListUrl, { userId: jobInfo.structureUserId, limit: 10000, page: 1, order: "ecs", state: state }, function (_data) {324 console.log(_data)325 if(_data.data.records.length==0){326 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");327 }328 for (var i in _data.data.records) {329 var thisItem = _data.data.records[i];330 var $listItemClone = $("#listItem").clone();331 $listItemClone.removeAttr("id");332 $listItemClone.attr("data-id", thisItem.id);333 $listItemClone.find(".listName").text(thisItem.number);334 $listItemClone.find(".money").text("Â¥" + thisItem.money);335 $listItemClone.find("#sj").text(thisItem.driverName);336 $listItemClone.find("#bxdType").text("è¿æ¡¥è´¹æ¥éå");337 var stateText;338 switch (thisItem.state) {339 case -2:340 stateText = "æªè¿å®¡";341 break;342 case -1:343 stateText = "æªè¿å®¡";344 break;345 case 0:346 stateText = "å¾
审æ¹";347 break;348 case 1:349 stateText = "å¾
å®¡æ ¸";350 break;351 case 2:352 stateText = "å¾
æ¥é";353 break;354 case 3:355 stateText = "å¾
æ款";356 break;357 case 4:358 stateText = "å¾
å¤ç";359 break;360 case 5:361 stateText = "å¨å¤ç";362 break;363 case 6:364 stateText = "å·²å®æ";365 break;366 case 7:367 stateText = "已审æ¹";368 break;369 }370 $listItemClone.find("#state").text(stateText);371 var thisDate = new Date();372 thisDate.setTime(thisItem.declarationTime * 1000);373 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));374 $listItemClone.click(function (_event) {375 location.href = "pontage.html?id=" + $(this).attr("data-id");376 });377 $(".listContent").append($listItemClone.show());378 }379 });380 break;381 }382 case "3":383 if (state == "-9") {384 $.get(getNSFFListUrl, { userId: jobInfo.structureUserId, isSend: "1,2", limit: 10000, page: 1, order: "ecs", state: "8" }, function (_data) {385 console.log(_data);386 if(_data.page.records.length==0){387 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");388 }389 for (var i in _data.page.records) {390 var thisItem = _data.page.records[i];391 var $listItemClone = $("#listItem").clone();392 $listItemClone.removeAttr("id");393 $listItemClone.attr("data-id", thisItem.id);394 $listItemClone.find(".listName").text(thisItem.number);395 $listItemClone.find(".money").text((thisItem.money == null ? "ææ " : ("Â¥" + thisItem.money)));396 $listItemClone.find("#sj").text(thisItem.driverName);397 $listItemClone.find("#bxdType").text("å°¿ç´ è´¹æ¥éå");398 var stateText;399 switch (parseInt(thisItem.isSend)) {400 case 1:401 stateText = "æªå¯";402 break;403 case 2:404 stateText = "å·²å¯";405 break;406 default:407 break;408 }409 $listItemClone.find("#state").text(stateText);410 var thisDate = new Date();411 thisDate.setTime(thisItem.declarationTime * 1000);412 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));413 $listItemClone.click(function (_event) {414 location.href = "ureadeclare.html?id=" + $(this).attr("data-id");415 });416 $(".listContent").append($listItemClone.show());417 }418 });419 break;420 } else if(state == 20 || state == "20"){421 $.get(getNSFFListUrl, { userId: jobInfo.structureUserId, limit: 10000, page: 1, order: "ecs", state: "1,2,3,6,8" }, function (_data) {422 console.log(_data);423 if(_data.page.records.length==0){424 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");425 }426 for (var i in _data.page.records) {427 var thisItem = _data.page.records[i];428 var $listItemClone = $("#listItem").clone();429 $listItemClone.removeAttr("id");430 $listItemClone.attr("data-id",thisItem.id);431 $listItemClone.find(".listName").text(thisItem.number);432 $listItemClone.find(".money").text((thisItem.money == null ? "ææ " : ("Â¥" + thisItem.money)));433 $listItemClone.find("#sj").text(thisItem.driverName);434 $listItemClone.find("#bxdType").text("å°¿ç´ è´¹æ¥éå");435 var stateText;436 switch (thisItem.state) {437 case -2:438 stateText = "æªè¿å®¡";439 break;440 case -1:441 stateText = "æªè¿å®¡";442 break;443 case 0:444 stateText = "å¾
审æ¹";445 break;446 case 1:447 stateText = "å¾
å®¡æ ¸";448 break;449 case 2:450 stateText = "å¾
æ¥é";451 break;452 case 3:453 stateText = "å¾
æ款";454 break;455 case 4:456 stateText = "å¾
å¤ç";457 break;458 case 5:459 stateText = "å¨å¤ç";460 break;461 case 6:462 stateText = "å·²å®æ";463 break;464 case 7:465 stateText = "已审æ¹";466 break;467 }468 $listItemClone.find("#state").text(stateText);469 var thisDate = new Date();470 thisDate.setTime(thisItem.declarationTime * 1000);471 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));472 $listItemClone.click(function (_event) {473 location.href = "ureadeclare.html?id=" + $(this).attr("data-id");474 });475 $(".listContent").append($listItemClone.show());476 }477 });478 break;479 }else {480 $.get(getNSFFListUrl, { userId: jobInfo.structureUserId, limit: 10000, page: 1, order: "ecs", state: state }, function (_data) {481 console.log(_data);482 if(_data.page.records.length==0){483 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");484 }485 for (var i in _data.page.records) {486 var thisItem = _data.page.records[i];487 var $listItemClone = $("#listItem").clone();488 $listItemClone.removeAttr("id");489 $listItemClone.attr("data-id",thisItem.id);490 $listItemClone.find(".listName").text(thisItem.number);491 $listItemClone.find(".money").text((thisItem.money == null ? "ææ " : ("Â¥" + thisItem.money)));492 $listItemClone.find("#sj").text(thisItem.driverName);493 $listItemClone.find("#bxdType").text("å°¿ç´ è´¹æ¥éå");494 var stateText;495 switch (thisItem.state) {496 case -2:497 stateText = "æªè¿å®¡";498 break;499 case -1:500 stateText = "æªè¿å®¡";501 break;502 case 0:503 stateText = "å¾
审æ¹";504 break;505 case 1:506 stateText = "å¾
å®¡æ ¸";507 break;508 case 2:509 stateText = "å¾
æ¥é";510 break;511 case 3:512 stateText = "å¾
æ款";513 break;514 case 4:515 stateText = "å¾
å¤ç";516 break;517 case 5:518 stateText = "å¨å¤ç";519 break;520 case 6:521 stateText = "å·²å®æ";522 break;523 case 7:524 stateText = "已审æ¹";525 break;526 }527 $listItemClone.find("#state").text(stateText);528 var thisDate = new Date();529 thisDate.setTime(thisItem.declarationTime * 1000);530 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));531 $listItemClone.click(function (_event) {532 location.href = "ureadeclare.html?id=" + $(this).attr("data-id");533 });534 $(".listContent").append($listItemClone.show());535 }536 });537 break;538 }539 case "4":540 console.log("æ¯ç¬¬å个æµç¨");541 $.get(getSGListUrl, { userId: jobInfo.structureUserId, limit: 10000, page: 1, order: "ecs", state: "1,2,3,4,5" }, function (_data) {542 console.log(_data);543 if(_data.page.records.length==0){544 $(".listContent").append("<p style='text-align:center;font-size:20px;'>ææ¶æ²¡ææ°æ®ï¼</p>");545 }546 for (var i in _data.page.records) {547 var thisItem = _data.page.records[i];548 var $listItemClone = $("#listItem").clone();549 $listItemClone.removeAttr("id");550 $listItemClone.attr("data-id",thisItem.id);551 console.log(thisItem);552 switch(thisItem.natureAccident){553 case 1:554 $listItemClone.find(".money").text("è£
å¸äºæ
");555 break;556 case 2:557 $listItemClone.find(".money").text("æ°è½¦æ£æ¥");558 break;559 case 3:560 $listItemClone.find(".money").text("交éäºæ
");561 break;562 case 4:563 $listItemClone.find(".money").text("æ°è½¦è£
å¸");564 break;565 }566 $listItemClone.find(".listName").text(thisItem.number);567 $listItemClone.find("#sj").text(thisItem.name);568 $listItemClone.find("#bxdType").text("äºæ
ç³æ¥");569 var stateText;570 switch (thisItem.start) {571 case 1:572 stateText = "æªå¤ç";573 break;574 case 2:575 stateText = "æªè°åº¦";576 break;577 case 3:578 stateText = "å·²è°åº¦";579 break;580 case 4:581 stateText = "继ç»è·";582 break;583 case 5:584 stateText = "å·²å®æ";585 break;586 }587 $listItemClone.find("#state").text(stateText);588 if(thisItem.declarationTime==null){589 $listItemClone.find(".time").text("ææªå¤ç");590 }else{591 var thisDate = new Date();592 thisDate.setTime(thisItem.declarationTime * 1000);593 $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));594 }595 $listItemClone.click(function (_event) {596 location.href = "accidentdeclare.html?id=" + $(this).attr("data-id");597 });598 $(".listContent").append($listItemClone.show());599 }600 });601 break;602 }603 // switch($("#select1").val()){604 // case "ä½å®¿è´¹":605 // $.get(getZSFListUrl,{declarationUserId:userInfo.id,limit:10000,page:1,order:"ecs"},function(_data){606 // for(var i in _data.data.records){607 // var thisItem = _data.data.records[i];608 // var $listItemClone = $("#listItem").clone();609 // $listItemClone.removeAttr("id");610 // $listItemClone.attr("data-id",thisItem.id);611 // $listItemClone.find(".listName").text(thisItem.number);612 // $listItemClone.find(".money").text("Â¥"+thisItem.money);613 // $listItemClone.find("#sj").text(thisItem.driverName);614 // $listItemClone.find("#bxdType").text("ä½å®¿è´¹æ¥éå");615 // var stateText;616 // switch(thisItem.state){617 // case -2:618 // stateText = "æªè¿å®¡";619 // break;620 // case -1:621 // stateText = "æªè¿å®¡";622 // break;623 // case 0:624 // stateText = "å¾
审æ¹";625 // break;626 // case 1:627 // stateText = "å¾
å®¡æ ¸";628 // break;629 // case 2:630 // stateText = "å¾
æ¥é";631 // break;632 // case 3:633 // stateText = "å¾
æ款";634 // break;635 // case 4:636 // stateText = "å¾
å¤ç";637 // break;638 // case 5:639 // stateText = "å¨å¤ç";640 // break;641 // case 6:642 // stateText = "å·²å®æ";643 // break;644 // case 7:645 // stateText = "å·²è¿å®¡æ¹";646 // break;647 // }648 // $listItemClone.find("#state").text(stateText);649 // var thisDate = new Date();650 // thisDate.setTime(thisItem.declarationTime*1000);651 // $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));652 // $listItemClone.click(function(_event){653 // location.href = "hotelbx.html?id="+$(this).attr("data-id");654 // });655 // $(".listContent").append($listItemClone.show());656 // }657 // });658 // break;659 // case "è¿æ¡¥è´¹":660 // $.get(getGQFListUrl,{declarationUserId:userInfo.id,limit:10000,page:1,order:"ecs"},function(_data){661 // for(var i in _data.data.records){662 // var thisItem = _data.data.records[i];663 // var $listItemClone = $("#listItem").clone();664 // $listItemClone.removeAttr("id");665 // $listItemClone.attr("data-id",thisItem.id);666 // $listItemClone.find(".listName").text(thisItem.number);667 // $listItemClone.find(".money").text("Â¥"+thisItem.money);668 // $listItemClone.find("#sj").text(thisItem.driverName);669 // $listItemClone.find("#bxdType").text("è¿æ¡¥è´¹æ¥éå");670 // var stateText;671 // switch(thisItem.state){672 // case -2:673 // stateText = "æªè¿å®¡";674 // break;675 // case -1:676 // stateText = "æªè¿å®¡";677 // break;678 // case 0:679 // stateText = "å¾
审æ¹";680 // break;681 // case 1:682 // stateText = "å¾
å®¡æ ¸";683 // break;684 // case 2:685 // stateText = "å¾
æ¥é";686 // break;687 // case 3:688 // stateText = "å¾
æ款";689 // break;690 // case 4:691 // stateText = "å¾
å¤ç";692 // break;693 // case 5:694 // stateText = "å¨å¤ç";695 // break;696 // case 6:697 // stateText = "å·²å®æ";698 // break;699 // case 7:700 // stateText = "已审æ¹";701 // break;702 // }703 // $listItemClone.find("#state").text(stateText);704 // var thisDate = new Date();705 // thisDate.setTime(thisItem.declarationTime*1000);706 // $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));707 // $listItemClone.click(function(_event){708 // location.href = "pontage.html?id="+$(this).attr("data-id");709 // });710 // $(".listContent").append($listItemClone.show());711 // }712 // });713 // break;714 // case "å°¿ç´ è´¹":715 // $.get(getNSFFListUrl,{declarationUserId:userInfo.id,limit:10000,page:1,order:"ecs"},function(_data){716 // for(var i in _data.page.records){717 // var thisItem = _data.page.records[i];718 // var $listItemClone = $("#listItem").clone();719 // $listItemClone.removeAttr("id");720 // $listItemClone.attr("data-id",thisItem.id);721 // $listItemClone.find(".listName").text(thisItem.number);722 // $listItemClone.find(".money").text("Â¥"+(thisItem.money==null?"ææ ":thisItem.money));723 // $listItemClone.find("#sj").text(thisItem.driverName);724 // $listItemClone.find("#bxdType").text("å°¿ç´ è´¹æ¥éå");725 // var stateText;726 // switch(thisItem.state){727 // case -2:728 // stateText = "æªè¿å®¡";729 // break;730 // case -1:731 // stateText = "æªè¿å®¡";732 // break;733 // case 0:734 // stateText = "å¾
审æ¹";735 // break;736 // case 1:737 // stateText = "å¾
å®¡æ ¸";738 // break;739 // case 2:740 // stateText = "å¾
æ¥é";741 // break;742 // case 3:743 // stateText = "å¾
æ款";744 // break;745 // case 4:746 // stateText = "å¾
å¤ç";747 // break;748 // case 5:749 // stateText = "å¨å¤ç";750 // break;751 // case 6:752 // stateText = "å·²å®æ";753 // break;754 // case 7:755 // stateText = "å·²è¿å®¡";756 // break;757 // }758 // $listItemClone.find("#state").text(stateText);759 // var thisDate = new Date();760 // thisDate.setTime(thisItem.declarationTime*1000);761 // $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));762 // $listItemClone.click(function(_event){763 // location.href = "ureadeclare.html?id="+$(this).attr("data-id");764 // });765 // $(".listContent").append($listItemClone.show());766 // }767 // });768 // break;769 // case "äºæ
ç³æ¥":770 // $.get(getSGListUrl,{declarationUserId:userInfo.id,limit:10000,page:1,order:"ecs"},function(_data){771 // for(var i in _data.page.records){772 // var thisItem = _data.page.records[i];773 // var $listItemClone = $("#listItem").clone();774 // $listItemClone.removeAttr("id");775 // $listItemClone.attr("data-id",thisItem.id);776 // $listItemClone.find(".listName").text(thisItem.number);777 // $listItemClone.find(".money").hide();778 // $listItemClone.find("#sj").text(thisItem.driverName);779 // $listItemClone.find("#bxdType").text("äºæ
ç³è¯·å");780 // var stateText;781 // switch(thisItem.state){782 // case -2:783 // stateText = "æªè¿å®¡";784 // break;785 // case -1:786 // stateText = "æªè¿å®¡";787 // break;788 // case 0:789 // stateText = "å¾
审æ¹";790 // break;791 // case 1:792 // stateText = "å¾
å®¡æ ¸";793 // break;794 // case 2:795 // stateText = "å¾
æ¥é";796 // break;797 // case 3:798 // stateText = "å¾
æ款";799 // break;800 // case 4:801 // stateText = "å¾
å¤ç";802 // break;803 // case 5:804 // stateText = "å¨å¤ç";805 // break;806 // case 6:807 // stateText = "å·²å®æ";808 // break;809 // case 7:810 // stateText = "å·²è¿å®¡";811 // break;812 // }813 // $listItemClone.find("#state").text(stateText);814 // var thisDate = new Date();815 // thisDate.setTime(thisItem.declarationTime*1000);816 // $listItemClone.find(".time").text(thisDate.Format("yyyy-MM-dd hh:mm"));817 // $listItemClone.click(function(_event){818 // location.href = "accidentdeclare.html?id="+$(this).attr("data-id");819 // });820 // $(".listContent").append($listItemClone.show());821 // }822 // });823 // break;824 // }825 }...
FriendState.js
Source:FriendState.js
1import React, { useRef, useState, useEffect } from "react";2import { useSelector } from "react-redux";3import styled from "styled-components";4import { updateUser } from "../../../util/firebase";5import { friendStateObj } from "../../../util/friendStateObj";6const RequestBtnDiv = styled.div`7 display: flex;8 flex-direction: column;9 align-items: center;10 position: absolute;11 bottom: 0px;12 left: 620px;13 @media (max-width: 1180px) {14 left: 500px;15 }16 @media (max-width: 932px) {17 left: calc(56% + 80px);18 }19 @media (max-width: 500px) {20 left: calc(56% + 20px);21 }22`;23const RequestBtn = styled.div`24 width: 70px;25 height: 70px;26 font-size: 36px;27 border-radius: 50%;28 display: flex;29 cursor: pointer;30 @media (max-width: 500px) {31 width: 50px;32 height: 50px;33 font-size: 20px;34 }35`;36const FontIcon = styled.i`37 margin: auto;38`;39const StateText = styled.div`40 width: 125px;41 text-align: center;42 font-size: 16px;43 margin-top: 2px;44 color: white;45`;46const RemoveRequest = styled.div`47 font-size: 20px;48 position: absolute;49 right: 0;50 bottom: 20px;51 cursor: pointer;52 :hover {53 color: #ae0000;54 }55`;56export default function FriendState({ userInfo }) {57 const requestBtnRef = useRef();58 const stateTextRef = useRef();59 const [friendState, setFriendState] = useState("none");60 const myInfo = useSelector((state) => state.userInfo);61 const { friends: myFriends } = myInfo;62 useEffect(() => {63 if (myFriends) {64 const friendObj = myFriends.filter(({ id }) => id === userInfo.id);65 setFriendState(66 friendObj.length &&67 Object.keys(friendStateObj).includes(friendObj[0].condition)68 ? friendObj[0].condition69 : "none"70 );71 }72 }, [myFriends, userInfo.id]);73 function handleRequestBtn(e, type) {74 const btnStyle = requestBtnRef.current.style;75 const stateText = stateTextRef.current;76 const stateChange = friendStateObj[friendState].state_change.my_state;77 if (type === "leave") {78 btnStyle.color = friendStateObj[friendState].style.color;79 btnStyle.backgroundColor =80 friendStateObj[friendState].style.backgroundColor;81 btnStyle.outline = friendStateObj[friendState].style.outline;82 stateText.innerText = friendStateObj[friendState].text;83 stateText.style.color = "white";84 } else if (type === "enter") {85 btnStyle.color = friendStateObj[stateChange].style.color;86 btnStyle.backgroundColor = friendStateObj[friendState].color_change;87 btnStyle.outline = friendStateObj[stateChange].style.outline;88 stateText.innerText = friendStateObj[friendState].text_change;89 stateText.style.color = friendStateObj[friendState].color_change;90 }91 }92 const createUpdateBody = (myInfo, friendInfo, friendCondition, stateFrom) => [93 ...myInfo.friends.filter((friend) => friend.id !== friendInfo.id),94 {95 id: friendInfo.id,96 condition: friendStateObj[friendCondition].state_change[stateFrom],97 },98 ];99 function handleFriendState() {100 const style = requestBtnRef.current.style;101 const stateText = stateTextRef.current;102 const stateChange = friendStateObj[friendState].state_change.my_state;103 style.color = friendStateObj[stateChange].style.color;104 style.backgroundColor = friendStateObj[stateChange].style.backgroundColor;105 style.outline = friendStateObj[stateChange].style.outline;106 stateText.style.color = "white";107 setFriendState(stateChange);108 updateUser(myInfo.id, {109 friends: createUpdateBody(myInfo, userInfo, friendState, "my_state"),110 });111 updateUser(userInfo.id, {112 friends: createUpdateBody(userInfo, myInfo, friendState, "friend_state"),113 });114 }115 function handleRemoveRequesState() {116 const stateText = stateTextRef.current;117 stateText.style.color = "white";118 setFriendState("none");119 updateUser(myInfo.id, {120 friends: createUpdateBody(myInfo, userInfo, "remove", "my_state"),121 });122 updateUser(userInfo.id, {123 friends: createUpdateBody(userInfo, myInfo, "remove", "friend_state"),124 });125 }126 function handleRemoveRequest(e, type) {127 const stateText = stateTextRef.current;128 if (type === "enter") {129 stateText.innerText = "remove request";130 stateText.style.color = "#AE0000";131 }132 }133 return (134 <RequestBtnDiv>135 <RequestBtn136 ref={requestBtnRef}137 style={friendStateObj[friendState].style}138 onMouseEnter={(e) => handleRequestBtn(e, "enter")}139 onMouseLeave={(e) => handleRequestBtn(e, "leave")}140 onClick={handleFriendState}141 >142 {friendState === "confirmed" ? (143 <FontIcon className="fas fa-user-friends" />144 ) : (145 <FontIcon className="fas fa-user-plus" />146 )}147 </RequestBtn>148 <StateText ref={stateTextRef}>149 {friendStateObj[friendState].text}150 </StateText>151 {friendState === "get_request" ? (152 <RemoveRequest153 onMouseEnter={(e) => handleRemoveRequest(e, "enter")}154 onMouseLeave={(e) => handleRequestBtn(e, "leave")}155 onClick={handleRemoveRequesState}156 >157 <i className="fas fa-minus-circle" />158 </RemoveRequest>159 ) : (160 <></>161 )}162 </RequestBtnDiv>163 );...
order.js
Source:order.js
1/*2* addOrder3* getOrderById4* getOrdersByUserId5*/6var db = require('../db/db.js');7var moment = require('moment');8module.exports = function (router) {9 //è·åç¨æ·é»è®¤å°å10 router.get('/order/getNewestAddress',function (req,res,next) {11 var userId = req.query.userId;12 db.getDefaultAddr(userId,function (address) {13 if(address == null){14 res.send({code:1});15 }else{16 res.send({17 code:0,18 data:address19 })20 }21 })22 });23 //åæ°æ®åºæ·»å 订å24 router.post('/order/createOrder',function (req,res,next) {25 var order = req.body.order;26 order.state = 3; //设置订åçç¶æ27 db.addOrder(order,function (result) {28 res.send({29 code:0,30 data:result31 })32 })33 });34 //订åå®æ页é¢35 router.get('/order/detail/:id',function (req,res,next) {36 var id = req.params.id;37 console.log(id);38 db.getOrderById(id,function (order) {39 var stateText = null;40 switch(order.state) {41 case 0:42 stateText = 'å¾
æ¯ä»';43 break;44 case 1:45 stateText = 'å·²ä»æ¬¾';46 break;47 case 2:48 stateText = '';49 break;50 case 3:51 stateText = 'å·²å®æ';52 break;53 case 4:54 stateText = 'åºéºæå';55 break;56 case 5:57 stateText = ' å家已æ¥å';58 break;59 case 6:60 stateText = 'å·²éå';61 break;62 case 7:63 stateText = 'æªæ¯ä»çåæ¶è®¢å';64 break;65 case 8:66 stateText = '订åå¼å¸¸';67 break;68 case 9:69 stateText = 'éåä¸';70 break;71 case 10:72 stateText = 'å家æç»éå';73 }74 //æ·»å ä¸ä¸ªå±æ§ï¼å¨é¡µé¢ä¸æ¾ç¤º75 order.stateText = stateText;76 //ä¿®æ¹ä¸ä¸ªå·²æçå±æ§å¼ï¼å¿
é¡»éè¿_docå±æ§æä½ï¼77 order._doc.arrive_time = moment(order.arrive_time).format('YYYY-MM-DD HH:mm');78 order._doc.detail = JSON.parse(order.detail);79 res.render('orderDetail',{data:order});80 })81 });...
Using AI Code Generation
1var tracetest = require('./tracetest.js');2tracetest.StateText("Hello World");3exports.StateText = function(text) {4 console.log(text);5}6var tracetest = require('./tracetest.js');7tracetest.StateText("Hello World");8var tracetest = require('./tracetest.js');9tracetest.StateText("Hello World");10var tracetest = require('./tracetest.js');11tracetest.StateText("Hello World");
Using AI Code Generation
1var trace = require('./tracetest');2trace.StateText('Hello World');3exports.StateText = function (text) {4 console.log(text);5}6var trace = require('./tracetest.js');
Using AI Code Generation
1var tracetest = require('tracetest');2tracetest.StateText('test.js is running');3console.log('test.js is running');4var tracetest = require('tracetest');5tracetest.StateText('test2.js is running');6console.log('test2.js is running');7var tracetest = require('tracetest');8tracetest.StateText('test3.js is running');9console.log('test3.js is running');10var tracetest = require('tracetest');11tracetest.StateText('test4.js is running');12console.log('test4.js is running');13var tracetest = require('tracetest');14tracetest.StateText('test5.js is running');15console.log('test5.js is running');16var tracetest = require('tracetest');17tracetest.StateText('test6.js is running');18console.log('test6.js is running');19var tracetest = require('tracetest');20tracetest.StateText('test7.js is running');21console.log('test7.js is running');22var tracetest = require('tracetest');23tracetest.StateText('test8.js is running');24console.log('test8.js is running');25var tracetest = require('tracetest');26tracetest.StateText('test9.js is running');27console.log('test9.js is running');28var tracetest = require('tracetest');29tracetest.StateText('test10.js is running');30console.log('test10.js is running');
Using AI Code Generation
1var tracetest = require('tracetest');2var stateText = tracetest.stateText(2);3console.log(stateText);4module.exports = {5 stateText: function(state) {6 switch (state) {7 return 'Start';8 return 'Middle';9 return 'End';10 return 'Unknown';11 }12 }13};14Operator Description = Used to assign a value to a variable. + Used to add together two values. - Used to subtract one value from another. * Used to multiply two values. / Used to divide one value by another. % Used to find the remainder of a division operation. ++ Used to increment a variable by 1. -- Used to decrement a variable by 1. == Used to compare two values (equal to). === Used to compare two values, including type (equal value and equal type). != Used to compare two values (not equal to). !== Used to compare two values
Using AI Code Generation
1var tracetest = require('tracetest');2var tracetestObj = new tracetest();3tracetestObj.StateText('test', function(err, data) {4 if (err) {5 console.log(err);6 }7 else {8 console.log(data);9 }10});11var tracetest = require('tracetest');12var tracetestObj = new tracetest();13tracetestObj.StateText('test', function(err, data) {14 if (err) {15 console.log(err);16 }17 else {18 console.log(data);19 }20});21var tracetest = require('tracetest');22var tracetestObj = new tracetest();23tracetestObj.StateText('test', function(err, data) {24 if (err) {25 console.log(err);26 }27 else {28 console.log(data);29 }30});31var tracetest = require('tracetest');32var tracetestObj = new tracetest();33tracetestObj.StateText('test', function(err, data) {34 if (err) {35 console.log(err);36 }37 else {38 console.log(data);39 }40});41var tracetest = require('tracetest');42var tracetestObj = new tracetest();43tracetestObj.StateText('test', function(err, data) {44 if (err) {45 console.log(err);46 }47 else {48 console.log(data);49 }50});51var tracetest = require('tracetest');52var tracetestObj = new tracetest();53tracetestObj.StateText('test', function(err, data) {54 if (err) {55 console.log(err);56 }57 else {58 console.log(data);59 }60});61var tracetest = require('tracetest');62var tracetestObj = new tracetest();
Using AI Code Generation
1var tracetest = require('tracetest');2var st = tracetest.StateText;3console.log('StateText: ' + st);4var StateText = 'Ready';5exports.StateText = StateText;6exports.StateText = 'Ready';7exports.LogMessage = function(msg) {8 console.log(msg);9}10var tracetest = require('tracetest');11var st = tracetest.StateText;12var lm = tracetest.LogMessage;13console.log('StateText: ' + st);14lm('LogMessage called');
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!