auth.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view style="display: flex;align-items: center;justify-content: center;height: 100vh;">
  3. <!-- <image src="../../static/logo.png" style="width: 90px;height:80px"></image> -->
  4. <!-- <tn-loading mode="circle" size="60"></tn-loading> -->
  5. </view>
  6. </template>
  7. <script>
  8. import request from '../../utils/request'
  9. export default {
  10. name: 'Auth',
  11. data() {
  12. return {
  13. }
  14. },
  15. created() {
  16. uni.reLaunch({
  17. url:'/pages/index/index'
  18. })
  19. },
  20. methods: {
  21. loginByCode(frontId) {
  22. const that = this;
  23. uni.setStorageSync('loginStatus', 'false');
  24. wx.getUserInfo({
  25. success: function(res) {
  26. console.error(res);
  27. request.post("/slbMpAutoLogin", {
  28. code:frontId,
  29. appType:'ma',
  30. encryptedData:res.encryptedData,
  31. iv: res.iv
  32. }, {
  33. login: false,
  34. warn:false,
  35. loading:false
  36. }).then(res2=>{
  37. console.error(res2);
  38. if(res2.success){
  39. //登录成功
  40. uni.setStorageSync('loginStatus', 'true');
  41. uni.setStorageSync('userMap', JSON.stringify(res2.resultMap));
  42. uni.setStorageSync('userNo', res2.resultMap.accountName);
  43. that.getUserInfo();
  44. }else{
  45. console.error(12345);
  46. uni.setStorageSync('loginStatus', 'false');
  47. uni.removeStorageSync('userMap');
  48. uni.removeStorageSync('userNo');
  49. uni.removeStorageSync('userInfo');
  50. uni.reLaunch({
  51. url:'/pages/index/index'
  52. })
  53. //登录失败,
  54. // uni.login({
  55. // success(res) {
  56. // console.error(res);
  57. // that.getOpenId(res.code);
  58. // },
  59. // fail(res) {
  60. // console.error(res);
  61. // uni.hideLoading();
  62. // }
  63. // });
  64. }
  65. console.error(res2);
  66. });
  67. }
  68. })
  69. },
  70. getUserInfo() {
  71. let that = this;
  72. request.post('/slbWxma/getPersonlInfo', {
  73. }).then(res => {
  74. console.warn(res);
  75. if(res&&res.success){
  76. that.personInfo = res.resultMap.userInfo||{};
  77. uni.setStorageSync('userInfo', JSON.stringify(res.resultMap.userInfo));
  78. uni.reLaunch({
  79. url:'/pages/index/index'
  80. })
  81. }else{
  82. uni.reLaunch({
  83. url:'/pages/index/index'
  84. })
  85. }
  86. console.warn(res);
  87. })
  88. },
  89. }
  90. }
  91. </script>
  92. <style>
  93. </style>