默认提交
Showing
3 changed files
with
49 additions
and
9 deletions
| ... | @@ -52,7 +52,8 @@ function Toast(msg) { | ... | @@ -52,7 +52,8 @@ function Toast(msg) { |
| 52 | // console.log(process.env); | 52 | // console.log(process.env); |
| 53 | let base = ""; | 53 | let base = ""; |
| 54 | const axios = axiosIns.create({ | 54 | const axios = axiosIns.create({ |
| 55 | baseURL: process.env.VUE_APP_BASE_URL, | 55 | // baseURL: process.env.VUE_APP_BASE_URL, |
| 56 | baseURL: "https://ow.go.qudone.com", | ||
| 56 | timeout: 5000 | 57 | timeout: 5000 |
| 57 | }) | 58 | }) |
| 58 | 59 | ... | ... |
| ... | @@ -4,6 +4,11 @@ import App from './App.vue'; | ... | @@ -4,6 +4,11 @@ import App from './App.vue'; |
| 4 | import router from './router'; | 4 | import router from './router'; |
| 5 | import store from './store/index'; | 5 | import store from './store/index'; |
| 6 | 6 | ||
| 7 | import { | ||
| 8 | httpGet, | ||
| 9 | httpPost | ||
| 10 | } from '@/api/fetch-api.js'; | ||
| 11 | |||
| 7 | import VueAwesomeSwiper from 'vue-awesome-swiper' | 12 | import VueAwesomeSwiper from 'vue-awesome-swiper' |
| 8 | import 'swiper/dist/css/swiper.css' | 13 | import 'swiper/dist/css/swiper.css' |
| 9 | Vue.use(VueAwesomeSwiper) | 14 | Vue.use(VueAwesomeSwiper) |
| ... | @@ -36,7 +41,6 @@ Vue.config.productionTip = false | ... | @@ -36,7 +41,6 @@ Vue.config.productionTip = false |
| 36 | Vue.use(VueI18n) | 41 | Vue.use(VueI18n) |
| 37 | const i18n = new VueI18n({ | 42 | const i18n = new VueI18n({ |
| 38 | locale: localStorage.getItem("lang") || 'tc', // 语言标识 | 43 | locale: localStorage.getItem("lang") || 'tc', // 语言标识 |
| 39 | //this.$i18n.locale // 通过切换locale的值来实现语言切换 | ||
| 40 | messages: { | 44 | messages: { |
| 41 | 'tc': require('@/common/lang/tc'), // 繁体语言包 | 45 | 'tc': require('@/common/lang/tc'), // 繁体语言包 |
| 42 | 'zh': require('@/common/lang/zh'), // 简体语言包 | 46 | 'zh': require('@/common/lang/zh'), // 简体语言包 |
| ... | @@ -44,9 +48,7 @@ const i18n = new VueI18n({ | ... | @@ -44,9 +48,7 @@ const i18n = new VueI18n({ |
| 44 | } | 48 | } |
| 45 | }) | 49 | }) |
| 46 | 50 | ||
| 47 | 51 | let vueInstance = new Vue({ | |
| 48 | |||
| 49 | new Vue({ | ||
| 50 | i18n, | 52 | i18n, |
| 51 | router, | 53 | router, |
| 52 | store, | 54 | store, |
| ... | @@ -55,6 +57,33 @@ new Vue({ | ... | @@ -55,6 +57,33 @@ new Vue({ |
| 55 | document.dispatchEvent(new Event('render-event')); | 57 | document.dispatchEvent(new Event('render-event')); |
| 56 | }, | 58 | }, |
| 57 | data: { | 59 | data: { |
| 58 | eventBus: new Vue() | 60 | eventBus: new Vue(), |
| 61 | queryConfigData: null, // 1.放内存 | ||
| 62 | // queryConfigData: localStorage.getItem("queryConfig") || null, // 2.放localStorage | ||
| 59 | } | 63 | } |
| 60 | }).$mount('#app') | 64 | }).$mount('#app'); |
| 65 | // window.vueInstance = vueInstance; // 实在不满足需要,可以把vue实例挂载到windows上 | ||
| 66 | |||
| 67 | /** | ||
| 68 | * 初始化请求配置 | ||
| 69 | * 根据需要看放内存还是放localStorage | ||
| 70 | * | ||
| 71 | * 具体方法访问方法见 首页index.js mounted方法 | ||
| 72 | * 具体方法访问方法见 首页index.js mounted方法 | ||
| 73 | * 具体方法访问方法见 首页index.js mounted方法 | ||
| 74 | */ | ||
| 75 | function initQueryConfig() { | ||
| 76 | |||
| 77 | /** | ||
| 78 | * 请求配置 httpGet/httpPost已引入 | ||
| 79 | * 这里先setTimeout 模拟 | ||
| 80 | */ | ||
| 81 | setTimeout(() => { | ||
| 82 | let configResult = { | ||
| 83 | a:123 | ||
| 84 | } | ||
| 85 | vueInstance.queryConfigData = configResult; // 放内存 | ||
| 86 | // localStorage.setItem("queryConfig",JSON.stringify(configResult)); // 放localStorage | ||
| 87 | }, 1000); | ||
| 88 | } | ||
| 89 | initQueryConfig(); | ... | ... |
| ... | @@ -159,14 +159,18 @@ export default { | ... | @@ -159,14 +159,18 @@ export default { |
| 159 | }, | 159 | }, |
| 160 | fetchBanner() { | 160 | fetchBanner() { |
| 161 | return new Promise((resolve, reject) => { | 161 | return new Promise((resolve, reject) => { |
| 162 | httpPost({ url: api.banner }).then(res => { | 162 | httpPost({ |
| 163 | url: api.banner | ||
| 164 | }).then(res => { | ||
| 163 | resolve(res); | 165 | resolve(res); |
| 164 | }); | 166 | }); |
| 165 | }); | 167 | }); |
| 166 | }, | 168 | }, |
| 167 | fetchIndexVideo() { | 169 | fetchIndexVideo() { |
| 168 | return new Promise((resolve, reject) => { | 170 | return new Promise((resolve, reject) => { |
| 169 | httpPost({ url: api.indexVideo }).then(res => { | 171 | httpPost({ |
| 172 | url: api.indexVideo | ||
| 173 | }).then(res => { | ||
| 170 | sessionStorage.setItem("_video_url", res.videoUrl); | 174 | sessionStorage.setItem("_video_url", res.videoUrl); |
| 171 | sessionStorage.setItem("_poster_url", res.posterUrl); | 175 | sessionStorage.setItem("_poster_url", res.posterUrl); |
| 172 | resolve(res); | 176 | resolve(res); |
| ... | @@ -214,6 +218,12 @@ export default { | ... | @@ -214,6 +218,12 @@ export default { |
| 214 | }, | 218 | }, |
| 215 | mounted() { | 219 | mounted() { |
| 216 | this.initData(); | 220 | this.initData(); |
| 221 | |||
| 222 | setTimeout(() => { | ||
| 223 | console.log("queryConfigData:", this.$root.queryConfigData); | ||
| 224 | // console.log("queryConfigData:", window.vueInstance.queryConfigData); // 挂载到windows的访问方法 | ||
| 225 | // 放localStorage直接是localStorage.getItem("queryConfig"); | ||
| 226 | }, 3000) | ||
| 217 | }, | 227 | }, |
| 218 | 228 | ||
| 219 | created() { | 229 | created() { | ... | ... |
-
Please register or sign in to post a comment