login.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!-- 登录页面 -->
  2. <template>
  3. <view>
  4. <!-- 登录 -->
  5. <view class="content">
  6. <view class="bg1"></view>
  7. <view class="bg2"></view>
  8. <view class="bg3"></view>
  9. <view class="top">
  10. <text class="YS-title">请登录</text>
  11. <text class="YS-subtitle">醍摩豆家长端</text>
  12. </view>
  13. <button @click="$noMultipleClicks(getUserInfo)" class="btn" plain="true">微信一键登录</button>
  14. </view>
  15. <!-- 动画 -->
  16. <view class="ocean"></view>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. mapMutations
  22. } from 'vuex';
  23. export default {
  24. data() {
  25. return {
  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. 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>