Commit ae6d27a7429de15a55b3235945555bbef2844b47
1 parent
d49200aa
update menu
Showing
2 changed files
with
24 additions
and
3 deletions
api/controllers/ApiController.js
... | ... | @@ -8,6 +8,13 @@ var https = require('https'); |
8 | 8 | var url = require('url'); |
9 | 9 | |
10 | 10 | var custom = sails.config.custom; |
11 | + | |
12 | +// 跳转map | |
13 | +var btnMaps = { | |
14 | + "btn_purchase":"http://m.nong12.com/user/my_purchase.do", | |
15 | + "btn_sale":"http://m.nong12.com/user/my_sale.do" | |
16 | +}; | |
17 | + | |
11 | 18 | module.exports = { |
12 | 19 | /** |
13 | 20 | * 微信通知入口方法 |
... | ... | @@ -113,6 +120,7 @@ module.exports = { |
113 | 120 | }) |
114 | 121 | |
115 | 122 | .then(function resolve(login_res) { |
123 | + // TODO 需要重构,建立btn 和 url的映射 | |
116 | 124 | var target_url = "http://m.nong12.com/user/user_home.do?open_id=" + OpenID; |
117 | 125 | if (EventKey == "btn_ordersearch") { |
118 | 126 | target_url = 'http://m.nong12.com/order/shopped_list.do?orderState=-1&user_id=' + login_res.accountId + '&open_id=' + OpenID; |
... | ... | @@ -129,6 +137,9 @@ module.exports = { |
129 | 137 | if (EventKey == "btn_category") { |
130 | 138 | target_url = "http://m.nong12.com/features/category.do?id=0&open_id=" + OpenID + "&user_id=" + login_res.accountId; |
131 | 139 | } |
140 | + if(btnMaps[EventKey]){ | |
141 | + target_url = btnMaps[EventKey]+'?user_id=' + login_res.accountId + '&open_id=' + OpenID; | |
142 | + } | |
132 | 143 | res.redirect(target_url); |
133 | 144 | }, function reject(err) { |
134 | 145 | var target_url = "http://m.nong12.com/user/user_home.do" + '?open_id=' + OpenID; |
... | ... | @@ -144,6 +155,10 @@ module.exports = { |
144 | 155 | if (EventKey == "release_supply") { |
145 | 156 | target_url = encodeURIComponent('http://m.nong12.com/supply/release_supply.do?open_id=' + OpenID); |
146 | 157 | } |
158 | + if(btnMaps[EventKey]){ | |
159 | + target_url = encodeURIComponent(btnMaps[EventKey] + '?open_id=' + OpenID); | |
160 | + } | |
161 | + | |
147 | 162 | console.log(err,EventKey,target_url); |
148 | 163 | // 跳转绑定 |
149 | 164 | if (err.name == "no_bind") { | ... | ... |
api/models/Menu.js
... | ... | @@ -38,9 +38,15 @@ |
38 | 38 | "name": "我", |
39 | 39 | "sub_button": [{ |
40 | 40 | "type": "view", |
41 | - "name": "个人中心", | |
42 | - "url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + sails.config.custom.appid + "&redirect_uri=http%3A%2F%2Fwx.nong12.com%2Fapi%2Fauth%3Fevent_key%3Dbtn_usercenter&response_type=code&scope=snsapi_base&state=1#wechat_redirect" | |
43 | - }] | |
41 | + "name": "我的采购", | |
42 | + "url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + sails.config.custom.appid + "&redirect_uri=http%3A%2F%2Fwx.nong12.com%2Fapi%2Fauth%3Fevent_key%3Dbtn_my_purchase&response_type=code&scope=snsapi_base&state=1#wechat_redirect" | |
43 | + }, | |
44 | + { | |
45 | + "type": "view", | |
46 | + "name": "我的销售", | |
47 | + "url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + sails.config.custom.appid + "&redirect_uri=http%3A%2F%2Fwx.nong12.com%2Fapi%2Fauth%3Fevent_key%3Dbtn_my_sale&response_type=code&scope=snsapi_base&state=1#wechat_redirect" | |
48 | + } | |
49 | + ] | |
44 | 50 | }] |
45 | 51 | } |
46 | 52 | }; |
47 | 53 | \ No newline at end of file | ... | ... |