123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- import { webLogin, getUserInfo, getConfigInfo, getTemplateInfo } from '@/common/utils/util.js'
- // #ifdef H5
- // 解析地址栏参数
- function getQueryVariable(variable) {
- // 从?开始获取后面的所有数据
- var query = window.location.search.substring(1)
- // 从字符串&开始分隔成数组split
- var vars = query.split('&')
- // 遍历该数组
- for (var i = 0; i < vars.length; i++) {
- // 从等号部分分割成字符
- var pair = vars[i].split('=')
- // 如果第一个元素等于 传进来的参的话 就输出第二个元素
- if (pair[0] == variable) {
- return pair[1]
- }
- }
- return undefined
- }
- if (!getQueryVariable('code')) {
- uni.removeStorageSync(`APPID${getQueryVariable('appid')}_token`)
- webLogin(true)
- }
- // #endif
- import Vue from 'vue'
- import App from './App'
- import store from 'store'
- import uView from 'uview-ui'
- Vue.use(uView)
- Vue.config.productionTip = false
- import { setStorage, getStorage, removeStorage } from '@/common/utils/storage.js'
- // #ifdef H5
- if (getQueryVariable('x-token')) {
- setStorage('token', getQueryVariable('x-token') || '')
- }
- if (getQueryVariable('openId')) {
- setStorage('openId', getQueryVariable('openId') || '')
- }
- if (getQueryVariable('username')) {
- setStorage('name', getQueryVariable('username') || '')
- }
- if (getQueryVariable('userId')) {
- setStorage('userId', getQueryVariable('userId') || '')
- }
- if (getQueryVariable('mobile')) {
- setStorage('mobile', getQueryVariable('mobile') || '')
- }
- if (getQueryVariable('miniProgram')) {
- setStorage('miniProgram', getQueryVariable('miniProgram') || '')
- }
- if (getQueryVariable('appId')) {
- setStorage('appId', getQueryVariable('appId') || '')
- }
- if (getQueryVariable('miniOpenId')) {
- setStorage('miniOpenId', getQueryVariable('miniOpenId') || '')
- }
- if (getQueryVariable('sharerOpenId')) {
- setStorage('sharerOpenId', getQueryVariable('sharerOpenId') || '')
- }
- // #endif
- import { Base64 } from 'js-base64'
- Vue.prototype.$Base64 = Base64
- import {
- toast,
- successToast,
- showLoading,
- tipLoading,
- hideLoading,
- modal,
- tips,
- navPage,
- redPage,
- backPage,
- callPhone,
- copy,
- openLocation,
- getLocation,
- getAddress,
- getNowDate,
- getNowDatetime
- } from 'common/utils/common'
- import { navToPage } from 'common/utils/navPag'
- Vue.prototype.$navToPage = navToPage
- Vue.prototype.$H5Href = process.env.VUE_APP_HREF
- Vue.prototype.$toast = toast
- Vue.prototype.$successToast = successToast
- Vue.prototype.$showLoading = showLoading
- Vue.prototype.$tipLoading = tipLoading
- Vue.prototype.$hideLoading = hideLoading
- Vue.prototype.$modal = modal
- Vue.prototype.$tips = tips
- Vue.prototype.$navPage = navPage
- Vue.prototype.$redPage = redPage
- Vue.prototype.$backPage = backPage
- Vue.prototype.$callPhone = callPhone
- Vue.prototype.$copy = copy
- Vue.prototype.$openLocation = openLocation
- Vue.prototype.$getLocation = getLocation
- Vue.prototype.$getAddress = getAddress
- Vue.prototype.$getNowDate = getNowDate
- Vue.prototype.$getNowDatetime = getNowDatetime
- Vue.prototype.$setStorage = setStorage
- Vue.prototype.$getStorage = getStorage
- Vue.prototype.$removeStorage = removeStorage
- // 注入全局
- import pages from 'mixins'
- Vue.mixin(pages)
- App.mpType = 'app'
- import api from '@/common/http/'
- Vue.prototype.$api = api
- import * as filters from './filters/index.js' // global filters
- // register global utility filters
- Object.keys(filters).forEach(key => {
- Vue.filter(key, filters[key])
- })
- Vue.prototype.$onLaunched = new Promise((resolve, reject) => {
- Vue.prototype.$isResolve = resolve
- Vue.prototype.$isReject = reject
- })
- import custom from '@/components/custom.vue'
- import Loading from '@/components/Loading.vue'
- import zjPageLayout from '@/components/zj-container/zj-page-layout.vue'
- Vue.component('custom', custom)
- Vue.component('Loading', Loading)
- Vue.component('zjPageLayout', zjPageLayout)
- import floatButton from '@/components/floatButton.vue'
- Vue.component('floatButton', floatButton)
- Vue.prototype.$getUserInfo = getUserInfo
- Vue.prototype.$getConfigInfo = getConfigInfo
- Vue.prototype.$getTemplateInfo = getTemplateInfo
- // #ifdef H5
- import { router, RouterMount } from 'router'
- Vue.use(router)
- import Mylink from 'uni-simple-router/dist/link.vue'
- // 组件式导航
- Vue.component('my-link', Mylink)
- // #endif
- // 渲染图片文件
- Vue.prototype.$imageUrl = process.env.VUE_APP_BASE_URL + process.env.VUE_APP_BASE_API + '/common/img/get?key='
- import { translaBeforeRegistration } from './global-text-processor' // 导入插件
- Vue.prototype.$setLanguage = function (type) {
- window.localStorage.setItem('Vue_Translation_Of_Text_Type', type)
- setTimeout(() => {
- location.reload(true)
- }, 200)
- }
- translaBeforeRegistration(function () {
- const app = new Vue({
- ...App,
- store
- })
- //v1.3.5起 H5端 你应该去除原有的app.$mount();使用路由自带的渲染方式
- // #ifdef H5
- RouterMount(app, router, '#app')
- // #endif
- // #ifndef H5
- app.$mount() //为了兼容小程序及app端必须这样写才有效果
- // #endif
- })
|