allcabinet.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="format-detection" content="telephone=no" />
  6. <meta name="format-detection" content="email=no" />
  7. <title>mes</title>
  8. <link rel="stylesheet" href="../css/reset.css">
  9. <script src="../script/flexible.js"></script>
  10. <style>
  11. html,body{
  12. height:100%;
  13. }
  14. .task_con {
  15. overflow-y: auto;
  16. overflow-x: hidden;
  17. padding-top: .23rem;
  18. -webkit-transform: translateZ(0);
  19. transform: translateZ(0);
  20. }
  21. .task_con ul{
  22. display: none;
  23. }
  24. .task_con li {
  25. min-width: 100%;
  26. height: 3rem;
  27. margin-bottom: .1rem;
  28. background-color: #fff;
  29. padding: .3rem .2rem;
  30. position: relative;
  31. }
  32. .task_con li>div {
  33. display: inline-block;
  34. }
  35. .task_taskCon{
  36. padding-top: .1rem;
  37. }
  38. .task_taskCon p{
  39. height: .5rem;
  40. margin-bottom: .25rem;
  41. }
  42. .selectDiv{
  43. width: 0;
  44. height: 100%;
  45. overflow: hidden;
  46. position: relative;
  47. -webkit-transition: .3s;
  48. transition: .3s;
  49. }
  50. .selectDiv img{
  51. display: inline-block;
  52. width: .6rem;
  53. height: .6rem;
  54. position: absolute;
  55. left: calc(50% - .3rem);
  56. top: calc(50% - .3rem);
  57. }
  58. .selectDiv.active{
  59. width: 1.5rem;
  60. }
  61. .disImg{
  62. width: 2.5rem;
  63. height: 2.3rem;
  64. margin-right: .15rem;
  65. }
  66. .disImg img{
  67. display: inline-block;
  68. width: 100%;
  69. height: 100%;
  70. }
  71. .task_dbqk {
  72. display: inline-block;
  73. font-size: .3rem;
  74. border-radius: .3rem;
  75. padding: 0 .2rem;
  76. margin-left: .23rem;
  77. white-space: nowrap;
  78. }
  79. .task_dbqk1{
  80. color: #f39700;
  81. border: 1px solid #f39700;
  82. }
  83. .task_dbqk2{
  84. color: #ff0000;
  85. border: 1px solid #ff0000;
  86. }
  87. .task_dbqk3{
  88. color: #bbbc5f;
  89. border: 1px solid #bbbc5f;
  90. }
  91. .task_dbqk4{
  92. color: #e60012;
  93. border: 1px solid #e60012;
  94. }
  95. .task_dbqk5{
  96. color: #cacbbb;
  97. border: 1px solid #cacbbb;
  98. }
  99. .task_name{
  100. font-size: .42rem;
  101. color: #3d3d3d;
  102. }
  103. .ds{
  104. font-size: .4rem;
  105. color: #818181;
  106. }
  107. .ms span{
  108. font-size: .3rem;
  109. padding: .1rem .15rem;
  110. color: #fff;
  111. background-color: #22ad38;
  112. border-radius: .1rem;
  113. margin-right: .1rem;
  114. }
  115. .ms span.active{
  116. background-color: #f36523;
  117. }
  118. .ds i{
  119. display: inline-block;
  120. height: .3rem;
  121. }
  122. .ds i:nth-of-type(1){
  123. width: .2rem;
  124. margin-right: .1rem;
  125. }
  126. .ds i:nth-of-type(2){
  127. width: .23rem;
  128. }
  129. .ds i img{
  130. display: inline-block;
  131. width: 100%;
  132. height: 100%;
  133. }
  134. .ds>span.active{
  135. color: #ff0000;
  136. }
  137. .task_jt {
  138. position: absolute;
  139. top:0;
  140. right: 0;
  141. height: 100%;
  142. line-height: 3rem;
  143. font-size: .5rem;
  144. color: #b5b5b5;
  145. padding: 0 .15rem;
  146. }
  147. .hid{
  148. display: none;
  149. }
  150. </style>
  151. </head>
  152. <body>
  153. <div class="flex-con task_con">
  154. <ul>
  155. <li class="flex-wrap" data-taskid="{{taskID}}" data-lon="{{lon}}" data-lat="{{lat}}">
  156. <div class="selectDiv"><img src="../image/selectIcon.png" alt="" rel="true"></div>
  157. <div class="disImg">{{img}}</div>
  158. <div class="task_taskCon flex-con">
  159. <p class="clearFix"><span class="task_name left">{{name}}</span><span class="task_dbqk task_dbqk2 left {{isH}}">温度过高</span></p>
  160. <p class="ds"><span class="{{dsactive1}}"><i><img src="{{dsimg1}}" alt=""></i>温度<span id="wd">{{wd}}</span>℃</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="{{dsactive2}}"><i><img src="{{msactive2}}" alt=""></i> 湿度<span id="sd">{{sd}}</span>%</span></p>
  161. <p class="ms"><span class="{{msactive}}">{{isjd}}</span>{{mss}}</p>
  162. </div>
  163. <div class="task_jt">〉</div>
  164. </li>
  165. </ul>
  166. </div>
  167. <script src="../script/publicData.js"></script>
  168. <script src="../script/jqueryMin.js"></script>
  169. <script type="text/javascript" src="../script/api.js"></script>
  170. <script>
  171. var selectArr=[],titArr=[];
  172. apiready = function() {
  173. if(api.systemType=="ios"){
  174. $(".task_taskCon p").css("margin-bottom",".1rem")
  175. }
  176. var photoBrowser = api.require('photoBrowser');
  177. api.showProgress({
  178. title: '努力加载中...',
  179. text: '请稍等...',
  180. modal: false
  181. });
  182. var duty=[];
  183. var postData={
  184. user_id:$api.getStorage("user").id
  185. };
  186. var ulModel=$(".task_con ul").html();
  187. var spanModel='<span class="{{ish}}">{{num}}</span>';
  188. var imgModel='<img src="{{img}}" alt="">';
  189. getData();
  190. function getData() {
  191. api.execScript({
  192. name: 'winname',
  193. script: 'selFalse();'
  194. });
  195. api.ajax({
  196. url: pageUrl+"/index/street/street-info",
  197. method: 'get',
  198. timeout: 30,
  199. dataType: 'text',
  200. returnAll: false,
  201. data: {
  202. values: {street_id:api.pageParam.index}
  203. }
  204. }, function (data, err) {
  205. data=JSON.parse(data)
  206. // console.log(JSON.stringify(data))
  207. var data=data.bdg,str="",str2="";
  208. var dataNames1=[];
  209. if(!data.length){
  210. str="<p style='padding-top: 5.3rem;font-size: .5rem;text-align: center;color: #818181'>暂无变电柜</p>"
  211. }else {
  212. for(var i in data){
  213. str+=ulModel.replace("{{taskID}}",data[i]['id']).replace("{{name}}",data[i]['title']).replace("{{img}}",imgModel.replace("{{img}}",pageImg+data[i]['img'])).replace("{{isH}}",data[i]['temperature']>50?"":"hid").replace("{{dsactive1}}",data[i]['temperature']>50?"active":"")
  214. .replace("{{dsactive2}}",data[i]['humidity']>50?"active":"").replace("{{msactive}}",data[i]['has_dian']=="0"?"active":"").replace("{{dsimg1}}",data[i]['temperature']>50?"../image/map_popups_icon1_2.png":"../image/map_popups_icon1.png")
  215. .replace("{{msactive2}}",data[i]['humidity']>50?"../image/map_popups_icon2_2.png":"../image/map_popups_icon2.png").replace("{{wd}}",data[i]['temperature']).replace("{{sd}}",data[i]['humidity']).replace("{{isjd}}",data[i]['has_dian']=="0"?"离线":"在线").replace("{{lon}}",data[i]['lon']).replace("{{lat}}",data[i]['lat'])
  216. str2="";
  217. for(var j in data[i]['lock']){
  218. str2+=spanModel.replace("{{ish}}",data[i]['lock'][j]["is_lock"]=="0"?"":"active").replace("{{num}}",data[i]['lock'][j]['title'])
  219. }
  220. str=str.replace("{{mss}}",str2)
  221. duty[i]={
  222. id:data[i]['id'],
  223. text: data[i]['title'],
  224. status: 'normal'
  225. }
  226. }
  227. }
  228. api.refreshHeaderLoadDone();
  229. api.hideProgress();
  230. $(".task_con ul").html(str).css("display","block");
  231. selBox();
  232. searchFn1(dataNames1)
  233. $api.setStorage("allBDG",duty);
  234. $(".task_con>ul>li").click(function () {
  235. //在名为winName的window中执行jsfun脚本
  236. if($(".selectDiv").hasClass("active")){
  237. $(this).find('.selectDiv')[0].click();
  238. }else {
  239. var that=$(this);
  240. api.openWin({
  241. name: 'createTask',
  242. url: './createTask.html',
  243. pageParam: {name: $(this).find(".task_name").text(),id:this.dataset.taskid}
  244. });
  245. }
  246. })
  247. $(".disImg>img").click(function (e) {
  248. e.stopPropagation();
  249. photoBrowser.open({
  250. images: [
  251. "http"+$(this).attr("src").slice(4)
  252. ],
  253. placeholderImg: 'widget://res/img/apicloud.png',
  254. bgColor: '#000'
  255. }, function(ret, err) {
  256. $api.setStorage("imgOpen","1");
  257. api.addEventListener({
  258. name: 'closeImg'
  259. }, function (ret, err) {
  260. photoBrowser.close();
  261. $api.setStorage("imgOpen",null);
  262. });
  263. if (ret) {
  264. if(ret.eventType=="click"){
  265. photoBrowser.close();
  266. $api.setStorage("imgOpen",null);
  267. }
  268. } else {
  269. api.toast({
  270. msg: '图片加载失败',
  271. duration: 2000,
  272. location: 'bottom'
  273. });
  274. }
  275. });
  276. })
  277. api.execScript({
  278. name: 'root',
  279. script: 'totalTime(0);'
  280. });
  281. });
  282. }
  283. function selBox() {
  284. var num=0;
  285. $(".selectDiv").click(function (e) {
  286. e.stopPropagation();
  287. if($(this).find("img").attr("rel")=="true"){
  288. $(this).find("img").attr({"src":"../image/selectIcon2.png","rel":"false"});
  289. $(this).parent().addClass("isSel");
  290. num++;
  291. api.execScript({
  292. name: 'root',
  293. script: 'selTrue();'
  294. });
  295. }else {
  296. $(this).find("img").attr({"src":"../image/selectIcon.png","rel":"true"});
  297. $(this).parent().removeClass("isSel");
  298. num--;
  299. if (!num) {
  300. api.execScript({
  301. name: 'root',
  302. script: 'selFalse();'
  303. });
  304. }
  305. }
  306. })
  307. }
  308. function getTime(time) {
  309. var time=new Date(time*1000),str="";
  310. var year=time.getFullYear();
  311. var month=time.getMonth()+1;
  312. var day=time.getDate();
  313. var hours=time.getHours();
  314. var minutes=time.getMinutes();
  315. var str=year+"-"+checkTime(month)+"-"+checkTime(day)+" "+checkTime(hours)+":"+checkTime(minutes);
  316. return str;
  317. }
  318. function checkTime(val) {
  319. var val=val;
  320. if((val+"").length==1){
  321. val="0"+val;
  322. }
  323. return val
  324. }
  325. function searchFn1(dataNames) {
  326. api.addEventListener({name:"search1"},function (ret) {
  327. var re=new RegExp("("+ret.value.val+")"),liArr=[];
  328. for(var i=0;i<dataNames.length;i++){
  329. if(re.test(dataNames[i])){
  330. liArr.push($(".task_con ul li").get(i));
  331. }
  332. }
  333. if(!liArr.length){
  334. api.toast({
  335. msg: '没有搜索到该任务',
  336. duration: 2000,
  337. location: 'bottom'
  338. });
  339. }else {
  340. $(".task_con ul").html(" ");
  341. for(var j=0;j<liArr.length;j++){
  342. $(".task_con ul").append(liArr[j]);
  343. }
  344. }
  345. })
  346. }
  347. $("body").click(function () {
  348. api.sendEvent({
  349. name: 'clInput'
  350. });
  351. })
  352. api.setRefreshHeaderInfo({
  353. loadingImg: 'widget://image/refresh.png',
  354. bgColor: '#fff',
  355. textColor: '#818181',
  356. textDown: '下拉刷新...',
  357. textUp: '松开刷新...'
  358. }, function(ret, err) {
  359. //在这里从服务器加载数据,加载完成后调用api.refreshHeaderLoadDone()方法恢复组件到默认状态
  360. getData();
  361. });
  362. }
  363. function showSelect() {
  364. $(".selectDiv").addClass("active");
  365. }
  366. function hidSelect() {
  367. var activeLi=document.getElementsByClassName("isSel"),selectArr=[],titArr=[];
  368. if(activeLi.length){
  369. for(var i=0;i<activeLi.length;i++){
  370. selectArr.push(activeLi[i].dataset.taskid);
  371. titArr.push(activeLi[i].getElementsByClassName("task_name")[0].innerText);
  372. }
  373. $api.setStorage("CTasks",selectArr);
  374. $api.setStorage("tasksTit",titArr);
  375. }
  376. $(".selectDiv").removeClass("active").find("img").attr("src","../image/selectIcon.png");
  377. }
  378. </script>
  379. </body>
  380. </html>