import Vue from 'vue'
import App from './App'
import store from './store/logion.js'	

// 定义全局提示title
const baseURL = 'http://192.168.1.12:8082';  
const msg = (title, duration=1500, mask=false, icon='none')=>{
	//统一提示方便全局修改
	if(Boolean(title) === false){
		return;
	}
	uni.showToast({
		title,
		duration,
		mask,
		icon
	});
}


const request = function(options) {
     options.url = baseUrl + options.url;
	 option.method =  options.method;
       const token = uni.getStorageSync('sessionId');
       if (sessionId) { // 如果存在sessionId 配置请求头
         options.header = {
           'Authorization' : sessionId,
		   'Content-Type' : 'application/json'
         }
        }else{	// 不存在token 跳转至登录
            
           
        }
      
		// 这里对response进行处理，
		options.complete = (response) => {
			if (response.statusCode == 401) {
				
			}
		}
		return uni.request(options);
	  }

// const request = (url, urlhead, sessIoid) => {
// 	uni.request({
// 		url: baseURL+url,
// 		method: urlhead,
// 		header = {
// 		  'Authorization' : 'Bearer ' + sessIoid,
// 		  'Content-Type' : 'application/json'
// 		},
		
// 	})
// }
Vue.prototype.$msg = msg
Vue.prototype.request = request
Vue.config.productionTip = false
Vue.prototype.$store = store
App.mpType = 'app'



const app = new Vue({
    ...App
})
app.$mount()
