73 lines
1.7 KiB
JavaScript
73 lines
1.7 KiB
JavaScript
import App from './App'
|
||
import navTo from './utils/navTo'
|
||
// #ifdef h5
|
||
import api from './api/api'
|
||
import cookie from './utils/cookie'
|
||
// #endif
|
||
import uviewPlus, { setConfig } from 'uview-plus'
|
||
// #ifndef VUE3
|
||
import Vue from 'vue'
|
||
import './uni.promisify.adaptor'
|
||
Vue.config.productionTip = false
|
||
App.mpType = 'app'
|
||
const app = new Vue({
|
||
...App
|
||
})
|
||
app.$mount()
|
||
// #endif
|
||
// #ifdef VUE3
|
||
import { createSSRApp } from 'vue'
|
||
export function createApp() {
|
||
const app = createSSRApp(App)
|
||
|
||
app.use(uviewPlus, async() => {
|
||
if(process.env.UNI_PLATFORM =="h5"){
|
||
|
||
let token = '';
|
||
if(window.location.href.indexOf('//casedata.igandan.com')>-1){
|
||
token = uni.getStorageSync('AUTH_TOKEN_CASEDATA');
|
||
}else{
|
||
token = uni.getStorageSync('DEV_AUTH_TOKEN_CASEDATA');
|
||
}
|
||
if(!token){
|
||
let video_token = cookie.readCookie('video_token');
|
||
alert(video_token)
|
||
const res = await api.h5Login({
|
||
token: video_token
|
||
});
|
||
let result = res.data;
|
||
if (window.location.href.indexOf('//casedata.igandan.com')>-1) {
|
||
uni.setStorageSync("AUTH_TOKEN_CASEDATA",result.token);
|
||
} else {
|
||
uni.setStorageSync("DEV_AUTH_TOKEN_CASEDATA",result.token);
|
||
};
|
||
uni.setStorageSync("userInfo",{
|
||
avatar:result.avatar,
|
||
user_id:result.user_id,
|
||
status:result.status,
|
||
user_name:result.user_name,
|
||
doctor_id:result.doctor_id,
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
|
||
return {
|
||
options: {
|
||
// 修改$u.config对象的属性
|
||
config: {
|
||
// 修改默认单位为rpx,相当于执行 uni.$u.config.unit = 'rpx'
|
||
unit: 'rpx'
|
||
}
|
||
}
|
||
}
|
||
})
|
||
|
||
//app.config.globalProperties.$navTo = navTo
|
||
return {
|
||
app
|
||
}
|
||
}
|
||
// #endif
|