| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import stringify from '@/utils/querystring'
- import { isWeixin } from '@/utils/util'
- import router from './router'
- import cookie from './cookie'
- import { useMainStore } from '@/store/store'
- export const handleLoginFailure = () => {
- uni.removeStorageSync('userinfo');
- uni.removeStorageSync('accessToken');
- const main = useMainStore()
- main.SET_MEMBER({});
- main.SET_TOKEN('');
- // #ifdef H5
- if(isWeixin()){
- uni.switchTab({
- url: '/pages/index/index'
- })
-
- return
- }
- // #endif
- uni.redirectTo({
- url: '/pages/components/pages/login/login',
- })
- }
- export function parseUrl(location) {
- if (typeof location === 'string') return location
- const { url, query } = location
- const queryStr = stringify(query)
- if (!queryStr) {
- return url
- }
- return `${url}?${queryStr}`
- }
- const toAuth = () => {
- uni.showToast({
- title: '暂未开放',
- icon: 'none',
- duration: 2000,
- })
- }
- export default {
- install: (app, options) => {
- // 在这里编写插件代码
- // 注入一个全局可用的 $translate() 方法
- app.config.globalProperties.$yrouter = router
- app.config.globalProperties.$cookie = cookie
- app.config.globalProperties.$toAuth = toAuth
- app.config.globalProperties.$onClickLeft = () => {
- router.back()
- //uni.navigateBack()
- //const mypage = getCurrentPages()
- //console.log('mypage:',mypage)
- }
- // #ifdef H5
- app.config.globalProperties.$platform = 'h5'
- // #endif
- // #ifdef APP-PLUS
- // app端
- app.config.globalProperties.$platform = 'app'
- // #endif
- // #ifdef MP-WEIXIN
- app.config.globalProperties.$platform = 'routine'
- // #endif
- },
- }
|