login.vue 2.5 KB

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