| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245 |
- const app = getApp();
- var util = require('../../../utils/util.js');
- var util1 = require('../../utils/wgs84Gcj02.js');
- var timerListJd = [];
- var timerList = [];
- var Jdtime;
- var Datetime;
- var searchTimer;
- Page({
- data: {
- Type: [], // 原先默认为【1】
- typeStr: '', // 原先默认为 "1"
- listType: '', // 传递过来的参数
- mileage: 0, //里程
- mileage1: 0, //转化进制后的里程
- posObj: {
- latitude: null,
- longitude: null,
- }, //当前坐标点
- lastPosObj: {
- latitude: null,
- longitude: null,
- }, //上一个坐标点
- polyline: [], //路线数组
- flag: false,
- flag1: true,
- info: {}, //当前巡查对象
- hours: '0' + 0, // 时
- minute: '0' + 0, // 分
- second: '0' + 0, // 秒
- imgDailog: false, //发现问题 弹框
- uploaderList: [], //保存上传图片url的数组
- fFileurl: [],
- uploaderNum: 0, //已经上传的图片数目
- formFileurl: [], //上传图片返回数据
- arrPoint: [], //坐标数组
- arrAddress: [],
- startTime: '',
- parkList: [],
- parkIndex: 0,
- isExist: 0,
- yhdwList: [],
- yhdwIndex: 0,
- // ===========
- WorkList: [], //工单列表
- text: null, //工单内容
- workZb: {
- latitude: null,
- longitude: null, // 记录 发现问题的 坐标
- },
- // 判断是否已经创建 巡查单
- status: false,
- endFlag: false,
- xiping: false,
- position: '', //角色权限判断
- positionFlag: false,
- yhCompanyId: null,
- maintenanceCompanyId: null,
- checkFlag: false, // 选路
- checkboxEd: false, //控制选路的 显示
- ldList: [], // 路 路段 的 数组 集合
- addldList: [], // 要巡查的 路段
- allldList: [], //所有的 路段 作为查询
- isBack:false,
- vehicleFlag: false,
- vehicleList: [{
- id: 1,
- name: '步行'
- },
- {
- id: 2,
- name: '非机动车'
- },
- {
- id: 3,
- name: '机动车'
- },
- ],
- addVehicleList: [],
- // 巡查单
- InspectionInfo: {},
- // 问题类型
- workTypeList: [],
- worktypeIndex: 0,
- workNum: 0, //问题数量
- XDSflag: 1,
- huatanFlag: false,
- huatanList: [],
- huatanIndex: 0,
- huatanType: '1',
- temperature: '', //温度
- humidity: '', //湿度
- wormList: [],
- wormIndex: null,
- hostbiology: '', //寄主生物
- hazardRatio: 0, //危害率
- remark: '',
- dangerLevelLIst: [],
- dangerLevelIndex: null,
- pestNewName: '',
- issueTypeList: [],
- issueTypeIndex: null,
- bchFlag: false, //是否显示病虫害
- xdsList: [],
- matchedDailog:false,
- detailList:[],//已匹配路段
- },
- huatanEdit(e) {
- this.setData({
- huatanType: e.detail.value,
- });
- },
- bindHostInput(e) {
- this.setData({
- hostbiology: e.detail.value,
- });
- },
- bindHazardRatioInput(e) {
- this.setData({
- // hazardRatio: parseInt(e.detail.value),
- hazardRatio: e.detail.value
- });
- },
- dangerLevelChange(e) {
- this.setData({
- dangerLevelIndex: e.detail.value,
- hazardRatio: this.data.dangerLevelLIst[e.detail.value].label
- });
- },
- bindRemarkInput(e) {
- this.setData({
- remark: e.detail.value,
- });
- },
- getHuatanbyid(i1, i2) {
- var that = this;
- app.loading();
- let url =
- app.globalData.httpsUrlServer + '/roadplantscondition/t-lhzx-road-plants-condition/list';
- let data = {
- sectionId: i1,
- maintenanceCompanyId: i2,
- };
- app.getReqNew(url, data, (res) => {
- if (res.code == 0) {
- that.setData({
- huatanList: res.data,
- });
- app.hideloading();
- }
- })
- },
- // 切换花坛
- changeHuatna(e) {
- this.setData({
- huatanIndex: e.detail.value,
- });
- },
- // 添加路 路段
- addItem(e) {
- let obj = e.currentTarget.dataset.item;
- let state;
- if (this.data.addldList.length > 0) {
- state = this.data.addldList.findIndex((v) => {
- return v.id == obj.id;
- });
- if (state == -1) {
- this.data.addldList.push(obj);
- } else {
- app.toast('已添加');
- }
- } else {
- this.data.addldList.push(obj);
- }
- this.setData({
- addldList: this.data.addldList,
- });
- },
- // 删除路 和路段
- removeItem(e) {
- let obj = e.currentTarget.dataset.item;
- this.data.addldList = this.data.addldList.filter((v) => {
- return v.id != obj.id;
- });
- this.setData({
- addldList: this.data.addldList,
- });
- },
- // 搜索 路 和路段
- searchItem(e) {
- clearTimeout(searchTimer);
- searchTimer = setTimeout(() => {
- wx.showLoading({
- title: '加载中',
- mask: true,
- });
- let val = e.detail.value.trim();
- let arr = [];
- this.data.allldList.forEach((v) => {
- let flag1 = v.roadName ? v.roadName.indexOf(val) != -1 : false;
- let flag2 = v.roadStartSpot ? v.roadStartSpot.indexOf(val) != -1 : false;
- let flag3 = v.roadEndSpot ? v.roadEndSpot.indexOf(val) != -1 : false;
- if (flag1 || flag2 || flag3) {
- arr.push(v);
- }
- });
- this.setData({
- ldList: arr,
- });
- wx.hideLoading();
- }, 1000);
- if (e.detail.value.trim() == '') {
- // 给 数组 重新赋值 但是已选择 的不能存在
- this.setData({
- ldList: this.data.allldList,
- });
- }
- },
- // 清空 路 和路段
- clearItem() {
- console.log('所有的路段', this.data.allldList);
- console.log('未选的路段', this.data.ldList);
- console.log('选择的路段', this.data.addldList);
- },
- // 隐藏
- hideCk() {
- let that = this;
- // 设置花坛
- // let id1 = that.data.parkList[that.data.parkIndex].sectionId;
- let id1 = that.data.parkList[that.data.parkIndex].fParkid;
- let id2;
- if (that.data.yhdwList.length == 0) {
- id2 = that.data.yhCompanyId;
- } else {
- // maintenanceCompanyId
- id2 = that.data.yhdwList[that.data.yhdwIndex].oldMaintenanceCompanyId;
- }
- that.getHuatanbyid(id1, id2);
- this.setData({
- checkboxEd: false,
- });
- },
- onSupple() {
- this.setData({
- checkboxEd: false,
- });
- },
- onBack(){
- this.setData({
- checkboxEd: false,
- });
- },
- // 显示
- ShowCk() {
- if (!this.data.parkList[this.data.parkIndex]) {
- return app.toast('请先选择路段');
- }
- if (this.data.flag) {
- return app.toast('巡查过程中不可更换');
- }
- // let id = this.data.parkList[this.data.parkIndex].sectionId;
- let id = this.data.parkList[this.data.parkIndex].id;
- if (id) {
- if (this.data.addldList.length == 0) {
- // this.getLdListbyid(id);
- this.getLdListbyid();
- }
- this.setData({
- checkboxEd: true,
- });
- } else {
- return app.toast('请先选择路段');
- }
- },
- ShowVehicle() {
- this.setData({
- vehicleFlag: true,
- });
- },
- hideVehicle() {
- this.setData({
- vehicleFlag: false,
- });
- },
- addVehicle(e) {
- let obj = e.currentTarget.dataset.item;
- let state;
- if (this.data.addVehicleList.length > 0) {
- state = this.data.addVehicleList.findIndex((v) => {
- return v.id == obj.id;
- });
- if (state == -1) {
- this.data.addVehicleList.push(obj);
- } else {
- app.toast('已添加');
- }
- } else {
- this.data.addVehicleList.push(obj);
- }
- this.setData({
- addVehicleList: this.data.addVehicleList,
- });
- },
- removeVehicle(e) {
- let obj = e.currentTarget.dataset.item;
- this.data.addVehicleList = this.data.addVehicleList.filter((v) => {
- return v.id != obj.id;
- });
- this.setData({
- addVehicleList: this.data.addVehicleList,
- });
- },
- // 获取坐标
- tap1() {
- let that = this;
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy: true,
- success(res) {
- var arr = [];
- arr.push({
- latitude: res.latitude,
- longitude: res.longitude,
- });
- that.getAddress(res.latitude, res.longitude);
- that.data.arrPoint = that.data.arrPoint.concat(arr);
- that.setData({
- arrPoint: that.data.arrPoint,
- posObj: {
- latitude: res.latitude,
- longitude: res.longitude,
- },
- });
- // 每次获取上一次的坐标点 计算里程数
- // 纬度 纬度
- if (that.data.arrPoint.length > 2) {
- let last = that.data.arrPoint[that.data.arrPoint.length - 2];
- that.data.lastPosObj.latitude = last.latitude;
- that.data.lastPosObj.longitude = last.longitude;
- that.setData({
- lastPosObj: that.data.lastPosObj,
- });
- that.distance(
- that.data.posObj.latitude * 1,
- that.data.posObj.longitude * 1,
- that.data.lastPosObj.latitude * 1,
- that.data.lastPosObj.longitude * 1
- );
- }
- },
- });
- },
- getAddress(latitude, longitude) {
- let that = this;
- wx.request({
- url: 'https://apis.map.qq.com/ws/geocoder/v1/', //仅为示例,并非真实的接口地址
- data: {
- location: latitude + ',' + longitude,
- get_poi: 1,
- key: "PIDBZ-L75KO-6HKWR-SGRJQ-IP7VV-UZBLJ",
- },
- header: {
- 'content-type': 'application/json' // 默认值
- },
- success(res) {
- let address = res.data.result.address_component.street;
- that.setData({
- arrAddress: that.dedupe(that.data.arrAddress.concat(address))
- })
- }
- })
- },
- dedupe(array) {
- return Array.from(new Set(array));
- },
- // 切换 行道树 或者绿地 或者 花坛
- toggleXDS(e) {
- app.loading();
- this.setData({
- XDSflag: e.detail.value,
- });
- this.getWorkTypeList(e.detail.value);
- if (e.detail.value == 3) {
- this.setData({
- huatanFlag: true,
- });
- } else {
- this.setData({
- huatanFlag: false,
- });
- }
- },
- // 点击 确定按钮
- UploadP() {
- if (this.data.huatanFlag) {
- // if (!this.data.huatanList[this.data.huatanIndex])
- // return app.toast('请选择花坛');
- if (this.data.formFileurl.length < 2) return app.toast('至少上传2张图片');
- if (this.data.huatanType == 1) {
- if (this.data.XDSflag != 4) {
- if (this.data.text == null || this.data.text.trim() == '') {
- return app.toast('请填写问题描述');
- }
- }
- }
- } else {
- if (this.data.formFileurl.length == 0) {
- return app.toast('请上传问题图片');
- }
- if (this.data.XDSflag == 4) {
- if (this.data.issueTypeIndex == null) {
- return app.toast('请选择问题类型');
- }
- } else {
- if (!this.data.workTypeList[this.data.worktypeIndex]) {
- return app.toast('请选择问题分类');
- }
- if (this.data.text == null || this.data.text.trim() == '') {
- return app.toast('请填写问题描述');
- }
- }
- }
- // 问题单保存
- // console.log('问题分类', this.data.workTypeList[this.data.worktypeIndex]);
- // wx.showLoading({
- // title: '加载中',
- // mask: true,
- // });
- if (this.data.XDSflag == 4) {
- // if (this.data.hazardRatio == null || this.data.hazardRatio == '') {
- // return app.toast('请填写危害率');
- // }
- let url = app.globalData.httpsUrlServer + '/patrolTrack/issue/';
- let formFileList = this.data.formFileurl;
- let newArr = [];
- formFileList.map(item => {
- let obj = {
- fileDes: item.fileDes,
- fileFormat: item.fileFormat,
- fileName: item.string1,
- fileSize: item.fileSize,
- fileUrl: item.fileUrl
- };
- newArr.push(obj);
- })
- // let fileCoordinates =
- // this.data.workZb.latitude + ',' + this.data.workZb.longitude;
- let fileCoordinates = util1.transformFromGCJToWGS(
- this.data.workZb.latitude,
- this.data.workZb.longitude
- );
- let pestName = null;
- let pestId = null;
- if (this.data.wormIndex != null) {
- pestId = this.data.wormList[this.data.wormIndex].id;
- if (pestId == -1) {
- // if(!this.data.pestNewName){
- // return app.toast('请输入病虫害名称');
- // }
- pestName = this.data.pestNewName;
- if (!pestName) {
- pestId = null;
- }
- } else {
- pestName = this.data.wormList[this.data.wormIndex].pestName;
- }
- }
- if (this.data.dangerLevelIndex == null) {
- return app.toast('请选择危害程度');
- }
- console.log(this.data.dangerLevelLIst[this.data.dangerLevelIndex], 'this.data.dangerLevelLIst[this.data.dangerLevelIndex]')
- let data = {
- patrolId: this.data.InspectionInfo.id,
- pestName: pestName,
- pestId: pestId,
- remark: this.data.remark,
- host: this.data.hostbiology,
- // dangerRate:this.data.hazardRatio,
- dangerLevel: this.data.dangerLevelLIst[this.data.dangerLevelIndex].id,
- dangerLevelName: this.data.dangerLevelLIst[this.data.dangerLevelIndex].name,
- issueType: 2,
- state: 0,
- dangerType: this.data.issueTypeList[this.data.issueTypeIndex].fWorkordertypeid,
- dangerTypeName: this.data.issueTypeList[this.data.issueTypeIndex].fName,
- // thresholdValue: this.data.issueTypeList[this.data.issueTypeIndex].thresholdValue,
- patrolTrackIssueFileList: newArr,
- currentCoordinates: fileCoordinates.longitude + ',' + fileCoordinates.latitude,
- temperature: this.data.temperature,
- humidity: this.data.humidity
- }
- app.postReqNew(url, data, (res) => {
- if (res.code == 0) {
- if (!(this.data.Type.indexOf(this.data.XDSflag) + 1)) {
- this.data.Type.push(this.data.XDSflag);
- }
- let str123 = this.data.Type.join(',');
- this.setData({
- imgDailog: false,
- XDSflag: 1,
- text: null,
- formFileurl: [],
- typeStr: str123,
- isExist: data.dangerLevel == 0 ? 0 : 1,
- });
- this.setData({
- InspectionInfo: res.data,
- });
- app.toast('问题上传成功');
- this.loadWormList();
- } else {
- this.setData({
- imgDailog: false,
- XDSflag: 1,
- text: null,
- formFileurl: [],
- XDSflag: 1,
- // isExist: 0,
- });
- app.toast('问题上传失败');
- }
- });
- } else {
- // 发送 请求 并向 问题数组中存值
- this.setData({
- workNum: this.data.workNum + 1,
- });
- let url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrackFile';
- let obj = {};
- let arr = [];
- this.data.formFileurl.forEach((v) => {
- v.fileCoordinates =
- this.data.workZb.latitude + ',' + this.data.workZb.longitude;
- v.remark = this.data.text;
- let obj = util1.transformFromGCJToWGS(
- this.data.workZb.latitude,
- this.data.workZb.longitude
- );
- v.fileCoordinatesGc = obj.latitude + ',' + obj.longitude;
- v.createDate = util.formatTime(new Date());
- v.string3 = this.data.workTypeList[this.data.worktypeIndex].fValuecode;
- v.string4 = this.data.workTypeList[this.data.worktypeIndex].fName;
- // 选择行道树
- v.number4 = this.data.XDSflag;
- if (this.data.XDSflag == 3) {
- // v.number5 = this.data.huatanList[
- // this.data.huatanIndex
- // ].id; // id
- // v.string5 = this.data.huatanList[this.data.huatanIndex].address;
- // v.string5 =
- // this.data.huatanList[this.data.huatanIndex].fAttractionsName +
- // '--' +
- // this.data.huatanList[this.data.huatanIndex].fAttractionsPlace; // 名字
- }
- v.number2 = this.data.huatanFlag ? this.data.huatanType : '1';
- });
- obj.fileList = this.data.formFileurl;
- arr.push(obj);
- let data = {
- aassessNo: this.data.InspectionInfo.aassessNo, //巡查单号
- fileList: arr, //图片列表
- id: this.data.InspectionInfo.id,
- };
- app.postReq(url, data, (res) => {
- if (res.status == 200) {
- if (!(this.data.Type.indexOf(this.data.XDSflag) + 1)) {
- this.data.Type.push(this.data.XDSflag);
- }
- let str123 = this.data.Type.join(',');
- this.setData({
- imgDailog: false,
- XDSflag: 1,
- text: null,
- formFileurl: [],
- typeStr: str123,
- isExist: 1,
- });
- app.toast('问题上传成功');
- } else {
- this.setData({
- imgDailog: false,
- XDSflag: 1,
- text: null,
- formFileurl: [],
- XDSflag: 1,
- // isExist: 0,
- });
- app.toast('问题上传失败');
- }
- });
- }
- //清空图片 文本 关闭弹框
- },
- changeType(e) {
- this.setData({
- worktypeIndex: e.detail.value,
- });
- // if(this.data.XDSflag == 4){
- // this.loadWormList();
- // this.hazardRateInit();
- // }
- },
- issueTypeChange(e) {
- console.log(e, 'issueTypeChange')
- this.setData({
- issueTypeIndex: e.detail.value,
- dangerLevelIndex: null
- });
- this.loadWormList();
- this.hazardRateInit();
- },
- //加载昆虫
- loadWormList() {
- let that = this;
- let pestType = that.data.issueTypeList[that.data.issueTypeIndex].id;
- let url =
- app.globalData.httpsUrlServer +
- '/common/pestType/list';
- let data = {
- pestType: pestType
- };
- app.getReqNew(url, data, (res) => {
- let newA = [{
- id: -1,
- pestName: '手动输入病虫名称'
- }];
- let lists = [...newA, ...res.data];
- that.setData({
- wormList: lists,
- wormIndex: null
- });
- });
- },
- changeWorm(e) {
- this.setData({
- wormIndex: e.detail.value,
- });
- },
- pestNameInput(e) {
- this.setData({
- pestNewName: e.detail.value,
- });
- },
- // 图片上传
- uploader: function () {
- var that = this;
- var token = wx.getStorageSync('token');
- let maxSize = 1024 * 1024 * 5;
- let maxLength = 5;
- wx.chooseImage({
- count: 5, //最多可以选择的图片总数
- sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
- success: function (res) {
- wx.showLoading({
- title: '上传中',
- mask: true,
- });
- for (let i = 0; i < res.tempFiles.length; i++) {
- if (res.tempFiles[i].size > maxSize) {
- flag = false;
- wx.showModal({
- content: '图片太大,不允许上传',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- //console.log('用户点击确定')
- }
- },
- });
- return;
- }
- }
- if (res.tempFiles.length > maxLength) {
- wx.showModal({
- content: '最多能上传' + maxLength + '张图片',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- //console.log('确定');
- }
- },
- });
- }
- for (var i = 0; i < res.tempFilePaths.length; i++) {
- wx.uploadFile({
- url: app.globalData.httpsUrlServer + '/file/uploadPatrolFile',
- filePath: res.tempFilePaths[i],
- name: 'images',
- header: {
- 'Content-Type': 'application/json;charset=UTF-8',
- token: token,
- fSource: 1,
- },
- success: function (res) {
- if (res.statusCode == 200) {
- var data = JSON.parse(res.data);
- if (data.status == 200) {
- that.setData({
- fFileurl: that.data.fFileurl.concat(data.data[0].fileDes),
- formFileurl: that.data.formFileurl.concat(data.data[0]),
- });
- setTimeout(() => {
- wx.showToast({
- title: '图片上传成功',
- mask: true,
- duration: 1000,
- });
- }, 500);
- } else if (data.status == 600) {
- wx.showModal({
- title: '登陆失败',
- content: '登录信息失效,请重新登录',
- success(res) {
- if (res.confirm) {
- wx.navigateTo({
- url: '/pages/login/login',
- });
- } else if (res.cancel) {
- wx.navigateTo({
- url: '/pages/login/login',
- });
- }
- },
- });
- } else {
- // 上传失败了
- wx.showToast({
- title: '图片上传失败',
- mask: true,
- duration: 2000,
- });
- }
- }
- },
- fail: function (res) {
- //console.log('失败', res);
- wx.showToast({
- title: '图片上传失败',
- icon: 'fail',
- duration: 1000,
- success(res) {
- //console.log(res);
- },
- });
- },
- });
- }
- },
- });
- },
- // 删除图片
- clearImg: function (e) {
- var index = e.currentTarget.dataset.index;
- let that = this;
- //console.log(index)
- let arr2 = this.data.formFileurl.filter((v, i) => {
- return i == index; // 删除 线上
- });
- let url = app.globalData.httpsUrlServer + '/file/deleteFile';
- let data = {
- fileDes: arr2[0],
- };
- wx.showLoading({
- title: '删除中',
- mask: true,
- });
- app.postReq(url, data, (res) => {
- if (res.status == 200) {
- let arr = that.data.uploaderList.filter((v, i) => {
- return i != index;
- });
- let arr1 = that.data.formFileurl.filter((v, i) => {
- return i != index; // 删除线上 上传
- });
- that.setData({
- uploaderList: arr,
- formFileurl: arr1,
- });
- app.toast('删除成功');
- } else {
- app.toast('删除失败');
- }
- });
- },
- // 预览图片
- showImg: function (e) {
- //获取当前图片的下标
- console.log(this.data.formFileurl);
- //console.log(e)
- var index = e.currentTarget.dataset.index;
- // //所有图片
- var imgs = this.data.formFileurl.map((v) => {
- return v.fileUrl;
- });
- wx.previewImage({
- //当前显示图片
- current: imgs[index].fileUrl,
- //所有图片
- urls: imgs,
- });
- },
- // 查看路线
- lineRoad() {
- var that = this;
- that.setData({
- polyline: [{
- points: that.data.arrPoint,
- color: '#FF0000',
- width: 9,
- arrowLine: true,
- borderWidth: 1,
- borderColor: '#555',
- }, ],
- });
- },
- // 文本域
- input(e) {
- this.setData({
- text: e.detail.value,
- });
- },
- // 按钮组 ↓ ↓ ↓ ↓ ↓ ↓ ↓
- // 开始巡查
- openAndEndSetting() {
- var that = this;
- // if (this.data.addldList.length == 0) {
- // return app.toast('请选择路段');
- // }
- if (this.data.addVehicleList.length == 0) {
- return app.toast('请选择交通工具');
- }
- // 开始巡查
- wx.showModal({
- title: '提示',
- content: '确定开始巡查',
- success(res) {
- if (res.confirm) {
- // 记录当前点位
- wx.showToast({
- title: '正在创建新的巡查记录',
- icon: 'loading',
- duration: 2000,
- });
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy: true,
- success(res) {
- var arr = [];
- arr.push({
- latitude: res.latitude,
- longitude: res.longitude,
- });
- that.getAddress(res.latitude, res.longitude);
- that.data.arrPoint = that.data.arrPoint.concat(arr);
- that.setData({
- arrPoint: that.data.arrPoint,
- posObj: {
- latitude: res.latitude,
- longitude: res.longitude,
- },
- });
- that.createBuild();
- },
- });
- // console.log('用户点击确定');
- // that.build()
- // 开始执行
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- },
- });
- },
- // 暂停巡查
- stopSetting() {
- console.log('暂停巡查');
- timerList.forEach((v) => {
- clearInterval(v);
- });
- timerListJd.forEach((v) => {
- clearInterval(v);
- });
- this.setData({
- flag1: false,
- });
- },
- // 继续巡查
- goSetting() {
- console.log('继续巡查');
- var that = this;
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy: true,
- success(res) {
- var arr = [];
- arr.push({
- latitude: res.latitude,
- longitude: res.longitude,
- });
- // that.getAddress(res.latitude, res.longitude);
- that.data.arrPoint = that.data.arrPoint.concat(arr);
- that.setData({
- arrPoint: that.data.arrPoint,
- posObj: {
- latitude: res.latitude,
- longitude: res.longitude,
- },
- });
- },
- });
- Datetime = setInterval(() => {
- that.setInterval();
- }, 1000);
- timerList.push(Datetime);
- Jdtime = setInterval(() => {
- that.tap1(); //获取坐标
- that.lineRoad(); //画线
- that.build(); // 更新数据
- }, 10000);
- timerListJd.push(Jdtime);
- this.setData({
- flag1: true,
- });
- },
- //重新巡查
- restInspection() {
- this.stopSetting();
- var that = this;
- console.log('重新巡查');
- wx.showModal({
- title: '提示',
- content: '是否要重新巡查',
- success(res) {
- if (res.confirm) {
- console.log('用户点击确定');
- wx.showLoading({
- title: '加载中',
- });
- that.reovem();
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- },
- });
- },
- // 生成本次巡查单 提交功能
- sumbit() {
- var that = this;
- // 暂停
- this.stopSetting();
- wx.showModal({
- title: '提示',
- content: '确定结束本次巡查吗?',
- success(res) {
- if (res.confirm) {
- // 保存最后一次 点位
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy: true,
- success(res) {
- var arr = [];
- arr.push({
- latitude: res.latitude,
- longitude: res.longitude,
- });
- that.getAddress(res.latitude, res.longitude);
- that.data.arrPoint = that.data.arrPoint.concat(arr);
- that.setData({
- arrPoint: that.data.arrPoint,
- posObj: {
- latitude: res.latitude,
- longitude: res.longitude,
- },
- });
- that.isOverSpeed()
- // // 处理demo
- // // 发现问题工单
- // if (that.data.workNum != 0) {
- // wx.showModal({
- // title: '提示',
- // content: '巡查中发现问题,确定则创建工单',
- // success(res) {
- // if (res.confirm) {
- // that.build();
- // that.sendGD();
- // that.out();
- // } else if (res.cancel) {
- // that.build();
- // that.out();
- // }
- // },
- // });
- // } else {
- // that.build();
- // that.out();
- // }
- },
- });
- } else if (res.cancel) {
- // 用户取消
- }
- },
- });
- },
- // 点击 发现问题 打开弹框
- openDailog() {
- let that = this;
- this.setData({
- imgDailog: true,
- huatanFlag: false,
- dangerLevelIndex: null,
- issueTypeIndex: null,
- host: ''
- });
- that.getUserInfo();
- // 记录当前点位
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy: true,
- success: (res) => {
- this.data.workZb.latitude = res.latitude;
- this.data.workZb.longitude = res.longitude;
- this.setData({
- workZb: this.data.workZb,
- });
- var httpUrl = 'https://free-api.heweather.net/s6/weather/now?'
- var loca = res.latitude + ',' + res.longitude;
- wx.request({
- url: httpUrl,
- data: {
- location: loca,
- key: 'e3f16084c5bb4aeda37a6b5b4c7c0032'
- },
- success: (res) => {
- let result = res.data.HeWeather6[0].now;
- that.setData({
- temperature: result.tmp + '℃',
- humidity: result.hum
- })
- }
- })
- },
- });
- let id1 = that.data.parkList[that.data.parkIndex].fParkid;
- let id2;
- if (that.data.yhdwList.length == 0) {
- id2 = that.data.yhCompanyId;
- } else {
- // maintenanceCompanyId
- id2 = that.data.yhdwList[that.data.yhdwIndex].oldMaintenanceCompanyId;
- }
- that.getHuatanbyid(id1, id2);
- },
- // 关闭 弹框
- closeDailog() {
- this.setData({
- imgDailog: false,
- XDSflag: 1,
- });
- },
- // 选择路段
- bindPickerParkChange(e) {
- let index = e.detail.value;
- this.setData({
- parkIndex: index,
- allldList: [],
- addldList: [],
- ldList: [],
- });
- let id = this.data.parkList[this.data.parkIndex].fParkid;
- // 获取当前 路段下的养护单位
- this.getYhdwList(id);
- },
- // 选择养护单位
- bindPickerParkChange2(e) {
- let index = e.detail.value;
- this.setData({
- yhdwIndex: index,
- });
- },
- // 计时器
- setInterval() {
- const that = this;
- var second = that.data.second;
- var minute = that.data.minute;
- var hours = that.data.hours;
- second++;
- if (second >= 60) {
- minute = Number(minute) + Math.floor(second / 60);
- second = 0; // 大于等于60秒归零
- if (minute >= 60) {
- minute = 0; // 大于等于60分归零
- hours++;
- if (hours < 10) {
- // 少于10补零
- that.setData({
- hours: '0' + hours,
- });
- } else {
- that.setData({
- hours: hours,
- });
- }
- }
- if (minute < 10) {
- // 少于10补零
- that.setData({
- minute: '0' + minute,
- });
- } else {
- that.setData({
- minute: minute,
- });
- }
- }
- if (second < 10) {
- // 少于10补零
- that.setData({
- second: '0' + second,
- });
- } else {
- that.setData({
- second: second,
- });
- }
- },
- // 获取地图上两点的距离
- distance(lat1, lng1, lat2, lng2) {
- var that = this;
- lat1 = lat1 || 0;
- lng1 = lng1 || 0;
- lat2 = lat2 || 0;
- lng2 = lng2 || 0;
- var rad1 = (lat1 * Math.PI) / 180.0;
- var rad2 = (lat2 * Math.PI) / 180.0;
- var a = rad1 - rad2;
- var b = (lng1 * Math.PI) / 180.0 - (lng2 * Math.PI) / 180.0;
- var r = 6378137;
- var s = (
- r *
- 2 *
- Math.asin(
- Math.sqrt(
- Math.pow(Math.sin(a / 2), 2) +
- Math.cos(rad1) * Math.cos(rad2) * Math.pow(Math.sin(b / 2), 2)
- )
- )
- ).toFixed(0);
- var kilimeter = (s * 1 + that.data.mileage * 1).toFixed(1);
- var kilimeter000 = ((s * 1 + that.data.mileage * 1) / 1000).toFixed(3);
- that.setData({
- mileage: kilimeter,
- mileage1: kilimeter000,
- });
- // that.Inspection()
- },
- createBuild() {
- var that = this;
- let url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrack';
- // 开始坐标 处理
- let start = '';
- let startGc = '';
- for (let k1 in that.data.arrPoint[0]) {
- start += that.data.arrPoint[0][k1];
- start += ',';
- }
- start = start.slice(0, start.length - 1);
- // 开始 gc 坐标处理
- let obj1 = util1.transformFromGCJToWGS(
- that.data.arrPoint[0].latitude,
- that.data.arrPoint[0].longitude
- );
- for (let k4 in obj1) {
- startGc += obj1[k4];
- startGc += ',';
- }
- startGc = startGc.slice(0, startGc.length - 1);
- let detailList = that.data.addldList;
- detailList.map(item => {
- item.roadId = item.id
- })
- let VehicleArr = [];
- let addVehicleList = this.data.addVehicleList;
- addVehicleList.map(item => {
- VehicleArr.push(item.id);
- })
- let data = {
- type: '', //绿地巡查 之前默认绿地巡查 为1;
- objectId: this.data.parkList[this.data.parkIndex].oldSectionId, //标段
- objectName: this.data.parkList[this.data.parkIndex].sectionName, //表单名称
- number3: this.data.yhCompanyId, // 养护单位id
- detailList: detailList, //选的路段
- string3: VehicleArr.toString(),
- startTime: new Date().getTime(), //开始 时间
- startCoordinates: start, //开始坐标
- startCoordinatesGc: startGc, // 开始gc坐标
- };
- if (this.data.position == '绿化科中心') {
- // data.number3 = this.data.yhdwList[this.data.yhdwIndex].fYhcompanyid;
- data.number3 = this.data.yhdwList[this.data.yhdwIndex].oldMaintenanceCompanyId;
- }
- app.postReq(url, data, (res) => {
- if (res.status == 200) {
- wx.hideLoading();
- Datetime = setInterval(() => {
- that.setInterval();
- }, 1000);
- timerList.push(Datetime);
- Jdtime = setInterval(() => {
- that.tap1(); //获取坐标
- that.lineRoad(); // 画线
- that.build(); // 更新数据
- }, 10000);
- timerListJd.push(Jdtime);
- that.setData({
- flag: true,
- InspectionInfo: res.data,
- });
- }
- });
- },
- // 更新 巡查单
- build(islast, isSupple) {
- var that = this;
- // console.log(this.data.InspectionInfo);
- let url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrack';
- let data = this.data.InspectionInfo;
- // 总路程坐标处理
- let totol = '';
- let totolGc = '';
- that.data.arrPoint.forEach((v) => {
- for (let k3 in v) {
- totol += v[k3];
- totol += ',';
- }
- totol = totol.slice(0, totol.length - 1);
- totol += ';';
- });
- totol = totol.slice(0, totol.length - 1);
- let arr = [];
- that.data.arrPoint.forEach((v) => {
- let obj3 = util1.transformFromGCJToWGS(v.latitude, v.longitude);
- arr.push(obj3);
- });
- arr.forEach((v) => {
- for (let k6 in v) {
- totolGc += v[k6];
- totolGc += ',';
- }
- totolGc = totolGc.slice(0, totolGc.length - 1);
- totolGc += ';';
- });
- totolGc = totolGc.slice(0, totolGc.length - 1);
- // 总路程坐标处理 ↑ ↑ ↑ ↑ ↑
- // 结束坐标处理 ↓↓↓↓↓↓↓↓
- let end = '';
- let endGc = '';
- for (let k2 in that.data.arrPoint[that.data.arrPoint.length - 1]) {
- end += that.data.arrPoint[that.data.arrPoint.length - 1][k2];
- end += ',';
- }
- end = end.slice(0, end.length - 1);
- let obj2 = util1.transformFromGCJToWGS(
- that.data.arrPoint[that.data.arrPoint.length - 1].latitude,
- that.data.arrPoint[that.data.arrPoint.length - 1].longitude
- );
- for (let k5 in obj2) {
- endGc += obj2[k5];
- endGc += ',';
- }
- endGc = endGc.slice(0, endGc.length - 1);
- // 结束坐标处理 ↑↑↑↑↑↑↑↑
- data.totalCoordinates = totol;
- data.totalCoordinatesGc = totolGc;
- data.endCoordinates = end;
- data.endCoordinatesGc = endGc;
- data.endTime = util.formatTime(new Date());
- data.totalTime =
- that.data.hours * 60 * 60 + that.data.minute * 60 + that.data.second * 1;
- data.mileage = that.data.mileage1;
- // data.fileList = that.data.WorkList;
- data.isExist = that.data.isExist;
- data.type = that.data.typeStr;
- // 最后一次提交,附加反编译地址
- if (islast && !isSupple) {
- let roadList = [];
- let arrAddress = that.data.arrAddress;
- if (arrAddress.length > 0) {
- arrAddress.map(item => {
- roadList.push({
- roadName: item
- })
- })
- }
- data.roadList = roadList;
- }
- if (isSupple) {
- let detailList = that.data.addldList;
- detailList.map(item => {
- item.roadId = item.id
- })
- data.detailList = detailList;
- }
- app.postReq(url, data, (res) => {
- if (res.status == 200) {
- // that.setData({
- // InspectionInfo: res.data,
- // });
- // 最后一次提交,提示已匹配道路信息
- if(isSupple && islast){
- if (that.data.workNum != 0) {
- wx.showModal({
- title: '提示',
- content: '巡查中发现问题,确定则创建工单?',
- success(res) {
- if (res.confirm) {
- that.sendGD();
- that.out();
- // wx.navigateBack({
- // delta: 1
- // })
- } else if (res.cancel) {
- that.out();
- // wx.navigateBack({
- // delta: 1
- // })
- }
- },
- });
- } else {
- that.out();
- // wx.navigateBack({
- // delta: 1
- // })
- }
- }
- else if (islast && !isSupple) {
- that.setData({
- 'InspectionInfo.roadList': [],
- detailList:res.data.detailList,
- matchedDailog:true
- });
- } else {
- console.log('巡查进度更新');
- that.setData({
- InspectionInfo: res.data,
- });
- }
- } else {
- console.log('巡查进度更新失败,请检查网络重试,本次巡查记录已经保存');
- }
- });
- },
- openRoadDailog(){
- let that = this;
- let id = that.data.parkList[that.data.parkIndex].id;
- if (id) {
- if (that.data.addldList.length == 0) {
- // this.getLdListbyid(id);
- that.getLdListbyid();
- }
- that.setData({
- checkboxEd: true,
- });
- } else {
- return app.toast('请先选择路段');
- }
- },
- addRoadList(){
- let that = this;
- this.build(true,true)
- },
- cancelAndSave(){
- let that = this;
- if (that.data.workNum != 0) {
- wx.showModal({
- title: '提示',
- content: '巡查中发现问题,确定则创建工单?',
- success(res) {
- if (res.confirm) {
- that.sendGD();
- that.out();
- // wx.navigateBack({
- // delta: 1
- // })
- } else if (res.cancel) {
- that.out();
- // wx.navigateBack({
- // delta: 1
- // })
- }
- },
- });
- } else {
- that.out();
- // wx.navigateBack({
- // delta: 1
- // })
- }
- },
- isOverSpeed(type) {
- var that = this;
- // console.log(this.data.InspectionInfo);
- let url = app.globalData.httpsUrlServer + '/lhgyWork/patrolTrackIsSpeeding';
- let data = this.data.InspectionInfo;
- // 总路程坐标处理
- let totol = '';
- let totolGc = '';
- that.data.arrPoint.forEach((v) => {
- for (let k3 in v) {
- totol += v[k3];
- totol += ',';
- }
- totol = totol.slice(0, totol.length - 1);
- totol += ';';
- });
- totol = totol.slice(0, totol.length - 1);
- let arr = [];
- that.data.arrPoint.forEach((v) => {
- let obj3 = util1.transformFromGCJToWGS(v.latitude, v.longitude);
- arr.push(obj3);
- });
- arr.forEach((v) => {
- for (let k6 in v) {
- totolGc += v[k6];
- totolGc += ',';
- }
- totolGc = totolGc.slice(0, totolGc.length - 1);
- totolGc += ';';
- });
- totolGc = totolGc.slice(0, totolGc.length - 1);
- // 总路程坐标处理 ↑ ↑ ↑ ↑ ↑
- // 结束坐标处理 ↓↓↓↓↓↓↓↓
- let end = '';
- let endGc = '';
- for (let k2 in that.data.arrPoint[that.data.arrPoint.length - 1]) {
- end += that.data.arrPoint[that.data.arrPoint.length - 1][k2];
- end += ',';
- }
- end = end.slice(0, end.length - 1);
- let obj2 = util1.transformFromGCJToWGS(
- that.data.arrPoint[that.data.arrPoint.length - 1].latitude,
- that.data.arrPoint[that.data.arrPoint.length - 1].longitude
- );
- for (let k5 in obj2) {
- endGc += obj2[k5];
- endGc += ',';
- }
- endGc = endGc.slice(0, endGc.length - 1);
- // 结束坐标处理 ↑↑↑↑↑↑↑↑
- data.totalCoordinates = totol;
- data.totalCoordinatesGc = totolGc;
- data.endCoordinates = end;
- data.endCoordinatesGc = endGc;
- data.endTime = util.formatTime(new Date());
- data.totalTime =
- that.data.hours * 60 * 60 + that.data.minute * 60 + that.data.second * 1;
- data.mileage = that.data.mileage1;
- // data.fileList = that.data.WorkList;
- data.isExist = that.data.isExist;
- data.type = that.data.typeStr;
- let roadList = [];
- let arrAddress = that.data.arrAddress;
- if (arrAddress.length > 0) {
- arrAddress.map(item => {
- roadList.push({
- roadName: item
- })
- })
- }
- data.roadList = roadList;
-
- app.postReqNew2(url, {
- data: data
- }, (res) => {
- if (res.status == 200) {
- if (res.data) {
- wx.navigateBack({ delta: 1 })
- } else {
- wx.showModal({
- title: '提示',
- content: '巡查失败!',
- success(res) {
- if (res.confirm) {
- wx.navigateBack({ delta: 1 })
- }
- }
- })
- }
- }
- });
- },
- NavBack() {
- let that = this;
- if (!this.data.flag) {
- wx.navigateBack({
- delta: 1
- })
- } else {
- if(that.data.matchedDailog){
- that.cancelAndSave();
- }else{
- wx.showModal({
- title: '提示',
- content: '确定结束本次巡查吗?',
- success(res) {
- if (res.confirm) {
- // 保存最后一次 点位
- wx.getLocation({
- type: 'gcj02',
- isHighAccuracy: true,
- success(res) {
- var arr = [];
- arr.push({
- latitude: res.latitude,
- longitude: res.longitude,
- });
- that.getAddress(res.latitude, res.longitude);
- that.data.arrPoint = that.data.arrPoint.concat(arr);
- that.setData({
- arrPoint: that.data.arrPoint,
- posObj: {
- latitude: res.latitude,
- longitude: res.longitude,
- },
- });
- that.isOverSpeed('back');
- },
- });
- } else if (res.cancel) {
- // 用户取消
- }
- },
- });
- }
- }
- },
- // 生成工单
- sendGD(val) {
- var that = this;
- let pages = getCurrentPages(); //页面栈
- let beforePage = '';
- beforePage = pages[pages.length - 1];
- let url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrackWork';
- let data = {
- id: this.data.InspectionInfo.id,
- };
- app.postReq(url, data, (res) => {
- if (res.status == 200) {
- if (val == 'flag') {
- beforePage.onPullDownRefresh();
- }
- }
- });
- },
- // 删除 巡查单
- reovem() {
- var that = this;
- let url = app.globalData.httpsUrlServer + '/lhgyWork/deletePatrolTrack';
- let data = {
- id: this.data.InspectionInfo.id,
- };
- app.postReq(url, data, (res) => {
- if (res.status == 200) {
- that.setData({
- flag: false,
- flag1: true,
- hours: '0' + 0, // 时
- minute: '0' + 0, // 分
- second: '0' + 0, // 秒
- polyline: [], //路线数组
- workNum: 0, //问题数量
- addldList: [], // 要巡查的 路段
- arrPoint: [], //坐标数组
- InspectionInfo: {},
- addVehicleList: [] // 交通工具
- });
- wx.hideLoading();
- } else {}
- });
- },
- // 页面进入加载
- onLoad: function (options) {
- if (options.listType) {
- this.setData({
- listType: options.listType,
- });
- }
- wx.disableAlertBeforeUnload({
- message: '测试'
- })
- var that = this;
- // 获取 选择项(公园,路段,等选择功能...)
- that.userSelect();
- that.getWorkTypeList();
- // 检测是否开启定位功能 ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
- wx.startLocationUpdateBackground({
- success(res) {
- console.log('开启后台定位', res);
- },
- fail(res) {
- console.log('开启后台定位失败', res);
- },
- });
- that.checkLocation();
- // 检测是否开启定位功能 ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
- //获取当前的坐标
- wx.getLocation({
- type: 'gcj02',
- // isHighAccuracy: true,
- success: (res) => {
- that.setData({
- posObj: {
- latitude: res.latitude,
- longitude: res.longitude,
- },
- });
- },
- });
- },
- onUnload() {
- },
- getUserInfo() {
- let that = this;
- // await
- let url =
- app.globalData.httpsUrlServer + '/sysroleinfo/selectRoleInfoByUserId';
- wx.request({
- url: url,
- method: 'get',
- header: {
- Accept: 'application/json',
- 'content-type': 'application/json;charset=UTF-8',
- token: wx.getStorageSync('token'),
- fSource: 1,
- },
- success: function (res) {
- let userInfo = res.data.data;
- let flagArr = [false, false, false];
- userInfo.map(item => {
- if (item.fRolecode == 'ZBY') {
- flagArr[0] = true;
- }
- if (item.fRolecode == 'LHKYHDW') {
- flagArr[1] = true;
- }
- if (item.fRolecode == 'LHK' || item.fRolecode == 'XTGLY') {
- flagArr[2] = true;
- }
- })
- if (flagArr[2] || (flagArr[0] && flagArr[1])) {
- let xdsList = [{
- name: '行道树',
- id: 1,
- checked: (that.data.listType == '' || that.data.listType == '1') ? true : false
- },
- {
- name: '绿地',
- id: 2,
- checked: that.data.listType == '2' ? true : false
- },
- {
- name: '花坛',
- id: 3,
- checked: that.data.listType == '3' ? true : false
- },
- {
- name: '病虫害',
- id: 4,
- checked: that.data.listType == '4' ? true : false
- }
- ]
- that.setData({
- xdsList: xdsList
- })
- } else if (flagArr[1]) {
- let xdsList = [{
- name: '行道树',
- id: 1,
- checked: (that.data.listType == '' || that.data.listType == '1') ? true : false
- },
- {
- name: '绿地',
- id: 2,
- checked: that.data.listType == '2' ? true : false
- },
- {
- name: '花坛',
- id: 3,
- checked: that.data.listType == '3' ? true : false
- }
- ]
- that.setData({
- xdsList: xdsList
- })
- } else if (flagArr[0]) {
- console.log(this.listType, 'flagArr[0]');
- let xdsList = [{
- name: '病虫害',
- id: 4,
- checked: true
- }]
- that.setData({
- xdsList: xdsList
- })
- let obj = {
- detail: {
- value: 4
- }
- }
-
- that.toggleXDS(obj);
- }
- const typeIndex = that.data.xdsList.findIndex(o => {
- return o.checked == true;
- });
- if (typeIndex > -1) {
- that.toggleXDS({
- detail: {
- value: that.data.xdsList[typeIndex].id,
- }
- });
- // that.issueTypeChange({
- // detail: {
-
- // value: typeIndex,
- // }
- // });
- }
- },
- fail: function (err) {
- reject(err);
- },
- });
- },
- onUnload: function () {},
- onShow: function () {},
- onHide() {},
- // 获取 数据 ↓ ↓ ↓ ↓ ↓
- // 判断人员, 选择公园权限 ( 选择项 )
- userSelect() {
- let that = this;
- let position = wx.getStorageSync('position');
- let position2 = wx.getStorageSync('position2');
- // 如果是 中心 人员 获取所有路段
- console.log(position)
- console.log(position2)
- // 如果是 养护人员 获取自己的 路段
- that.getLDbyId();
- },
- // 查询所有标段 根据养护单位id 查询路段标
- // getLDbyId() {
- // wx.showLoading({
- // title: '加载中',
- // mask: true,
- // });
- // let that = this;
- // let url =
- // app.globalData.httpsUrlServer +
- // // "/t-lhgy-section/selectSectionByCompany"
- // '/tLhgyFacilitySummaryRoad/selectRoadInfoByYhCompanyId';
- // console.log('养护公司id:'+ wx.getStorageSync('yhCompanyId'))
- // let data = {
- // // yhCompanyId: wx.getStorageSync('yhCompanyId'),
- // maintenanceCompanyId: wx.getStorageSync('maintenanceCompanyId'),
- // };
- // this.setData({
- // yhCompanyId: wx.getStorageSync('yhCompanyId'),
- // });
- // app.postReq(url, data, (res) => {
- // if (res.status == 200) {
- // that.setData({
- // parkList: res.data,
- // });
- // wx.hideLoading();
- // }
- // });
- // },
- getLDbyId() {
- wx.showLoading({
- title: '加载中',
- mask: true,
- });
- let that = this;
- let url = app.globalData.httpsUrlServer + '/parkInfoApp/selectAppParkInfoList';
- // let data = {
- // // yhCompanyId: wx.getStorageSync('yhCompanyId'),
- // maintenanceCompanyId: wx.getStorageSync('maintenanceCompanyId'),
- // };
- this.setData({
- yhCompanyId: wx.getStorageSync('yhCompanyId'),
- maintenanceCompanyId: wx.getStorageSync('maintenanceCompanyId'),
- });
- console.log('getLDbyId')
- app.getReq(url, (res) => {
- console.log('getLDbyId-res', res)
- if (res.status == 200) {
- that.setData({
- parkList: res.data,
- });
- wx.hideLoading();
- }
- });
- },
- // 获得当前路段 的所有 路和路段
- // getLdListbyid(id) {
- // wx.showLoading({
- // title: '加载中',
- // mask: true,
- // });
- // let url =
- // app.globalData.httpsUrlServer +
- // '/tLhgyFacilitySummaryRoad/selectBySectionId';
- // let data = {
- // sectionId: id,
- // };
- // app.postReq(url, data, (res) => {
- // // console.log("res", res)
- // if (res.status == 200) {
- // let arr = res.data;
- // let newArr = [];
- // arr.forEach((v) => {
- // if (v.roadScopeList) {
- // v.roadScopeList.forEach((item) => {
- // newArr.push(item);
- // });
- // }
- // });
- // this.setData({
- // ldList: newArr,
- // allldList: newArr, //所有的路段 留查询使用
- // });
- // // console.log('路和路段');
- // // console.log(this.data.ldList);
- // wx.hideLoading();
- // }
- // });
- // },
- getLdListbyid() {
- let that = this;
- wx.showLoading({
- title: '加载中',
- mask: true,
- });
- let url = app.globalData.httpsUrlServer + '/road/selectRoadList';
- // let url =
- // app.globalData.httpsUrlServer +
- // '/road/selectRoadList';
- let data = {
- sectionId: that.data.parkList[that.data.parkIndex].fParkid,
- maintenanceCompanyId: that.data.maintenanceCompanyId
- };
- if (that.data.yhdwList.length == 0) {
- data.maintenanceCompanyId = that.data.maintenanceCompanyId
- } else {
- data.maintenanceCompanyId = that.data.yhdwList[that.data.yhdwIndex].id
- }
- app.getReqNew(url, data, (res) => {
- if (res.code == 0) {
- let arr = res.data;
- // let newArr = [];
- // arr.forEach((v) => {
- // if (v.roadScopeList) {
- // v.roadScopeList.forEach((item) => {
- // newArr.push(item);
- // });
- // }
- // });
- this.setData({
- ldList: arr,
- allldList: arr, //所有的路段 留查询使用
- });
- // console.log('路和路段');
- // console.log(this.data.ldList);
- wx.hideLoading();
- }
- });
- },
- getYhdwList(id) {
- wx.showLoading({
- title: '加载中',
- mask: true,
- });
- let that = this;
- let url =
- app.globalData.httpsUrlServer + '/maintenance/company/selectMaintenanceCompanyBySectionId';
- let data = {
- sectionId: id,
- };
- app.getReqNew(url, data, (res) => {
- // console.log("res", res)
- if (res.code == 0) {
- that.setData({
- yhdwList: res.data,
- });
- wx.hideLoading();
- }
- });
- },
- // 获取问题类型
- getWorkTypeList(val = 1) {
- let that = this;
- // 获取等待
- app.loading('loading~');
- if (val == 4) {
- let surl = app.globalData.httpsUrlServer +
- '/common/kind/list';
- let data = {
- type: 1
- }
- app.getReqNew(surl, data, (res) => {
- if (res.code == "0") {
- let lists = res.data;
- this.setData({
- issueTypeList: lists,
- });
- }
- app.hideloading();
- });
- } else {
- let url =
- app.globalData.httpsUrlServer +
- '/woworkordertype/selectOrderTypeList';
- let data = {
-
- };
- app.getReq(url, (res) => {
- console.log('sadfaf', res)
- if (res.status == 200) {
- let lists = res.data.filter(item => item.fParentid == 3);
- this.setData({
- workTypeList: lists,
- });
- // that.hazardRateInit();
- // that.loadWormList();
- }
- app.hideloading();
- });
- }
- // if (val == 4) {
- // let surl = app.globalData.httpsUrlServer +
- // '/common/kind/list';
- // let data = {
- // type: 1
- // }
- // // let lists = [{fValuecode:1,fName:'食叶性害虫'},
- // // {fValuecode:2,fName:'刺吸性害虫'},
- // // {fValuecode:3,fName:'钻蛀性害虫'},
- // // {fValuecode:4,fName:'地下害虫'},
- // // {fValuecode:5,fName:'病害类'}]
- // app.getReqNew(surl, data, (res) => {
- // if (res.code == "0") {
- // let lists = res.data;
- // // lists.map(item =>{
- // // item.fValuecode = item.id;
- // // item.fName = item.kindName;
- // // })
- // this.setData({
- // issueTypeList: lists,
- // });
- // // that.hazardRateInit();
- // // that.loadWormList();
- // }
- // app.hideloading();
- // });
- // // this.setData({
- // // workTypeList: lists,
- // // });
- // // app.hideloading();
- // } else {
- // app.postReq(url, data, (res) => {
- // if (res.status == 200) {
- // this.setData({
- // workTypeList: res.data,
- // });
- // app.hideloading();
- // }
- // });
- // }
- },
- hazardRateInit() {
- let arr1 = [];
- let issueTypeList = this.data.issueTypeList;
- let issueTypeIndex = this.data.issueTypeIndex;
- if (issueTypeList[issueTypeIndex].id == 1 || issueTypeList[issueTypeIndex].id == 2 || issueTypeList[issueTypeIndex].id == 5) {
- arr1 = [{
- name: '轻度(≤10%)',
- id: 0,
- label: '≤10%'
- },
- {
- name: '中度(>10%,≤15%)',
- id: 1,
- label: '>10%,≤15%'
- },
- {
- name: '重度(>15%)',
- id: 2,
- label: '>15%'
- }
- ];
- } else if (issueTypeList[issueTypeIndex].id == 3 || issueTypeList[issueTypeIndex].id == 4) {
- arr1 = [{
- name: '轻度(零星为害)',
- id: 0,
- label: '零星为害'
- },
- {
- name: '中度(≤3%)',
- id: 1,
- label: '≤3%'
- },
- {
- name: '重度(>3%)',
- id: 2,
- label: '>3%'
- }
- ];
- } else {
- arr1 = [{
- name: '轻度(≤10%)',
- id: 0,
- label: '≤10%'
- },
- {
- name: '中度(>10%,≤15%)',
- id: 1,
- label: '>10%,≤15%'
- },
- {
- name: '重度(>15%)',
- id: 2,
- label: '>15%'
- }
- ];
- }
- this.setData({
- dangerLevelLIst: arr1,
- // hazardRatio:arr1[this.data.dangerLevelIndex].label
- })
- },
- // 设置项 ↓ ↓ ↓ ↓ ↓ ↓
- //校验位置权限是否打开
- checkLocation() {
- let that = this;
- //选择位置,需要用户授权
- wx.getSetting({
- success(res) {
- //console.log("res", res)
- if (
- !res.authSetting['scope.userLocation'] &&
- !res.authSetting['scope.userLocationBackground']
- ) {
- wx.authorize({
- scope: 'scope.userLocation',
- success() {
- wx.showToast({
- //这里提示失败原因
- title: '授权成功!',
- duration: 1500,
- });
- },
- fail() {
- that.showSettingToast('需要授权位置信息');
- },
- });
- }
- },
- });
- },
- // 打开权限设置页提示框
- showSettingToast: function (e) {
- var that = this;
- wx.showModal({
- title: '提示!',
- confirmText: '去设置',
- showCancel: false,
- content: e,
- success: function (res) {
- if (res.confirm) {
- wx.openSetting({
- success: (res) => {
- //console.log("设置res", res)
- if (res.errMsg == 'openSetting:ok') {
- // wx.navigateBack({
- // delta: 1,
- // })
- wx.hideToast();
- setTimeout(() => {
- app.toast('设置成功');
- that.onLoad();
- }, 500);
- }
- },
- fail: (err) => {
- //console.log("err", err)
- wx.showToast({
- //这里提示失败原因
- title: '授权失败',
- duration: 1500,
- });
- },
- });
- }
- },
- });
- },
- onHide() {},
- onShow: function () {},
- out() {
- this.setData({
- endFlag: true,
- });
- let pages = getCurrentPages(); //页面栈
- let beforePage = '';
- beforePage = pages[pages.length - 2];
- wx.navigateBack({
- delta: 1, //返回上一级页面
- success: function () {
- beforePage.onPullDownRefresh();
- },
- });
- },
- out1() {
- this.setData({
- endFlag: true,
- });
- let pages = getCurrentPages(); //页面栈
- let beforePage = '';
- beforePage = pages[pages.length - 2];
- beforePage.onPullDownRefresh();
- },
- onUnload() {
- var that = this;
- that.stopSetting();
- if (this.data.arrPoint.length == 0) {
- return;
- }
- if (this.data.endFlag) return;
- if (that.data.workNum != 0) {
- wx.showModal({
- title: '提示',
- content: '巡查中发现问题,确定则创建工单',
- success(res) {
- if (res.confirm) {
- that.build();
- that.sendGD('flag');
- } else if (res.cancel) {
- that.build();
- that.out1();
- }
- },
- });
- } else {
- that.build();
- that.out1();
- }
- },
- });
|