You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
2.7 KiB
121 lines
2.7 KiB
import Vue from "vue";
|
|
import App from "./App";
|
|
import store from './store'
|
|
import * as enums from './common/enums.js';
|
|
import * as date from './common/date';
|
|
import * as messageType from './common/messageType';
|
|
import emotion from './common/emotion.js';
|
|
import url from './common/url.js';
|
|
|
|
// 导入网络请求的包
|
|
import { $http } from '@escook/request-miniprogram';
|
|
uni.$http = $http;
|
|
|
|
// 请求的根路径
|
|
// #ifdef H5
|
|
$http.baseUrl = 'https://www.sanduolantoyoga.com/yoga'
|
|
// $http.baseUrl = 'http://192.168.13.9:8083'
|
|
// #endif
|
|
|
|
//#ifdef APP-PLUS
|
|
$http.baseUrl = 'https://www.sanduolantoyoga.com/yoga'
|
|
// $http.baseUrl = 'http://192.168.13.9:8083'
|
|
//#endif
|
|
|
|
|
|
// WebSocket 地址(可根据平台条件编译)
|
|
// #ifdef H5
|
|
// Vue.prototype.$wsUrl = 'ws://192.168.13.9:8528/im' // 开发环境
|
|
Vue.prototype.$wsUrl = 'wss://www.sanduolantoyoga.com/yoga-imserver' // 生产环境
|
|
// #endif
|
|
|
|
// #ifdef APP-PLUS
|
|
// Vue.prototype.$wsUrl = 'ws://192.168.13.9:8528/im' // 开发环境
|
|
Vue.prototype.$wsUrl = 'wss://www.sanduolantoyoga.com/yoga-imserver' // 生产环境
|
|
// #endif
|
|
|
|
// 请求开始之前做一些事情
|
|
$http.beforeRequest = function (options) {
|
|
|
|
var iftoken = uni.getStorageSync("iftoken");
|
|
if(iftoken){
|
|
// 去掉身份认证
|
|
options.header = {
|
|
isToken: false
|
|
}
|
|
uni.setStorageSync('iftoken', "");
|
|
}
|
|
else{
|
|
var token = uni.getStorageSync("token");
|
|
// 判断请求是否为有权限的 API 接口
|
|
if(token) {
|
|
// 为请求头添加身份认证
|
|
options.header = {
|
|
Authorization: token
|
|
}
|
|
}
|
|
uni.setStorageSync('iftoken', "");
|
|
}
|
|
|
|
};
|
|
|
|
// 请求完成之后做一些事情
|
|
$http.afterRequest = function (response) {
|
|
|
|
uni.hideLoading();
|
|
// 拦截未登录,跳转到登录
|
|
if (response.data.status == 10105) {
|
|
uni.showToast({
|
|
title: '登录已失效!请您重新登录!',
|
|
duration: 2000,
|
|
icon: "none"
|
|
});
|
|
setTimeout(function() {
|
|
uni.redirectTo({
|
|
url: '/pages/login/login'
|
|
});
|
|
}, 2000);
|
|
|
|
}
|
|
//
|
|
else if (response.data.status == 10106) {
|
|
uni.showToast({
|
|
title: '登录已失效!请您重新登录!',
|
|
duration: 2000,
|
|
icon: "none"
|
|
});
|
|
setTimeout(function() {
|
|
uni.redirectTo({
|
|
url: '/pages/login/login'
|
|
});
|
|
}, 2000);
|
|
}
|
|
else {
|
|
return
|
|
}
|
|
}
|
|
|
|
Vue.config.productionTip = false;
|
|
Vue.prototype.isConnected = false; // ws是否已经连接;
|
|
Vue.prototype.heartbeatInterval = null; // 心跳;
|
|
Vue.prototype.heartbeatTimeout =20000; // ws20秒执行一次
|
|
Vue.prototype.$enums = enums
|
|
Vue.prototype.$date = date
|
|
Vue.prototype.$msgType = messageType
|
|
Vue.prototype.$emo = emotion
|
|
Vue.prototype.$url = url
|
|
App.mpType = "app";
|
|
|
|
// 引入全局uView
|
|
import uView from "uview-ui";
|
|
Vue.use(uView);
|
|
|
|
const app = new Vue({
|
|
store,
|
|
...App
|
|
})
|
|
|
|
app.$mount();
|
|
|
|
|