123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- 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.code == 1) { // 服务端返回的状态码不等于200,则reject()
- uni.showToast({
- icon:'none',
- mask:false,
- title:`${response.data.msg}`,
- duration: 2000
- });
- return Promise.reject(response)
- };
- // console.log('response',response);
- if(response.data.code == 401){
- uni.showToast({
- title:response.data.message + " 即将跳转到登录页",
- icon:"none",
- duration:2000
- });
- uni.setStorage({
- key: "hasLogin",
- data: false
- });
- 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;
- const goback = () =>{
- // let menuButtonInfo = uni.getMenuButtonBoundingClientRect();//胶囊按钮信息
- let pages = getCurrentPages();
- let prevPage = pages[pages.length - 2]; //上一个页面
- // console.log('pages',pages);
- // console.log('prevPage',prevPage.route);
- // console.log('pages[0].route',pages[0].route);
- if(prevPage.route == 'pages/use/useRouter'){
- // if(pages.length == '2'){
- uni.switchTab({
- url:'/pages/index/index',
- fail: (err) => {
- console.log('switchTab',err)
- }
- })
- return;
- };
- uni.navigateBack({})
- };
- Vue.prototype.$api = {msg,http,href,goback};
- Vue.prototype.$getimg = config.imgUrl;
- // Vue.prototype.$getInnerImg = config.innerImgUrl;
- Vue.prototype.$onlineImg = config.onlineImg;
- Vue.prototype.$placeImg = config.placeImg;
- // Vue.prototype.$qnyImg = config.qnyImg;
- Vue.prototype.$store = store;
- Vue.prototype.config = config;
- App.mpType = 'app'
- const app = new Vue({
- ...App
- })
- app.$mount()
|