import * as apiConfig from './apiconfig'
import { apiVerify } from './apiVerify'
import MFetch from "./MFetch"
import store from '@/store'
import { Toast } from 'vant'
import MConfirm from '../components/m-components/m-confirm'
import Router from "../router/index"
let notifyErrMsg = msg => {
	// Toast(msg)
	if(msg==="会话过期，请重新登录！"){
		MConfirm({
			content: msg,
			confirm: () => {
				Router.push({ name: "login",query:{source:'back'} });
			}
		})
	}else{
		Toast(msg)
	}
	
}
let clearAccountInfo = () => {
	store.commit("clearAccountInfo")
	store.commit("clearSearchHistory")
	// store.commit("clearRewardRule")
}

const mFetch = new MFetch(apiConfig, apiVerify, notifyErrMsg, clearAccountInfo)
export default mFetch