Authored by ccbikai

优化资源位

... ... @@ -5,7 +5,7 @@ const resourcesProcess = require('../../../utils/resources-process');
let channel = {
getResourcesData(params) {
if (!params.contentCode) {
return Promise.reject([]);
return Promise.resolve([]);
}
return api.get('operations/api/v5/resource/get', {
content_code: params.contentCode
... ...
<div id="app">
<tab></tab>
<resources></resources>
<div id="channel">
<tab v-bind:page="page"></tab>
<resources v-bind:content-code.sync="contentCode"></resources>
</div>
... ...
const Vue = require('yoho-vue');
const lazyload = require('yoho-vue-lazyload');
const qs = require('yoho-qs');
const contentCode = require('content-code');
const tab = require('channel/tab.vue');
const resources = require('channel/resources.vue');
require('common/vue-filter');
Vue.use(lazyload, {
try: 2
});
Vue.use(lazyload);
new Vue({
el: '#app',
el: '#channel',
data() {
return {
page: 'channel',
contentCode: contentCode.channel[qs.channel || 'men']
};
},
components: {
tab: tab,
resources: resources
... ...
... ... @@ -39,7 +39,12 @@
const dataCache = {};
module.exports = {
props: ['contentCode'],
props: {
contentCode: {
type: String,
default: contentCode.channel.men
}
},
data() {
return {
resources: []
... ... @@ -64,8 +69,6 @@
if (this.contentCode) {
data.contentCode = this.contentCode;
} else {
data.contentCode = contentCode.channel.men;
}
let param = $.param(data);
... ... @@ -91,8 +94,8 @@
},
created() {
this.getResourcesData();
bus.$on('changeChannel', channel => {
this.contentCode = contentCode.channel[channel];
bus.$on('changeChannel', (page, channel) => {
this.contentCode = contentCode[page][channel];
});
}
};
... ...
... ... @@ -15,6 +15,10 @@
type: Number,
default: 0
},
page: {
type: String,
default: 'channel'
},
},
data() {
return {
... ... @@ -33,7 +37,7 @@
methods: {
changeChannel(index) {
this.current = index;
bus.$emit('changeChannel', this.channel[index].channel);
bus.$emit('changeChannel', this.page, this.channel[index].channel);
}
}
};
... ...