Authored by 郭成尧

dispatch-bus

1 const Vue = require('vue'); 1 const Vue = require('vue');
2 const Logistics = require('home/refund/logistics.vue'); 2 const Logistics = require('home/refund/logistics.vue');
3 const LogisticsCompany = require('home/refund/logistics-company.vue'); 3 const LogisticsCompany = require('home/refund/logistics-company.vue');
  4 +const bus = require('plugin/vue-bus');
4 5
5 new Vue({ 6 new Vue({
6 el: '#logistics', 7 el: '#logistics',
@@ -13,11 +14,11 @@ new Vue({ @@ -13,11 +14,11 @@ new Vue({
13 logistics: Logistics, 14 logistics: Logistics,
14 logisticsCompany: LogisticsCompany 15 logisticsCompany: LogisticsCompany
15 }, 16 },
16 - events: {  
17 - changeView: function(obj) { 17 + created() {
  18 + bus.$on('changeView', function(obj) {
18 this.currentView = obj.view; 19 this.currentView = obj.view;
19 this.company_id = obj.company_id; 20 this.company_id = obj.company_id;
20 this.company_name = obj.company_name; 21 this.company_name = obj.company_name;
21 - } 22 + });
22 } 23 }
23 }); 24 });
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 15
16 <script> 16 <script>
17 const indexList = require('components/tools/index-list.vue'); 17 const indexList = require('components/tools/index-list.vue');
  18 + const bus = require('plugin/vue-bus');
18 19
19 module.exports = { 20 module.exports = {
20 props: ['company_list'], 21 props: ['company_list'],
@@ -54,7 +55,7 @@ @@ -54,7 +55,7 @@
54 this.showData = filter; 55 this.showData = filter;
55 }, 56 },
56 select(companyId, companyName) { 57 select(companyId, companyName) {
57 - this.$dispatch('changeView', { 58 + bus.$emit('changeView', {
58 view: 'logistics', 59 view: 'logistics',
59 company_id: companyId, 60 company_id: companyId,
60 company_name: companyName 61 company_name: companyName
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 const $ = require('yoho-jquery'); 18 const $ = require('yoho-jquery');
19 const tip = require('plugin/tip'); 19 const tip = require('plugin/tip');
20 const modal = require('plugin/modal2'); 20 const modal = require('plugin/modal2');
  21 + const bus = require('plugin/vue-bus');
21 22
22 module.exports = { 23 module.exports = {
23 props: ['applyid', 'type', 'company_id', 'company_name'], 24 props: ['applyid', 'type', 'company_id', 'company_name'],
@@ -28,7 +29,7 @@ @@ -28,7 +29,7 @@
28 }, 29 },
29 methods: { 30 methods: {
30 companylist() { 31 companylist() {
31 - this.$dispatch('changeView', { // TAR-TODO 弃用的方法 32 + bus.$emit('changeView', {
32 view: 'logisticsCompany' 33 view: 'logisticsCompany'
33 }); 34 });
34 }, 35 },