接口域名更改,取消H5域名跨域配置

master
chen 2022-04-02 09:17:26 +08:00
parent 8e65b1c87b
commit 476de6e246
4 changed files with 16 additions and 21 deletions

View File

@ -10,12 +10,10 @@
onLaunch: function() { onLaunch: function() {
// //
// #ifdef APP-PLUS // #ifdef APP-PLUS
// uni.setStorageSync('hostapi','http://maintain.7and5.cn'); getApp().globalData.hostapi = 'https://7and5.cn';
getApp().globalData.hostapi = 'http://maintain.7and5.cn';
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// uni.setStorageSync('hostapi','http://maintain.7and5.cn'); this.globalData.hostapi = 'https://7and5.cn';
this.globalData.hostapi = 'http://maintain.7and5.cn';
// #endif // #endif
// #ifdef H5 // #ifdef H5
// uni.setStorageSync('hostapi','/web'); // uni.setStorageSync('hostapi','/web');

View File

@ -3,13 +3,14 @@ const ENV = process.env.NODE_ENV;
console.log(ENV,'当前环境'); // development开发环境 test测试环境 production生产环境 console.log(ENV,'当前环境'); // development开发环境 test测试环境 production生产环境
// 配置全局域名 // 配置全局域名
// #ifdef APP-PLUS // #ifdef APP-PLUS
const hostapi = 'http://maintain.7and5.cn'; const hostapi = 'https://7and5.cn';
// #endif // #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
const hostapi = 'http://maintain.7and5.cn'; const hostapi = 'https://7and5.cn';
// #endif // #endif
// #ifdef H5 // #ifdef H5
const hostapi = '/web'; // const hostapi = '/web';
const hostapi = 'https://7and5.cn';
// #endif // #endif
// 清理所有缓存并前往授权页 // 清理所有缓存并前往授权页
const goLogin = () => { const goLogin = () => {
@ -88,11 +89,14 @@ const request = (method, url, options) => {
if(options!=undefined) params = options; if(options!=undefined) params = options;
// params.token = uni.getStorageSync('token'); // params.token = uni.getStorageSync('token');
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.log(hostapi,91);
uni.request({ uni.request({
url: `${hostapi}${url}`, url: `${hostapi}${url}`,
method: methods, method: methods,
data: params, data: params,
header: headers, header: headers,
// sslVerify:false,//验证 ssl 证书 仅App安卓端支持
// withCredentials:true,//跨域请求时是否携带凭证cookies仅H5支持
success: res => { success: res => {
console.log(`${url}返的结果===>`,res); console.log(`${url}返的结果===>`,res);
if (res.statusCode == 200) { if (res.statusCode == 200) {
@ -117,7 +121,6 @@ const request = (method, url, options) => {
// 上传文件 封装请求 // 上传文件 封装请求
const uploadFile = (url, options) => { const uploadFile = (url, options) => {
let tempData = options || {} let tempData = options || {}
console.log(tempData,108);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.uploadFile({ uni.uploadFile({
url: `${hostapi}${url}`, url: `${hostapi}${url}`,
@ -125,6 +128,8 @@ const uploadFile = (url, options) => {
name: 'image', name: 'image',
fileType:'image', fileType:'image',
formData: tempData, formData: tempData,
// sslVerify:false,//验证 ssl 证书 仅App安卓端支持
// withCredentials:true,//跨域请求时是否携带凭证cookies仅H5支持
header: { header: {
'Content-Type': 'multipart/form-data;charset=UTF-8', 'Content-Type': 'multipart/form-data;charset=UTF-8',
'Authorization': 'Bearer '+uni.getStorageSync('token') || '', 'Authorization': 'Bearer '+uni.getStorageSync('token') || '',

View File

@ -111,7 +111,7 @@
"https" : false, "https" : false,
"proxy" : { "proxy" : {
"/web" : { "/web" : {
"target" : "http://maintain.7and5.cn", "target" : "https://7and5.cn",
"changeOrigin" : true, "changeOrigin" : true,
"secure" : false, "secure" : false,
"pathRewrite" : { "pathRewrite" : {

View File

@ -59,8 +59,7 @@
<!-- <cmd-progress type="circle" :percent="item.num" :width="60" :stroke-color="['#00a2e9','#e87c00','#0b56ec'][index]" :circleStrokeColor="['#c6e6f5','#f4dfc6','#c8d7f5'][index]" :strokeShape="'square'"></cmd-progress> --> <!-- <cmd-progress type="circle" :percent="item.num" :width="60" :stroke-color="['#00a2e9','#e87c00','#0b56ec'][index]" :circleStrokeColor="['#c6e6f5','#f4dfc6','#c8d7f5'][index]" :strokeShape="'square'"></cmd-progress> -->
<arprogress :percent="item.num" :inactiveColor="['#c6e6f5','#f4dfc6','#c8d7f5'][index]" <arprogress :percent="item.num" :inactiveColor="['#c6e6f5','#f4dfc6','#c8d7f5'][index]"
:activeColor="['#00a2e9','#e87c00','#0b56ec'][index]" :borderWidth="7.8" :width="120" :activeColor="['#00a2e9','#e87c00','#0b56ec'][index]" :borderWidth="7.8" :width="120"
:duration="500" bgColor="transparent"><text :duration="500" bgColor="transparent"><text :style="{color: ['#00a2e9','#e87c00','#0b56ec'][index]}">{{item.num}}%</text>
:style="{color: ['#00a2e9','#e87c00','#0b56ec'][index]}">{{item.num}}%</text>
</arprogress> </arprogress>
<view class="fon24 mar-s20">{{item.title}}</view> <view class="fon24 mar-s20">{{item.title}}</view>
</view> </view>
@ -123,15 +122,15 @@
], ],
percentageList: [{ percentageList: [{
title: '预约及时率', title: '预约及时率',
num: 100 num: 0
}, },
{ {
title: '上门准时率', title: '上门准时率',
num: 60 num: 0
}, },
{ {
title: '项目报修率', title: '项目报修率',
num: 40 num: 0
}, },
], ],
gridList: [{ gridList: [{
@ -197,13 +196,6 @@
this.$toolAll.tools.showToast('退出成功'); this.$toolAll.tools.showToast('退出成功');
// //
uni.clearStorageSync(); uni.clearStorageSync();
//
// #ifdef APP-PLUS
uni.setStorageSync('hostapi', 'http://maintain.7and5.cn');
// #endif
// #ifdef H5
uni.setStorageSync('hostapi', '/web');
// #endif
setTimeout(() => { setTimeout(() => {
uni.reLaunch({ uni.reLaunch({
url: '/pages/login/login' url: '/pages/login/login'