2022-06-08 15:48:09 +08:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
import App from './App'
|
|
|
|
|
|
2022-08-02 15:11:04 +08:00
|
|
|
Vue.config.productionTip = false
|
2022-06-08 15:48:09 +08:00
|
|
|
|
|
|
|
|
App.mpType = 'app'
|
|
|
|
|
|
|
|
|
|
//全局变量
|
|
|
|
|
// Vue.prototype.mobileTopHeight = uni.getMenuButtonBoundingClientRect()?uni.getMenuButtonBoundingClientRect().top:0;
|
2022-08-02 15:11:04 +08:00
|
|
|
Vue.prototype.url_config = ''
|
|
|
|
|
// Vue.prototype.COMPANY = "longguang"
|
|
|
|
|
Vue.prototype.COMPANY = "nanchang"
|
2022-06-08 15:48:09 +08:00
|
|
|
// Vue.prototype.COMPANY = ""
|
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
|
// 开发环境
|
2022-07-25 15:28:55 +08:00
|
|
|
console.log('开发环境')
|
2022-08-02 15:11:04 +08:00
|
|
|
if (uni.getStorageSync('ipPort')) {
|
|
|
|
|
Vue.prototype.url_config = uni.getStorageSync('ipPort') + '/'
|
|
|
|
|
} else {
|
|
|
|
|
// Vue.prototype.url_config = 'http://8.142.139.165:7080/' // 湖里
|
|
|
|
|
// Vue.prototype.url_config = 'http://139.9.66.234:8/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://192.168.34.125:6023/'
|
|
|
|
|
Vue.prototype.url_config = 'http://182.90.224.237:7000/' //广西联通
|
|
|
|
|
// Vue.prototype.url_config = 'http://192.168.34.148:6023' //广西联通/本地
|
|
|
|
|
// Vue.prototype.url_config = 'http://223.82.100.80:9000/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://120.236.247.200:9000/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://zhgd.loganwy.com/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://183.60.227.61:30249/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://183.60.227.61:30249/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://124.71.178.44:9000/'
|
|
|
|
|
// Vue.prototype.url_config = "http://58.34.63.88:9090/"
|
|
|
|
|
// Vue.prototype.url_config = "http://183.95.84.34:7185/"
|
|
|
|
|
// Vue.prototype.url_config = "http://218.92.215.138:9090/" //新佳城小区 123456
|
|
|
|
|
// Vue.prototype.url_config = "http://36.137.53.203:9090/" //南昌地铁 gdjt 123456
|
|
|
|
|
// Vue.prototype.url_config = 'http://124.71.178.44:8/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://124.71.87.250/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://124.71.178.44:8012' // 河南
|
|
|
|
|
// Vue.prototype.url_config = 'http://124.71.178.44:100/' //演示平台
|
|
|
|
|
}
|
2022-06-08 15:48:09 +08:00
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// 生产环境
|
|
|
|
|
console.log('生产环境')
|
2022-08-02 15:11:04 +08:00
|
|
|
if (uni.getStorageSync('ipPort')) {
|
|
|
|
|
Vue.prototype.url_config = uni.getStorageSync('ipPort') + '/'
|
|
|
|
|
} else {
|
|
|
|
|
// Vue.prototype.url_config = 'http://124.71.178.44:100/' //演示平台
|
|
|
|
|
// Vue.prototype.url_config ='http://124.71.178.44:8012/' // 河南
|
|
|
|
|
// Vue.prototype.url_config = 'http://8.142.139.165:7080/' //湖里
|
|
|
|
|
// Vue.prototype.url_config = 'http://139.9.66.234:8/'
|
2022-06-08 15:48:09 +08:00
|
|
|
// Vue.prototype.url_config = 'http://192.168.34.125:6023/'
|
2022-08-02 15:11:04 +08:00
|
|
|
Vue.prototype.url_config = 'http://182.90.224.237:7000/' //广西联通
|
|
|
|
|
// Vue.prototype.url_config = 'http://192.168.34.148:6023' //广西联通/本地
|
2022-06-08 15:48:09 +08:00
|
|
|
// Vue.prototype.url_config = 'http://223.82.100.80:9000/'
|
2022-07-25 15:28:55 +08:00
|
|
|
// Vue.prototype.url_config = 'http://120.236.247.200:9000/'
|
2022-06-08 15:48:09 +08:00
|
|
|
// Vue.prototype.url_config = "http://58.34.63.88:9090/"
|
|
|
|
|
// Vue.prototype.url_config = 'http://124.71.178.44:9000/'
|
|
|
|
|
// Vue.prototype.url_config = "http://183.95.84.34:7185/"
|
|
|
|
|
// Vue.prototype.url_config = "http://36.137.53.203:9090/"
|
|
|
|
|
// Vue.prototype.url_config = 'http://192.168.34.125:6023/'
|
|
|
|
|
// Vue.prototype.url_config = 'http://183.60.227.61:30249/'
|
2022-08-02 15:11:04 +08:00
|
|
|
// Vue.prototype.url_config = 'http://zhgd.loganwy.com/'
|
2022-06-08 15:48:09 +08:00
|
|
|
// Vue.prototype.url_config = "http://36.137.53.203:9090/"
|
|
|
|
|
// Vue.prototype.url_config = 'http://124.71.87.250/'
|
|
|
|
|
}
|
2022-08-02 15:11:04 +08:00
|
|
|
|
2022-06-08 15:48:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vue.prototype.sendRequest = function(param) {
|
|
|
|
|
var _self = this,
|
|
|
|
|
url = param.url,
|
|
|
|
|
method = param.method,
|
|
|
|
|
header = param.header || {
|
|
|
|
|
'content-type': "application/json"
|
|
|
|
|
},
|
|
|
|
|
data = param.data || {},
|
|
|
|
|
token = "",
|
|
|
|
|
hideLoading = param.hideLoading || false;
|
|
|
|
|
|
|
|
|
|
//拼接完整请求地址
|
2022-08-02 15:11:04 +08:00
|
|
|
var requestUrl = Vue.prototype.url_config + url + '?lang=' + uni.getStorageSync('language');
|
|
|
|
|
if (uni.getStorageSync('userInfo') && url != 'xmgl/base/login' && url !=
|
|
|
|
|
'xmgl/wirelessEducationQuestionSubject/getDeviceRandomEducationQuestion' && url !=
|
|
|
|
|
'xmgl/wirelessEducationQuestionAnswer/add' && url !=
|
|
|
|
|
'xmgl/safeEducationQuestionAnswer/getAnswerWorkerInfo' && url != 'xmgl/safeEducationQuestionAnswer/add' &&
|
|
|
|
|
url != 'xmgl/safeEducationQuestion/selectSafeEducationQuestionInfo') {
|
2022-06-08 15:48:09 +08:00
|
|
|
token = "Bearer " + JSON.parse(uni.getStorageSync('userInfo')).token;
|
|
|
|
|
header["Authorization"] = token
|
2022-08-02 15:11:04 +08:00
|
|
|
}
|
|
|
|
|
|
2022-06-08 15:48:09 +08:00
|
|
|
// var timestamp = Date.parse(new Date());//时间戳
|
|
|
|
|
// data["timestamp"] = timestamp;
|
|
|
|
|
// #ifdef MP-WEIXIN
|
|
|
|
|
// data["device"] = "wxapp";
|
|
|
|
|
// data["ver"] = "1.1.30";
|
|
|
|
|
// #endif
|
|
|
|
|
// #ifdef APP-PLUS || H5
|
|
|
|
|
// data["device"] = "iosapp";
|
|
|
|
|
// data["ver"] = "1.0.0";
|
|
|
|
|
// #endif
|
|
|
|
|
if (method) {
|
|
|
|
|
method = method.toUpperCase(); //小写改为大写
|
|
|
|
|
}
|
|
|
|
|
//加密sessionStorage.getItem("loginData")
|
|
|
|
|
// if (uni.getStorageSync("loginData") && data != {}) {
|
|
|
|
|
// console.log(url+"参数");
|
|
|
|
|
// console.log(data);
|
|
|
|
|
// data = encryptByDES(data);
|
|
|
|
|
// }
|
|
|
|
|
//用户交互:加载圈
|
|
|
|
|
if (!hideLoading) {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '加载中...'
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-08-02 15:11:04 +08:00
|
|
|
console.log(requestUrl,"网络请求start");
|
2022-06-08 15:48:09 +08:00
|
|
|
//网络请求
|
|
|
|
|
uni.request({
|
|
|
|
|
url: requestUrl,
|
|
|
|
|
method: method,
|
|
|
|
|
header: header,
|
|
|
|
|
data: data,
|
|
|
|
|
success: res => {
|
|
|
|
|
// console.log("网络请求success:" + JSON.stringify(res.data));
|
|
|
|
|
if (res.data.code != 200) {
|
2022-08-02 15:11:04 +08:00
|
|
|
if (res.data.code == 401 || res.data.code == 403) {
|
2022-06-08 15:48:09 +08:00
|
|
|
uni.showToast({
|
|
|
|
|
title: '登录过期,请重新登录',
|
|
|
|
|
icon: "none"
|
|
|
|
|
})
|
2022-08-02 15:11:04 +08:00
|
|
|
setTimeout(function() {
|
2022-06-08 15:48:09 +08:00
|
|
|
uni.removeStorageSync('userInfo')
|
|
|
|
|
uni.redirectTo({
|
2022-08-02 15:11:04 +08:00
|
|
|
url: '/pages/login/login.vue'
|
2022-06-08 15:48:09 +08:00
|
|
|
})
|
2022-08-02 15:11:04 +08:00
|
|
|
}, 1000)
|
|
|
|
|
} else {
|
|
|
|
|
setTimeout(function() {
|
2022-06-08 15:48:09 +08:00
|
|
|
uni.showToast({
|
|
|
|
|
title: res.data.message,
|
|
|
|
|
icon: "none"
|
|
|
|
|
})
|
2022-08-02 15:11:04 +08:00
|
|
|
}, 200)
|
2022-06-08 15:48:09 +08:00
|
|
|
}
|
2022-08-02 15:11:04 +08:00
|
|
|
|
2022-06-08 15:48:09 +08:00
|
|
|
typeof param.error == "function" && param.error(Data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
let Data = res.data;
|
|
|
|
|
// if (res.data.data && res.data.data.requestData) {
|
|
|
|
|
// let data = decryptByDES(
|
|
|
|
|
// res.data.data.requestData,
|
|
|
|
|
// res.data.data.encrypted
|
|
|
|
|
// );
|
|
|
|
|
// Data.data = JSON.parse(data);
|
|
|
|
|
// console.log(url + "解密后的数据");
|
|
|
|
|
// console.log(Data);
|
|
|
|
|
// }
|
|
|
|
|
typeof param.success == "function" && param.success(Data);
|
|
|
|
|
},
|
|
|
|
|
fail: (e) => {
|
|
|
|
|
// console.log("网络请求fail:" + JSON.stringify(e));
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// content: "" + e.errMsg
|
|
|
|
|
// });
|
2022-08-02 15:11:04 +08:00
|
|
|
uni.showToast({
|
|
|
|
|
title: '服务器开小差了呢,请您稍后再试',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
2022-06-08 15:48:09 +08:00
|
|
|
typeof param.fail == "function" && param.fail(e.data);
|
|
|
|
|
},
|
|
|
|
|
complete: () => {
|
|
|
|
|
console.log("网络请求complete");
|
|
|
|
|
if (!hideLoading) {
|
|
|
|
|
uni.hideLoading();
|
|
|
|
|
}
|
|
|
|
|
typeof param.complete == "function" && param.complete();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const app = new Vue({
|
2022-08-02 15:11:04 +08:00
|
|
|
...App
|
2022-06-08 15:48:09 +08:00
|
|
|
})
|
|
|
|
|
app.$mount()
|