123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726 |
- <!DOCTYPE html>
- <html lang="zh-cn">
- <head>
- <meta charset="UTF-8">
- <meta name="format-detection" content="email=no" />
- <meta name="format-detection" content="telephone=no" />
- <title>添加变电柜</title>
- <link rel="stylesheet" href="../css/reset.css">
- <link rel="stylesheet" href="../css/style.css">
- <script src="../script/flexible.js"></script>
- <style>
- html,body{
- height: 100%;
- }
- html::-webkit-scrollbar {display:none}
- body::-webkit-scrollbar {display:none}
- .flex-wrap{
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- }
- .flex-con{
- -webkit-box-flex: 1;
- -webkit-flex: 1;
- flex: 1;
- }
- body{
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-orient: vertical;
- -webkit-flex-flow: column;
- flex-flow: column;
- background-color: #fff;
- }
- #header {
- min-height: 1.3rem;
- line-height: 1.3rem;
- background-color: #fff;
- color: #0b0b0b;
- position: relative;
- /*box-sizing: content-box;*/
- }
- #backBtn {
- width: 1.2rem;
- height: 1.4rem;
- line-height: 1rem;
- text-align: center;
- font-size: 1.3rem;
- position: absolute;
- left: 0;
- bottom: 0;
- }
- #backBtn img{
- display: inline-block;
- width: 50%;
- height: 40%;
- }
- .headTit {
- text-align: center;
- line-height: 1.4rem;
- font-size: .5rem;
- font-weight: normal;
- }
- .headGN {
- position: absolute;
- right: 0;
- bottom: 0;
- }
- .headGN li {
- display: none;
- width: 2.3rem;
- line-height: 1.4rem;
- font-size: .42rem;
- }
- .headGN li.active {
- display: block;
- }
- ::-webkit-input-placeholder{
- color: #b4b4b4;
- }
- main{
- overflow-x: hidden;
- overflow-y: auto;
- }
- .hr{
- width: 100%;
- height: .23rem;
- background-color: #fafafa;
- }
- .taskXQ{
- padding: .3rem;
- }
- .taskXQ>div{
- margin-bottom: .3rem;
- }
- .taskXQ>div h3{
- font-size: .42rem;
- color: #818181;
- font-weight: normal;
- margin-bottom: .1rem;
- }
- .task_taskCon p {
- margin-bottom: .2rem;
- color: #818181;
- font-size: .42rem;
- }
- .selectDiv>label{
- width: 100%;
- position: relative;
- }
- .selectDiv input{
- display: inline-block;
- width: 100%;
- font-size: .42rem;
- padding: .2rem;
- color: #818181;
- background-color: #fafafa;
- border: 1px solid #f0f0f0;
- }
- .xcms,.jwd,.zbbm,.selectUDiv,.selectStreet,.wxry,.lymac,.sctp,.s1,.s2,.s3,.s4{
- background-color: #fafafa;
- border: 1px solid #f0f0f0;
- padding: .2rem;
- }
- .searchBtn{
- width: 1.8rem;
- height: .9rem;
- line-height: 1rem;
- text-align: center;
- color: #fff;
- font-size: .4rem;
- background-color: dodgerblue;
- border-radius: .1rem;
- }
- label{
- padding: .1rem 0;
- color: #515151;
- }
- label input{
- border: none;
- outline: none;
- background-color: #fafafa;
- }
- .type_icon{
- color: #818181;
- font-size: .42rem;
- position: absolute;
- right: 0.16rem;
- top: 0;
- }
- .task_text{
- width: 100%;
- height: .6rem;
- max-height: .6rem;
- font-size: .42rem;
- color: #818181;
- background-color: #fafafa;
- resize: none;
- border: none;
- overflow-y: auto;
- }
- input.task_text2{
- width: 100%;
- font-size: .42rem;
- color: #818181;
- background-color: #fafafa;
- resize: none;
- border: none;
- overflow-x: auto;
- }
- .startBtn{
- width: 100%;
- height: 1.2rem;
- line-height: 1.2rem;
- font-size: .42rem;
- text-align: center;
- color: #fff;
- background-color: #22ad38;
- border-radius: .1rem;
- margin-top: .3rem;
- }
- .imgDiv div{
- width: 31.5%;
- height: 3.2rem;
- float: left;
- margin-right: 2%;
- margin-bottom: .1rem;
- }
- .imgDiv div:nth-of-type(3n){
- margin-right: 0;
- }
- .imgDiv div img{
- display: inline-block;
- width: 100%;
- height: 2.8rem;
- }
- .imgDiv div p{
- text-align: center;
- font-size: .3rem;
- line-height: .38rem;
- color: #717171;
- }
- .h3{
- font-size: .42rem;
- color: #515151;
- margin: .1rem 0 .2rem;
- }
- </style>
- </head>
- <body>
- <header>
- <div id="header">
- <i id="backBtn"><img src="../image/backBtn.png" alt=""></i>
- <h3 class="headTit">添加变电柜</h3>
- <!--<ul class="headGN">-->
- <!--<li></li>-->
- <!--</ul>-->
- </div>
- </header>
- <main class="flex-con">
- <div class="hr"></div>
- <div class="taskXQ">
- <div class="xcms">
- <h3>变电柜名称:</h3>
- <input id="name" class="task_text2">
- </div>
- <div class="jwd">
- <h3>变电柜经纬度:</h3>
- <label>经度:<input type="text" readonly="readonly" id="lon"></label><br>
- <label>纬度:<input type="text" readonly="readonly" id="lat"></label>
- </div>
- <div class="xcms">
- <h3>变电柜详细地址:</h3>
- <textarea id="address" class="task_text"></textarea>
- </div>
- <div class="sctp">
- <h3>变电柜图片:</h3>
- <div class="imgDiv clearFix"></div>
- </div>
- <div class="selectStreet">
- <h3>所属街道:</h3>
- <input id="selectStreet" class="task_text2" readonly="readonly" value="">
- </div>
- <div class="selectUDiv">
- <h3>维修人员:</h3>
- <input id="selectUser" class="task_text2" readonly="readonly" value="">
- </div>
- <div class="zbbm" rel="main">
- <h3>主板编码:</h3>
- <input id="code" class="task_text2" readonly="readonly">
- </div>
- <div class="lymac" rel="main">
- <h3>蓝牙mac:</h3>
- <input id="BleCode" class="task_text2" readonly="readonly">
- </div>
- <div>
- <div class="startBtn" id="bdgBtn">确认添加变电柜</div>
- </div>
- </div>
- </main>
- <script src="../script/jqueryMin.js"></script>
- <script src="../script/createTime.js"></script>
- <script src="../script/publicData.js"></script>
- <script src="../script/api.js"></script>
- <script>
- apiready=function () {
- $("#selectUser").val($api.getStorage("user").name);
- var imgdata=[],bl=false,bdgid=null,street=[];
- var arr=["锁1","锁2","锁3","锁4"];
- var selectData=[],userArr=[];
- var UIMediaScanner = api.require('UIMediaScanner');
- var streetList=$api.getStorage("streetList");
- $(".zbbm,.lymac").click(function () {
- showCode($(".zbbm").find('input'),$(".lymac").find('input'))
- })
- $(".s1,.s2,.s3,.s4").click(function () {
- showCode($(this).find('input'))
- })
- $(".jwd").click(function () {
- getLoc($("#lat"),$("#lon"),$("#address"));
- api.toast({
- msg: '正在获取当前位置',
- duration: 2000,
- location: 'bottom'
- });
- })
- $(".sctp").click(function () {
- getPhoto($(".imgDiv"));
- })
- $(".imgDiv").on('click','div',function (e) {
- e.stopPropagation();
- uploading($(this),imgdata);
- })
- var selectData=$api.getStorage("userList");
- $(".selectUDiv").click(function () {
- showBox($(".selectUDiv"),selectData,true);
- })
- $(".selectStreet").click(function () {
- showBox($(".selectStreet"),streetList,true);
- })
- $(".selectDiv label").click(function () {
- api.actionSheet({
- title: '选择锁',
- buttons: arr
- }, function (ret, err) {
- if(ret.buttonIndex>arr.length) return;
- $("#type").val(arr[ret.buttonIndex-1])
- $("#key1").val("0"+ret.buttonIndex.toString())
- });
- })
- $("#bdgBtn").click(function () {
- checkNull($("#name"));
- checkNull($("#address"));
- checkNull($("#lat"));
- checkNull($("#lon"));
- checkNull($("#code"));
- checkNull($("#BleCode"));
- checkNull($("#selectStreet"));
- if(imgdata.length==0){
- bl=true;
- }
- if (bl) {
- api.toast({
- msg: '还有未填项',
- duration: 2000,
- location: 'bottom'
- });
- bl=false;
- return;
- }
- var postData = {
- title: $("#name").val(),
- address: $("#address").val(),
- lat: $("#lat").val(),
- lon: $("#lon").val(),
- code: $("#code").val().toLocaleUpperCase(),
- mac_address: $("#BleCode").val(),
- street_id:street[0],
- img: imgdata[0],
- temperature: 0,
- humidity: 0,
- user_id: userArr[0]||$api.getStorage("user").id
- }
- api.showProgress({
- title: '正在添加中...',
- text: '请稍等...',
- modal: false
- });
- api.ajax({
- url: pageUrl + "/index/bdg/addbdg",
- method: 'post',
- timeout: 30,
- dataType: 'text',
- returnAll: false,
- data: {
- values: postData
- }
- }, function (data, err) {
- var data = JSON.parse(data);
- api.hideProgress();
- if (data.status) {
- bdgid = data.bdg_id;
- $("#name").val(" ");
- $("#address").val(" ");
- $("#lat").val(" ");
- $("#lon").val(" ");
- $("#code").val(" ");
- $("#BleCode").val(" ");
- imgdata = [];
- $(".imgDiv").html(" ")
- api.openWin({
- name: 'addKey',
- url: './addKey.html',
- pageParam: {bdgid: bdgid}
- });
- setTimeout(function () {
- api.closeWin();
- },300)
- }
- api.toast({
- msg: data.status == "0" ? "添加失败" : "添加成功",
- duration: 2000,
- location: 'bottom'
- });
- api.execScript({
- name: 'root',
- script: 'totalTime(0);'
- });
- });
- })
- function showBox(that,data,bl) {
- var UIMultiSelector= api.require('UIMultiSelector');
- if(data.length==0) {
- api.toast({
- msg: '暂无数据',
- duration: 2000,
- location: 'bottom'
- });
- return;
- }
- var user=$api.getStorage("user");
- UIMultiSelector.open({
- rect: {
- h: 244
- },
- text: {
- title: '',
- leftBtn: '',
- rightBtn: '',
- selectAll: '全选'
- },
- max: 0,
- singleSelection:bl,
- styles: {
- mask: 'rgba(0,0,0,0.2)',
- title: {
- bg: '#efefef',
- h: 44
- },
- leftButton: {
- w: 60,
- h: 30,
- marginT: 5,
- marginL: 8,
- bg:"widget://image/cancel.png"
- },
- rightButton: {
- w: 60,
- h: 30,
- marginT: 5,
- marginR: 8,
- bg:"widget://image/finish.png"
- },
- item: {
- h: 40,
- bg: '#fff',
- bgActive: '#fff',
- bgHighlight: '#fff',
- color: '#818181',
- active: '#818181',
- highlight: '#818181',
- size: 14,
- lineColor: '#efefef',
- textAlign: 'left',
- marginR:5
- },
- icon: {
- w: 20,
- h: 20,
- marginT: 11,
- marginH: 8,
- bg: 'widget://image/select.png',
- bgActive: 'widget://image/selected.png',
- align: 'left'
- }
- },
- animation: true,
- items: data
- }, function(ret, err) {
- if (ret) {
- if(ret.eventType=="clickRight"){
- var nameStr="",arr=[],arr2=[];
- try{
- for(var i in ret.items){
- arr[i]={
- type:ret.items[i].id,
- name:ret.items[i].text
- }
- arr2.push(ret.items[i].id)
- if(i==ret.items.length-1||ret.items.length==1){
- nameStr+=ret.items[i].text;
- }else {
- nameStr+=ret.items[i].text+"、";
- }
- }
- if(that.hasClass("selectUDiv")){
- userArr= arr2;
- }else if(that.hasClass("selectStreet")){
- street= arr2;
- }
- }catch (e){
- nameStr="";
- }
- that.find("input").val(nameStr);
- UIMultiSelector.close();
- }else if(ret.eventType=="clickLeft"){
- UIMultiSelector.close();
- }
- } else {
- // alert(JSON.stringify(err));
- }
- });
- }
- function getLoc(this_lat,this_lon,address) {
- var map = api.require('bMap');
- map.getLocationServices(function(ret, err) {
- if (ret.enable) {
- map.getLocation({
- accuracy: '10m',
- autoStop: true,
- filter: 1
- }, function (ret, err) {
- if (ret.status) {
- this_lon.val(ret.lon);
- this_lat.val(ret.lat);
- map.stopLocation();
- map.getNameFromCoords({
- lon: ret.lon,
- lat: ret.lat
- }, function(ret, err) {
- if (ret.status) {
- address.val(ret.address)
- }
- });
- }
- else {
- // alert(err.code);
- }
- });
- }else {
- api.toast({
- msg: '未开启定位功能!',
- duration: 2000,
- location: 'bottom'
- });
- }
- })
- }
- function showCode(that,xll) {
- // var FNScanner = api.require('FNScanner');
- // FNScanner.openScanner({
- // autorotation: true
- // }, function(ret) {
- //
- // });
- api.openWin({
- name: 'QRCode',
- url: './QRCode.html',
- pageParam: {
- name: 'BdgQRData'
- }
- });
- api.addEventListener({
- name: 'BdgQRData'
- }, function (ret, err) {
- var ret = ret.value.data;
- if (ret) {
- if(ret.eventType=="success"){
- if(xll){
- that.val(JSON.parse(ret.content)['code'])
- xll.val(JSON.parse(ret.content)['mac'])
- }else {
- that.val(JSON.parse(ret.content)['code'])
- }
- }
- }
- })
- }
- function uploading(that,arr) {
- if(that.hasClass("uploadImg")){
- api.actionSheet({
- title: '上传/删除图片',
- cancelTitle: '取消',
- buttons: ['上传', '删除']
- }, function(ret, err) {
- var index = ret.buttonIndex;
- if(index==1){
- var imageFilter = api.require('imageFilter');
- var imageName = "znmsimg";
- var imageCachePath = api.cacheDir;
- var newimg="";
- imageFilter.compress({
- img: that.children('img').attr('src'),
- quality:0.8,
- size:{
- w:550,
- h:480
- },
- save: {
- album: false,
- imgPath: imageCachePath,
- imgName: imageName + '.jpg'
- }
- }, function(ret, err) {
- var tx = imageCachePath + '/' + imageName + '.jpg';
- that.children('p').text('正在上传中');
- api.ajax({
- url: pageUrl + "/api/uploadImage",
- method: 'post',
- timeout: 30,
- dataType: 'json',
- returnAll: false,
- data: {
- files: {
- file: tx
- }
- }
- }, function (ret, err) {
- // var data=JSON.parse(ret);
- // alert(JSON.stringify(ret));
- that.children('p').text(ret.status == 1 ? "上传成功" : "上传失败");
- if (ret.status == 1) {
- arr[0] = ret.uri;
- }
- api.execScript({
- name: 'root',
- script: 'totalTime(0);'
- });
- });
- })
- }else if(index==2){
- that.remove();
- }
- })
- }
- }
- function getPhoto(that) {
- api.actionSheet({
- title: '上传图片',
- cancelTitle: '取消',
- buttons: ['相册', '相机']
- }, function(ret, err) {
- var index = ret.buttonIndex;
- if(index==1){
- UIMediaScanner.open({
- type: 'picture',
- column: 4,
- max: 1,
- sort: {
- key: 'time',
- order: 'desc'
- },
- texts: {
- stateText: '已选择*项',
- cancelText: '取消',
- finishText: '完成'
- },
- styles: {
- bg: '#fff',
- mark: {
- icon: '',
- position: 'bottom_left',
- size: 20
- },
- nav: {
- bg: '#eee',
- stateColor: '#000',
- stateSize: 18,
- cancelBg: 'rgba(0,0,0,0)',
- cancelColor: '#000',
- cancelSize: 18,
- finishBg: 'rgba(0,0,0,0)',
- finishColor: '#000',
- finishSize: 18
- }
- },
- exchange: true
- }, function(ret) {
- if (ret.eventType=="confirm") {
- for(var i in ret.list){
- if(api.systemType=="ios"){
- UIMediaScanner.transPath({
- path: ret.list[i]["path"]
- }, function(ret, err) {
- if (ret) {
- that.html("<div class='uploadImg'><img src='file://"+ret.path+"' alt=''><p class='imgRemind'>点击图片上传</p></div>");
- // imgData.push("file://"+ret.path);
- } else {
- // alert(JSON.stringify(err));
- }
- });
- }else {
- that.html("<div class='uploadImg'><img src='file://"+ret.list[i]["path"]+"' alt=''><p class='imgRemind'>点击图片上传</p></div>");
- // imgData.push("file://"+ret.list[i]["path"]);
- }
- }
- }
- });
- }else if(index==2){
- api.getPicture({
- sourceType: 'camera',
- encodingType: 'jpg',
- mediaValue: 'pic',
- saveToPhotoAlbum:'true',
- destinationType: 'url',
- quality: 50
- }, function(ret, err) {
- if (ret) {
- if(!ret.data) return;
- // imgData.push("file://"+ret.data);
- that.html("<div class='uploadImg'><img src='file://"+ret.data+"' alt=''><p class='imgRemind'>点击图片上传</p></div>");
- } else {
- // alert(JSON.stringify(err));
- }
- });
- }else {}
- });
- }
- function checkNull(that) {
- if(that.val()==""){
- bl=true;
- }
- return that.val()
- }
- $("#backBtn").click(function () {
- api.closeToWin({
- name: 'root',
- animation: {
- type: 'push',
- subType: 'from_left',
- duration: 300
- },
- delay:300
- });
- })
- }
- </script>
- </body>
- </html>
|