123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409 |
- // pages/ucenter/control/batteryControl.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- code: '202007221111110201',
- chargPile:{
- // chargPileName:'测试电池包',
- // chargPileId:'202007221111110201',
- // address:'雁塔区小寨西路',
- // wxTest:'wxTest',
- chargPileName:'',
- chargPileId:'',
- address:'',
- wxTest:'wxTest',
- },
- cars:[],
- carIndex: -1,
- locations:[],
- locationIndex: -1,
- wxTest:{
- msg:'uuddudududud',
- index:0,
- t: new Date().valueOf(),
- tnum: 0,
- },
- tractorTaskTypeIndex: -1,
- tractorTaskTypeList:[
- {
- "txt": "装载电池包",
- "val": 2
- },
- {
- "txt": "卸载电池包",
- "val": 3
- },
- {
- "txt": "离开电池包",
- "val": 4
- }
- ]
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let that = this
- // let {code} = options
- // this.setData({
- // code
- // })
-
-
-
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/ivCar',
- data: {
- },
- method: 'POST',
- success(res) {
- console.info(res);
- let cars = res?.data?.result?res?.data?.result:[]
- that.setData({
- cars
- })
- }
- })
-
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/ivParkPoint',
- data: {
- },
- method: 'POST',
- success(res) {
- console.info(res);
- let locations = res?.data?.result?res?.data?.result:[]
- that.setData({
- locations
- })
- }
- })
- let userInfo = wx.getStorageSync('userInfo');
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
- data: {
- chargPileId:that.data.code,
- userId: userInfo.userId
- },
- method: 'POST',
- success(res) {
- // log.info('[首页]', '[获取扫一扫充电桩]', '[响应]', res.data);
- console.info(res)
- if (!res.data || res.data.code == 500) {
- wx.showModal({
- showCancel: false,
- content: res && res.data && res.data.msg ? res.data.msg :'无效的终端编号',
- confirmColor:'#00AADD',
- });
- }else{
- let chargPile = res.data.result;
- that.setData({
- chargPile
- })
- }
-
- },
- fail(e) {
- getApp().showNetworkError();
- }
- });
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- },
- upBtn(){
- let that = this;
- // if(that.wxTestDebug(that,'u') > 4){
- // return ;
- // }
- that.bettyControl(1)
- },
- downBtn(){
- let that = this;
- // if(that.wxTestDebug(that,'d') > 4){
- // return ;
- // }
- that.bettyControl(2);
- },
- bettyControl(bettyControl){
- let that = this;
- wx.showLoading({
- title: '控制电池中。。。',
- mask: true
- })
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/pileLog/bettyControl',
- data: {
- bettyControl,
- chargPileId: that.data.chargPile.chargPileId
- },
- method: 'POST',
- success(res) {
- console.info(res)
- wx.hideLoading()
- wx.showToast({
- icon: 'none',
- title: res.data.msg,
- duration: 1000
- })
- }
- })
- },
- wxTestDebugClick(){
- let that = this
- if(new Date().valueOf() - that.data.wxTest.t <= 1000){
- that.data.wxTest.tnum = that.data.wxTest.tnum + 1
- }else{
- that.data.wxTest.tnum = 0
- }
- that.data.wxTest.t = new Date().valueOf()
- if(that.data.wxTest.tnum > 10){
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/wxTest/switch',
- data: {
- },
- method: 'GET',
- success(res) {
- that.data.wxTest.tnum = 0
- wx.showToast({
- title: "调试模式: " + res.data.msg,
- duration: 1000
- })
- }
- })
- }
-
- },
- wxTestDebug(that,s){
- // let that = this;
-
- if(that.data.wxTest.msg.length == that.data.wxTest.index + 1){
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/wxTest/switch',
- data: {
- },
- method: 'GET',
- success(res) {
- wx.showToast({
- title: "调试模式: " + res.data.msg,
- duration: 1000
- })
- }
- })
- idx = 0;
- that.setData({
- wxTest:{
- msg:that.data.wxTest.msg,
- index: idx,
- }
- })
- return;
- }
- let idx = 0
- if(that.data.wxTest.msg.substr(that.data.wxTest.index,1) == s){
- idx = that.data.wxTest.index + 1
- that.setData({
- wxTest:{
- msg:that.data.wxTest.msg,
- index: idx,
- }
- })
- }else{
- idx = 0;
- that.setData({
- wxTest:{
- msg:that.data.wxTest.msg,
- index: idx,
- }
- })
- }
- return idx;
- },
- carTap(e){
- let carIndex = e.currentTarget.dataset.idx;
- this.setData({
- carIndex
- })
- },
- locationTap(e){
- let locationIndex = e.currentTarget.dataset.idx;
- this.setData({
- locationIndex
- })
-
- },
- tractorTaskTypeTap(e){
- let tractorTaskTypeIndex = e.currentTarget.dataset.idx;
- this.setData({
- tractorTaskTypeIndex
- })
- },
- submit(){
- let that = this;
- if(this.data.carIndex==-1){
- wx.showToast({
- icon: 'none',
- title: '请选择车辆',
- duration: 1000
- })
- return ;
- }
- if(this.data.locationIndex==-1){
- wx.showToast({
- icon: 'none',
- title: '请选择点位',
- duration: 1000
- })
- return ;
- }
- if(this.data.tractorTaskTypeIndex==-1){
- wx.showToast({
- icon: 'none',
- title: '请选择任务类型',
- duration: 1000
- })
- return ;
- }
- let car = this.data.cars[this.data.carIndex];
- let location = this.data.locations[this.data.locationIndex]
- wx.showModal({
- title: '提示',
- content: '是否调度当前车辆?' + car.carName + "|" + location.pointShowName,
- complete: (res) => {
- if (res.cancel) {
-
- }
- if (res.confirm) {
- wx.showLoading({
- title: '调度车辆中。。。',
- mask: true
- })
-
- let userInfo = wx.getStorageSync('userInfo');
- // userId:
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/createIvCarRequirement?'
- + 'finalTargetParkPointId=' + location.id
- + '&carId=' + car.id
- // + '&chargePileId=' + that.data.chargPile.id
- + '&chargePileId=12'
- + '&userId=' + userInfo.userId
- // + '&requirementType=' + that.data.tractorTaskTypeList[that.data.tractorTaskTypeIndex]['val'],
- + '&requirementType=0',
- data:{
- // "finalTargetParkPointId":location.id,
- // "carId":car.id,
- // "chargePileId":that.data.chargPile.chargPileId,
- // "userId":userInfo.userId,
- // "requirementType":that.data.tractorTaskTypeList[that.data.tractorTaskTypeIndex]['val'],
- },
- method: 'POST',
- success(ress) {
- if(ress && ress.statusCode==200){
- let iid = ress.data.result.id;
- console.info(iid);
- console.info("11111111111111111");
- wx.request({
- url: getApp().globalData.postHeadAgreement +'/restapi/wechat/xingshen',
- data: {
- // capacityResourceId: car.id,
- // targetParkPointId: location.id,
- // tractorTaskType: that.data.tractorTaskTypeList[that.data.tractorTaskTypeIndex]['val'],
-
- // ivCarId:car.id,
- // targetParkPointId: 1,
- // capacityResourceId: location.id,
- // tractorTaskType: that.data.tractorTaskTypeList[that.data.tractorTaskTypeIndex]['val'],
-
- carId:car.id,
- parkPointId: location.id,
- carRequirementId: iid,
- tractorTaskType: that.data.tractorTaskTypeList[that.data.tractorTaskTypeIndex]['val'],
- },
- method: 'POST',
- success(res) {
- wx.hideLoading();
- if(res.statusCode==200){
- if(res.data.code==200){
- wx.showToast({
- icon: 'success',
- title: res.data.msg,
- duration: 1000
- })
- }else{
- wx.showToast({
- icon: 'none',
- title: '调度失败:' + res.data.msg,
- duration: 1000
- })
- }
- }else{
- wx.showToast({
- icon: 'none',
- title: '调度失败',
- duration: 1000
- })
- }
- }
- })
- }
- },
- })
- }
- }
- })
- },
- })
|