login.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. //没有点击
  26. noClick: true
  27. }
  28. },
  29. methods: {
  30. ...mapMutations('m_parent', ['updateParentInfo', 'updateToken']),
  31. //获取用户信息事件
  32. async getUserInfo() {
  33. await uni.getUserProfile({
  34. desc: '获取您的基本信息',
  35. success: infoRes => {
  36. uni.login({
  37. success: loginRes => {
  38. this.$api.getUserToken({
  39. js_code: loginRes.code
  40. }).then(res => {
  41. console.log(res);
  42. this.updateToken(res.data)
  43. // uni.setStorageSync('tokenKey',res.data.token)
  44. }).catch(err => {
  45. uni.showToast({
  46. title: '加载数据失败~',
  47. icon: 'none',
  48. })
  49. })
  50. }
  51. })
  52. this.updateParentInfo(infoRes.userInfo)
  53. uni.redirectTo({
  54. url: '/subpkg/startup/guide'
  55. })
  56. },
  57. fail: err => {
  58. uni.showToast({
  59. title: '您已拒绝授权',
  60. icon: 'error'
  61. });
  62. }
  63. });
  64. },
  65. }
  66. }
  67. </script>
  68. <style lang="scss">
  69. @import 'startup_pages.scss';
  70. //登录页面
  71. .content {
  72. width: 100vw;
  73. height: 100vh;
  74. background-color: #FFFFFF;
  75. .bg1 {
  76. position: fixed;
  77. top: -250rpx;
  78. right: -250rpx;
  79. width: 680rpx;
  80. height: 680rpx;
  81. border-radius: 100%;
  82. background-color: $color-blue;
  83. z-index: 5;
  84. }
  85. .bg2 {
  86. position: fixed;
  87. right: -300rpx;
  88. top: 200rpx;
  89. width: 600rpx;
  90. height: 600rpx;
  91. border-radius: 100%;
  92. background-color: $color-red;
  93. z-index: 4;
  94. }
  95. .bg3 {
  96. position: fixed;
  97. top: 500rpx;
  98. right: 450rpx;
  99. width: 600rpx;
  100. height: 600rpx;
  101. border-radius: 100%;
  102. background-color: $color-yellow;
  103. z-index: 4;
  104. }
  105. }
  106. </style>