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