|
@@ -1,162 +1,468 @@
|
|
|
import axios from 'axios'
|
|
|
-export default {
|
|
|
- websocket: (url, callback,) => {
|
|
|
+export default{
|
|
|
+ websocket:(url,callback)=>{
|
|
|
+
|
|
|
+ // let isTrue = true;
|
|
|
+ let websocket=null
|
|
|
+ if ("WebSocket" in window) {
|
|
|
+ // websocket = new WebSocket("ws://"+url);
|
|
|
+ websocket = new WebSocket(url);
|
|
|
+ }
|
|
|
+ else if ("MozWebSocket" in window) {
|
|
|
+ // websocket = new WebSocket("ws://"+url);
|
|
|
+ websocket = new WebSocket(url);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // console.error("'不支持 WebSocKet");
|
|
|
+ }
|
|
|
+ //连接发生错误的回调方法
|
|
|
+ websocket.onerror = () => {
|
|
|
+ onerror();
|
|
|
+ }
|
|
|
+ //接收到消息的回调方法
|
|
|
+ websocket.onopen = () => {
|
|
|
+ //接收到消息的回调方法
|
|
|
+
|
|
|
+ websocket.onmessage = event => {
|
|
|
+ if(callback){
|
|
|
+ if(event.data){
|
|
|
+ try{
|
|
|
+ callback(event.data,websocket);
|
|
|
+ }catch(e){
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ //连接关闭的回调方法
|
|
|
+ // websocket.onclose = () => console.log("close");
|
|
|
+ //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
|
|
|
+ window.onbeforeunload = () => websocket.close();
|
|
|
+ //return websocket;
|
|
|
+ };
|
|
|
+ function onerror(){
|
|
|
+ setTimeout(function(){
|
|
|
+ websocket = null
|
|
|
+ if ("WebSocket" in window) {
|
|
|
+ websocket = new WebSocket(url);
|
|
|
+ } else if ("MozWebSocket" in window) {
|
|
|
+ websocket = new WebSocket(url);
|
|
|
+ }
|
|
|
+ websocket.onerror = () => {
|
|
|
+ onerror();
|
|
|
+ }
|
|
|
+ //接收到消息的回调方法
|
|
|
+ websocket.onopen = () => {
|
|
|
+ //接收到消息的回调方法
|
|
|
+ websocket.onmessage = event => {
|
|
|
+ if (callback) {
|
|
|
+ if (event.data) {
|
|
|
+ // console.log(event.data,'==============')
|
|
|
+ try {
|
|
|
+ // console.log(event.data)
|
|
|
+ let data = JSON.parse(event.data)
|
|
|
+ console.log(data,'=------------')
|
|
|
+ if (data.status == '0000') {
|
|
|
+ callback(data,websocket);
|
|
|
+ } else {
|
|
|
+ console.log(data,'=------------')
|
|
|
+ if (error) {
|
|
|
+ error(data)
|
|
|
+ }
|
|
|
+ if (this_.version == 1) {
|
|
|
+ this_.$alert(data.msg, 'System hints', {
|
|
|
+ confirmButtonText: 'Confirm',
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this_.$alert(data.msg, '系统提示', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // let res = JSON.parse(event.data)
|
|
|
+ if (data.data.status == 2) {
|
|
|
+ // websocket.close();
|
|
|
+ // console.log('websocket链接关闭')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ //连接关闭的回调方法
|
|
|
+ // websocket.onclose = () => console.log("close");
|
|
|
+ //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
|
|
|
+ window.onbeforeunload = () => websocket.close();
|
|
|
+ //return websocket;
|
|
|
+ };
|
|
|
+ },1000)
|
|
|
+ console.log("error");
|
|
|
+ }
|
|
|
+
|
|
|
+ return websocket;
|
|
|
+ },
|
|
|
+ websocket1: (url, callback, error, this_) => {
|
|
|
+ console.log(url)
|
|
|
+ // let isTrue = true;
|
|
|
+ url = window.location.protocol == 'https:' ? url.replace('wss','wss') : url.replace('wss','ws');
|
|
|
let websocket = null
|
|
|
- // console.log(this_)
|
|
|
if ("WebSocket" in window) {
|
|
|
+ // websocket = new WebSocket("ws://"+url);
|
|
|
websocket = new WebSocket(url);
|
|
|
} else if ("MozWebSocket" in window) {
|
|
|
+ // websocket = new WebSocket("ws://"+url);
|
|
|
websocket = new WebSocket(url);
|
|
|
} else {
|
|
|
// console.error("'不支持 WebSocKet");
|
|
|
}
|
|
|
//连接发生错误的回调方法
|
|
|
- websocket.onerror = event => {
|
|
|
- console.log(event)
|
|
|
- websocket = null
|
|
|
- if ("WebSocket" in window) {
|
|
|
- websocket = new WebSocket(url);
|
|
|
- } else if ("MozWebSocket" in window) {
|
|
|
- websocket = new WebSocket(url);
|
|
|
- }
|
|
|
- if(websocket){
|
|
|
- websocketOnopen(websocket)
|
|
|
- }
|
|
|
- console.log("error");
|
|
|
+ websocket.onerror = () => {
|
|
|
+ onerror();
|
|
|
}
|
|
|
//接收到消息的回调方法
|
|
|
- websocketOnopen(websocket)
|
|
|
- function websocketOnopen(websocket) {
|
|
|
- websocket.onopen = () => {
|
|
|
- // console.log(event,error)
|
|
|
- callback(websocket)
|
|
|
- //接收到消息的回调方法
|
|
|
- // websocket.onmessage = event => {
|
|
|
- // if (callback) {
|
|
|
- // if (event.data) {
|
|
|
- // try {
|
|
|
- // let data = JSON.parse(event.data)
|
|
|
- // if (data.code == '0000') {
|
|
|
- // callback(data,websocket);
|
|
|
- // } else {
|
|
|
- // if (error) {
|
|
|
- // error(data)
|
|
|
- // }
|
|
|
- // this_.$alert(data.msg, this_.$t('App.message.text1'), {
|
|
|
- // confirmButtonText: this_.$t('App.message.text2'),
|
|
|
- // });
|
|
|
- // }
|
|
|
- // if (data.data.status == 2) {
|
|
|
- // websocket.close();
|
|
|
- // }
|
|
|
- // } catch (e) {
|
|
|
- // console.log()
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // callback()
|
|
|
- // }
|
|
|
- // }
|
|
|
- // };
|
|
|
- //连接关闭的回调方法
|
|
|
- // websocket.onclose = () => console.log("close");
|
|
|
- //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
|
|
|
- window.onbeforeunload = () => websocket.close();
|
|
|
- //return websocket;
|
|
|
+ websocket.onopen = () => {
|
|
|
+ //接收到消息的回调方法
|
|
|
+ websocket.onmessage = event => {
|
|
|
+ if (callback) {
|
|
|
+ if (event.data) {
|
|
|
+ // console.log(event.data,'==============')
|
|
|
+ try {
|
|
|
+ // console.log(event.data)
|
|
|
+ let data = JSON.parse(event.data)
|
|
|
+ console.log(data,'=------------')
|
|
|
+ if (data.status == '0000') {
|
|
|
+ callback(data,websocket);
|
|
|
+ } else {
|
|
|
+ console.log(data,'=------------')
|
|
|
+ if (error) {
|
|
|
+ error(data)
|
|
|
+ }
|
|
|
+ if (this_.version == 1) {
|
|
|
+ this_.$alert(data.msg, 'System hints', {
|
|
|
+ confirmButtonText: 'Confirm',
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this_.$alert(data.msg, '系统提示', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // let res = JSON.parse(event.data)
|
|
|
+ if (data.data.status == 2) {
|
|
|
+ // websocket.close();
|
|
|
+ // console.log('websocket链接关闭')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
+ //连接关闭的回调方法
|
|
|
+ // websocket.onclose = () => console.log("close");
|
|
|
+ //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
|
|
|
+ window.onbeforeunload = () => websocket.close();
|
|
|
+ //return websocket;
|
|
|
+ };
|
|
|
+ function onerror(){
|
|
|
+ setTimeout(function(){
|
|
|
+ websocket = null
|
|
|
+ if ("WebSocket" in window) {
|
|
|
+ websocket = new WebSocket(url);
|
|
|
+ } else if ("MozWebSocket" in window) {
|
|
|
+ websocket = new WebSocket(url);
|
|
|
+ }
|
|
|
+ websocket.onerror = () => {
|
|
|
+ onerror();
|
|
|
+ }
|
|
|
+ //接收到消息的回调方法
|
|
|
+ websocket.onopen = () => {
|
|
|
+ //接收到消息的回调方法
|
|
|
+ websocket.onmessage = event => {
|
|
|
+ if (callback) {
|
|
|
+ if (event.data) {
|
|
|
+ // console.log(event.data,'==============')
|
|
|
+ try {
|
|
|
+ // console.log(event.data)
|
|
|
+ let data = JSON.parse(event.data)
|
|
|
+ console.log(data,'=------------')
|
|
|
+ if (data.status == '0000') {
|
|
|
+ callback(data,websocket);
|
|
|
+ } else {
|
|
|
+ console.log(data,'=------------')
|
|
|
+ if (error) {
|
|
|
+ error(data)
|
|
|
+ }
|
|
|
+ if (this_.version == 1) {
|
|
|
+ this_.$alert(data.msg, 'System hints', {
|
|
|
+ confirmButtonText: 'Confirm',
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this_.$alert(data.msg, '系统提示', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // let res = JSON.parse(event.data)
|
|
|
+ if (data.data.status == 2) {
|
|
|
+ // websocket.close();
|
|
|
+ // console.log('websocket链接关闭')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ //连接关闭的回调方法
|
|
|
+ // websocket.onclose = () => console.log("close");
|
|
|
+ //监听窗口关闭事件,当窗口关闭时,主动去关闭websocket连接,防止连接还没断开就关闭窗口,server端会抛异常。
|
|
|
+ window.onbeforeunload = () => websocket.close();
|
|
|
+ //return websocket;
|
|
|
+ };
|
|
|
+ },1000)
|
|
|
+ console.log("error");
|
|
|
}
|
|
|
|
|
|
return websocket;
|
|
|
},
|
|
|
-
|
|
|
- ajax_get: (url, param, callback, this_) => {
|
|
|
- axios.get(url, { params: param }).then(res => {
|
|
|
- let data = res.data
|
|
|
- if (data.result) {
|
|
|
- if (callback) {
|
|
|
- if (data.model && JSON.stringify(data.model).length > 2) {
|
|
|
- try {
|
|
|
+ ajax_get:(url,param,callback,this_) => {
|
|
|
+ // console.log(url)
|
|
|
+ // console.log(param)
|
|
|
+ param = Object.assign({
|
|
|
+ version:this_.version,
|
|
|
+ }, param);
|
|
|
+ axios.get( url, { params:param }).then(res => {
|
|
|
+ let data= res.data
|
|
|
+ data = Object.assign({
|
|
|
+ version:this_.version,
|
|
|
+ }, data);
|
|
|
+ if(data.result){
|
|
|
+ if(callback){
|
|
|
+ if(data.model&&JSON.stringify(data.model).length>2){
|
|
|
+ try{
|
|
|
+ // console.log(data.model)
|
|
|
callback(data.model)
|
|
|
- } catch (e) {
|
|
|
+ }catch(e){
|
|
|
// console.log('异常了')
|
|
|
// console.log(e)
|
|
|
}
|
|
|
- } else {
|
|
|
+ }else{
|
|
|
callback(data.model)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- } else {
|
|
|
- this_.$alert(data.message, this_.$t('App.message.text26'));
|
|
|
+ }else{
|
|
|
+ this_.$alert(data.message,'系统提示');
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- ajax_post: (url, data, param, callback, this_, error, error_t) => {
|
|
|
+ ajax_post: (url,data,param,callback,this_,error,error_t) => {
|
|
|
let qs = require('qs')
|
|
|
- data.version = this_.version;
|
|
|
- data.os = '0';
|
|
|
- axios.post(url, qs.stringify(data), { params: param }).then(res => {
|
|
|
- let data = res.data
|
|
|
- if (data.code == '0000') {
|
|
|
- if (callback) {
|
|
|
- callback(data, this_)
|
|
|
- }
|
|
|
- } else if (data.code == '0001' || data.code == '0002' || data.code == '0003' || data.code == '0004' || data.code == '0102') {
|
|
|
- if (error) {
|
|
|
- error(data, this_)
|
|
|
- }
|
|
|
- this_.$alert(data.msg, this_.$t('App.message.text1'), {
|
|
|
- confirmButtonText: this_.$t('App.message.text2'),
|
|
|
- });
|
|
|
- this_.$store.commit('ROUTERSTRFUN',{
|
|
|
- routerStr:'/login',
|
|
|
- })
|
|
|
- var oDate = new Date();
|
|
|
- oDate.setTime(oDate.getTime() + ('' * 24 * 60 * 60 * 1000));
|
|
|
- oDate = oDate.toUTCString()
|
|
|
- document.cookie = 'userData' + '=' + '' + ';expires=' + oDate;
|
|
|
- this_.$router.push({path:'/login'})
|
|
|
-
|
|
|
- // if(this_.websocket){
|
|
|
- // this_.websocket.close();
|
|
|
- // }
|
|
|
- } else {
|
|
|
- if (error) {
|
|
|
- error(data, this_)
|
|
|
- }
|
|
|
- if (!error_t) {
|
|
|
- this_.$alert(data.msg, this_.$t('App.message.text1'), {
|
|
|
- confirmButtonText: this_.$t('App.message.text2'),
|
|
|
- });
|
|
|
+ data = Object.assign({
|
|
|
+ version:this_.version,
|
|
|
+ }, data);
|
|
|
+ // console.log(url,data,param)
|
|
|
+ // console.log(qs.stringify(data))
|
|
|
+ axios.post( url,qs.stringify(data), { params:param }).then(res => {
|
|
|
+ let data= res.data
|
|
|
+ // console.log(data)
|
|
|
+ if(data.status == '0000'){
|
|
|
+ if(callback){
|
|
|
+ callback(data,this_)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(error){
|
|
|
+ error(data,this_)
|
|
|
+ }
|
|
|
+ if(!error_t){
|
|
|
+ var url_tt = window.location.href.split("/")[2];
|
|
|
+ if(url_tt == 'localhost:8081'){
|
|
|
+ url_tt = 'newtest.solar-iot.com';
|
|
|
+ // url_tt = '10.0.0.123/solar';
|
|
|
+ }
|
|
|
+ if(url !='http://'+url_tt+'/api/device/lampcontrol/turnonoff'
|
|
|
+ && url !='http://'+url_tt+'/api/device/lampcontrol/load_setting'
|
|
|
+ && url !='http://'+url_tt+'/api/device/lampcontrol/set_load'
|
|
|
+ && url !='http://'+url_tt+'/api/device/lampcontrol/battery_setting'
|
|
|
+ && url !='http://'+url_tt+'/api/device/lampcontrol/set_battery'){
|
|
|
+ if(data.status == '0001' || data.status == '0002' || data.status == '0003' || data.status == '0004' || data.status == '0102'){
|
|
|
+ var storage = window.localStorage;
|
|
|
+ storage.setItem('UserInformation','false');
|
|
|
+ storage.setItem('loginState','false');
|
|
|
+ window.location.href="login.html";
|
|
|
+ }
|
|
|
+ if(this_.version == 1){
|
|
|
+ this_.$alert(data.msg, 'System hints', {
|
|
|
+ confirmButtonText: 'Confirm',
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ this_.$alert(data.msg, '系统提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /*version 初始值*/
|
|
|
+ ajax_post3: (url,data,param,callback,this_,error,error_t) => {
|
|
|
+ let qs = require('qs')
|
|
|
+ // console.log(url,data,param)
|
|
|
+ // console.log(qs.stringify(data))
|
|
|
+ data = Object.assign({
|
|
|
+ version:this_.version,
|
|
|
+ }, data);
|
|
|
+ axios.post( url,qs.stringify(data), { params:param }).then(res => {
|
|
|
+ let data= res.data
|
|
|
+ // console.log(data)
|
|
|
+ if(data.status == '0000'){
|
|
|
+ if(callback){
|
|
|
+ callback(data,this_)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(error){
|
|
|
+ error(data,this_)
|
|
|
+ }
|
|
|
+ if(!error_t){
|
|
|
+ var url_tt = window.location.href.split("/")[2];
|
|
|
+ if(url_tt == 'localhost:8081'){
|
|
|
+ url_tt = 'newtest.solar-iot.com';
|
|
|
+ // url_tt = '10.0.0.123/solar';
|
|
|
+ }
|
|
|
+ if(url !='http://'+url_tt+'/api/device/lampcontrol/turnonoff'
|
|
|
+ && url !='http://'+url_tt+'/api/device/lampcontrol/load_setting'
|
|
|
+ && url !='http://'+url_tt+'/api/device/lampcontrol/set_load'
|
|
|
+ && url !='http://'+url_tt+'/api/device/lampcontrol/battery_setting'
|
|
|
+ && url !='http://'+url_tt+'/api/device/lampcontrol/set_battery'){
|
|
|
+ if(data.status == '0001' || data.status == '0002' || data.status == '0003' || data.status == '0004' || data.status == '0102'){
|
|
|
+ var storage = window.localStorage;
|
|
|
+ storage.setItem('UserInformation','false');
|
|
|
+ storage.setItem('loginState','false');
|
|
|
+ window.location.href="login.html";
|
|
|
+ }
|
|
|
+ if(this_.version == 1){
|
|
|
+ this_.$alert(data.msg, 'System hints', {
|
|
|
+ confirmButtonText: 'Confirm',
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ this_.$alert(data.msg, '系统提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ ajax_post2: (url,data,param,callback,this_) => {
|
|
|
+ let qs = require('qs')
|
|
|
+ data = Object.assign({
|
|
|
+ version:this_.version,
|
|
|
+ }, data);
|
|
|
+ // console.log(url)
|
|
|
+ // console.log(data)
|
|
|
+ // console.log(param)
|
|
|
+ // console.log(qs.stringify(data))
|
|
|
+ axios.post( url,qs.stringify(data), { params:param }).then(res => {
|
|
|
+ let data= res.data
|
|
|
+ if(data.result){
|
|
|
+ if(callback){
|
|
|
+ if(data.model&&JSON.stringify(data.model).length>2){
|
|
|
+ try{
|
|
|
+ // callback(JSON.parse(data.message,this_))
|
|
|
+ // console.log(data)
|
|
|
+ callback(data)
|
|
|
+ }catch(e){
|
|
|
+ // console.log('异常了')
|
|
|
+ // console.log(e)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ callback(data.message,this_)
|
|
|
+ }
|
|
|
}
|
|
|
+ }else{
|
|
|
+ this_.$alert(data.message,'系统提示');
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- ajax_postWs: (url, data, this_,) => {
|
|
|
+ ajax_postAction: (url,data,param,callback,this_) => {
|
|
|
let qs = require('qs')
|
|
|
- data.version = this_.version;
|
|
|
- data.os = '0';
|
|
|
- axios.post(url, qs.stringify(data)).then(() => {})
|
|
|
+ data = Object.assign({
|
|
|
+ version:this_.version,
|
|
|
+ }, data);
|
|
|
+ axios.post( url,qs.stringify(data), { params:param }).then(res => {
|
|
|
+ let data= res.data
|
|
|
+ if(data.result){
|
|
|
+ try{
|
|
|
+ callback(data.message)
|
|
|
+ }catch(e){
|
|
|
+ // console.log('异常了');
|
|
|
+ // console.log(e)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this_.$alert(data.message,'系统提示');
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ ajax_post1: (url,data,param,callback,this_) => {
|
|
|
+ // console.log(url)
|
|
|
+ // console.log(data)
|
|
|
+ // console.log(param)
|
|
|
+ data = Object.assign({
|
|
|
+ version:this_.version,
|
|
|
+ }, data);
|
|
|
+ axios.post( url,data, { params:param }).then(res => {
|
|
|
+ let data= res.data
|
|
|
+ if(data.result){
|
|
|
+ if(callback){
|
|
|
+ if(data.model&&JSON.stringify(data.model).length>2){
|
|
|
+ try{
|
|
|
+ // callback(JSON.parse(data.message,this_))
|
|
|
+ // console.log(data.model)
|
|
|
+ callback(data.model)
|
|
|
+ }catch(e){
|
|
|
+ // console.log('异常了')
|
|
|
+ // console.log(e)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ callback(data.message,this_)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this_.$alert(data.message,'系统提示');
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
- setCookie: (key, value, iDay) => {
|
|
|
- var oDate = new Date();
|
|
|
- oDate.setTime(oDate.getTime() + (iDay * 24 * 60 * 60 * 1000));
|
|
|
- oDate = oDate.toUTCString();
|
|
|
- // document.cookie = key + '=' + value;
|
|
|
- // console.log(key + '=' + value + ';expires=' + oDate)
|
|
|
- document.cookie = key + '=' + value + ';expires=' + oDate;
|
|
|
+ ajax_post_ws: (url, data,this_) => {
|
|
|
+ let qs = require('qs')
|
|
|
+ data = Object.assign({
|
|
|
+ version:this_.version,
|
|
|
+ }, data);
|
|
|
+ axios.post(url, qs.stringify(data), { params: {} }).then(res => {console.log(res)})
|
|
|
},
|
|
|
- // removeCookie: (key) => {
|
|
|
- // setCookie(key, '', -1); //这里只需要把Cookie保质期退回一天便可以删除
|
|
|
- // },
|
|
|
- getCookie: (key) => {
|
|
|
- var cookieArr = document.cookie.split('; ');
|
|
|
- for (var i = 0; i < cookieArr.length; i++) {
|
|
|
- var arr = cookieArr[i].split('=');
|
|
|
- if (arr[0] === key) {
|
|
|
- return arr[1];
|
|
|
+ ajax_weather:(url,param,callback,this_) =>{
|
|
|
+ axios.get( url, { params:param }).then(res => {
|
|
|
+ let data= res.data
|
|
|
+ console.log(data,'----------')
|
|
|
+ if(data.HeWeather6[0].status == 'ok'){
|
|
|
+ if(callback){
|
|
|
+ callback(data.HeWeather6[0])
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this_.$alert('获取天气信息失败','系统提示');
|
|
|
}
|
|
|
- }
|
|
|
- return false;
|
|
|
+ })
|
|
|
}
|
|
|
}
|