Blame view

java110-doc/src/main/resources/static/js/doc-ui.js 3.4 KB
88e030b7   王彪总   init project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
  (function(vc) {
      var vm = new Vue({
          el: '#component',
          data: {
              docInfo:{
                  title:'',
                  description:'',
                  version:'',
                  company:''
             },
              menus: [],
              pages: [],
              curMenuName: '',
              content: {
                  title:'',
                  url:'',
                  httpMethod:'',
                  headers:[],
                  reqParam:[],
                  resParam:[],
                  reqBody:'',
                  resBody:''
              },
          },
          mounted: function() {
              this.getDocumentAndMenus();
          },
          methods: {
              getDocumentAndMenus: function(_catalog) {
                  let _that = this;
                  let _param = {
                          params: {
  
                          }
                      }
                      //发送get请求
                  Vue.http.get('/doc/api', _param)
                  //Vue.http.get('mock/api.json', _param)
                  .then(function(res) {
                      _that.docInfo = res.data.api;
                      _that.menus = res.data.mappings;
                      _that.switchMenu(_that.menus[0])
                  }, function(res) {
  
                  });
              },
              _activeMenu: function (_menuName) {
                 this.menus.forEach(item => {
                      item.active = false;
                      if (_menuName == item.name) {
                          item.active = true;
                      }
                  });
  
                  console.log(this.menus)
              },
               switchMenu: function(_menu){
                  this.pages = [];
                  this.curMenuName = _menu.name;
                  this._activeMenu(_menu.name);
                  this._listDocumentPages(_menu);
              },
  
              _gotoPage: function(_page){
                 let _that  = this;
                 let _param = {
                     params: {
                         name: this.curMenuName,
                         serviceCode:_page.serviceCode,
                         resource:_page.resource
                     }
                 };
  
                 //发送get请求
               Vue.http.get('/doc/api/pageContent', _param)
                  //Vue.http.get('mock/page.json', _param)
                .then(function(res) {
                         _that.content = res.data;
                     },
                     function (errInfo, error) {
                         console.log('请求失败处理');
                     }
                 );
              },
              _listDocumentPages: function (_menu) {
                  let _that  = this;
                  let _param = {
                      params: {
                          name: _menu.name,
                          resource:_menu.resource
                      }
                  };
  
                  //发送get请求
                 Vue.http.get('/doc/api/page', _param)
                   //Vue.http.get('mock/pages.json', _param)
                 .then(function(res) {
                          _that.pages = res.data;
                          if (_that.pages.length < 1) {
                              return;
                          }
                          _that._gotoPage(res.data[0]);
                      },
                      function (errInfo, error) {
                          console.log('请求失败处理');
                      }
                  );
              },
          },
  
      });
  
  })(window.vc)