login.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <view class="login">
  3. <loadSke :loading='getUserInfo'>
  4. <view class="user-info">
  5. <view class="avatar">
  6. <open-data type="userAvatarUrl"></open-data>
  7. </view>
  8. <view class="nickname">
  9. <open-data type="userNickName"></open-data>
  10. </view>
  11. <button open-type="getUserProfile" @tap="getUserProfile">授权用户头像信息</button>
  12. </view>
  13. </loadSke>
  14. </view>
  15. </template>
  16. <script>
  17. import loadSke from '@/components/skeleton/login.vue'
  18. export default {
  19. components: {
  20. loadSke
  21. },
  22. props: ['login'],
  23. data: () => ({
  24. getUserInfo: true
  25. }),
  26. async created() {
  27. this.init()
  28. },
  29. methods: {
  30. async init() {
  31. if (true) {
  32. let loginRes = await this.$store.dispatch('Login')
  33. if (loginRes.code == 200) {
  34. this.$emit('update:login', true)
  35. }else{
  36. this.Toast('登录失败');
  37. this.$emit('update:login', true)
  38. }
  39. } else {
  40. this.getUserInfo = false
  41. }
  42. },
  43. getUserProfile: function(e) {
  44. wx.getUserProfile({
  45. desc: '业务需要',
  46. success: res => {
  47. console.log(res)
  48. }
  49. })
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .login {
  56. width: 100vw;
  57. height: 80vh;
  58. display: flex;
  59. justify-content: center;
  60. align-items: center;
  61. .user-info {
  62. display: flex;
  63. flex-direction: column;
  64. justify-content: center;
  65. align-items: center;
  66. .avatar {
  67. border-radius: 50%;
  68. width: 100px;
  69. height: 100px;
  70. overflow: hidden;
  71. }
  72. .nickname {
  73. text-align: center;
  74. }
  75. }
  76. }
  77. </style>