Merge branch 'refs/heads/develop'
Showing
1 changed file
with
44 additions
and
0 deletions
@@ -14,6 +14,7 @@ const QQStrategy = require('passport-qq').Strategy; | @@ -14,6 +14,7 @@ const QQStrategy = require('passport-qq').Strategy; | ||
14 | const DoubanStrategy = require('passport-douban').Strategy; | 14 | const DoubanStrategy = require('passport-douban').Strategy; |
15 | const RenrenStrategy = require('passport-renren').Strategy; | 15 | const RenrenStrategy = require('passport-renren').Strategy; |
16 | const AlipayStrategy = require('./models/passport-alipay').Strategy; | 16 | const AlipayStrategy = require('./models/passport-alipay').Strategy; |
17 | +const request = require('request-promise'); | ||
17 | 18 | ||
18 | const CaptchaServiceModel = require('./models/captcha-img-service'); | 19 | const CaptchaServiceModel = require('./models/captcha-img-service'); |
19 | 20 | ||
@@ -23,6 +24,35 @@ const config = global.yoho.config; | @@ -23,6 +24,35 @@ const config = global.yoho.config; | ||
23 | const cookie = global.yoho.cookie; | 24 | const cookie = global.yoho.cookie; |
24 | const logger = global.yoho.logger; | 25 | const logger = global.yoho.logger; |
25 | 26 | ||
27 | +class BaiduSDK { | ||
28 | + /* | ||
29 | + * @ description: 广告主回传转化数据接口, 上报百度 | ||
30 | + * @ author: huzhiming | ||
31 | + * @ date: 2019-11-19 17:21:29 | ||
32 | + * @ version: v1.0.0 | ||
33 | + * 详情见文档:[http://ocpc.baidu.com/developer/d/guide/?iurl=api%2Fapi-doc%2Fapi-interface%2F] | ||
34 | + */ | ||
35 | + static reportOcpcApi({ | ||
36 | + token = '7GULUkX90QLZU6cHO9OEqUsRKttGNqpN@O62eFfb91OUVhmkakV1bQHIxF8xURBvP', | ||
37 | + conversionTypes = [{ logidUrl: '', newType: null }] | ||
38 | + }) { | ||
39 | + logger.info('--------------百度ocpc--------------'); | ||
40 | + request({ | ||
41 | + method: 'POST', | ||
42 | + uri: 'http://ocpc.baidu.com/ocpcapi/api/uploadConvertData', | ||
43 | + body: { | ||
44 | + token, | ||
45 | + conversionTypes | ||
46 | + }, | ||
47 | + json: true | ||
48 | + }).then((result) => { | ||
49 | + logger.info(`[账号注册成功后上报 百度ocpc返回信息:${JSON.stringify(result)}`); | ||
50 | + }).catch((error) => { | ||
51 | + logger.info(`[账号注册成功后上报 百度ocpc失败 错误信息:${error}`); | ||
52 | + }); | ||
53 | + } | ||
54 | +} | ||
55 | + | ||
26 | let siteUrl = config.siteUrl.indexOf('//') === 0 ? 'http:' + config.siteUrl : config.siteUrl; | 56 | let siteUrl = config.siteUrl.indexOf('//') === 0 ? 'http:' + config.siteUrl : config.siteUrl; |
27 | 57 | ||
28 | // 本地登录 | 58 | // 本地登录 |
@@ -48,6 +78,20 @@ passport.use('local', new LocalStrategy({ | @@ -48,6 +78,20 @@ passport.use('local', new LocalStrategy({ | ||
48 | (async function() { | 78 | (async function() { |
49 | const result = await req.ctx(LoginApi).signin(type, area, username, password, shoppingKey, close, id, captcha); | 79 | const result = await req.ctx(LoginApi).signin(type, area, username, password, shoppingKey, close, id, captcha); |
50 | 80 | ||
81 | + if (_.get(result, 'data.nFlag', 'N') === 'Y') { | ||
82 | + const logidUrl = req.cookies.bd_vid_path; | ||
83 | + | ||
84 | + logger.info('-------logidUrl---auth-----', `${logidUrl}:${username}`); | ||
85 | + if (logidUrl) { | ||
86 | + BaiduSDK.reportOcpcApi({ | ||
87 | + conversionTypes: { | ||
88 | + logidUrl, | ||
89 | + newType: 3 | ||
90 | + } | ||
91 | + }); | ||
92 | + } | ||
93 | + } | ||
94 | + | ||
51 | if (result.code && (result.code === 200 || result.code === 510) && result.data.uid) { | 95 | if (result.code && (result.code === 200 || result.code === 510) && result.data.uid) { |
52 | return done(null, Object.assign(result.data, {code: result.code})); | 96 | return done(null, Object.assign(result.data, {code: result.code})); |
53 | } | 97 | } |
-
Please register or login to post a comment