|
@@ -19,7 +19,6 @@
|
|
|
import EventBus from '@/utils/eventBus.js';
|
|
|
import QR from '../plugins/qr';
|
|
|
import {fetch} from '@/api/page.js'
|
|
|
-import {mapActions} from 'vuex'
|
|
|
|
|
|
export default {
|
|
|
data(){
|
|
@@ -51,14 +50,15 @@ export default {
|
|
|
EventBus.$emit('loading', val);
|
|
|
},
|
|
|
$route(){
|
|
|
+ this.getPageInfo();
|
|
|
}
|
|
|
},
|
|
|
created(){
|
|
|
- let {id } = this.$route.params;
|
|
|
- if(id=="main") id = '679773f089e7bbf1b50a43e2c83645be';
|
|
|
- this.uuid = id
|
|
|
- console.log("uuid", id)
|
|
|
- this.init()
|
|
|
+ if(!this.loaded) {
|
|
|
+ this.init();
|
|
|
+ } else {
|
|
|
+ this.getPageInfo();
|
|
|
+ }
|
|
|
},
|
|
|
mounted(){
|
|
|
if(!this.isMobile) {
|
|
@@ -68,19 +68,29 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapActions('pages', ['setPage']),
|
|
|
+ getPageInfo() {
|
|
|
+ const { data } = this.$store.state.pages;
|
|
|
+ console.log("getinfo", data)
|
|
|
+ const { pages, main } = data;
|
|
|
+ const { id = 'main'} = this.$route.params;
|
|
|
+ let page = pages[id]||{};
|
|
|
+ this.isMain = (id == 'main');
|
|
|
+ this.page = { ...main, ...page };
|
|
|
+ const { title } = this.page;
|
|
|
+ title && (document.title = title);
|
|
|
+ },
|
|
|
init(){
|
|
|
- let uuid = this.uuid;
|
|
|
+ let {uuid} = this.$route.params;
|
|
|
+ console.log("loadData", uuid);
|
|
|
if(this.loading) return;
|
|
|
this.loading = true;
|
|
|
fetch("paper.getpaper", {uuid}).then((res) => {
|
|
|
this.loading = false;
|
|
|
- this.isMain = true
|
|
|
- console.log( res, res)
|
|
|
- this.page = res;
|
|
|
- this.setPage(this.page);
|
|
|
+ this.$store.dispatch('setPage', res);
|
|
|
res.title && (document.title = res.title);
|
|
|
- }).catch(() => {
|
|
|
+ this.getPageInfo()
|
|
|
+ }).catch((err) => {
|
|
|
+ console.log("err", err)
|
|
|
this.loading = false;
|
|
|
this.error = true;
|
|
|
})
|