| 
															
																@@ -49,7 +49,8 @@ module.exports = app => { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																          * @return {void} 
															 | 
															
															 | 
															
																          * @return {void} 
															 | 
														
													
												
													
														
															| 
															 | 
															
																          */ 
															 | 
															
															 | 
															
																          */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         async oauth(ctx) { 
															 | 
															
															 | 
															
																         async oauth(ctx) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-            const url = await app.wechat.oauth.getAuthorizeURL('http://jluat.smartcost.com.cn/wx/bind', '', 'snsapi_userinfo'); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            const redirect_uri = ctx.query.redirect_uri; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            const url = await app.wechat.oauth.getAuthorizeURL(redirect_uri, '', 'snsapi_userinfo'); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             ctx.redirect(url); 
															 | 
															
															 | 
															
																             ctx.redirect(url); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } 
															 | 
															
															 | 
															
																         } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -61,10 +62,6 @@ module.exports = app => { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																          */ 
															 | 
															
															 | 
															
																          */ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         async bind(ctx) { 
															 | 
															
															 | 
															
																         async bind(ctx) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             try { 
															 | 
															
															 | 
															
																             try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                if (!ctx.session.wechatToken) { 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                    const token = await app.wechat.oauth.getAccessToken(ctx.query.code); 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                    ctx.session.wechatToken = token.data; 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																-                } 
															 | 
															
															 | 
															
																 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 const user = await app.wechat.oauth.getUser(ctx.session.wechatToken.openid); 
															 | 
															
															 | 
															
																                 const user = await app.wechat.oauth.getUser(ctx.session.wechatToken.openid); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 const errorMessage = ctx.session.loginError; 
															 | 
															
															 | 
															
																                 const errorMessage = ctx.session.loginError; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 // 获取系统维护信息 
															 | 
															
															 | 
															
																                 // 获取系统维护信息 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -108,6 +105,25 @@ module.exports = app => { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 if (!result2) { 
															 | 
															
															 | 
															
																                 if (!result2) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                     throw '绑定失败'; 
															 | 
															
															 | 
															
																                     throw '绑定失败'; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 } 
															 | 
															
															 | 
															
																                 } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                const projectData = await ctx.service.project.getDataById(accountData.project_id); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                // 绑定成功通知 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                const templateId = 'ElT988uf7EV8ROPKSAX7z7tN9ZxZCDMaXK5ouc9N49E'; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                const url = ''; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                const msgData = { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    first: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        value: '微信绑定成功', 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    }, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    keyword1: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        value: accountData.account, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    }, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    keyword2: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        value: '项目编号' + projectData.code + ' 账号' + accountData.account + ' 绑定成功', 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    }, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    remark: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        value: '欢迎使用纵横云计量,我们竭诚为您服务。', 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    }, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                }; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                await app.wechat.api.sendTemplate(ctx.session.wechatToken.openid, templateId, url, '', msgData); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 ctx.body = '绑定成功'; 
															 | 
															
															 | 
															
																                 ctx.body = '绑定成功'; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             } catch (error) { 
															 | 
															
															 | 
															
																             } catch (error) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																                 this.log(error); 
															 | 
															
															 | 
															
																                 this.log(error); 
															 | 
														
													
												
											
												
													
														
															 | 
															
																@@ -119,6 +135,34 @@ module.exports = app => { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         async oauthTxt(ctx) { 
															 | 
															
															 | 
															
																         async oauthTxt(ctx) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																             ctx.body = 't3MkWAMqplVxPjmr'; 
															 | 
															
															 | 
															
																             ctx.body = 't3MkWAMqplVxPjmr'; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																         } 
															 | 
															
															 | 
															
																         } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+ 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        async testwx(ctx) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            try { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                // 绑定成功通知 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                const templateId = 'ElT988uf7EV8ROPKSAX7z7tN9ZxZCDMaXK5ouc9N49E'; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                const url = ''; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                const topColor = '#FFFFFF'; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                const msgData = { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    first: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        value: '微信绑定成功', 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    }, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    keyword1: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        value: 'hello world', 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    }, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    keyword2: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        value: 'hello world 绑定成功', 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    }, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    remark: { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                        value: '欢迎使用纵横云计量,我们竭诚为您服务。', 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                    }, 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                }; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                await app.wechat.api.sendTemplate(ctx.session.wechatToken.openid, templateId, url, topColor, msgData); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                ctx.body = 'success'; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            } catch (error) { 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                console.log(error); 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+                ctx.body = error; 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+            } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																 
															 | 
															
															 | 
															
																+        } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																     } 
															 | 
															
															 | 
															
																     } 
															 | 
														
													
												
													
														
															| 
															 | 
															
																  
															 | 
															
															 | 
															
																  
															 | 
														
													
												
													
														
															| 
															 | 
															
																     return WechatController; 
															 | 
															
															 | 
															
																     return WechatController; 
															 |