Authored by QC-L

添加页面跳转登录效果 review by 黄敬囿

... ... @@ -15,7 +15,8 @@ import { Event } from '/login/utils/index.js';
import { wxLogin } from '/login/utils/login/login.js';
import { appReport } from './libs/appReport.js';
global.event = new Event();
const event = new Event();
global.event = event;
import { logEvent,
YB_LAUNCH_APP,
... ... @@ -100,6 +101,25 @@ App({
}, 1000);
this.mtainit(options);
await wxLogin();
event.on('user-is-login', ({ logged, loginSuccess }) => {
const userInfo = wx.getStorageSync('userInfo');
console.log(userInfo);
if (userInfo && userInfo.uid && userInfo.session_key) {
this.globalData.userInfo = userInfo;
if (logged) {
logged(userInfo);
}
} else {
event.once('user-login-success', (userInfo) => {
if (loginSuccess) {
loginSuccess(userInfo);
}
});
wx.navigateTo({
url: '/login/login-page/login-page',
})
}
});
},
//当应用程序进入前台显示状态时触发
... ...
... ... @@ -305,4 +305,11 @@ const _onceWrap = (target, type, listener) => {
wrapped.listener = listener;
state.wrapFn = wrapped;
return wrapped;
}
function arrayClone(arr, n) {
var copy = new Array(n);
for (var i = 0; i < n; ++i)
copy[i] = arr[i];
return copy;
}
\ No newline at end of file
... ...
... ... @@ -94,6 +94,7 @@ const wechatUnionIdIsBind = async (union_id, userInfo) => {
login.sendWeChatUserData(uid, userInfo.nickName, userInfo.avatarUrl).catch(error => {});
// 触发事件登录成功
event.emit('wechat-login-success', newUserInfo);
event.emit('user-login-success', newUserInfo);
} else {
// 修改按钮状态, 获取手机号绑定手机号
event.emit('wechat-login-change-status', { openType: 'getPhoneNumber' });
... ...
... ... @@ -231,6 +231,19 @@ Page(Object.assign({
},
goLogin() {
const event = global.event;
event.emit('user-is-login', { logged: this.logged, loginSuccess: this.loginSuccess });
},
logged() {
},
loginSuccess() {
},
_getGroupList() {
this.commonService.getGroupList({
limit: 20,
... ...
... ... @@ -42,7 +42,7 @@
</view>
<block wx:if="{{product.status === 2}}">
<button class="action-item confirm" open-type="{{!hasUnionID ? 'getUserInfo':'getPhoneNumber'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>0元参加抽奖</button>
<button class="action-item confirm" bindtap="goLogin">0元参加抽奖</button>
</block>
<block wx:else>
... ...