auth.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <u-loading-page loading-color="#000000" :loading="true" loadingText="正在请求微信授权"></u-loading-page>
  3. </template>
  4. <script>
  5. import qs from 'qs';
  6. export default {
  7. data() {
  8. return {
  9. }
  10. },
  11. onLoad(option){
  12. let { shiYuWxLogin , username : userName } = option;
  13. if(shiYuWxLogin){
  14. uni.redirectTo({
  15. url : "/pages/login/index?shiYuWxLogin=" + shiYuWxLogin,
  16. })
  17. }else if(userName){
  18. uni.$u.api.shiYuWxLoginGetInfo({userName}).then((res)=>{
  19. const { access_token } = res.data;
  20. this.$store.commit("user/SET_TOKEN", access_token);
  21. this.$store.dispatch("user/getUserInfo").then(()=>{
  22. uni.reLaunch({
  23. url:"/pages/bindSuccess/index",
  24. });
  25. // uni.switchTab({
  26. // url: `/pages/person/index`,
  27. // success: () => {
  28. // this.$store.dispatch("app/register");
  29. // uni.$u.toast("登录成功");
  30. // }
  31. // })
  32. })
  33. })
  34. }else{
  35. window.location.href = "https://crm.nanjingshiyu.com/prod-api/auth/shiYuWxLogin";
  36. }
  37. },
  38. }
  39. </script>
  40. <style lang="scss" scoped>
  41. </style>