import Vue from 'vue';
import App from './App';

import wxContact from './components/wxcontact/wxcontact.vue';

import uView from '@/uni_modules/uview-ui'
Vue.use(uView)


Vue.config.productionTip = false;

Vue.component('wxContact', wxContact);

App.mpType = 'app';

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

// request 接口设置
import {
	req
} from '@/common/request/request.js';
// let baseUrl = 'http://bd.odd_job.com/';
let baseUrl = 'https://linggong.jinjianghc.com/';
// let baseUrl = 'https://linggong.jiangzi.xin/';
req.baseuUrl = baseUrl + 'mainapp.php/';

req.defaultReq.type = "GET";
req.defaultReq.baseData = { //设置公共参数，默认为空，设置此参数后每次发送请求都会带上此参数
	access_token: uni.getStorageSync('access_token') || ""
}
req.defaultReq.beforeFinsh = (res) => {
	// console.log("res: " + JSON.stringify(res)); 
	if (res.data.code == 0) {
		return res.data.data;
	} else {
		return Promise.reject(res.data.msg);
	}

}
Vue.prototype.$req = req; //挂载到原型上

// 判断登录
Vue.prototype.checkLogin = function(backpage) {
	const userinfo = uni.getStorageSync('userinfo') || null;
	if (userinfo == null) {
		uni.navigateTo({
			url: "/pages/login/login?backpage=" + encodeURIComponent(backpage)
		});
		return false;
	}
	return userinfo;
}

Vue.prototype.$getImageUrl = function(url) {
	return baseUrl + url;
}