Authored by shuaiguo

Merge branch 'refs/heads/release'

const request = require('request-promise');
const _ = require('lodash');
const url = require('url');
const helpers = global.yoho.helpers;
... ... @@ -9,6 +10,34 @@ const cookie = global.yoho.cookie;
const AuthHelperModel = require('../models/auth-helper');
const config = global.yoho.config;
class BaiduSDK {
/*
* @ description: 广告主回传转化数据接口, 上报百度
* @ author: huzhiming
* @ date: 2019-11-19 17:21:29
* @ version: v1.0.0
* 详情见文档:[http://ocpc.baidu.com/developer/d/guide/?iurl=api%2Fapi-doc%2Fapi-interface%2F]
*/
static reportOcpcApi({
token = '7GULUkX90QLZU6cHO9OEqUsRKttGNqpN@O62eFfb91OUVhmkakV1bQHIxF8xURBvP',
conversionTypes = [{ logidUrl: '', newType: null }]
}) {
request({
method: 'POST',
uri: 'http://ocpc.baidu.com/ocpcapi/api/uploadConvertData',
body: {
token,
conversionTypes
},
json: true
}).then((result) => {
console.log(`[账号注册成功后上报 百度ocpc返回信息:${JSON.stringify(result)}`);
}).catch((error) => {
console.log(`[账号注册成功后上报 百度ocpc失败 错误信息:${error}`);
});
}
}
class Reg {
/**
* 注册页面
... ... @@ -224,6 +253,24 @@ class Reg {
delete req.session.phoneNum;
/*
* @ description: feat(oCPC搜索推广): 推广链接转化数据发送给百度服务器,埋点:OCPC推广链接打开并完成注册进行数据上报
* @ author: huzhiming
* @ date: 2019-11-19 19:09:39
* @ version: v1.0.0
* bd_vid_path存值见:public/js/common.js 文件
*/
const logidUrl = req.cookies.bd_vid_path;
if (logidUrl) {
BaiduSDK.reportOcpcApi({
conversionTypes: {
logidUrl,
newType: 25
}
});
}
return res.json({
code: 200,
message: '注册成功',
... ...
... ... @@ -49,10 +49,14 @@ module.exports = function(req, res, next) {
captchaReq.from_json_string(JSON.stringify(params));
// eslint-disable-next-line new-cap
client.DescribeCaptchaResult(captchaReq, function(errMsg) {
client.DescribeCaptchaResult(captchaReq, function(errMsg, response) {
if (errMsg) {
return res.jsonp({code: 400, message: errMsg.Message});
}
if (response.CaptchaCode !== 1) {
return res.jsonp({ code: 400, message: '验证码错误'});
}
next();
});
} else {
... ...
{
"name": "yohobuywap-node",
"version": "6.9.17-beta-2",
"version": "6.9.20",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -288,6 +288,17 @@ $.extend({
// 尝试打开 APP
// require('./common/open-app');
/* 【加入ocpcApi代码】: 判断当前页面地址若百度sem推广链接,即将推广链接存到cookies,支付成功后将推广链接上报百度 ocpcapi
* @ description: 收集百度sem推广链接
* @ author: huzhiming
* @ date: 2019-11-18 16:55:17
* @ version: v1.0.0
* 详情见文档:[http://ocpc.baidu.com/developer/d/guide/?iurl=api%2Fapi-doc%2Fapi-interface%2F]
*/
if (location.href.includes('bd_vid=')) {
setCookie('bd_vid_path', location.href, { path: '/', domain: '.yohobuy.com', expires: 90 });
}
// 尝试打开 MINIAPP
require('./common/open-miniapp');
}());
... ... @@ -531,6 +542,7 @@ function givePoint(parameter) {
}
}());
// 暴露公共接口
window.cookie = cookie;
... ...