login.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="normal-login-container">
  3. <view class="login-form-content">
  4. <view class="flex">
  5. <view class="login-title flex">
  6. 吉农宝
  7. </view>
  8. <button @click="getUserInfo"> 获取头像昵称 </button>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import {
  15. wxLogin
  16. } from '@/api/login'
  17. export default {
  18. data() {
  19. return {
  20. }
  21. },
  22. created() {
  23. this.getUserInfo();
  24. },
  25. methods: {
  26. getUserInfo() {
  27. let _this = this;
  28. uni.login({
  29. success (res) {
  30. if (res.code) {
  31. //发起网络请求
  32. wxLogin(res.code).then(res => {
  33. _this.$modal.closeLoading()
  34. uni.switchTab({
  35. url:'/pages/index'
  36. })
  37. })
  38. } else {
  39. console.log('登录失败!' + res.errMsg)
  40. }
  41. }
  42. })
  43. }
  44. },
  45. }
  46. </script>
  47. <style lang="scss">
  48. page {
  49. background-color: #ffffff;
  50. }
  51. .normal-login-container {
  52. width: 100%;
  53. .login-bg-img {
  54. width: 100%;
  55. height: 100vh;
  56. position: absolute;
  57. top: 0;
  58. left: 0;
  59. z-index: -1;
  60. }
  61. .logo-content {
  62. width: 100%;
  63. font-size: 21px;
  64. text-align: center;
  65. padding-top: 15%;
  66. image {
  67. border-radius: 4px;
  68. }
  69. .title {
  70. margin-left: 10px;
  71. }
  72. }
  73. .login-form-content {
  74. text-align: center;
  75. width: 90%;
  76. min-height: 45vh;
  77. background-color: #ffffff;
  78. border-radius: 40rpx;
  79. padding: 5%;
  80. box-shadow: 0 0 10px #a7a7a7;
  81. position: absolute;
  82. bottom: 10vh;
  83. left: 50%;
  84. transform: translateX(-50%);
  85. .login-title {
  86. margin-top: 20px;
  87. font-size: 40rpx;
  88. color: #898989;
  89. image {
  90. width: 70rpx;
  91. height: 53rpx;
  92. margin-right: 20rpx;
  93. }
  94. }
  95. .input-item {
  96. margin: 20px auto;
  97. background-color: #f5f6f7;
  98. height: 96rpx;
  99. border-radius: 50px;
  100. .icon {
  101. font-size: 38rpx;
  102. margin-left: 10px;
  103. color: #999;
  104. }
  105. .input {
  106. width: 100%;
  107. font-size: 14px;
  108. line-height: 20px;
  109. text-align: left;
  110. padding-left: 15px;
  111. }
  112. }
  113. .login-btn {
  114. margin-top: 40px;
  115. height: 96rpx;
  116. background: linear-gradient(105deg, #72C6FF, #79A4F0);
  117. box-shadow: 0rpx 18rpx 24rpx 0rpx rgba(63, 143, 255, 0.23);
  118. border-radius: 48rpx;
  119. color: #f5f6f7;
  120. }
  121. .reg {
  122. margin-top: 15px;
  123. }
  124. .xieyi {
  125. color: #333;
  126. margin-top: 20px;
  127. }
  128. .login-code {
  129. height: 38px;
  130. float: right;
  131. .login-code-img {
  132. height: 38px;
  133. position: absolute;
  134. margin-left: 10px;
  135. width: 200rpx;
  136. }
  137. }
  138. }
  139. }
  140. </style>