againToken.js 796 B

12345678910111213141516171819202122232425262728
  1. // 获取登录token
  2. export function againToken($u, openid,userId) {
  3. $u.api.reLogin({wechatOpenid: openid}).then((userData) => {
  4. if(userData && userData.code ===200) {
  5. if(userData.data && userData.data.accessToken){
  6. $u.vuex('vuex_user_info', userData.data);
  7. } else {
  8. // 清空用户数据缓存
  9. $u.vuex('vuex_user_info', {});
  10. $u.vuex('vuex_member_info', {});
  11. }
  12. $u.api.memberInfo({id:userId}).then(({code, data, msg}) => {
  13. if(code ===200) {
  14. $u.vuex('vuex_member_info', data)
  15. if(window && window.location){
  16. window.location.reload(false);
  17. }else{
  18. $u.route('/pages/index/index',{type:'reLaunch'});
  19. }
  20. }
  21. })
  22. } else {
  23. // 清空用户数据缓存
  24. $u.vuex('vuex_user_info', {});
  25. $u.vuex('vuex_member_info', {});
  26. }
  27. })
  28. }