Authored by 李奇

登录注册上报

... ... @@ -101,9 +101,7 @@ App({
}
} else {
event.once('user-login-success', (userInfo) => {
// TODO
yasReport(YB_MY_LOGIN);
console.log('登录注册上报');
yasReport(YB_MY_LOGIN, {LOGIN_TYPE: 4});
if (loginSuccess) {
loginSuccess(userInfo);
}
... ...
... ... @@ -8,18 +8,10 @@ import {
const event = global.event;
Page({
/**
* 页面的初始数据
*/
data: {
openType: 'getUserInfo'
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function () {
this.checkUnionId();
event.on('wechat-login-success', this.loginSuccess);
event.on('wechat-login-callback', this.loginCallback);
... ... @@ -63,7 +55,6 @@ Page({
},
loginSuccess(params) {
console.log(params);
this.goReferer();
},
... ...
... ... @@ -58,6 +58,23 @@ export default class EventEmitter {
return true;
}
one(type, listener) {
let events;
if (typeof listener !== 'function')
throw new Error('"listener" argument must be a function');
events = this._events;
console.log(events);
if (typeof events === 'undefined') {
events = this._events = Object.create(null);
this._eventsCount = 0;
}
events[type] = listener;
++this._eventsCount;
return this;
}
_addListener(type, listener, prepend) {
let events;
let existing;
... ...
... ... @@ -6,10 +6,12 @@ const login = new LoginService();
const loginPromise = toPromiseWX('login');
const saveLoginData = (loginData) => {
const app = getApp();
setStorageValueForKey('open_id', loginData.openid);
setStorageValueForKey('srd_session', loginData.srd_session);
if (loginData && loginData.unionid) {
setStorageValueForKey('union_id', loginData.unionid);
app && app.setWXUnionID(loginData.unionid);
}
}
... ...
... ... @@ -110,23 +110,11 @@ Page(extend({},Toast,{
});
},
// calcPosition: function (i, dataVal) {
// let positionX, positionY;
// let index = i;
// let count = parseInt(dataVal, 10) + 1;
// let unit = 'px';
// positionX = -index * 80 + unit;
// positionY = -count * 80 + unit;
// return [positionX, positionY].join(' ');
// },
didSelectImage: function (e) {
let index = e.currentTarget.dataset.itemindex;
let graphicsCodeElement = this.data.graphicsCodeElement;
let elem = graphicsCodeElement[index];
let dataVal = (parseInt(elem.dataVal)) % 4 + 1;
// let position = this.calcPosition(index, elem.dataVal);
// elem.position = position;
elem.dataVal = dataVal;
this.setData({graphicsCodeElement});
},
... ... @@ -395,7 +383,6 @@ verifyBtnAction:function(){
bindBtnAction:function (needBind, callBackFun) {
let that = this
// console.log('phoneNumber,verifyCode', that.data.phoneNum, that.data.verifyCode)
if (!that.data.phoneNum) {
that.wetoast.toast({
title: '请输入有效手机号',
... ... @@ -416,7 +403,6 @@ bindBtnAction:function (needBind, callBackFun) {
}
bindAction(that.data.phoneNum, that.data.verifyCode, that.data.country_area, that.data.inviteCode, function (result) {
// console.log("result:",result)
if (result.message)
that.wetoast.toast({
title: result.message,
... ... @@ -425,7 +411,6 @@ bindBtnAction:function (needBind, callBackFun) {
});
if (result.succeed) {
//新人toast提示
if (result.is_register) {
that.showZanToast({ title:'欢迎加入Yoho!Family!新人礼包已发放到个人中心-优惠券,请注意查收',success: function(){
that.redirectAction();
... ... @@ -433,6 +418,7 @@ bindBtnAction:function (needBind, callBackFun) {
} else {
that.redirectAction();
}
event.emit('user-login-success');
event.emit('wechat-login-success');
}
})
... ... @@ -451,13 +437,6 @@ redirectAction: function() {
url: '../webview/webview?url=' + that.data.h5back
})
} else {
// let prePage = getCurrentPages();
// that.newCustomerStorage();
// if (prePage.length > 1 && prePage[prePage.length - 2].bindPhoneNumComplete != undefined) {
// prePage[prePage.length - 2].bindPhoneNumComplete();
// }
// console.log("currentPage:", getCurrentPages())
wx.navigateBack({
delta: 2,
})
... ...
... ... @@ -471,7 +471,6 @@ Page(Object.assign({
})
})
.catch(error => {
console.log(error)
})
},
... ...
... ... @@ -237,7 +237,6 @@ Page(Object.assign({
this.dialog.showDialog();
})
.catch(error => {
console.log(error)
})
},
... ... @@ -251,7 +250,6 @@ Page(Object.assign({
})
})
.catch(error => {
console.log(error)
})
},
... ... @@ -507,7 +505,6 @@ Page(Object.assign({
},
loginError(error) {
console.log(error);
router.go('bindPhoneNumber');
},
... ...
//login.js
import {GET, POST} from '../libs/request';
import {API_HOST, SERVICE_HOST} from '../libs/config';
import {Encrypt} from '../libs/aes'
import {isStringEmpty} from './util'
import { yasReport,
YB_MY_LOGIN,
YB_PAGE_OPEN_L,
YB_REGISTER_SUCCESS,
} from '../libs/yas.js'
import {
yasReport,
YB_REGISTER_SUCCESS
} from '../libs/yas.js'
//获取应用实例
var app = getApp()
... ... @@ -53,8 +50,6 @@ function wechatLoginAction(callbackFunc) {
app.setOpenID(responseData.openid);
//如果unionID不存在(未使用过任何有货微信产品的全新用户),调用getUnionID函数,再次获取unionID
//对于已经授权过的用户,拿到unionid之后获取一次userinfo更新个人信息.
let params = { LOGIN_TYPE: 4, PV_ID: PV_ID, };
yasReport(YB_MY_LOGIN, params);
//当unionId为空或者头像为空时,调用微信接口获取用户信息
if (!isStringEmpty(responseData.unionid)) {
... ... @@ -356,8 +351,7 @@ function checkVerifyCode(phoneNumb, verifyCode, areaCode, inviteCode, callbackFu
app.setSessionkey(data.data.session_key);
app.setUserInfo(userInfo);
sendWeChatUserData(userInfo.uid, app.globalData.userInfo.nickName, app.globalData.userInfo.avatarUrl);
// console.log("登录成功:", userInfo)
if (data.data.is_register !== undefined && data.data.is_register !== null && data.data.is_register === 0 ) {
if (data.data.nFlag === 'Y') {
let logParams = {
YB_REGISTER_SUCCESS: 5,
};
... ... @@ -458,17 +452,21 @@ function autoSignin(mobile, verifyCode, areaCode, inviteCode, callbackFunc) {
userInfo.profile = data.data.profile;
app.setSessionkey(data.data.session_key);
app.setUserInfo(userInfo);
if (data.data.is_register !== undefined && data.data.is_register !== null && data.data.is_register === 0) {
let params = {
succeed: true,
code: data.code,
message:data.message,
};
if (data.data.nFlag === 'Y') {
params.is_register = true;
let logParams = {
YB_REGISTER_SUCCESS: 5,
};
yasReport(YB_REGISTER_SUCCESS, logParams);
}
callbackFunc({
succeed: true,
code: data.code,
message:data.message,
});
callbackFunc(params);
}else{
callbackFunc({
succeed: false,
... ... @@ -554,7 +552,7 @@ function BindMiniAppByAuto(mobile, countryCode, inviteCode, callbackFunc){
app.setSessionkey(data.data.session_key)
app.updateUid(data.data.uid)
sendWeChatUserData(data.data.uid, app.globalData.userInfo.nickName, app.globalData.userInfo.avatarUrl);
if (data.data.is_register !== undefined && data.data.is_register !== null && data.data.is_register === 0) {
if (data.data.nFlag === 'Y') {
let logParams = {
YB_REGISTER_SUCCESS: 5,
};
... ...