Blame view

apps/common/sdk.js 738 Bytes
陈峰 authored
1 2
import Login from 'yoho-activity-sdk/src/public/login';
import Base from 'yoho-activity-sdk/src/public/base';
陈峰 authored
3 4
import yoho from 'common/yoho';
import cookie from 'yoho-cookie';
陈峰 authored
5 6 7 8 9 10


var env = Base.env();
var loginUrl = Base.loginUrl();
var login = new Login({loginUrl: loginUrl, env: env});
陈峰 authored
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
async function getUser() {
  if (yoho.isApp) {
    const user = await Base.getUser();

    if (user && user.uid) {
      cookie.set('app_uid', user.uid);
      cookie.set('app_session_key', user.sessionKey);
      cookie.set('app_version', user.appVersion);
      cookie.set('app_client_type', user.sessionType);
    }

    return user;
  } else {
    return Base.getUser();
  }
}
陈峰 authored
28 29
export default {
  goLogin: login.goLogin.bind(login),
陈峰 authored
30
  getUser
陈峰 authored
31
};