import Vue from 'vue'
import App from './App'
import { config } from './config/config'
import store from './store' 

import Request from '@/js_sdk/luch-request/luch-request/index.js';
const http = new Request();
http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/
  //  if (response.data.retHead.errCode !== 200) { // 服务端返回的状态码不等于200，则reject()
	 //   uni.showToast({
		// icon:'none',
		// mask:false,
		// title:`${response.data.message}`,
		// duration: 2000
	 //   });
	 // };
	 // console.log('response',response);
	 // if(response.data.code == 401){
		// uni.showToast({
		//  	title:response.data.message + "    即将跳转到登录页",
		//  	icon:"none",
		//  	duration:2000
		// });
		// setTimeout(i=>{
		// 	uni.navigateTo({
		// 		url: '/pages/login/loginType',
		// 		fail:function(err){
		// 			console.log(err)
		// 		}
		// 	});
		// },2000);
		// return Promise.reject(response) 
		
	 // };
     // return Promise.reject(response) // return Promise.reject 可使promise状态进入catch
 if (response.config.custom.verification) { // 演示自定义参数的作用
    return response.data
  }
  // console.log(response)
  return response
}, (response) => { /*  对响应错误做点什么 （statusCode !== 200）*/
  console.log(response);
  return Promise.reject(response)
});

import './utils/filter' 

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

// import $wxApi from "./wxapi.js";
// Vue.prototype.$wxApi = $wxApi;

// //微信支付封装
// import $pay from "./pay.js";
// Vue.prototype.$pay = $pay

const href = (data,type = 1) =>{
	uni.navigateTo({
		url:data,
		fail:function(err){
			console.log('navigateTo fail',err)
		}
	})
};

Vue.config.productionTip = false;

Vue.prototype.$api = {msg,http,href};
Vue.prototype.$getimg = config.imgUrl;
Vue.prototype.$getInnerImg = config.innerImgUrl;
Vue.prototype.$onlineImg = config.onlineImg;
Vue.prototype.$placeImg = config.placeImg;
Vue.prototype.$store = store;
Vue.prototype.config = config;

App.mpType = 'app'

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