Authored by ccbikai

add bus

@@ -9,10 +9,5 @@ new Vue({ @@ -9,10 +9,5 @@ new Vue({
9 components: { 9 components: {
10 tab: tab, 10 tab: tab,
11 resources: resources 11 resources: resources
12 - },  
13 - created() {  
14 - this.$on('changeChannel', channel => {  
15 - this.$refs.resources.channel = channel;  
16 - });  
17 } 12 }
18 }); 13 });
  1 +const Vue = require('yoho-vue');
  2 +
  3 +let vue = new Vue();
  4 +
  5 +module.exports = vue;
@@ -11,11 +11,10 @@ @@ -11,11 +11,10 @@
11 <script> 11 <script>
12 const $ = require('yoho-jquery'); 12 const $ = require('yoho-jquery');
13 const tip = require('common/tip'); 13 const tip = require('common/tip');
  14 + const bus = require('common/vue-bus');
14 const focus = require('component/resources/focus.vue'); 15 const focus = require('component/resources/focus.vue');
15 const titleImage = require('component/resources/title-image.vue'); 16 const titleImage = require('component/resources/title-image.vue');
16 const goods = require('component/resources/goods.vue'); 17 const goods = require('component/resources/goods.vue');
17 - const Loading = require('common/loading');  
18 - const loading = new Loading();  
19 18
20 module.exports = { 19 module.exports = {
21 props: ['channel', 'contentCode'], 20 props: ['channel', 'contentCode'],
@@ -47,13 +46,11 @@ @@ -47,13 +46,11 @@
47 data.channel = this.channel; 46 data.channel = this.channel;
48 } 47 }
49 48
50 - loading.show();  
51 $.ajax({ 49 $.ajax({
52 url: '/resources', 50 url: '/resources',
53 data: data 51 data: data
54 }).then(result => { 52 }).then(result => {
55 this.resources = result; 53 this.resources = result;
56 - loading.hide();  
57 }).fail(() => { 54 }).fail(() => {
58 tip('网络错误'); 55 tip('网络错误');
59 }); 56 });
@@ -61,6 +58,10 @@ @@ -61,6 +58,10 @@
61 }, 58 },
62 created() { 59 created() {
63 this.getResourcesData(); 60 this.getResourcesData();
  61 + bus.$on('changeChannel', channel => {
  62 + this.channel = channel;
  63 + this.getResourcesData();
  64 + });
64 } 65 }
65 }; 66 };
66 </script> 67 </script>
@@ -7,6 +7,8 @@ @@ -7,6 +7,8 @@
7 </template> 7 </template>
8 8
9 <script> 9 <script>
  10 + const bus = require('common/vue-bus');
  11 +
10 module.exports = { 12 module.exports = {
11 data() { 13 data() {
12 return { 14 return {
@@ -26,7 +28,7 @@ @@ -26,7 +28,7 @@
26 methods: { 28 methods: {
27 changeChannel(index) { 29 changeChannel(index) {
28 this.current = index; 30 this.current = index;
29 - this.$parent.$emit('changeChannel', this.channel[index].channel); 31 + bus.$emit('changeChannel', this.channel[index].channel);
30 } 32 }
31 } 33 }
32 }; 34 };