How to use getStorage method in Cypress

Best JavaScript code snippet using cypress

map.js

Source:map.js Github

copy

Full Screen

1var juli_elc=$api.getStorage('juli_el'+$api.getStorage('usid'));2var jingdu_elc=$api.getStorage('jingdu_el'+$api.getStorage('usid'));3var shijian_elc=$api.getStorage('shijian_el'+$api.getStorage('usid'));4 // var trace_interval = "30s"; //定位最小间隔时间5 // var trace_accuracy = "100m"; //定位最小间隔距离6// var trace_filter = 10; //过滤定位精度7 var trace_interval = shijian_elc;8 var trace_accuracy = juli_elc+"m"; //定位最小间隔距离9 var trace_filter = jingdu_elc; //过滤定位精度10// console.log(113);11// console.log(trace_filter);12// console.log(trace_accuracy);13// console.log(trace_interval);14 //彩砂船主定位15// function opendw()16// {17//18// $("#sdwa").css("display","none");19// $("#sdwa1").css("display","block");20// api.toast({21// msg: '开始定位',22// duration: 2000,23// location: 'middle'24// });25// console.log(1);26// $api.setStorage('sy_uid',1);27// getLocation3(trace_interval, trace_accuracy, trace_filter);28// }29//30// function opendw1()31// {32//33// $("#sdwa").css("display","block");34// $("#sdwa1").css("display","none");35// api.toast({36// msg: '结束定位',37// duration: 2000,38// location: 'middle'39// });40// $api.rmStorage('sy_uid');41// getLocation3(trace_interval, trace_accuracy, trace_filter);42// //api.stopLocation();43// // var reportLocation = api.require('reportLocation');44// // reportLocation.stopLocation();45// }46 function startAutoJoin() {47 //凡是涉及到偏好设置的内容,第一次都要给它一个默认值,然后再保存48 //1.保存偏好设置49 // setPrefers();50 //2.同步读取偏好设置51 // getPrefers();52 //3.带参数自动执行GPS定位53 getLocation3(trace_interval, trace_accuracy, trace_filter);54 }55 function getLocation3(trace_interval, trace_accuracy, trace_filter) {56 //console.log($api.getStorage('ucsc06ownerId'));57 //console.log("进入方法 getLocation3");58 var juli_elc=$api.getStorage('juli_el'+$api.getStorage('usid'));59 var jingdu_elc=$api.getStorage('jingdu_el'+$api.getStorage('usid'));60 var shijian_elc=$api.getStorage('shijian_el'+$api.getStorage('usid'));61 var trace_interval = shijian_elc;62 var trace_accuracy = juli_elc+"m"; //定位最小间隔距离63 var trace_filter = jingdu_elc; //过滤定位精度64 // console.log(trace_filter);65 // console.log(trace_accuracy);66 // console.log(trace_interval);67 reportLocation.startLocation({68 accuracy: 'hight_accuracy', //取值范围:1.battery_saving:低功耗模式(65) 2.device_sensors:仅设备(Gps)模式(165) 3.hight_accuracy:高精度模式(69) 对应android过滤定位精度69 filter: trace_filter, //(可选项)位置更新所需最小距离(单位米) 对应android 定位最小间隔距离70 autoStop: false,71 report: {72 uid: '0123456789', //字符串类型;上报数据时携带的用户id(用于服务器端唯一标识用户)73 url: functionURL + 'sandBoatScreen/update.json',74 interval: 3,75 type: 'post'76 }77 }, function(ret) {78 if (ret.status) {79 api.getPrefs({80 key: 'loginStatus'81 }, function(retsa, err) {82 //当偏好设置尚未设置或者曾设置后被移除后,返回值(ret.value)均为空。83 var val = retsa.value;84 console.log("aaab"+val);85 // console.log(JSON.stringify(val));86 if (val =="") {87$api.rmStorage('sy_uid');88 // reportLocation.stopLocation();89 }90 });91 // alert(JSON.stringify(ret));92 console.log(JSON.stringify(ret));93 var bd09togcj02 = coordtransform.bd09togcj02(ret.loc.lon, ret.loc.lat);94 // console.log("国测:" + JSON.stringify(bd09togcj02));95 //国测局坐标转wgs84坐标96 var gcj02towgs84 = coordtransform.gcj02towgs84(bd09togcj02[0], bd09togcj02[1]);97 // console.log("GPS:" + JSON.stringify(gcj02towgs84));98 // console.log(bd09togcj02);99 // console.log($api.getStorage('ucsc06id'));100 if($api.getStorage('sy_uid')==1){101 api.ajax({102 url: functionURL + 'sandBoatScreen/update.json',103 method: 'post',104 dataType: 'text',105 headers:106 {107 login_token:$api.getStorage('loginToken')108 },109 data: {110 values: {111 uid: $api.getStorage('ucsc06id'), //采砂船id,到时候传参数112 longitude: gcj02towgs84[0], //经度113 latitude: gcj02towgs84[1] //纬度114 }115 }116 }, function(ret, err) {117 if (ret) {118 //alert(JSON.stringify(ret));119 var date = new Date();120 console.log(JSON.stringify(ret));121 } else {122 //alert(JSON.stringify(err));123 console.log(JSON.stringify(err));124 getLocation3(trace_interval, trace_accuracy, trace_filter);125 // resumeLocationJoin(); //ajax提交发生错误重启定位,如网络错误等126 }127 });128}129else {130 console.log("首页未定位");131}132 } else {133 //alert(JSON.stringify(err));134 console.log(JSON.stringify(err));135 getLocation3(trace_interval, trace_accuracy, trace_filter);136 // resumeLocationJoin(); //获取定位信息错误137 }138 });139 // api.startLocation({140 // accuracy: trace_accuracy,// 间隔距离141 // filter: trace_filter,//过滤精度142 // autoStop: false143 // }, function(ret, err) {144 // if (ret && ret.status) {145 // // alert(JSON.stringify(ret));146 // console.log(JSON.stringify(ret));147 // api.ajax({148 // url: functionURL + 'sandBoatScreen/update.json',149 // //url: 'http://47.96.165.26:8080/ncgctest/sandBoatScreen/update.json', //采砂船上传经纬度150 // method: 'post',151 // dataType: 'text',152 // data: {153 // values: {154 // uid: $api.getStorage('ucsc06id'), //采砂船id,到时候传参数155 // longitude: ret.longitude, //经度156 // latitude: ret.latitude //纬度157 // }158 // }159 // }, function(ret, err) {160 // if (ret) {161 // //alert(JSON.stringify(ret));162 // var date = new Date();163 // // console.log(date.toLocaleTimeString() + "---" + JSON.stringify(ret));164 // } else {165 // //alert(JSON.stringify(err));166 // resumeLocationJoin(); //ajax提交发生错误重启定位,如网络错误等167 // }168 // });169 // } else {170 // // alert(JSON.stringify(err));171 // resumeLocationJoin(); //GPS定位发生错误重启定位,如断网等172 // }173 // });174 }175//运沙船上传位置176 function getLocation4(trace_interval, trace_accuracy, trace_filter,uid) {177 //console.log("进入方法 getLocation3");178//alert("12333");179 var juli_elc=$api.getStorage('juli_el'+$api.getStorage('usid'));180 var jingdu_elc=$api.getStorage('jingdu_el'+$api.getStorage('usid'));181 var shijian_elc=$api.getStorage('shijian_el'+$api.getStorage('usid'));182 var trace_interval = shijian_elc;183 var trace_accuracy = juli_elc+"m"; //定位最小间隔距离184 var trace_filter = jingdu_elc; //过滤定位精度185 console.log(trace_filter);186 console.log(trace_accuracy);187 console.log(trace_interval);188console.log("1234f");189console.log(uid);190var uid=$api.getStorage('yx_uid');191//var uid=321;192 var reportLocation;193 reportLocation = api.require('reportLocation');194 reportLocation.startLocation({195 accuracy: 'hight_accuracy', //取值范围:1.battery_saving:低功耗模式(65) 2.device_sensors:仅设备(Gps)模式(165) 3.hight_accuracy:高精度模式(69) 对应android过滤定位精度196 filter: trace_filter, //(可选项)位置更新所需最小距离(单位米) 对应android 定位最小间隔距离197 autoStop: false,198 report: {199 uid: '0123456789', //字符串类型;上报数据时携带的用户id(用于服务器端唯一标识用户)200 url: functionURL + 'boatPositionScreen/add.json',201 interval: trace_interval,202 type: 'post'203 }204 }, function(ret) {205 if (ret.status) {206 api.getPrefs({207 key: 'loginStatus'208 }, function(retsa, err) {209 //当偏好设置尚未设置或者曾设置后被移除后,返回值(ret.value)均为空。210 var val = retsa.value;211 console.log("aaaa"+val);212 // console.log(JSON.stringify(val));213 if (val =="") {214 reportLocation.stopLocation();215 }216 });217 var bd09togcj02 = coordtransform.bd09togcj02(ret.loc.lon, ret.loc.lat);218 // console.log("国测:" + JSON.stringify(bd09togcj02));219 //国测局坐标转wgs84坐标220 var gcj02towgs84 = coordtransform.gcj02towgs84(bd09togcj02[0], bd09togcj02[1]);221 // console.log("GPS:" + JSON.stringify(gcj02towgs84));222 //alert(JSON.stringify(ret));223 console.log(JSON.stringify(ret));224 api.ajax({225 url: functionURL + 'boatPositionScreen/add.json',226 method: 'post',227 dataType: 'text',228 headers:229 {230 login_token:$api.getStorage('loginToken')231 },232 data: {233 values: {234 waybillId: uid, //订单ID235 longitude: gcj02towgs84[0], //经度236 latitude: gcj02towgs84[1] //纬度237 // longitude: ret.loc.lon, //经度238 // latitude: ret.loc.lat //纬度239 }240 }241 }, function(ret, err) {242 if (ret) {243 var date = new Date();244 console.log(date.toLocaleTimeString() + "---" + JSON.stringify(ret));245 } else {246 //alert(JSON.stringify(err));247 console.log(JSON.stringify(err));248 getLocation4(trace_interval, trace_accuracy, trace_filter,uid);249 }250 });251 } else {252 //alert(JSON.stringify(err));253 console.log(JSON.stringify(err));254 getLocation4(trace_interval, trace_accuracy, trace_filter,uid);255 }256 });257 // api.startLocation({258 // accuracy: trace_accuracy,// 间隔距离259 // filter: trace_filter,//过滤精度260 // autoStop: false261 // }, function(ret, err) {262 // if (ret && ret.status) {263 // //alert(JSON.stringify(ret));264 // console.log(JSON.stringify(ret));265 // api.ajax({266 // url: functionURL + 'boatPositionScreen/add.json',267 // //url: 'http://47.96.165.26:8080/ncgctest/sandBoatScreen/update.json', //采砂船上传经纬度268 // method: 'post',269 // dataType: 'text',270 // data: {271 // values: {272 // waybillId: uid, //订单ID273 // longitude: ret.longitude, //经度274 // latitude: ret.latitude //纬度275 // }276 // }277 // }, function(ret, err) {278 // if (ret) {279 // //alert(JSON.stringify(ret));280 // var date = new Date();281 // console.log(date.toLocaleTimeString() + "---" + JSON.stringify(ret));282 // } else {283 // //alert(JSON.stringify(err));284 // getLocation4(trace_interval, trace_accuracy, trace_filter,uid);285 // //resumeLocationJoin(); //ajax提交发生错误重启定位,如网络错误等286 // }287 // });288 // } else {289 // //alert(JSON.stringify(err));290 // //resumeLocationJoin(); //GPS定位发生错误重启定位,如断网等291 // getLocation4(trace_interval, trace_accuracy, trace_filter,uid);292 // }293 // });294 }295 //1.如果定位功能异常,重新执行自动定位296 //2.如果ajax请求网络异常297 function resumeLocation() {298 //api.stopLocation();//先停止GPS定位299 startAuto();300 }301 function resumeLocationJoin() {302 //api.stopLocation();//先停止GPS定位303 startAutoJoin();304 }305 // function setPrefers() {306 // //巡查轨迹307 // //定位最小间隔时间 0s 5s 10s 30s308 // //此参数暂时无效309 // api.setPrefs({310 // key: 'trace_interval',311 // value: '30s' //先默认30秒312 // });313 // //定位最小间隔距离 0米 10米 50米 100米 500米314 // api.setPrefs({315 // key: 'trace_accuracy',316 // value: '100m' //先默认500米317 // });318 // //过滤定位精度 0米 10米 30米 不过滤319 // api.setPrefs({320 // key: 'trace_filter',321 // value: '10' //先默认10米322 // });323 // //照片大小 512K 1M 2M 原图324 // api.setPrefs({325 // key: 'trace_photoSize',326 // value: '512K' //先默认512K327 // });328 // }329 //330 // //同步读取偏好设置331 // function getPrefers() {332 // //异步返回结果:333 // api.getPrefs({334 // key: 'trace_interval',335 // sync: true336 // }, function(ret, err) {337 // trace_interval = ret.value;338 // console.log("trace_interval:" + trace_interval);339 // });340 //341 // api.getPrefs({342 // key: 'trace_accuracy',343 // sync: true344 // }, function(ret, err) {345 // trace_accuracy = ret.value;346 // console.log("trace_accuracy:" + trace_accuracy);347 // });348 //349 // api.getPrefs({350 // key: 'trace_filter',351 // sync: true352 // }, function(ret, err) {353 // trace_filter = ret.value;354 // console.log("trace_filter:" + trace_filter);355 // });356 //357 // api.getPrefs({358 // key: 'trace_photoSize',359 // sync: true360 // }, function(ret, err) {361 // trace_photoSize = ret.value;362 // console.log("trace_photoSize:" + trace_photoSize);363 // });364 //365 // console.log("读取偏好设置成功...");366 // }367 function canConfirmBill(fromLon, fromLat, toLon, toLat) {368 // console.log(fromLon);369 // console.log(fromLat);370 // console.log(toLon);371 // console.log(toLat);372 var flag = false;373 if (fromLon > 0 && fromLat > 0 && toLon > 0 && toLat > 0) {374 var jd = 102834.74258026089786013677476285; //(米/每经度)375 var wd = 111712.69150641055729984301412873; //(米/每纬度)376 var x = Math.abs((fromLon - toLon) * jd);377 var y = Math.abs((fromLat - toLat) * wd);378 var d = Math.sqrt((x * x + y * y)); //最终2点距离379 console.log(d);380 console.log("x:" + x + "---" + "y:" + y + "---" + "d:" + d + "---");381 if (d <= 2000)382 flag = true;383 console.log("flag:" + flag);384 return flag;385 } else {386 console.log("flag:" + flag);387 return flag;388 }389 }390function getinfo_jl(sid)391{392 console.log(sid);393console.log("33");394 var xx;//运沙船经度395 var yy;396 var sx;//砂场经度397 var sy;398var scid='';//砂场ID399 var order_detail_el=document.getElementById("order_detail");400 api.ajax({401 url: functionURL + 'wayBillScreen/getListForApp.json',402 method: 'get',403 headers:404 {405 login_token:$api.getStorage('loginToken')406 },407 data: {408 values: {409 uid: sid410 },411 files: {412 file: 'fs://a.gif'413 }414 }415 }, function(ret, err) {416 if (ret) {417 if( ret['data'].length>0){418 var item = ret['data'][0];419 xx=item['longitude']420 xy=item['latitude'];421 scid=item['toDistrict'];422 console.log(scid);423 api.ajax({424 url: functionURL + 'sandPlantScreen/find.json',425 method: 'get',426 headers:427 {428 login_token:$api.getStorage('loginToken')429 },430 data: {431 values: {432 uid: scid433 },434 files: {435 file: 'fs://a.gif'436 }437 }438 }, function(res, err) {439 if (res) {440 sx=res['longitude']441 sy=res['latitude'];442 // if(canConfirmBill(xx, xy, sx, sy))443 // {444 arr_da();445 // }446 // else {447 // api.toast({448 // msg: '未到达目标砂厂附近,暂时不能卸货',449 // duration: 2000,450 // location: 'middle'451 // });452 // console.log(123);453 // console.log(sid);454 // }455 }456 });457 }458 }459 });460}461//砂厂收货员收货462function canConfirmBill_s(fromLon, fromLat, toLon, toLat) {463// console.log(fromLon);464// console.log(fromLat);465// console.log(toLon);466// console.log(toLat);467 var flag = false;468 if (fromLon > 0 && fromLat > 0 && toLon > 0 && toLat > 0) {469 var jd = 102834.74258026089786013677476285; //(米/每经度)470 var wd = 111712.69150641055729984301412873; //(米/每纬度)471 var x = Math.abs((fromLon - toLon) * jd);472 var y = Math.abs((fromLat - toLat) * wd);473 var d = Math.sqrt((x * x + y * y)); //最终2点距离474 console.log(d);475 console.log("x:" + x + "---" + "y:" + y + "---" + "d:" + d + "---");476 if (d <= 1000)477 flag = true;478 console.log("flag:" + flag);479 return flag;480 } else {481 console.log("flag:" + flag);482 return flag;483 }484 }485function getinfo_shj_sh(uid)486{487 console.log(uid);488 var xx;489 var xy;490 var sx;491 var sy;492 var juli_elc=$api.getStorage('juli_el'+$api.getStorage('usid'));493 var jingdu_elc=$api.getStorage('jingdu_el'+$api.getStorage('usid'));494 var shijian_elc=$api.getStorage('shijian_el'+$api.getStorage('usid'));495 var trace_interval = shijian_elc;496 var trace_accuracy = juli_elc+"m"; //定位最小间隔距离497 var trace_filter = jingdu_elc; //过滤定位精度498 //var reportLocation;499 reportLocation.startLocation({500 accuracy: 'hight_accuracy', //取值范围:1.battery_saving:低功耗模式(65) 2.device_sensors:仅设备(Gps)模式(165) 3.hight_accuracy:高精度模式(69) 对应android过滤定位精度501 filter: trace_filter, //(可选项)位置更新所需最小距离(单位米) 对应android 定位最小间隔距离502 autoStop: false,503 report: {504 uid: '0123456789', //字符串类型;上报数据时携带的用户id(用于服务器端唯一标识用户)505 url: functionURL + 'wayBillScreen/getListForApp.json',506 interval: 10,507 type: 'post'508 }509 }, function(ret) {510 if (ret.status) {511 $api.setStorage('fpsdw'+uid,1);512 api.getPrefs({513 key: 'loginStatus'514 }, function(retsa, err) {515 var val = retsa.value;516 console.log("aaaa"+val);517 if (val =="") {518 }519 });520 var bd09togcj02 = coordtransform.bd09togcj02(ret.loc.lon, ret.loc.lat);521 var gcj02towgs84 = coordtransform.gcj02towgs84(bd09togcj02[0], bd09togcj02[1]);522 console.log(JSON.stringify(gcj02towgs84));523 sx=gcj02towgs84[0];524 sy=gcj02towgs84[1];525 api.ajax({526 url: functionURL + 'wayBillScreen/agreeUnload.json',527 dataType:'text',528 headers:529 {530 login_token:$api.getStorage('loginToken')531 },532 method: 'post',533 data: {534 values: {535 waybillId: uid,536 longitude:sx,537 latitude:sy,538 sandplantManager:$api.getStorage('usid')539 },540 files: {541 file: 'fs://a.gif'542 }543 }544 }, function(ret, err) {545 if (ret) {546 if(ret==1){547 api.alert({548 title: '修改成功'549 });550$api.rmStorage('fpsdw'+uid);551console.log("卸货:"+uid);552// api.closeWin({553// name: 'order_orderinfo_3'554// });555api.closeWin({556name: 'order_orderlist'557});558 setTimeout(function() {559 api.openWin({560 name : 'order_orderlist',561 url : '../order/orderlist.html',562 reload:true,563 slidBackEnabled:false,564 delay:150,565 animation:{566 type:"fade",567 subType:"from_bottom",568 }569 })570}, 300);571// setTimeout(function() {572//573// api.execScript({574// frameName:'order_ju',575//576// script: 'closeju();'577// });578// }, 500);579 // setTimeout(function() {580 // api.execScript({581 // frameName:'order_ju',582 //583 // script: 'closeju();'584 // });585 // }, 300);586 }587else {588 api.toast({589 msg: '距离太远,正在定位中',590 duration: 2000,591 location: 'middle'592 });593}594 }595 });596 }597 });598}599function getinfo_shjl(uid)600{601console.log(uid);602var xx;603var xy;604var sx;605var sy;606var juli_elc=$api.getStorage('juli_el'+$api.getStorage('usid'));607var jingdu_elc=$api.getStorage('jingdu_el'+$api.getStorage('usid'));608var shijian_elc=$api.getStorage('shijian_el'+$api.getStorage('usid'));609 var trace_interval = shijian_elc;610 var trace_accuracy = juli_elc+"m"; //定位最小间隔距离611 var trace_filter = jingdu_elc; //过滤定位精度612 var reportLocation;613 reportLocation = api.require('reportLocation');614reportLocation.startLocation({615 accuracy: 'hight_accuracy', //取值范围:1.battery_saving:低功耗模式(65) 2.device_sensors:仅设备(Gps)模式(165) 3.hight_accuracy:高精度模式(69) 对应android过滤定位精度616 filter: trace_filter, //(可选项)位置更新所需最小距离(单位米) 对应android 定位最小间隔距离617 autoStop: false,618 report: {619 uid: '0123456789', //字符串类型;上报数据时携带的用户id(用于服务器端唯一标识用户)620 url: functionURL + 'wayBillScreen/getListForApp.json',621 interval: trace_interval,622 type: 'post'623 }624}, function(ret) {625 if (ret.status) {626 api.getPrefs({627 key: 'loginStatus'628 }, function(retsa, err) {629 //当偏好设置尚未设置或者曾设置后被移除后,返回值(ret.value)均为空。630 var val = retsa.value;631 console.log("aaaa"+val);632 // console.log(JSON.stringify(val));633 if (val =="") {634 // reportLocation.stopLocation();635 }636 });637 // alert(JSON.stringify(ret));638 // console.log(JSON.stringify(ret));639 var bd09togcj02 = coordtransform.bd09togcj02(ret.loc.lon, ret.loc.lat);640 // console.log("国测:" + JSON.stringify(bd09togcj02));641 //国测局坐标转wgs84坐标642 var gcj02towgs84 = coordtransform.gcj02towgs84(bd09togcj02[0], bd09togcj02[1]);643 console.log(JSON.stringify(gcj02towgs84));644 sx=gcj02towgs84[0];645 sy=gcj02towgs84[1];646 api.ajax({647 url: functionURL + 'wayBillScreen/getListForApp.json',648 method: 'get',649 headers:650 {651 login_token:$api.getStorage('loginToken')652 },653 data: {654 values: {655 uid: uid656 },657 files: {658 file: 'fs://a.gif'659 }660 }661 }, function(ret, err) {662 if (ret) {663 if( ret['data'].length>0){664 var item = ret['data'][0];665 xx=item['longitude']666 xy=item['latitude'];667 }668 console.log(xx);669 console.log(xy);670 console.log(sx);671 console.log(sy);672 // if(canConfirmBill_s(xx, xy, sx, sy))673 // {674 $api.setStorage('shybut',0);675 // }676 // else {677 // $api.setStorage('shybut',1);678 // api.toast({679 // msg: '与砂船距离过大,请移至距离砂船1000m范围内',680 // duration: 2000,681 // location: 'middle'682 // });683 // }684 }685 else686 {687 getinfo_shjl(uid);688 }689 });690 } else {691 console.log(JSON.stringify(err));692 getinfo_shjl(uid);693 }694});695 // api.startLocation({696 // accuracy: trace_accuracy,// 间隔距离697 // filter: trace_filter,//过滤精度698 // autoStop: false699 // }, function(ret, err) {700 // if (ret && ret.status) {701 // //alert(JSON.stringify(ret));702 // console.log(JSON.stringify(ret));703 // sx=ret.longitude;704 // sy=ret.latitude;705 // api.ajax({706 // url: functionURL + 'wayBillScreen/getListForApp.json',707 // method: 'get',708 // data: {709 // values: {710 // uid: uid711 // },712 // files: {713 // file: 'fs://a.gif'714 // }715 // }716 // }, function(ret, err) {717 // if (ret) {718 // if( ret['data'].length>0){719 // var item = ret['data'][0];720 // xx=item['longitude']721 // xy=item['latitude'];722 //723 // }724 // // console.log(xx);725 // // console.log(xy);726 // // console.log(sx);727 // // console.log(sy);728 //729 // if(canConfirmBill_s(xx, xy, sx, sy))730 // {731 // $api.setStorage('shybut',0);732 //733 // }734 // else {735 // $api.setStorage('shybut',1);736 // api.toast({737 // msg: '与砂船距离过大,请移至距离砂船1000m范围内',738 // duration: 2000,739 // location: 'middle'740 // });741 // }742 //743 // }744 // });745 // } else {746 // //alert(JSON.stringify(err));747 // getinfo_shjl(uid)748 // //resumeLocationJoin(); //GPS定位发生错误重启定位,如断网等749 // }750 // });751}752function reportLocationStart() {753 var reportLocation;754 reportLocation = api.require('reportLocation');755 reportLocation.startLocation({756 accuracy: 'hight_accuracy', //取值范围:1.battery_saving:低功耗模式(65) 2.device_sensors:仅设备(Gps)模式(165) 3.hight_accuracy:高精度模式(69) 对应android过滤定位精度757 filter: 100, //(可选项)位置更新所需最小距离(单位米) 对应android 定位最小间隔距离758 autoStop: false,759 report: {760 uid: '0123456789', //字符串类型;上报数据时携带的用户id(用于服务器端唯一标识用户)761 url: "http://47.96.165.26:8080/ncgctest/boatPositionScreen/add.json",762 interval: 10,763 type: 'post'764 }765 }, function(ret) {766 if (ret.status) {767 alert(JSON.stringify(ret));768 console.log(JSON.stringify(ret));769 var bd09togcj02 = coordtransform.bd09togcj02(ret.loc.lon, ret.loc.lat);770 // console.log("国测:" + JSON.stringify(bd09togcj02));771 //国测局坐标转wgs84坐标772 var gcj02towgs84 = coordtransform.gcj02towgs84(bd09togcj02[0], bd09togcj02[1]);773 api.ajax({774 url: 'http://47.96.165.26:8080/ncgctest/boatPositionScreen/add.json', //运砂船上传经纬度775 method: 'post',776 dataType: 'text',777 headers:778 {779 login_token:$api.getStorage('loginToken')780 },781 data: {782 values: {783 waybillId: 295, //订单ID784 longitude: gcj02towgs84[0], //经度785 latitude: gcj02towgs84[1] //纬度786 }787 }788 }, function(ret, err) {789 if (ret) {790 //alert(JSON.stringify(ret));791 console.log(JSON.stringify(ret));792 } else {793 //alert(JSON.stringify(err));794 console.log(JSON.stringify(err));795 resumeLocationJoin(); //ajax提交发生错误重启定位,如网络错误等796 }797 });798 } else {799 //alert(JSON.stringify(err));800 console.log(JSON.stringify(err));801 resumeLocationJoin(); //获取定位信息错误802 }803 });804 }805 function getLocation411() {806 console.log("进入方法 getLocation411");807 // alert("12333");808 var juli_elc=$api.getStorage('juli_el'+$api.getStorage('usid'));809 var jingdu_elc=$api.getStorage('jingdu_el'+$api.getStorage('usid'));810 var shijian_elc=$api.getStorage('shijian_el'+$api.getStorage('usid'));811 var trace_interval = shijian_elc;812 var trace_accuracy = juli_elc+"m"; //定位最小间隔距离813 var trace_filter = jingdu_elc; //过滤定位精度814 // console.log(trace_filter);815 // console.log(trace_accuracy);816 // console.log(trace_interval);817 // console.log("1234f");818 // console.log(uid);819// var uid=$api.getStorage('yx_uid');820var uid=$api.getStorage('yunshuid'+$api.getStorage('usid'));821console.log(uid);822 dmapong(uid);823// var uid=321;824 // alert("12333");825 // alert(trace_filter);826 // alert(trace_interval);827 // var reportLocation;828 //intervalId = setInterval( dmapong, 1000);829//clearInterval(intervalId);830 // var interval = setInterval(function () { //代码B831 // console.log("interval执行,当前value=" + value);832 // if (value > 1) {833 // temp = value;834 // clearInterval(interval); //终止循环835 // }836 // }, 200);837 }838function dmapong(uid)839{840 var juli_elc=$api.getStorage('juli_el'+$api.getStorage('usid'));841 var jingdu_elc=$api.getStorage('jingdu_el'+$api.getStorage('usid'));842 var shijian_elc=$api.getStorage('shijian_el'+$api.getStorage('usid'));843 var trace_interval = shijian_elc;844 var trace_accuracy = juli_elc+"m"; //定位最小间隔距离845 var trace_filter = jingdu_elc; //过滤定位精度846// console.log(trace_filter);847// console.log(trace_accuracy);848// console.log(trace_interval);849// console.log("1234f");850// console.log(uid);851// var uid=$api.getStorage('yx_uid');852 // console.log(123);853 // console.log(trace_interval);854// if($api.getStorage('maptime')==1)855// {856// api.toast({857// msg: '调用GPS 成功',858// duration: 2000,859// location: 'middle'860// });861// clearInterval(intervalId);862//863// }864// else{865 //reportLocation = api.require('reportLocation');866 reportLocation.startLocation({867 accuracy: 'hight_accuracy', //取值范围:1.battery_saving:低功耗模式(65) 2.device_sensors:仅设备(Gps)模式(165) 3.hight_accuracy:高精度模式(69) 对应android过滤定位精度868 filter: trace_filter, //(可选项)位置更新所需最小距离(单位米) 对应android 定位最小间隔距离869 autoStop: false,870 report: {871 uid: '0123456789', //字符串类型;上报数据时携带的用户id(用于服务器端唯一标识用户)872 url: functionURL + 'boatPositionScreen/add.json',873 interval: trace_interval,874 type: 'post'875 }876 }, function(ret) {877 console.log(JSON.stringify(ret));878 if (ret.status) {879 var trace_filter_a = $api.getStorage('jingdu_el'+$api.getStorage('usid'));880$api.setStorage('maptime',1);//调用成功881 api.getPrefs({882 key: 'loginStatus'883 }, function(retsa, err) {884 //当偏好设置尚未设置或者曾设置后被移除后,返回值(ret.value)均为空。885 var val = retsa.value;886 console.log("aaaa"+val);887 // console.log(JSON.stringify(val));888 if (val =="") {889$api.rmStorage('yx_uid');890 // reportLocation.stopLocation();891$api.rmStorage('maptime');892$api.rmStorage('sy_uid');893 }894 });895 var bd09togcj02 = coordtransform.bd09togcj02(ret.loc.lon, ret.loc.lat);896 // console.log("国测:" + JSON.stringify(bd09togcj02));897 //国测局坐标转wgs84坐标898 var gcj02towgs84 = coordtransform.gcj02towgs84(bd09togcj02[0], bd09togcj02[1]);899 // console.log("GPS:" + JSON.stringify(gcj02towgs84));900var uid=$api.getStorage('yx_uid');901 //alert(JSON.stringify(ret));902 console.log(getNowFormatDate());903 console.log(trace_interval);904 console.log(JSON.stringify(ret));905 console.log(uid);906 console.log($api.getStorage('maptime'));907 var accuracy=ret.accuracy;908 console.log(trace_filter_a);909 $api.setStorage('jdnum'+uid,gcj02towgs84[0]);910 $api.setStorage('wdnum'+uid,gcj02towgs84[1]);911 console.log("经度"+uid,gcj02towgs84[0]);912 console.log(uid);913 console.log("纬度"+uid,gcj02towgs84[1]);914 if(uid!=undefined)915 {916 console.log("进入运单");917 if(trace_filter_a==3000)918 {919console.log("不过滤添加");920 api.ajax({921 url: functionURL + 'boatPositionScreen/add.json',922 method: 'post',923 dataType: 'text',924 headers:925 {926 login_token:$api.getStorage('loginToken')927 },928 data: {929 values: {930 waybillId: uid, //订单ID931 longitude: gcj02towgs84[0], //经度932 latitude: gcj02towgs84[1] //纬度933 // longitude: ret.loc.lon, //经度934 // latitude: ret.loc.lat //纬度935 }936 }937 }, function(ret, err) {938 if (ret) {939 var date = new Date();940 console.log(date.toLocaleTimeString() + "---" + JSON.stringify(ret));941 } else {942 //alert(JSON.stringify(err));943 console.log(JSON.stringify(err));944 // getLocation411();945 }946 });947 }948 else {949console.log("过滤添加11");950 if(accuracy<trace_filter_a){951 api.ajax({952 url: functionURL + 'boatPositionScreen/add.json',953 method: 'post',954 dataType: 'text',955 headers:956 {957 login_token:$api.getStorage('loginToken')958 },959 data: {960 values: {961 waybillId: uid, //订单ID962 longitude: gcj02towgs84[0], //经度963 latitude: gcj02towgs84[1] //纬度964 // longitude: ret.loc.lon, //经度965 // latitude: ret.loc.lat //纬度966 }967 }968 }, function(ret, err) {969 if (ret) {970 var date = new Date();971 console.log(date.toLocaleTimeString() + "---" + JSON.stringify(ret));972 } else {973 //alert(JSON.stringify(err));974 console.log(JSON.stringify(err));975 // getLocation411();976 }977 });978 }979 }980 }981 else982 {983 // reportLocation.stopLocation();984 //console.log("请选择运单");985console.log("选择运单");986 console.log($api.getStorage('sy_uid'));987 if($api.getStorage('sy_uid')!=undefined){988console.log("首页定位");989 api.ajax({990 url: functionURL + 'sandBoatScreen/update.json',991 method: 'post',992 dataType: 'text',993 headers:994 {995 login_token:$api.getStorage('loginToken')996 },997 data: {998 values: {999 uid: $api.getStorage('ucsc06id'), //采砂船id,到时候传参数1000 longitude: gcj02towgs84[0], //经度1001 latitude: gcj02towgs84[1] //纬度1002 }1003 }1004 }, function(ret, err) {1005 if (ret) {1006 //alert(JSON.stringify(ret));1007 var date = new Date();1008 console.log(JSON.stringify(ret));1009 } else {1010 //alert(JSON.stringify(err));1011 console.log(JSON.stringify(err));1012 // getLocation411();1013 // resumeLocationJoin(); //ajax提交发生错误重启定位,如网络错误等1014 }1015 });1016 }1017 else {1018 console.log("首页未定位");1019 }1020 }1021 } else {1022 //alert(JSON.stringify(err));1023 console.log(JSON.stringify(err));1024 // getLocation411();1025 }1026 });1027//}1028}1029function getNowFormatDate() {1030 var date = new Date();1031 var seperator1 = "-";1032 var seperator2 = ":";1033 var month = date.getMonth() + 1;1034 var strDate = date.getDate();1035 if (month >= 1 && month <= 9) {1036 month = "0" + month;1037 }1038 if (strDate >= 0 && strDate <= 9) {1039 strDate = "0" + strDate;1040 }1041 var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate1042 + " " + date.getHours() + seperator2 + date.getMinutes()1043 + seperator2 + date.getSeconds();1044 return currentdate;1045}1046function closemap()1047{1048 var reportLocation;1049 reportLocation = api.require('reportLocation');1050reportLocation.stopLocation();1051}1052function getLocation311() {1053 //console.log($api.getStorage('ucsc06ownerId'));1054 //console.log("进入方法 getLocation3");1055 var juli_elc=$api.getStorage('juli_el'+$api.getStorage('usid'));1056 var jingdu_elc=$api.getStorage('jingdu_el'+$api.getStorage('usid'));1057 var shijian_elc=$api.getStorage('shijian_el'+$api.getStorage('usid'));1058 var trace_interval = shijian_elc;1059 var trace_accuracy = juli_elc+"m"; //定位最小间隔距离1060 var trace_filter = jingdu_elc; //过滤定位精度1061 // console.log(trace_filter);1062 // console.log(trace_accuracy);1063 // console.log(trace_interval);1064// reportLocation = api.require('reportLocation');1065 reportLocation2.startLocation({1066 accuracy: 'hight_accuracy', //取值范围:1.battery_saving:低功耗模式(65) 2.device_sensors:仅设备(Gps)模式(165) 3.hight_accuracy:高精度模式(69) 对应android过滤定位精度1067 filter: trace_filter, //(可选项)位置更新所需最小距离(单位米) 对应android 定位最小间隔距离1068 autoStop: false,1069 report: {1070 uid: '0123456789', //字符串类型;上报数据时携带的用户id(用于服务器端唯一标识用户)1071 url: functionURL + 'sandBoatScreen/update.json',1072 interval: 3,1073 type: 'post'1074 }1075 }, function(ret) {1076 if (ret.status) {1077 api.getPrefs({1078 key: 'loginStatus'1079 }, function(retsa, err) {1080 //当偏好设置尚未设置或者曾设置后被移除后,返回值(ret.value)均为空。1081 var val = retsa.value;1082 console.log("aaab"+val);1083 // console.log(JSON.stringify(val));1084 if (val =="") {1085$api.rmStorage('sy_uid');1086 // reportLocation.stopLocation();1087 }1088 });1089 // alert(JSON.stringify(ret));1090 console.log(JSON.stringify(ret));1091 var bd09togcj02 = coordtransform.bd09togcj02(ret.loc.lon, ret.loc.lat);1092 // console.log("国测:" + JSON.stringify(bd09togcj02));1093 //国测局坐标转wgs84坐标1094 var gcj02towgs84 = coordtransform.gcj02towgs84(bd09togcj02[0], bd09togcj02[1]);1095 // console.log("GPS:" + JSON.stringify(gcj02towgs84));1096 // console.log(bd09togcj02);1097 // console.log($api.getStorage('ucsc06id'));1098var accuracy=ret.accuracy;1099console.log(accuracy);1100console.log(trace_filter);1101 if($api.getStorage('sy_uid')!=undefined){1102 if(accuracy<50){1103 api.ajax({1104 url: functionURL + 'sandBoatScreen/update.json',1105 method: 'post',1106 dataType: 'text',1107 headers:1108 {1109 login_token:$api.getStorage('loginToken')1110 },1111 data: {1112 values: {1113 uid: $api.getStorage('ucsc06id'), //采砂船id,到时候传参数1114 longitude: gcj02towgs84[0], //经度1115 latitude: gcj02towgs84[1] //纬度1116 }1117 }1118 }, function(ret, err) {1119 if (ret) {1120 //alert(JSON.stringify(ret));1121 var date = new Date();1122 console.log(JSON.stringify(ret));1123 } else {1124 //alert(JSON.stringify(err));1125 console.log(JSON.stringify(err));1126 getLocation311();1127 // resumeLocationJoin(); //ajax提交发生错误重启定位,如网络错误等...

Full Screen

Full Screen

product.js

Source:product.js Github

copy

Full Screen

...13 14 15});16function showGuestByTableId(){17 getWithHeader('/table/'+getStorage('selected_table_id')+'/guests',{},function(response){18 console.log(response);19 if(response.success == false){20 return;21 }22 // forloop the guest counts for selection23 var container = $('#guest-container');24 container.empty();25 var guest_count = response.data.guests;26 console.log(guest_count)27 for(var y=0; y < guest_count; y++){28 var guest = y+1;29 console.log( 'guest: ' + guest );30 container.append(31 '<div class="col-md-3 col-sm-3">'+32 '<div class=" card avatar-card text-center"> '+33 '<div class="card-body">'+34 '<span class="badge badge-pill badge-success namber" >'+guest+'</span>'+35 '<img data-guest-no="'+guest+'" src="/assets/images/avatar.png" class="img-fluid avatar" alt="Responsive image">'+36 '</div>'+ 37 '</div> '+38 '</div> '39 );40 }41 // end42 selectGuest();43 });44}45function selectGuest(){46 $(".img-fluid.avatar").on('click', function(){47 let self = $(this);48 console.log(self.data('guest-no'));49 setStorage('selected_guest_no', self.data('guest-no'));50 $('#modal-lg').modal('hide');51 return;52 });53}54function getProduct(){ 55 //parse 56 let outlet = JSON.parse(getStorage('outlet')); 57 let data = {58 product_id : getStorage('selected-product'),59 outlet_id : outlet.id60 };61 postWithHeader(routes.product, data, function(response){62 if(response.success == false){ 63 showError('',response.message, function(){64 });65 return;66 }67 68 displayProduct(response.result,response.base_url);69 getComponentsOfProduct();70 getComponentsNonModifiableOfProduct();71 });72}73function displayProduct(data, base_url){74 75 $('#product_name').text(data.short_code);76 $('#product_price').text(data.price);77 $('#product-image').attr('src', base_url + data.img_path);78 79 var po = JSON.parse( getStorage('product_order') ); 80 po = {81 product_id : parseInt(data.product_id),82 name : data.short_code,83 price : data.price,84 qty : 1,85 main_product_id : parseInt(data.product_id),86 main_product_component_id : null,87 main_product_component_qty : null,88 total : (1 * data.price),89 instruction : "",90 is_take_out : false,91 part_number : data.part_number,92 others:[],93 guest_no : parseInt( getStorage('selected_guest_no') ),94 guest_type : 1,95 discount : 0,96 total_without_vat : 0,97 vat : 098 99 }; 100 setStorage('product_order', JSON.stringify(po));101 logicDisplay();102 //discount();103}104$('#instruction').on('change', function(){105 var _this = $(this);106 var po = JSON.parse( getStorage('product_order') ); 107 po.instruction = _this.val(); 108 setStorage('product_order', JSON.stringify(po)); 109});110$('#is_takeout').change('change', function(){ 111 var _this = $(this); 112 var po = JSON.parse( getStorage('product_order') );113 po.is_take_out = _this.is(':checked');114 setStorage('product_order', JSON.stringify(po)); 115});116 117$('#btn-m-minus').on('click', function(){ 118 var po = JSON.parse( getStorage('product_order') ); 119 if(po.qty > 1){ 120 po.qty--; 121 po.total = po.qty * po.price; 122 // deduct sub component first123 $.each(po.others, function(k,v){ 124 var qty_to_be_deduct = 1 * v.main_product_component_qty; 125 if( (v.others).length > 0 ){ 126 for(var i = 0; i < (v.others).length; i++){ 127 if(qty_to_be_deduct > 0){ // to check if there is qty to be deduct128 if( v.others[i].qty > 0){129 if( qty_to_be_deduct <= v.others[i].qty){130 v.others[i].qty = v.others[i].qty - qty_to_be_deduct;131 qty_to_be_deduct = 0;132 }133 134 if( v.others[i].qty == 0){ // should be removed if zero 135 var _id = '#'+po.product_id+'-'+v.product_id+'-categories-'+v.others[i].product_id+'-qty';136 $(_id).text(0);137 v.others.splice(i, 1);138 }139 }140 }141 }142 }143 144 // deduct component145 if(qty_to_be_deduct >= 0){146 v.qty = v.qty - qty_to_be_deduct;147 }148 }); 149 } 150 setStorage('product_order', JSON.stringify(po));151 logicDisplay();152 // discount();153});154$('#btn-m-plus').on('click', function(){ 155 var po = JSON.parse( getStorage('product_order') ); 156 po.qty++;157 po.total = po.qty * po.price; 158 $.each(po.others, function(k,v){159 v.qty += v.main_product_component_qty * 1;160 }); 161 setStorage('product_order', JSON.stringify(po));162 logicDisplay();163 // discount();164}); 165$('.btn.btn-info.add-to-order').on('click', function(){ 166 //$(this).attr('disabled','disabled');167 $.confirm({168 title: 'Confirmation!',169 content: 'You are about to submit this item as order, do you want to continue?',170 type: 'dark',171 boxWidth: '80%',172 useBootstrap: false,173 closeIcon: function(){174 //return false; // to prevent close the modal.175 // or176 //return 'aRandomButton'; // set a button handler, 'aRandomButton' prevents close. 177 },178 buttons: { 179 cancel: function () { 180 // enableButton();181 },182 183 somethingElse: {184 text: 'Confirm',185 btnClass: 'btn-green',186 keys: ['enter', 'shift'],187 action: function(){ 188 189 // initialize product order 190 var po = JSON.parse( getStorage('product_order') );191 var nmc = JSON.parse( getStorage('none-modifiable-item') );192 po.none_modifiable_component = nmc;193 postWithHeader(routes.orderSlip, po , function(response){ 194 setStorage('selected_guest_no','');195 redirectTo('/');196 }); 197 198 }199 }200 }201 });202 203});204function getComponentsOfProduct(){205 let outlet = JSON.parse(getStorage('outlet')); 206 let data = {207 product_id : getStorage('selected-product'),208 outlet_id : outlet.id,209 group_by : 'mc'210 }; 211 postWithHeader(routes.productComponents, data, function(response){212 if(response.success == false){ 213 showError('',response.message, function(){214 });215 return;216 } 217 componentsDisplayer(response.result.data); 218 });219}220function getComponentsNonModifiableOfProduct(){221 let outlet = JSON.parse(getStorage('outlet')); 222 let data = {223 product_id : getStorage('selected-product'),224 outlet_id : outlet.id,225 group_by : 'nmc'226 }; 227 postWithHeader(routes.productComponents, data, function(response){228 if(response.success == false){ 229 showError('',response.message, function(){230 });231 return;232 }233 console.log(response.result.data);234 var container = $('.nmc');235 container.empty();236 $.each(response.result.data, function(k,v){237 container.append(238 // '<li> '+ v.description+' | ' + parseInt(v.quantity, 10) + '</li>'239 '<li> '+ v.description+' </li>'240 );241 });242 setStorage('none-modifiable-item', JSON.stringify(response.result.data));243 });244}245function componentsDisplayer(data){246 var cc = $('.components-container');247 cc.empty();248 var po = JSON.parse( getStorage('product_order') ); 249 $.each(data, function(k,v){ 250 v.quantity = parseInt(v.quantity, 10); 251 po.others.push({252 product_id : parseInt(v.product_id),253 name : v.description,254 price : 0,255 qty : v.quantity,256 main_product_id : parseInt(po.product_id),257 main_product_component_id : parseInt(v.product_id),258 main_product_component_qty : v.quantity,259 total : (v.quantity * 0), 260 part_number : v.product_partno,261 others: []262 });263 var _id = po.product_id+'-'+v.product_id;264 cc.append(265 '<div class="mrg-top-0">'+266 '<div id="accordion-cc-'+k+'" class="accordion border-less" role="tablist" aria-multiselectable="true">'+267 '<div class="panel panel-default">'+268 '<div class="panel-heading" role="tab">'+269 '<h4 class="panel-title">'+270 '<a class="collapsed" data-toggle="collapse" data-parent="#accordion-cc-'+k+'" href="#collapse-cc-'+k+'" aria-expanded="false">'+271 '<span>'+v.description+' | <i class="text-success" id="'+_id+'">'+v.quantity+'</i></span>'+272 '<i class="icon ti-arrow-circle-down"></i> '+273 '</a>'+274 '</h4>'+275 '</div>'+276 '<div id="collapse-cc-'+k+'" class="panel-collapse collapse" style="">'+277 '<div class="panel-body" id="'+_id+'-categories'+'"> '+ 278 '</div>'+279 '</div>'+280 '</div> '+281 '</div>'+282 '</div>'283 );284 getComponentCategories(v.product_id, _id+'-categories');285 }); 286 setStorage('product_order', JSON.stringify(po)); 287} 288function getComponentCategories(product_id,container){289 let outlet = JSON.parse(getStorage('outlet')); 290 let data = {291 product_id : product_id,292 outlet_id : outlet.id293 }; 294 postWithHeader(routes.productComponentCategories, data, function(response){295 if(response.success == false){ 296 showError('',response.message, function(){297 });298 return;299 }300 301 componentCategoriesDisplayer(response.result.product,response.result.categories.data,container);302 });303}304function componentCategoriesDisplayer(product,data,container){305 var c = $('#'+container);306 c.empty();307 $.each(data, function(k,v){ 308 if(v.price <= product.price){309 v.price = 0;310 }else{311 v.price = v.price - product.price;312 }313 var _id = container+'-'+v.product_id;314 c.append(315 '<div class="row border bottom">'+316 '<div class="col-md-8">'+317 '</span>'+318 '<span class="mrg-left-0 font-size-14 text-dark ">'+v.short_code+' (₱ '+ numberWithCommas(v.price)+')</span>'+319 '</div>'+320 '<div class="col-md-4 text-right">'+321 '<p class="mrg-top-10">'+322 '<span>(<i class="text-success" id="'+_id+'-qty">0</i> )</span>'+323 '<button '+324 'id="'+_id+'-minus" '+ 325 'data-main_product_component_id="'+product.product_id+'" '+ 326 'data-main_product_id="'+getStorage('selected-product')+'" '+327 'data-name="'+v.short_code+'" '+328 'data-price="'+v.price+'" '+329 'data-product_id="'+v.product_id+'" '+330 'class="btn btn-danger btn-inverse btn-xs no-mrg-btm mrg-left-10 border-radius-4">'+331 '<i class="fa fa-minus"></i>'+332 '</button> '+ 333 '<button '+ 334 'id="'+_id+'-plus" '+335 'data-main_product_component_id="'+product.product_id+'" '+ 336 'data-main_product_id="'+getStorage('selected-product')+'" '+337 'data-name="'+v.short_code+'" '+338 'data-price="'+v.price+'" '+339 'data-product_id="'+v.product_id+'" '+340 'class="btn btn-success btn-inverse btn-xs no-mrg-btm mrg-left-10 border-radius-4">'+341 '<i class="fa fa-plus"></i>'+342 '</button>'+343 '</p>'+344 '</div>'+345 '</div>'346 );347 btnComponentCategoryMinus(_id+'-minus');348 btnComponentCategoryPlus(_id+'-plus');349 });350}351function btnComponentCategoryMinus(id){352 $('#'+id).on('click', function(){353 var data = {354 main_product_component_id : $(this).data('main_product_component_id'),355 main_product_id : $(this).data('main_product_id'),356 name : $(this).data('name'),357 price : $(this).data('price'),358 product_id : $(this).data('product_id')359 }; 360 // initialize product order 361 var po = JSON.parse( getStorage('product_order') ); 362 $.each(po.others, function(k,v){ 363 if(data.main_product_component_id == v.main_product_component_id){ 364 var _index_to_remove = -1;365 $.each(v.others, function(kk,vv){ 366 if(data.product_id == vv.product_id){ 367 if(vv.qty > 0){368 v.qty++; 369 vv.qty--;370 vv.total = vv.price * vv.qty; 371 if(vv.qty == 0){ 372 var _id = '#'+po.product_id+'-'+v.product_id+'-categories-'+vv.product_id+'-qty';373 $(_id).text(0); 374 375 _index_to_remove = kk;376 }377 } 378 }379 });380 // to remove zero quantity of sub components381 if (_index_to_remove > -1) {382 v.others.splice(_index_to_remove, 1);383 }384 } 385 });386 //387 setStorage('product_order', JSON.stringify(po)); 388 logicDisplay();389 });390}391function btnComponentCategoryPlus(id){392 $('#'+id).on('click', function(){ 393 var data = {394 main_product_component_id : $(this).data('main_product_component_id'),395 main_product_id : $(this).data('main_product_id'),396 name : $(this).data('name'),397 price : $(this).data('price'),398 product_id : $(this).data('product_id')399 }; 400 // initialize product order 401 var po = JSON.parse( getStorage('product_order') ); 402 // check if the selected sub component category is exist in sub component403 $.each(po.others, function(k,v){ 404 if(data.main_product_component_id == v.main_product_component_id){ 405 if(v.qty > 0){406 // adding to sub component if not exist407 var if_exist = false;408 $.each(v.others, function(kk,vv){409 if(data.product_id == vv.product_id){ 410 if_exist = true;411 vv.qty++;412 vv.total = vv.price * vv.qty;413 v.qty--; 414 }415 });416 if(if_exist == false){ 417 v.others.push({418 product_id : parseInt(data.product_id),419 name : data.name,420 price : data.price,421 qty : 1,422 main_product_id : parseInt(po.product_id),423 main_product_component_qty : v.quantity,424 main_product_component_id : parseInt(v.product_id),425 426 total : (data.price * 1),427 part_number : v.part_number,428 });429 v.qty -= 1; 430 }431 }else{432 cl(['No Available Qty']);433 }434 }435 });436 //437 setStorage('product_order', JSON.stringify(po)); 438 logicDisplay();439 });440}441function logicDisplay(){ 442 console.log('moew');443 var grand_total = 0; 444 var po = JSON.parse( getStorage('product_order') ); 445 446 447 /**448 * MAIN PRODUCT SECTION449 */ 450 grand_total += po.total; 451 $('#m-product-qty').val(po.qty); 452 /**453 * COMPONENTS SECTION454 */455 $.each(po.others, function(k,v){456 $('#'+po.product_id+'-'+v.product_id).text(v.qty);457 }); 458 /**459 * SUB COMPONENTS SECTION460 */461 $.each(po.others, function(k,v){462 $.each(v.others, function(kk,vv){ 463 var _id = '#'+po.product_id+'-'+v.product_id+'-categories-'+vv.product_id+'-qty';464 $(_id).text(vv.qty);465 grand_total += vv.total;466 });467 });468 469 console.log(':: ' + numberWithCommas(grand_total));470 $('#grand-total').text('TOTAL : ' + numberWithCommas(grand_total));471}472$('input[type=radio][name=guest-type]').change(function() {473 var po = JSON.parse( getStorage('product_order') );474 po.guest_type = parseInt(this.value);475 setStorage('product_order', JSON.stringify(po)); 476 // discount();477});478// $('#guest-no').on('change', function(){479// var po = JSON.parse( getStorage('product_order') );480// po.guest_no = parseInt(this.value);481// setStorage('product_order', JSON.stringify(po)); 482// discount();483// });484function discount(){485 var new_price = 0;486 var po = JSON.parse( getStorage('product_order') );487 488 po.total_without_vat = (po.total/1.12);489 po.vat = po.total_without_vat * .12 ;490 if (po.guest_type == 2 || po.guest_type == 3 ){ 491 po.discount= po.total_without_vat * .20;492 493 new_price = po.total_without_vat - po.discount;494 }else{495 po.discount = 0;496 new_price = po.total - po.discount;497 }498 499 setStorage('product_order', JSON.stringify(po));500 ...

Full Screen

Full Screen

ytongji.js

Source:ytongji.js Github

copy

Full Screen

...8 url: functionURL + 'wayBillScreen/getSum.json',9 method: 'get',10 headers:11 {12 login_token:$api.getStorage('loginToken')13 },14 data: {15 values: {16 //deliver: $api.getStorage('usid'),17 sandboatId: $api.getStorage('ucsc06id'),18 begintime:myArray[0],19 endtime:myArray[1],20 remark:121 },22 files: {23 file: 'fs://a.gif'24 }25 }26 }, function(ret, err) {27 console.log(JSON.stringify(ret));28 //if(ret['sum(real_weight)'])29 //console.log(JSON.stringify(ret['sum(real_weight)']));30 if(ret['sum(real_weight)']==null)31 {32 $api.setStorage('yz'+i,0);33 }34 else {35 $api.setStorage('yz'+i,ret['sum(real_weight)']);36 }37 //arr_sum[i]=ret;38 });39 }40 else {41 $api.setStorage('yz'+i,0);42 }43}44function ymyArraysum_arr_list7(myArray,i)45{46 //console.log(myArray);47 if(myArray[0]!=0)48 {49 api.ajax({50 url: functionURL + 'wayBillScreen/getSum.json',51 method: 'get',52 headers:53 {54 login_token:$api.getStorage('loginToken')55 },56 data: {57 values: {58 //deliver: $api.getStorage('usid'),59 fromDistrict: $api.getStorage('fromDistrict'),60 begintime:myArray[0],61 endtime:myArray[1],62 remark:163 },64 files: {65 file: 'fs://a.gif'66 }67 }68 }, function(ret, err) {69 console.log(JSON.stringify(ret));70 //if(ret['sum(real_weight)'])71 //console.log(JSON.stringify(ret['sum(real_weight)']));72 if(ret['sum(real_weight)']==null)73 {74 $api.setStorage('yz'+i,0);75 }76 else {77 $api.setStorage('yz'+i,ret['sum(real_weight)']);78 }79 //arr_sum[i]=ret;80 });81 }82 else {83 $api.setStorage('yz'+i,0);84 }85}86function ymyArraysum_arr_list5(myArray,i)87{88 //console.log(myArray);89 if(myArray[0]!=0)90 {91 api.ajax({92 url: functionURL + 'wayBillScreen/getSum.json',93 method: 'get',94 headers:95 {96 login_token:$api.getStorage('loginToken')97 },98 data: {99 values: {100 sandboatId: $api.getStorage('sandboatId'),101 begintime:myArray[0],102 endtime:myArray[1],103 remark:1104 },105 files: {106 file: 'fs://a.gif'107 }108 }109 }, function(ret, err) {110 //if(ret['sum(real_weight)'])111 //console.log(JSON.stringify(ret['sum(real_weight)']));112 if(ret['sum(real_weight)']==null)113 {114 $api.setStorage('yz'+i,0);115 }116 else {117 $api.setStorage('yz'+i,ret['sum(real_weight)']);118 }119 //arr_sum[i]=ret;120 });121 }122 else {123 $api.setStorage('yz'+i,0);124 }125}126function ymyArraysum_arr_list4(myArray,i)127{128 //console.log(myArray);129 if(myArray[0]!=0)130 {131 api.ajax({132 url: functionURL + 'wayBillScreen/getSum.json',133 method: 'get',134 headers:135 {136 login_token:$api.getStorage('loginToken')137 },138 data: {139 values: {140 boatId: $api.getStorage('boatId'),141 begintime:myArray[0],142 endtime:myArray[1],143 remark:1144 },145 files: {146 file: 'fs://a.gif'147 }148 }149 }, function(ret, err) {150 //if(ret['sum(real_weight)'])151 //console.log(JSON.stringify(ret['sum(real_weight)']));152 if(ret['sum(real_weight)']==null)153 {154 $api.setStorage('yz'+i,0);155 }156 else {157 $api.setStorage('yz'+i,ret['sum(real_weight)']);158 }159 //arr_sum[i]=ret;160 });161 }162 else {163 $api.setStorage('yz'+i,0);164 }165}166function ymyArraysum_arr_list3(myArray,i)167{168 //console.log(myArray);169 if(myArray[0]!=0)170 {171 api.ajax({172 url: functionURL + 'wayBillScreen/getSum.json',173 method: 'get',174 headers:175 {176 login_token:$api.getStorage('loginToken')177 },178 data: {179 values: {180 toDistrict: $api.getStorage('toDistrict'),181 begintime:myArray[0],182 endtime:myArray[1],183 remark:1184 },185 files: {186 file: 'fs://a.gif'187 }188 }189 }, function(ret, err) {190 //if(ret['sum(real_weight)'])191 //console.log(JSON.stringify(ret['sum(real_weight)']));192 if(ret['sum(real_weight)']==null)193 {194 $api.setStorage('yz'+i,0);195 }196 else {197 $api.setStorage('yz'+i,ret['sum(real_weight)']);198 }199 //arr_sum[i]=ret;200 });201 }202 else {203 $api.setStorage('yz'+i,0);204 }205}206function ymyArraysum_arr(myArray)207{208 // $api.rmStorage('yz0');209 // $api.rmStorage('yz1');210 // $api.rmStorage('yz2');211 // $api.rmStorage('yz3');212 // $api.rmStorage('yz4');213 // $api.rmStorage('yz5');214 for (i = 0; i < myArray.length; i++) {215// console.log($api.getStorage('usid'));216// console.log($api.getStorage('ucsc06id'));217// console.log(myArray[i]);218// console.log(add_time(myArray[i]));219 if($api.getStorage('uroles')=='采砂船管理员')220 {221 ymyArraysum_arr_list6(myArray[i],i);222 }223 if($api.getStorage('uroles')=='采区负责人')224 {225 ymyArraysum_arr_list7(myArray[i],i);226 }227 if($api.getStorage('uroles')=='采砂船船主')228 {229 ymyArraysum_arr_list5(myArray[i],i);230 }231 if($api.getStorage('uroles')=='运砂船船主')232 {233 ymyArraysum_arr_list4(myArray[i],i);234 }235 if($api.getStorage('uroles')=='砂场收货员')236 {237 ymyArraysum_arr_list3(myArray[i],i);238 }239 if($api.getStorage('uroles')=='二级砂厂负责人')240 {241 ymyArraysum_arr_list3(myArray[i],i);242 }243 if($api.getStorage('uroles')=='采运船主')244 {245 ymyArraysum_arr_list5(myArray[i],i);246 }247 }248 // setTimeout(function(){249 // ysetrez();250 // }, 1800);251}252function ymyArraycount_arr_list6(myArray,i)253{254 console.log(myArray);255// console.log(t_todaa(myArray[1]));256 if(myArray[0]!=0)257 {258 api.ajax({259 url: functionURL + 'wayBillScreen/getCount.json',260 method: 'get',261 headers:262 {263 login_token:$api.getStorage('loginToken')264 },265 data: {266 values: {267 //deliver: $api.getStorage('usid'),268 sandboatId: $api.getStorage('ucsc06id'),269 begintime:myArray[0],270 endtime:myArray[1],271 remark:1272 },273 files: {274 file: 'fs://a.gif'275 }276 }277 }, function(ret, err) {278 //if(ret['sum(real_weight)'])279console.log(JSON.stringify(ret));280 if(ret['count']==0)281 {282 $api.setStorage('yz1'+i,0);283 }284 else {285 $api.setStorage('yz1'+i,ret['count']);286 }287 //arr_sum[i]=ret;288 });289 }290 else {291 $api.setStorage('yz1'+i,0);292 }293}294function ymyArraycount_arr_list7(myArray,i)295{296 console.log(myArray);297// console.log(t_todaa(myArray[1]));298 if(myArray[0]!=0)299 {300 api.ajax({301 url: functionURL + 'wayBillScreen/getCount.json',302 method: 'get',303 headers:304 {305 login_token:$api.getStorage('loginToken')306 },307 data: {308 values: {309 //deliver: $api.getStorage('usid'),310 fromDistrict: $api.getStorage('fromDistrict'),311 begintime:myArray[0],312 endtime:myArray[1],313 remark:1314 },315 files: {316 file: 'fs://a.gif'317 }318 }319 }, function(ret, err) {320 //if(ret['sum(real_weight)'])321console.log(JSON.stringify(ret));322 if(ret['count']==0)323 {324 $api.setStorage('yz1'+i,0);325 }326 else {327 $api.setStorage('yz1'+i,ret['count']);328 }329 //arr_sum[i]=ret;330 });331 }332 else {333 $api.setStorage('yz1'+i,0);334 }335}336function ymyArraycount_arr_list5(myArray,i)337{338 //console.log(myArray);339 if(myArray[0]!=0)340 {341 api.ajax({342 url: functionURL + 'wayBillScreen/getCount.json',343 method: 'get',344 headers:345 {346 login_token:$api.getStorage('loginToken')347 },348 data: {349 values: {350 sandboatId: $api.getStorage('sandboatId'),351 begintime:myArray[0],352 endtime:myArray[1],353 remark:1354 },355 files: {356 file: 'fs://a.gif'357 }358 }359 }, function(ret, err) {360 //if(ret['sum(real_weight)'])361 if(ret['count']==null)362 {363 $api.setStorage('yz1'+i,0);364 }365 else {366 $api.setStorage('yz1'+i,ret['count']);367 }368 //arr_sum[i]=ret;369 });370 }371 else {372 $api.setStorage('yz1'+i,0);373 }374}375function ymyArraycount_arr_list4(myArray,i)376{377 //console.log(myArray);378 if(myArray[0]!=0)379 {380 api.ajax({381 url: functionURL + 'wayBillScreen/getCount.json',382 method: 'get',383 headers:384 {385 login_token:$api.getStorage('loginToken')386 },387 data: {388 values: {389 boatId: $api.getStorage('boatId'),390 begintime:myArray[0],391 endtime:myArray[1],392 remark:1393 },394 files: {395 file: 'fs://a.gif'396 }397 }398 }, function(ret, err) {399 //if(ret['sum(real_weight)'])400 if(ret['count']==null)401 {402 $api.setStorage('yz1'+i,0);403 }404 else {405 $api.setStorage('yz1'+i,ret['count']);406 }407 //arr_sum[i]=ret;408 });409 }410 else {411 $api.setStorage('yz1'+i,0);412 }413}414function ymyArraycount_arr_list3(myArray,i)415{416 //console.log(myArray);417 if(myArray[0]!=0)418 {419 api.ajax({420 url: functionURL + 'wayBillScreen/getCount.json',421 method: 'get',422 headers:423 {424 login_token:$api.getStorage('loginToken')425 },426 data: {427 values: {428 toDistrict: $api.getStorage('toDistrict'),429 begintime:myArray[0],430 endtime:myArray[1],431 remark:1432 },433 files: {434 file: 'fs://a.gif'435 }436 }437 }, function(ret, err) {438 //if(ret['sum(real_weight)'])439 if(ret['count']==null)440 {441 $api.setStorage('yz1'+i,0);442 }443 else {444 $api.setStorage('yz1'+i,ret['count']);445 }446 //arr_sum[i]=ret;447 });448 }449 else {450 $api.setStorage('yz1'+i,0);451 }452}453function ymyArraycount_arr(myArray)454{455 // $api.rmStorage('yz10');456 // $api.rmStorage('yz11');457 // $api.rmStorage('yz12');458 // $api.rmStorage('yz13');459 // $api.rmStorage('yz14');460 // $api.rmStorage('yz15');461 for (i = 0; i < myArray.length; i++) {462// console.log($api.getStorage('usid'));463// console.log($api.getStorage('ucsc06id'));464// console.log(myArray[i]);465// console.log(add_time(myArray[i]));466if($api.getStorage('uroles')=='采砂船管理员')467{468 ymyArraycount_arr_list6(myArray[i],i);469}470if($api.getStorage('uroles')=='采区负责人')471{472 ymyArraycount_arr_list7(myArray[i],i);473}474if($api.getStorage('uroles')=='采砂船船主')475{476 ymyArraycount_arr_list5(myArray[i],i);477}478if($api.getStorage('uroles')=='运砂船船主')479{480 ymyArraycount_arr_list4(myArray[i],i);481}482if($api.getStorage('uroles')=='砂场收货员')483{484 ymyArraycount_arr_list3(myArray[i],i);485}486if($api.getStorage('uroles')=='二级砂厂负责人')487{488 ymyArraycount_arr_list3(myArray[i],i);489}490if($api.getStorage('uroles')=='采运船主')491{492 ymyArraycount_arr_list5(myArray[i],i);493}494 }495 // setTimeout(function(){496 // ysetrez1();497 // }, 1800);498}499// function GetDayaa(year, month, day)500// {501// var today=new Date(year, month-1 ,day);502// var yesterday_milliseconds=today.getTime()-1000*60*60*24;503//504// var yesterday=new Date();...

Full Screen

Full Screen

push.js

Source:push.js Github

copy

Full Screen

...10 $.setStorage('registerID',registerID);11 }12}13function push_message(){14 if(!$.getStorage("pushMesFlag")){15 $.setStorage('pushMesFlag',"1");16 }17 var pushMesFlag = $.getStorage('pushMesFlag');18 var registerID=$.getStorage('registerID');19 var epsbht01006 =$.getStorage('log');20 var epsbht01007 =$.getStorage('lat');21 if(pushMesFlag=="1"&&registerID&&epsbht01006&&epsbht01007){22 getRoundStationNames(registerID,epsbht01006,epsbht01007);//查询用户附近市场接口23 getStationCheapProducts(registerID,epsbht01006,epsbht01007);//推送用户附近的市场的便宜信息接口24 getFocusProductsInfo(registerID,epsbht01006,epsbht01007);//推送用户关注产品在附近市场最便宜价格接口25 getFocusStationInfo(registerID);//推送用户关注市场有哪些便宜产品接口26 getPushHistoryMessage(registerID);//查询推送过得消息接口27 }28}29function push_getRoundStationNames_message(){30 if(!$.getStorage("pushMesFlag")){31 $.setStorage('pushMesFlag',"1");32 }33 var pushMesFlag = $.getStorage('pushMesFlag');34 var registerID=$.getStorage('registerID');35 if(pushMesFlag=="1"&&registerID){36 var epsbht01006 =$.getStorage('log');37 var epsbht01007 =$.getStorage('lat');38 getRoundStationNames(registerID,epsbht01006,epsbht01007);//查询用户附近市场接口39 }40}41function push_getStationCheapProducts_message(){42 if(!$.getStorage("pushMesFlag")){43 $.setStorage('pushMesFlag',"1");44 }45 var pushMesFlag = $.getStorage('pushMesFlag');46 var registerID=$.getStorage('registerID');47 var epsbht01006 =$.getStorage('log');48 var epsbht01007 =$.getStorage('lat');49 if(pushMesFlag=="1"&&registerID&&epsbht01006&&epsbht01007){50 getStationCheapProducts(registerID,epsbht01006,epsbht01007);//推送用户附近的市场的便宜信息接口51 }52}53function push_getFocusProductsInfo_message(){54 if(!$.getStorage("pushMesFlag")){55 $.setStorage('pushMesFlag',"1");56 }57 var pushMesFlag = $.getStorage('pushMesFlag');58 var registerID=$.getStorage('registerID');59 var epsbht01006 =$.getStorage('log');60 var epsbht01007 =$.getStorage('lat');61 if(pushMesFlag=="1"&&registerID&&epsbht01006&&epsbht01007){62 getFocusProductsInfo(registerID,epsbht01006,epsbht01007);//推送用户关注产品在附近市场最便宜价格接口63 }64}65function push_getFocusStationInfo_message(){66 if(!$.getStorage("pushMesFlag")){67 $.setStorage('pushMesFlag',"1");68 }69 var pushMesFlag = $.getStorage('pushMesFlag');70 var registerID=$.getStorage('registerID');71 if(pushMesFlag=="1"&&registerID){72 getFocusStationInfo(registerID);//推送用户关注市场有哪些便宜产品接口73 }74}75/*=============================推送公用方法==================================================*/76//function notice_callback(){77// getNotReadNum(messageCallback);78//}79//推送消息载入数据80function setData(json){81 var data = json.data;82 var len = json.data.length;83 var html='';84 var msg_html='';85 $('#mc-msg-num').html(len);86 for(var i=0;i<len;i++){87 var title=data[i].cltpush01001;88 var content=data[i].cltpush01002;89 var time=data[i].cltpush01003;90 msg_html+='<span>';91 msg_html+='<img class="push_img" src="static/mCheap/images/circle.png">';92 msg_html+='<span class="push_span">'+content+'</span>';93 msg_html+='</span>';94 html+="<div class='mdui-box mdui-box-ver mc-lineone'>";95 html+="<div class='mdui-box mdui-box-flex-1'>";96 html+="<div class='mdui-box mdui-box-flex-1 mdui-box-align-center mdui-box-pack-center'>";97 if(data[i].cltpush01004=='0'){98 html+="<img class='circle' src='static/mCheap/images/circle.png'>";99 }else{100 html+="<img class='circle-visibility' src='static/mCheap/images/circle.png'>";101 }102 html+="</div>";103 html+="<div class='mdui-box mdui-box-flex-9 mdui-box-align-center list-title'>"+title+"</div>";104 html+="<div class='mdui-box mdui-box-pack-end mdui-box-flex-1'>";105 if(data[i].cltpush01004=='0'){106 html+="<img class='pic-new' src='static/mCheap/images/new.png'>";107 }else{108 html+="<img class='pic-new-visibility' src='static/mCheap/images/new.png'>";109 }110 html+="</div>";111 html+="</div>";112 html+="<div class='mdui-box mdui-box-flex-1 list-content'>"+content+"</div>";113 html+="<div class='mdui-box mdui-box-flex-1 mdui-box-pack-end list-time'>"+time+"</div>";114 html+="</div>";115 }116 $('.box>div:first-child').css('margin-top','0');117 $('.push').show();118 $("#push_msg").html(msg_html);119 $('#new_msg').html(html);120 //document.querySelector('#new_msg').insertAdjacentHTML('afterbegin',html);121 $("#new_msg>div:last-child").addClass("mc-xby");122 $("#new_msg>div>div:last-child").addClass("mc-xby");123}124//给首页推送消息设置数据125function indexSetData(json){126 var ln = json.data.length;127 if(ln<=0){128 }else{129 $("#mc").css("display","block");130 $("#mc").addClass("mc");131 $("#push_msg").empty();132 $('#new_msg').html('');133 setData(json);134 }135}136//查询用户附近市场接口137function getRoundStationNames(registerID,epsbht01006,epsbht01007){138 $.request({139 urlType:'getRoundStationNames',140 data:{141 "access_token": $.getStorage('access_token'),142 epsbht01006:epsbht01006,143 epsbht01007:epsbht01007,144 epsbht01008:'01',145 registerId:""+registerID146 }147 },function(data){148 //alert("getRoundStationNames"+"*");149 });150}151//推送用户附近的市场的便宜信息接口152function getStationCheapProducts(registerID,epsbht01006,epsbht01007){153 $.request({154 urlType:'getStationCheapProducts',155 data:{156 "access_token": $.getStorage('access_token'),157 epsbht01006:epsbht01006,158 epsbht01007:epsbht01007,159 epsbht01008:'01',160 registerId:""+registerID161 }162 },function(data){163 //alert("getStationCheapProducts"+"*");164 });165}166//推送用户关注产品在附近市场最便宜价格接口167function getFocusProductsInfo(registerID,epsbht01006,epsbht01007){168 $.request({169 urlType:'getFocusProductsInfo',170 data:{171 "access_token": $.getStorage('access_token'),172 epsbht01006:epsbht01006,173 epsbht01007:epsbht01007,174 epsbht01008:'01',175 registerId:""+registerID176 }177 },function(data){178 //alert("getFocusProductsInfo"+"*");179 });180}181//推送用户关注市场有哪些便宜产品接口182function getFocusStationInfo(registerID){183 $.request({184 urlType:'getFocusStationInfo',185 data:{186 "access_token": $.getStorage('access_token'),187 registerId:""+registerID188 }189 },function(data){190 //alert("getFocusStationInfo"+"*");191 });192}193//查询推送过得消息接口194function getPushHistoryMessage(registerID){195 $.request({196 urlType:'getPushHistoryMessage',197 data:{198 "access_token": $.getStorage('access_token'),199 registerId:""+registerID200 }201 },function(data){202 if(data.success) {203 indexSetData(data);204 }205 else {206 $.alert('网络错误')207 }208 });209}210//点击推送消息的产品211$(document).on('tap','.a_product',function(){212 var cltpro01id = $(this).data('cltpro01id');...

Full Screen

Full Screen

tongji.js

Source:tongji.js Github

copy

Full Screen

...7 url: functionURL + 'wayBillScreen/getSum.json',8 method: 'get',9 headers:10 {11 login_token:$api.getStorage('loginToken')12 },13 data: {14 values: {15 // deliver: $api.getStorage('usid'),16 sandboatId: $api.getStorage('ucsc06id'),17 begintime:myArray,18 //endtime:add_time(myArray),19 endtime:myArray,20 remark:121 },22 files: {23 file: 'fs://a.gif'24 }25 }26 }, function(ret, err) {27 //if(ret['sum(real_weight)'])28 console.log(JSON.stringify(ret));29 //console.log(JSON.stringify(ret['sum(real_weight)']));30 if(ret['sum(real_weight)']==null)31 {32 $api.setStorage('z'+i,0);33 }34 else {35 $api.setStorage('z'+i,ret['sum(real_weight)']);36 }37 //arr_sum[i]=ret;38 });39}40function myArraysum_arr_list7(myArray,i)41{42 //console.log(myArray);43console.log(myArray);44 api.ajax({45 url: functionURL + 'wayBillScreen/getSum.json',46 method: 'get',47 headers:48 {49 login_token:$api.getStorage('loginToken')50 },51 data: {52 values: {53 // deliver: $api.getStorage('usid'),54 fromDistrict: $api.getStorage('fromDistrict'),55 begintime:myArray,56 //endtime:add_time(myArray),57 endtime:myArray,58 remark:159 },60 files: {61 file: 'fs://a.gif'62 }63 }64 }, function(ret, err) {65 //if(ret['sum(real_weight)'])66 console.log(JSON.stringify(ret));67 //console.log(JSON.stringify(ret['sum(real_weight)']));68 if(ret['sum(real_weight)']==null)69 {70 $api.setStorage('z'+i,0);71 }72 else {73 $api.setStorage('z'+i,ret['sum(real_weight)']);74 }75 //arr_sum[i]=ret;76 });77}78function myArraysum_arr_list5(myArray,i)79{80 //console.log(myArray);81 api.ajax({82 url: functionURL + 'wayBillScreen/getSum.json',83 method: 'get',84 headers:85 {86 login_token:$api.getStorage('loginToken')87 },88 data: {89 values: {90 sandboatId: $api.getStorage('sandboatId'),91 begintime:myArray,92 endtime:myArray,93 remark:194 },95 files: {96 file: 'fs://a.gif'97 }98 }99 }, function(ret, err) {100 //if(ret['sum(real_weight)'])101 //console.log(JSON.stringify(ret['sum(real_weight)']));102 if(ret['sum(real_weight)']==null)103 {104 $api.setStorage('z'+i,0);105 }106 else {107 $api.setStorage('z'+i,ret['sum(real_weight)']);108 }109 //arr_sum[i]=ret;110 });111}112function myArraysum_arr_list4(myArray,i)113{114 //console.log(myArray);115 api.ajax({116 url: functionURL + 'wayBillScreen/getSum.json',117 method: 'get',118 headers:119 {120 login_token:$api.getStorage('loginToken')121 },122 data: {123 values: {124 boatId: $api.getStorage('boatId'),125 begintime:myArray,126 endtime:myArray,127 remark:1128 },129 files: {130 file: 'fs://a.gif'131 }132 }133 }, function(ret, err) {134 //if(ret['sum(real_weight)'])135 //console.log(JSON.stringify(ret['sum(real_weight)']));136 if(ret['sum(real_weight)']==null)137 {138 $api.setStorage('z'+i,0);139 }140 else {141 $api.setStorage('z'+i,ret['sum(real_weight)']);142 }143 //arr_sum[i]=ret;144 });145}146function myArraysum_arr_list3(myArray,i)147{148 //console.log(myArray);149 api.ajax({150 url: functionURL + 'wayBillScreen/getSum.json',151 method: 'get',152 headers:153 {154 login_token:$api.getStorage('loginToken')155 },156 data: {157 values: {158 toDistrict: $api.getStorage('toDistrict'),159 begintime:myArray,160 endtime:myArray,161 remark:1162 },163 files: {164 file: 'fs://a.gif'165 }166 }167 }, function(ret, err) {168 //if(ret['sum(real_weight)'])169 //console.log(JSON.stringify(ret['sum(real_weight)']));170 if(ret['sum(real_weight)']==null)171 {172 $api.setStorage('z'+i,0);173 }174 else {175 $api.setStorage('z'+i,ret['sum(real_weight)']);176 }177 //arr_sum[i]=ret;178 });179}180function myArraysum_arr(myArray)181{182 var j=0;183 for (i = 0; i < myArray.length; i++) {184// console.log($api.getStorage('usid'));185// console.log($api.getStorage('ucsc06id'));186// console.log(myArray[i]);187// console.log(add_time(myArray[i]));188 if($api.getStorage('uroles')=='采砂船管理员')189 {190 myArraysum_arr_list6(myArray[i],i);191 }192 if($api.getStorage('uroles')=='采区负责人')193 {194 myArraysum_arr_list7(myArray[i],i);195 }196 if($api.getStorage('uroles')=='采砂船船主')197 {198 myArraysum_arr_list5(myArray[i],i);199 }200 if($api.getStorage('uroles')=='运砂船船主')201 {202 myArraysum_arr_list4(myArray[i],i);203 }204 if($api.getStorage('uroles')=='砂场收货员')205 {206 myArraysum_arr_list3(myArray[i],i);207 }208 if($api.getStorage('uroles')=='二级砂厂负责人')209 {210 myArraysum_arr_list3(myArray[i],i);211 }212 if($api.getStorage('uroles')=='采运船主')213 {214 myArraysum_arr_list5(myArray[i],i);215 }216 j=j+1;217 }218 console.log(j);219//if(j==myArray.length)220//{221 // setTimeout(function(){222 // setrez();223 // }, 1800);224//}225 // setTimeout(function(){226 // setrez();227 // }, 1900);228}229function myArraycount_arr_list6(myArray,i)230{231 //console.log(myArray);232 api.ajax({233 url: functionURL + 'wayBillScreen/getCount.json',234 method: 'get',235 headers:236 {237 login_token:$api.getStorage('loginToken')238 },239 data: {240 values: {241 //deliver: $api.getStorage('usid'),242 sandboatId: $api.getStorage('ucsc06id'),243 begintime:myArray,244 endtime:myArray,245 remark:1246 },247 files: {248 file: 'fs://a.gif'249 }250 }251 }, function(ret, err) {252 //if(ret['sum(real_weight)'])253console.log(JSON.stringify(ret));254 if(ret['count']==null)255 {256 $api.setStorage('z1'+i,0);257 }258 else {259$api.setStorage('z1'+i,ret['count']);260 }261 // $api.setStorage('z1'+i,ret['count']);262 //arr_sum[i]=ret;263 });264}265function myArraycount_arr_list7(myArray,i)266{267 //console.log(myArray);268 api.ajax({269 url: functionURL + 'wayBillScreen/getCount.json',270 method: 'get',271 headers:272 {273 login_token:$api.getStorage('loginToken')274 },275 data: {276 values: {277 //deliver: $api.getStorage('usid'),278 fromDistrict: $api.getStorage('fromDistrict'),279 begintime:myArray,280 endtime:myArray,281 remark:1282 },283 files: {284 file: 'fs://a.gif'285 }286 }287 }, function(ret, err) {288 //if(ret['sum(real_weight)'])289console.log(JSON.stringify(ret));290 if(ret['count']==null)291 {292 $api.setStorage('z1'+i,0);293 }294 else {295$api.setStorage('z1'+i,ret['count']);296 }297 // $api.setStorage('z1'+i,ret['count']);298 //arr_sum[i]=ret;299 });300}301function myArraycount_arr_list5(myArray,i)302{303 //console.log(myArray);304 api.ajax({305 url: functionURL + 'wayBillScreen/getCount.json',306 method: 'get',307 headers:308 {309 login_token:$api.getStorage('loginToken')310 },311 data: {312 values: {313 sandboatId: $api.getStorage('sandboatId'),314 begintime:myArray,315 endtime:myArray,316 remark:1317 },318 files: {319 file: 'fs://a.gif'320 }321 }322 }, function(ret, err) {323 //if(ret['sum(real_weight)'])324 if(ret['count']==null)325 {326 $api.setStorage('z1'+i,0);327 }328 else {329$api.setStorage('z1'+i,ret['count']);330 }331 //arr_sum[i]=ret;332 });333}334function myArraycount_arr_list4(myArray,i)335{336 //console.log(myArray);337 api.ajax({338 url: functionURL + 'wayBillScreen/getCount.json',339 method: 'get',340 headers:341 {342 login_token:$api.getStorage('loginToken')343 },344 data: {345 values: {346 boatId: $api.getStorage('boatId'),347 begintime:myArray,348 endtime:myArray,349 remark:1350 },351 files: {352 file: 'fs://a.gif'353 }354 }355 }, function(ret, err) {356 //if(ret['sum(real_weight)'])357 if(ret['count']==null)358 {359 $api.setStorage('z1'+i,0);360 }361 else {362$api.setStorage('z1'+i,ret['count']);363 }364 //arr_sum[i]=ret;365 });366}367function myArraycount_arr_list3(myArray,i)368{369 //console.log(myArray);370 api.ajax({371 url: functionURL + 'wayBillScreen/getCount.json',372 method: 'get',373 headers:374 {375 login_token:$api.getStorage('loginToken')376 },377 data: {378 values: {379 toDistrict: $api.getStorage('toDistrict'),380 begintime:myArray,381 endtime:myArray,382 remark:1383 },384 files: {385 file: 'fs://a.gif'386 }387 }388 }, function(ret, err) {389 //if(ret['sum(real_weight)'])390// console.log("砂厂");391// console.log(JSON.stringify(ret));392 if(ret['count']==null)393 {394 $api.setStorage('z1'+i,0);395 }396 else {397$api.setStorage('z1'+i,ret['count']);398 }399 //arr_sum[i]=ret;400 });401}402function myArraycount_arr(myArray)403{404 var j=0;405 console.log(myArray.length);406 for (i = 0; i < myArray.length; i++) {407// console.log($api.getStorage('usid'));408// console.log($api.getStorage('ucsc06id'));409// console.log(myArray[i]);410// console.log(add_time(myArray[i]));411if($api.getStorage('uroles')=='采砂船管理员')412{413 myArraycount_arr_list6(myArray[i],i);414}415if($api.getStorage('uroles')=='采区负责人')416{417 myArraycount_arr_list7(myArray[i],i);418}419if($api.getStorage('uroles')=='采砂船船主')420{421 myArraycount_arr_list5(myArray[i],i);422}423if($api.getStorage('uroles')=='运砂船船主')424{425 myArraycount_arr_list4(myArray[i],i);426}427if($api.getStorage('uroles')=='砂场收货员')428{429 myArraycount_arr_list3(myArray[i],i);430}431if($api.getStorage('uroles')=='二级砂厂负责人')432{433myArraycount_arr_list3(myArray[i],i);434}435if($api.getStorage('uroles')=='采运船主')436{437myArraycount_arr_list5(myArray[i],i);438}439j=j+1;440 }441 console.log(j);442// if(j==myArray.length)443// {444 // setTimeout(function(){445 // setrez1();446 // }, 1800);447// }448 // setTimeout(function(){449 // setrez1();...

Full Screen

Full Screen

jquery.storage-manager.js

Source:jquery.storage-manager.js Github

copy

Full Screen

...22 * @example23 *24 * Getting the localStorage/sessionStorage (polyfill) object25 *26 * var localStorage = StorageManager.getStorage('local');27 * var sessionStorage = StorageManager.getStorage('session');28 *29 * You can also use its shorthands:30 *31 * var localStorage = StorageManager.getLocalStorage();32 * var sessionStorage = StorageManager.getSessionStorage();33 */34 window.StorageManager = (function () {35 var storage = {36 local: window.localStorage,37 session: window.sessionStorage38 },39 p;40 /**41 * Helper function to detect if cookies are enabled.42 * @returns {boolean}43 */44 function hasCookiesSupport() {45 // if cookies are already present assume cookie support46 if ('cookie' in document && (document.cookie.length > 0)) {47 return true;48 }49 document.cookie = 'testcookie=1;';50 var writeTest = (document.cookie.indexOf('testcookie') !== -1);51 document.cookie = 'testcookie=1' + ';expires=Sat, 01-Jan-2000 00:00:00 GMT';52 return writeTest;53 }54 // test for safari's "QUOTA_EXCEEDED_ERR: DOM Exception 22" issue.55 for (p in storage) {56 if (!storage.hasOwnProperty(p)) {57 continue;58 }59 try {60 storage[p].setItem('storage', '');61 storage[p].removeItem('storage');62 } catch (err) {63 }64 }65 // Just return the public API instead of all available functions66 return {67 /**68 * Returns the storage object/polyfill of the given type.69 *70 * @returns {Storage|StoragePolyFill}71 */72 getStorage: function (type) {73 return storage[type];74 },75 /**76 * Returns the sessionStorage object/polyfill.77 *78 * @returns {Storage|StoragePolyFill}79 */80 getSessionStorage: function () {81 return this.getStorage('session');82 },83 /**84 * Returns the localStorage object/polyfill.85 *86 * @returns {Storage|StoragePolyFill}87 */88 getLocalStorage: function () {89 return this.getStorage('local');90 },91 /**92 * Calls the clear() method of the storage from the given type.93 *94 * @param {String} type95 */96 clear: function (type) {97 this.getStorage(type).clear();98 },99 /**100 * Calls the getItem() method of the storage from the given type.101 *102 * @param {String} type103 * @param {String} key104 * @returns {String}105 */106 getItem: function (type, key) {107 return this.getStorage(type).getItem(key);108 },109 /**110 * Calls the key() method of the storage from the given type.111 *112 * @param {String} type113 * @param {Number|String} i114 * @returns {String}115 */116 key: function (type, i) {117 return this.getStorage(type).key(i);118 },119 /**120 * Calls the removeItem() method of the storage from the given type.121 *122 * @param {String} type123 * @param {String} key124 */125 removeItem: function (type, key) {126 this.getStorage(type).removeItem(key);127 },128 /**129 * Calls the setItem() method of the storage from the given type.130 *131 * @param {String} type132 * @param {String} key133 * @param {String} value134 */135 setItem: function (type, key, value) {136 this.getStorage(type).setItem(key, value);137 },138 /**139 * Helper function call to check if cookies are enabled.140 */141 hasCookiesSupport: hasCookiesSupport()142 };143 })();...

Full Screen

Full Screen

cookiestorage.js

Source:cookiestorage.js Github

copy

Full Screen

...12 var cookieStorage = new CookieStorage();13 assert.isTrue(baseCookie.areCookiesEnabled());14 localStorage.clear();15 var uid = String(new Date());16 cookieStorage.getStorage().set(uid, uid);17 assert.equal(cookieStorage.getStorage().get(uid), uid);18 assert.equal(cookie.get(uid), uid);19 assert.equal(cookieStorage.getStorage().get(uid), cookie.get(uid));20 cookieStorage.getStorage().remove(uid);21 assert.isNull(cookieStorage.getStorage().get(uid));22 assert.isNull(cookie.get(uid));23 // assert nothing added to localstorage24 assert.isNull(localStorage.getItem(keyPrefix + uid));25 });26 it('should fall back to localstorage if cookies disabled', function () {27 var cookieStorage = new CookieStorage();28 const stub = sinon.stub(baseCookie, 'areCookiesEnabled').returns(false);29 assert.isFalse(baseCookie.areCookiesEnabled());30 localStorage.clear();31 var uid = String(new Date());32 cookieStorage.getStorage().set(uid, uid);33 assert.equal(cookieStorage.getStorage().get(uid), uid);34 assert.equal(localStorage.getItem(keyPrefix + uid), JSON.stringify(uid));35 assert.equal(cookieStorage.getStorage().get(uid), JSON.parse(localStorage.getItem(keyPrefix + uid)));36 cookieStorage.getStorage().remove(uid);37 assert.isNull(cookieStorage.getStorage().get(uid));38 assert.isNull(localStorage.getItem(keyPrefix + uid));39 // assert nothing added to cookie40 assert.isNull(cookie.get(uid));41 stub.restore();42 });43 it('should load data from localstorage if cookies disabled', function () {44 var cookieStorage = new CookieStorage();45 const stub = sinon.stub(baseCookie, 'areCookiesEnabled').returns(false);46 assert.isFalse(baseCookie.areCookiesEnabled());47 localStorage.clear();48 var uid = String(new Date());49 localStorage.setItem(keyPrefix + uid, JSON.stringify(uid));50 assert.equal(cookieStorage.getStorage().get(uid), uid);51 localStorage.removeItem(keyPrefix + uid);52 assert.isNull(cookieStorage.getStorage().get(uid));53 stub.restore();54 });55 });...

Full Screen

Full Screen

Util.js

Source:Util.js Github

copy

Full Screen

...5const getRandomConversionRate = () => random(10, 1100, true)6const getStorage = (name, defaultValue) =>7 JSON.parse(window.localStorage.getItem(name) || defaultValue)8export const loadBlocks = () =>9 Number(getStorage('blocks', defaultBlocks))10export const loadClicks = () =>11 getStorage('clicks', '[]')12export const loadHashingRate = () =>13 Number(getStorage('hashingRate', initialHashingRate))14export const loadCoins = () =>15 Number(getStorage('coins', 0))16export const loadCoinLog = () =>17 Number(getStorage('coinlog', 0))18export const loadMoney = () =>19 Number(getStorage('money', 0))20export const loadAssets = () =>21 getStorage('assets', '[]')22export const loadAchievements = () =>23 getStorage('achievements', '[]')24export const loadSellingRate = () =>25 getStorage('sellingrate', getRandomConversionRate())26export const loadElectricity = () =>27 Number(getStorage('electricity', 0))28export const loadShopAssets = () =>29 getStorage('shopAssets') || shopAssets30export const loadPowerUps = () =>31 getStorage('powerUps') || powerUps32export const loadPowerUpsOwned = () =>33 getStorage('powerUpsOwned', '[]')34export const gameOverShown = () =>35 getStorage('gameOverShown', false)36// TODO: this should be in redux middleware37export const saveSellingRate = sellingrate =>...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('getStorage', (key) => {2 return cy.window().then((window) => {3 return window.localStorage.getItem(key);4 });5});6describe('test', () => {7 it('test', () => {8 cy.getStorage('token').then((token) => {9 });10 });11});

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('getStorage', (key) => {2 return cy.window().then((win) => {3 return win.localStorage.getItem(key);4 });5});6it('should get the storage of the browser', () => {7 cy.getStorage('key').should('be.eq', 'value');8});

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful