Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
dev
/
pingan-life-index-pro
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d6694631
authored
2020-01-03 14:39:18 +0800
by
simon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
默认提交
1 parent
00614d72
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
9 deletions
src/api/fetch-api.js
src/main.js
src/pages/index/index.js
src/api/fetch-api.js
View file @
d669463
...
...
@@ -52,7 +52,8 @@ function Toast(msg) {
// console.log(process.env);
let
base
=
""
;
const
axios
=
axiosIns
.
create
({
baseURL
:
process
.
env
.
VUE_APP_BASE_URL
,
// baseURL: process.env.VUE_APP_BASE_URL,
baseURL
:
"https://ow.go.qudone.com"
,
timeout
:
5000
})
...
...
src/main.js
View file @
d669463
...
...
@@ -4,6 +4,11 @@ import App from './App.vue';
import
router
from
'./router'
;
import
store
from
'./store/index'
;
import
{
httpGet
,
httpPost
}
from
'@/api/fetch-api.js'
;
import
VueAwesomeSwiper
from
'vue-awesome-swiper'
import
'swiper/dist/css/swiper.css'
Vue
.
use
(
VueAwesomeSwiper
)
...
...
@@ -36,7 +41,6 @@ Vue.config.productionTip = false
Vue
.
use
(
VueI18n
)
const
i18n
=
new
VueI18n
({
locale
:
localStorage
.
getItem
(
"lang"
)
||
'tc'
,
// 语言标识
//this.$i18n.locale // 通过切换locale的值来实现语言切换
messages
:
{
'tc'
:
require
(
'@/common/lang/tc'
),
// 繁体语言包
'zh'
:
require
(
'@/common/lang/zh'
),
// 简体语言包
...
...
@@ -44,9 +48,7 @@ const i18n = new VueI18n({
}
})
new
Vue
({
let
vueInstance
=
new
Vue
({
i18n
,
router
,
store
,
...
...
@@ -55,6 +57,33 @@ new Vue({
document
.
dispatchEvent
(
new
Event
(
'render-event'
));
},
data
:
{
eventBus
:
new
Vue
()
eventBus
:
new
Vue
(),
queryConfigData
:
null
,
// 1.放内存
// queryConfigData: localStorage.getItem("queryConfig") || null, // 2.放localStorage
}
}).
$mount
(
'#app'
);
// window.vueInstance = vueInstance; // 实在不满足需要,可以把vue实例挂载到windows上
/**
* 初始化请求配置
* 根据需要看放内存还是放localStorage
*
* 具体方法访问方法见 首页index.js mounted方法
* 具体方法访问方法见 首页index.js mounted方法
* 具体方法访问方法见 首页index.js mounted方法
*/
function
initQueryConfig
()
{
/**
* 请求配置 httpGet/httpPost已引入
* 这里先setTimeout 模拟
*/
setTimeout
(()
=>
{
let
configResult
=
{
a
:
123
}
}).
$mount
(
'#app'
)
vueInstance
.
queryConfigData
=
configResult
;
// 放内存
// localStorage.setItem("queryConfig",JSON.stringify(configResult)); // 放localStorage
},
1000
);
}
initQueryConfig
();
...
...
src/pages/index/index.js
View file @
d669463
...
...
@@ -159,14 +159,18 @@ export default {
},
fetchBanner
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
httpPost
({
url
:
api
.
banner
}).
then
(
res
=>
{
httpPost
({
url
:
api
.
banner
}).
then
(
res
=>
{
resolve
(
res
);
});
});
},
fetchIndexVideo
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
httpPost
({
url
:
api
.
indexVideo
}).
then
(
res
=>
{
httpPost
({
url
:
api
.
indexVideo
}).
then
(
res
=>
{
sessionStorage
.
setItem
(
"_video_url"
,
res
.
videoUrl
);
sessionStorage
.
setItem
(
"_poster_url"
,
res
.
posterUrl
);
resolve
(
res
);
...
...
@@ -214,6 +218,12 @@ export default {
},
mounted
()
{
this
.
initData
();
setTimeout
(()
=>
{
console
.
log
(
"queryConfigData:"
,
this
.
$root
.
queryConfigData
);
// console.log("queryConfigData:", window.vueInstance.queryConfigData); // 挂载到windows的访问方法
// 放localStorage直接是localStorage.getItem("queryConfig");
},
3000
)
},
created
()
{
...
...
Please
register
or
sign in
to post a comment