Authored by weiqingting

提交

@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 * @type {Object} 3 * @type {Object}
4 */ 4 */
5 module.exports = { 5 module.exports = {
6 - url:'http://admin.yohobuy.com',//'http://admin.portal.yohobuy.com', 6 + url:'http://admin.portal.yohobuy.com',
7 sessionKeep:'/account/profile/display', 7 sessionKeep:'/account/profile/display',
8 timeout:30000 8 timeout:30000
9 }; 9 };
@@ -25,20 +25,21 @@ var errorMessage = { @@ -25,20 +25,21 @@ var errorMessage = {
25 util.setLogger(res.app.logger); 25 util.setLogger(res.app.logger);
26 var options = { 26 var options = {
27 url:oldService.login, 27 url:oldService.login,
28 - form:'["'+user+'","'+password+'",1]' 28 + form:{
  29 + account:user,
  30 + password:password,
  31 + website:WEBSITE
  32 + }
29 } 33 }
30 34
31 //调用登陆 35 //调用登陆
32 util.httpCall(options,function(err,ret){ 36 util.httpCall(options,function(err,ret){
33 - console.log("************************************");  
34 - console.log(ret);  
35 if(err) { 37 if(err) {
36 res.json(errorMessage); 38 res.json(errorMessage);
37 return; 39 return;
38 } else { 40 } else {
39 -  
40 //调用菜单 41 //调用菜单
41 - _callGetMenu(ret.data.pid,ret.data.role_id,function(err,data){ 42 + _callGetMenu(ret.data.pid,function(err,data){
42 if(err) { 43 if(err) {
43 res.json(errorMessage); 44 res.json(errorMessage);
44 } else { 45 } else {
@@ -65,18 +66,21 @@ var errorMessage = { @@ -65,18 +66,21 @@ var errorMessage = {
65 * @param {Number} pid 操作员ID 66 * @param {Number} pid 操作员ID
66 * @param {Function} callback 回调 67 * @param {Function} callback 回调
67 */ 68 */
68 -function _callGetMenu(pid,roleid,callback) { 69 +function _callGetMenu(pid,callback) {
69 var options = { 70 var options = {
70 url:oldService.getResourceByPid, 71 url:oldService.getResourceByPid,
71 - form:'['+pid+','+roleid+',1]' 72 + form:{
  73 + pid:pid,
  74 + website:WEBSITE
72 } 75 }
73 -console.log(options); 76 + }
  77 +
74 util.httpCall(options,function(err,ret){ 78 util.httpCall(options,function(err,ret){
75 if(err) { 79 if(err) {
76 callback(err); 80 callback(err);
77 } else { 81 } else {
78 var menuData = {menu:[],right:{}}; 82 var menuData = {menu:[],right:{}};
79 - if(ret.data) { 83 + if(ret.data && ret.data.length>0) {
80 menuData = _makeMenu(ret.data); 84 menuData = _makeMenu(ret.data);
81 } 85 }
82 _getAllMenu(function(ret){ 86 _getAllMenu(function(ret){
@@ -99,9 +103,9 @@ function filterRight(ret,menuData) { @@ -99,9 +103,9 @@ function filterRight(ret,menuData) {
99 var noRight = {}; 103 var noRight = {};
100 //匹配没有权限 104 //匹配没有权限
101 _.forEach(ret,function(v,k){ 105 _.forEach(ret,function(v,k){
102 - if(v.menu_url!=='') {  
103 - if(!menuData.right[v.menu_url]) {  
104 - noRight[v.menu_url] = true; 106 + if(v.module_url!=='') {
  107 + if(!menuData.right[v.module_url]) {
  108 + noRight[v.module_url] = true;
105 } 109 }
106 } 110 }
107 }); 111 });
@@ -136,51 +140,27 @@ function _getAllMenu (callback) { @@ -136,51 +140,27 @@ function _getAllMenu (callback) {
136 function _makeMenu (data) { 140 function _makeMenu (data) {
137 var menu = []; 141 var menu = [];
138 var right = {}; 142 var right = {};
139 - for(var key in data){  
140 -  
141 - var v=data[key]; 143 + _.forEach(data,function(v){
142 var item = { 144 var item = {
143 - title:v.menu_name, 145 + title:v.resource_name,
144 } 146 }
145 if(v.parent_id === "0") { 147 if(v.parent_id === "0") {
146 item.parent = 'menu-template'; 148 item.parent = 'menu-template';
147 var itemSubs = []; 149 var itemSubs = [];
148 _.forEach(v.sub,function(val) { 150 _.forEach(v.sub,function(val) {
149 var sub = { 151 var sub = {
150 - title:val.menu_name,  
151 - href:val.menu_url, 152 + title:val.resource_name,
  153 + href:val.module_url,
152 icon: 'list-alt' 154 icon: 'list-alt'
153 } 155 }
154 - right[val.menu_url] = true; 156 + right[val.module_url] = true;
155 itemSubs.push(sub); 157 itemSubs.push(sub);
156 }); 158 });
157 159
158 item.menu = itemSubs; 160 item.menu = itemSubs;
159 } 161 }
160 menu.push(item); 162 menu.push(item);
161 - }  
162 - // _.forEach(data,function(v){  
163 - // var item = {  
164 - // title:v.menu_name,  
165 - // }  
166 - // if(v.parent_id === "0") {  
167 - // item.parent = 'menu-template';  
168 - // var itemSubs = [];  
169 - // _.forEach(v.sub,function(val) {  
170 - // console.log(v.sub);  
171 - // var sub = {  
172 - // title:val.menu_name,  
173 - // href:val.menu_url,  
174 - // icon: 'list-alt'  
175 - // }  
176 - // right[val.menu_url] = true;  
177 - // itemSubs.push(sub);  
178 - // });  
179 -  
180 - // item.menu = itemSubs;  
181 - // }  
182 - // menu.push(item);  
183 - // }); 163 + });
184 164
185 return { 165 return {
186 menu:menu, 166 menu:menu,
1 -// var oldSerDomain = 'http://service.api.yohobuy.com';  
2 -// module.exports = {  
3 -// login: oldSerDomain + '/account/api/v1/profile/login',  
4 -// getResourceByPid: oldSerDomain + '/account/api/v1/profile/getResourceByPid',  
5 -// getAllResByWebsite: oldSerDomain + '/account/api/v1/resources/getAllResByWebsite'  
6 -// };  
7 -  
8 -var oldSerDomain = 'http://lserve.yohobuy.com'; 1 +var oldSerDomain = 'http://service.api.yohobuy.com';
9 module.exports = { 2 module.exports = {
10 - login: oldSerDomain + '/service/account/v1/Profile/login',  
11 - getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid',  
12 - getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu' 3 + login: oldSerDomain + '/account/api/v1/profile/login',
  4 + getResourceByPid: oldSerDomain + '/account/api/v1/profile/getResourceByPid',
  5 + getAllResByWebsite: oldSerDomain + '/account/api/v1/resources/getAllResByWebsite'
13 }; 6 };
14 -