123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- // pages/charginfo/eleCarMap.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- longitude:116.4965075,
- latitude: 40.006103,
- speed:0,
- scale:20,
- accuracy:0,
- chargid:0,
- ele_chargList:[],
- ele_park:[1,2,3],
- markers:[],
- markTemp:{
- id: 1,
- latitude: 23.098994,
- longitude: 113.322520,
- iconPath: '/images/triangle.png',
- height: 5,
- width: 5,
- customCallout: {
- anchorX: 0,
- anchorY: 0,
- display: "ALWAYS"
- }
- // anchor:{x: 0.5, y:1 },
- // callout: {
- // content: '文本内容',
- // color: '#000000',
- // fontSize: 14,
- // borderWidth: 2,
- // borderRadius: 5,
- // borderColor: '#FFFFFF',
- // bgColor: '#ffffff',
- // padding: 5,
- // display: 'ALWAYS',
- // textAlign: 'center'
- // }
- },
- eleActiveIndex: -1,
- parkActiveIndex: -1,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let that = this;
- let json = wx.getStorageSync("eleCarMapPage")
- let {chargid} = json;
- that.setData({chargid})
- let userInfo = wx.getStorageSync('userInfo');
- that.setData({
- userInfo
- })
- this.getEleData()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- },
- addHandler(json){
- let {
- chargid
- } = json
- this.setData({
- chargid
- })
- this.getEleData()
- },
- callouttap(e){
- // eleActiveIndex: -1,
- // parkActiveIndex: -1,
- let that = this;
- let index = e.markerId;
- console.info(e.markerId)
- let ele_chargList = this.data.ele_chargList;
- let mm = ele_chargList[index]
- if(mm.lock){
- return
- }
- if(mm.active){
-
- mm.active = false;
- if(mm.objType == 'ele'){
-
- that.setData({
- eleActiveIndex:-1
- })
- }else{
-
- that.setData({
- parkActiveIndex:-1
- })
- }
- this.setData({
- ele_chargList
- })
-
- return;
- }
- mm.active = true;
- if(mm.objType == 'ele'){
- if( that.data.eleActiveIndex >=0){
- ele_chargList[ that.data.eleActiveIndex].active = false
- }
-
- that.setData({
- eleActiveIndex:index
- })
- }else{
- if( that.data.parkActiveIndex >=0){
- ele_chargList[ that.data.parkActiveIndex].active = false
- }
-
-
- that.setData({
- parkActiveIndex:index
- })
- }
- // ele_chargList.forEach(key=>{
- // })
- console.info(this.data.ele_chargList)
- let car_active = false
- if(this.data.parkActiveIndex >=0 && this.data.eleActiveIndex >=0 ){
- car_active = true
- }
- this.setData({
- ele_chargList,
- car_active
- })
- },
- getEleData(){
- console.info("查询数据")
- // 新源恒远210调试站
- let that = this;
- // 充电桩
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/chargInfo',
- data: {
- id: that.data.chargid,
- pagenum: 1,
- ivType: 1,
- pagesize: 10000,
- },
- method: 'POST',
- success(res) {
- console.log(res);
- let chargList = res.data.chargList.rows;
- let ele_chargList = []
- chargList.forEach(key => {
- let chargstatusname = '';
- let chargstatusclass = '';
- if(key.chargstatus == 2){
- chargstatusname='空闲中'
- chargstatusclass = 'chargstatus_kxz'
- }else if(key.chargstatus == 11){
- chargstatusname='已插枪'
- chargstatusclass = 'chargstatus_ycq'
- }else if(key.chargstatus == 3 || key.chargstatus == 10){
- chargstatusname='充电中'
- chargstatusclass = 'chargstatus_cdz'
- }else if(key.chargstatus == 0){
- chargstatusname='离线'
- chargstatusclass = 'chargstatus_lx'
- }else{
- chargstatusname='故障'
- chargstatusclass = 'chargstatus_gz'
- }
- key.chargstatusname = chargstatusname;
- key.chargstatusclass = chargstatusclass;
- let mark = JSON.parse(JSON.stringify(that.data.markTemp));
-
- if(key?.currentParkPoint?.latitude && key?.currentParkPoint?.longitude ){
- mark.id = that.data.ele_chargList.length + ele_chargList.length;
- mark.latitude = key?.currentParkPoint?.latitude
- mark.longitude = key?.currentParkPoint?.longitude
- mark['ele_lock'] = key?.lockStatus == 1
- mark['ele_unlock'] = key?.lockStatus == 0
- mark['park_lock'] = false
- mark['park_unlock'] = false
- mark['lock'] = mark['ele_lock'] || mark['park_lock']
- mark['active'] = false
- mark['title'] = key?.currentSoc? key?.currentSoc + '%' : '-'
- mark['type'] = mark['ele_lock'] ? '锁定' : '未锁定'
- mark['objType'] = 'ele'
- // mark['chargPileId'] = that.data.chargid
- // mark['chargPileId'] = key?.chargPileId
- mark['chargPileId'] = key?.id
- // mark.callout.content = key?.currentParkPoint?.pointShowName
- ele_chargList.push(mark)
- that.setData({
- longitude:mark.longitude,
- latitude:mark.latitude,
- })
- }
- })
- console.log(ele_chargList);
- // that.rechargeTimeOrder(chargemoneylogs);
- wx.hideLoading()
- that.setData({
- ele_chargList: that.data.ele_chargList.concat(ele_chargList),
- markers: that.data.markers.concat(ele_chargList),
- // ele_total: res.data.chargList.total,
- // ele_dataLoading: false,
- // ele_fastFree : res.data.fastFree,
- // ele_slowFree : res.data.slowFree,
- // ele_fastSum : res.data.fastSum,
- // ele_slowSum : res.data.slowSum
- });
- console.log(ele_chargList);
- }
- });
- // 停靠点
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/ivparkByStation',
- data: {
- id: that.data.chargid,
- pagenum: 1,
- ivType: 1,
- pagesize: 10000,
- },
- method: 'POST',
- success(res) {
- console.log(res);
- let chargList = res.data;
- let ele_chargList = []
- chargList.forEach(key => {
- let chargstatusname = '';
- let chargstatusclass = '';
- if(key.chargstatus == 2){
- chargstatusname='空闲中'
- chargstatusclass = 'chargstatus_kxz'
- }else if(key.chargstatus == 11){
- chargstatusname='已插枪'
- chargstatusclass = 'chargstatus_ycq'
- }else if(key.chargstatus == 3 || key.chargstatus == 10){
- chargstatusname='充电中'
- chargstatusclass = 'chargstatus_cdz'
- }else if(key.chargstatus == 0){
- chargstatusname='离线'
- chargstatusclass = 'chargstatus_lx'
- }else{
- chargstatusname='故障'
- chargstatusclass = 'chargstatus_gz'
- }
- key.chargstatusname = chargstatusname;
- key.chargstatusclass = chargstatusclass;
- let mark = JSON.parse(JSON.stringify(that.data.markTemp));
-
- mark.id = that.data.ele_chargList.length + ele_chargList.length;
- mark.latitude = key?.latitude
- mark.longitude = key?.longitude
- mark['ele_lock'] = false
- mark['ele_unlock'] = false
- mark['park_lock'] = key?.parkStatus == 1
- mark['park_unlock'] = key?.parkStatus == 0
- mark['lock'] = mark['ele_lock'] || mark['park_lock']
- mark['active'] = false
- mark['title'] = key?.pointShowName? key?.pointShowName : '-'
- mark['type'] = mark['ele_lock'] ? '占用' : '空闲'
- mark['objType'] = 'park'
- mark['ivParkPointId'] = key?.ivParkPointId;
- // mark.callout.content = key?.currentParkPoint?.pointShowName
- ele_chargList.push(mark)
- that.setData({
- longitude:mark.longitude,
- latitude:mark.latitude,
- })
- })
-
- console.log(ele_chargList);
- // that.rechargeTimeOrder(chargemoneylogs);
-
- wx.hideLoading()
- that.setData({
- ele_chargList: that.data.ele_chargList.concat(ele_chargList),
- markers: that.data.markers.concat(ele_chargList),
- // ele_park: that.data.ele_park.concat(chargList),
- // ele_total: res.data.chargList.total,
- // ele_dataLoading: false,
- // ele_fastFree : res.data.fastFree,
- // ele_slowFree : res.data.slowFree,
- // ele_fastSum : res.data.fastSum,
- // ele_slowSum : res.data.slowSum
- });
- }
- });
- },
- callCar(){
- let that = this
- let car_active = that.data.car_active;
- if(!car_active){
- return;
- }
- let ivParkPointId = that.data.ele_chargList[that.data.parkActiveIndex].ivParkPointId
- let chargePileId = that.data.ele_chargList[that.data.eleActiveIndex].chargPileId
- let userId = that.data.userInfo.userId
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/callCarRequirement?'
- + 'ivParkPointId=' + ivParkPointId
- + '&chargePileId=' + chargePileId
- + '&userId=' + userId
- + '&requirementType=0',
- data: {
- },
- method: 'POST',
- success: function (res) {
- if( res.data.code ==200){
- // 走你
- let url = `/pages/batteryPack/batteryPackWait`;
- wx.redirectTo({
- url
- });
- }else{
- // 给出提示
- wx.showModal({
- showCancel: false,
- content: "调度失败" + res.data?.msg,
- confirmColor:'#00AADD',
- });
- }
- },
- fail(e) {
- console.log("呼叫充电车失败");
- }
- })
- }
- })
|