123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- Page({
-
- data: {
- chargePileId: -9,
- timer:{},
- userInfo:{},
-
- },
-
- onLoad(options) {
- let that = this
- let userInfo = wx.getStorageSync('userInfo');
- let timer = setInterval(()=>{
- that.wait(that)
- }, 2000);
- that.setData({
- timer,
- userInfo
- })
- },
- wait(that){
- let userInfo = that.data.userInfo;
- if(!userInfo){
- return;
- }
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/ivCarRequirement' +
- '?userId='+userInfo.userId,
- data: {
- },
- method: 'POST',
- success(res) {
-
- if(res?.data?.result?.requirementStep>=0 && res?.data?.result?.requirementStep<=7
-
- ){
- that.setData({
- chargePileId: res?.data?.result?.terminalId,
-
-
- })
-
- console.log(new Date() + " - requirementStep:" + res?.data?.result?.requirementStep)
- }else if(res?.data?.result?.requirementStep==8
-
- ){
- that.setData({
- chargePileId: res?.data?.result?.terminalId,
-
-
- })
-
- clearInterval(that.data.timer)
- that.gotoScan_result(that)
- }else{
- that.gotoIndex()
- }
-
- },
- fail(e) {
- getApp().showNetworkError();
- }
- });
- },
- gotoIndex(){
- let url = `/pages/index/index`;
- wx.reLaunch({
- url
- });
- },
- gotoScan_result(that){
- let chargPileId = that.data.chargePileId
- let userInfo = that.data.userInfo
- wx.request({
- url: getApp().globalData.postHeadAgreement + '/restapi/wechat/chargPile',
-
- data:{
- chargPileId,
- userId: userInfo.userId
- },
- method: 'POST',
- success(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 {
- res.data = res.data.result
-
- if (!res.data.chargstatus || res.data.chargstatus == 0 || res.data.chargstatus == 1 || res.data.chargstatus == 4 || res.data.chargstatus == 5 || res.data.chargstatus == 6 || res.data.chargstatus == 9) {
-
- wx.showModal({
- showCancel: false,
- content: '终端故障,维修中',
- confirmColor:'#00AADD',
- });
- } else if (res.data.chargstatus == 3 || res.data.chargstatus == 8 || res.data.chargstatus == 10) {
- wx.showModal({
- showCancel: false,
- content: '正在充电中',
- confirmColor:'#00AADD',
- });
- } else if (res.data.chargstatus == 2 || res.data.chargstatus == 11) {
- wx.setStorage({
- key: "scan_chargpile",
- data: res.data
- });
-
- let url = `/pages/scan_result/scan_result`;
- wx.reLaunch({
- url
- });
- }
- }
- },
- fail(e) {
- getApp().showNetworkError();
- }
- });
- },
-
- onReady() {
- },
-
- onShow() {
- },
-
- onHide() {
- },
-
- onUnload() {
- },
-
- onPullDownRefresh() {
- },
-
- onReachBottom() {
- },
-
- onShareAppMessage() {
- }
- })
|