login.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view>
  3. <!-- 登录 -->
  4. <view class="content">
  5. <view class="bg1"></view>
  6. <view class="bg2"></view>
  7. <view class="bg3"></view>
  8. <view class="top">
  9. <text class="YS-title">请登录</text>
  10. <text class="YS-subtitle">醍摩豆家长端</text>
  11. </view>
  12. <button @click="$noMultipleClicks(getUserInfo)" class="btn" plain="true">微信一键登录</button>
  13. </view>
  14. <!-- 动画 -->
  15. <view class="ocean"></view>
  16. </view>
  17. </template>
  18. <script>
  19. import {
  20. mapMutations
  21. } from 'vuex';
  22. export default {
  23. data() {
  24. return {
  25. query: '',
  26. //没有点击
  27. noClick: true
  28. }
  29. },
  30. methods: {
  31. ...mapMutations('m_parent', ['updateParentInfo', 'updateToken']),
  32. //获取用户信息事件
  33. async getUserInfo() {
  34. await uni.getUserProfile({
  35. desc: '获取您的基本信息',
  36. success: infoRes => {
  37. uni.login({
  38. success: loginRes => {
  39. this.$api.getUserToken({
  40. js_code: loginRes.code
  41. }).then(res => {
  42. console.log(res);
  43. this.updateToken(res.data)
  44. // uni.setStorageSync('tokenKey',res.data.token)
  45. }).catch(err => {
  46. uni.showToast({
  47. title: '加载数据失败~',
  48. icon: 'none',
  49. })
  50. })
  51. }
  52. })
  53. this.updateParentInfo(infoRes.userInfo)
  54. uni.redirectTo({
  55. url: '/subpkg/startup/guide'
  56. })
  57. },
  58. fail: err => {
  59. uni.showToast({
  60. title: '您已拒绝授权',
  61. icon: 'error'
  62. });
  63. }
  64. });
  65. },
  66. }
  67. }
  68. </script>
  69. <style lang="scss">
  70. @import 'startup_pages.scss';
  71. //登录页面
  72. .content {
  73. width: 100vw;
  74. height: 100vh;
  75. background-color: #FFFFFF;
  76. .bg1 {
  77. position: fixed;
  78. top: -250rpx;
  79. right: -250rpx;
  80. width: 680rpx;
  81. height: 680rpx;
  82. border-radius: 100%;
  83. background-color: $color-blue;
  84. z-index: 5;
  85. }
  86. .bg2 {
  87. position: fixed;
  88. right: -300rpx;
  89. top: 200rpx;
  90. width: 600rpx;
  91. height: 600rpx;
  92. border-radius: 100%;
  93. background-color: $color-red;
  94. z-index: 4;
  95. }
  96. .bg3 {
  97. position: fixed;
  98. top: 500rpx;
  99. right: 450rpx;
  100. width: 600rpx;
  101. height: 600rpx;
  102. border-radius: 100%;
  103. background-color: $color-yellow;
  104. z-index: 4;
  105. }
  106. }
  107. </style>