Authored by ccbikai

完善组件

'use strict';
const api = global.yoho.ServiceAPI;
const contentCode = require('../../../config/content-code');
const resourcesProcess = require('../../../utils/resources-process');
let channel = {
getResourcesData(params) {
let code;
if (params.channel) {
code = contentCode.channel[params.channel];
} else if (params.contentCode) {
code = params.contentCode;
} else {
code = contentCode.channel.men;
if (!params.contentCode) {
return Promise.reject([]);
}
return api.get('operations/api/v5/resource/get', {
content_code: code
content_code: params.contentCode
}, {
cache: true,
code: 200
... ...
... ... @@ -13,9 +13,6 @@ const channel = require(cRoot + '/channel');
const router = expressRouter();
router.get('/', channel.index); // 首页
router.get('/men', channel.index); // 首页
router.get('/women', channel.index); // 首页
router.get('/lifestyle', channel.index); // 首页
router.get('/resources', channel.resources); // 资源位接口
module.exports = router;
... ...
<div id="app">
<tab></tab>
<resources v-bind:channel="'{{channel}}' || 'men'"></resources>
<resources></resources>
</div>
... ...
/**
* 前端资源位配置文件
*/
'use strict';
const channel = {
men: '9ee58aadd9559d07207fe4a98843eaac',
women: 'aa8d34c85934c2ccc16e2babd3eb5e47',
lifestyle: '3ad8826fc89fb0d023a4cd06a6991219'
};
module.exports = {
channel
};
... ...
... ... @@ -27,6 +27,7 @@
const $ = require('yoho-jquery');
const tip = require('common/tip');
const bus = require('common/vue-bus');
const contentCode = require('content-code');
const focus = require('component/resources/focus.vue');
const focusLeftRight = require('component/resources/focus-left-right.vue');
... ... @@ -38,7 +39,7 @@
const dataCache = {};
module.exports = {
props: ['channel', 'contentCode'],
props: ['contentCode'],
data() {
return {
resources: []
... ... @@ -53,9 +54,6 @@
goods
},
watch: {
channel() {
this.getResourcesData();
},
contentCode() {
this.getResourcesData();
}
... ... @@ -67,7 +65,7 @@
if (this.contentCode) {
data.contentCode = this.contentCode;
} else {
data.channel = this.channel;
data.contentCode = contentCode.channel.men;
}
let param = $.param(data);
... ... @@ -77,7 +75,7 @@
return;
}
$.ajax({
return $.ajax({
url: '/resources',
data: data
}).then(result => {
... ... @@ -94,7 +92,7 @@
created() {
this.getResourcesData();
bus.$on('changeChannel', channel => {
this.channel = channel;
this.contentCode = contentCode.channel[channel];
});
}
};
... ...
... ... @@ -10,9 +10,14 @@
const bus = require('common/vue-bus');
module.exports = {
props: {
current: {
type: Number,
default: 0
},
},
data() {
return {
current: 0,
channel: [{
name: 'MEN男士',
channel: 'men'
... ...