login.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. var _this = this
  24. uni.showModal({
  25. title: '温馨提示',
  26. content: '亲,授权微信登录后才能正常使用小程序功能',
  27. success(res) {
  28. //如果用户点击了确定按钮
  29. if (res.confirm) {
  30. uni.getUserProfile({
  31. desc: '获取你的昵称、头像、地区及性别',
  32. success: res => {
  33. getApp().globalData.userInfo = res.userInfo, //登录用户信息
  34. uni.switchTab({
  35. url: '/pages/index'
  36. })
  37. },
  38. fail: res => {
  39. //拒绝授权
  40. uni.showToast({
  41. title: '您拒绝了请求,不能正常使用小程序',
  42. icon: 'error',
  43. duration: 2000
  44. });
  45. return;
  46. }
  47. });
  48. } else if (res.cancel) {
  49. //如果用户点击了取消按钮
  50. uni.showToast({
  51. title: '您拒绝了请求,不能正常使用小程序',
  52. icon: 'error',
  53. duration: 2000
  54. });
  55. return;
  56. }
  57. }
  58. });
  59. }
  60. },
  61. }
  62. </script>
  63. <style lang="scss">
  64. page {
  65. background-color: #ffffff;
  66. }
  67. .normal-login-container {
  68. width: 100%;
  69. .login-bg-img {
  70. width: 100%;
  71. height: 100vh;
  72. position: absolute;
  73. top: 0;
  74. left: 0;
  75. z-index: -1;
  76. }
  77. .logo-content {
  78. width: 100%;
  79. font-size: 21px;
  80. text-align: center;
  81. padding-top: 15%;
  82. image {
  83. border-radius: 4px;
  84. }
  85. .title {
  86. margin-left: 10px;
  87. }
  88. }
  89. .login-form-content {
  90. text-align: center;
  91. width: 90%;
  92. min-height: 45vh;
  93. background-color: #ffffff;
  94. border-radius: 40rpx;
  95. padding: 5%;
  96. box-shadow: 0 0 10px #a7a7a7;
  97. position: absolute;
  98. bottom: 10vh;
  99. left: 50%;
  100. transform: translateX(-50%);
  101. .login-title {
  102. margin-top: 20px;
  103. font-size: 40rpx;
  104. color: #898989;
  105. image {
  106. width: 70rpx;
  107. height: 53rpx;
  108. margin-right: 20rpx;
  109. }
  110. }
  111. .input-item {
  112. margin: 20px auto;
  113. background-color: #f5f6f7;
  114. height: 96rpx;
  115. border-radius: 50px;
  116. .icon {
  117. font-size: 38rpx;
  118. margin-left: 10px;
  119. color: #999;
  120. }
  121. .input {
  122. width: 100%;
  123. font-size: 14px;
  124. line-height: 20px;
  125. text-align: left;
  126. padding-left: 15px;
  127. }
  128. }
  129. .login-btn {
  130. margin-top: 40px;
  131. height: 96rpx;
  132. background: linear-gradient(105deg, #72C6FF, #79A4F0);
  133. box-shadow: 0rpx 18rpx 24rpx 0rpx rgba(63, 143, 255, 0.23);
  134. border-radius: 48rpx;
  135. color: #f5f6f7;
  136. }
  137. .reg {
  138. margin-top: 15px;
  139. }
  140. .xieyi {
  141. color: #333;
  142. margin-top: 20px;
  143. }
  144. .login-code {
  145. height: 38px;
  146. float: right;
  147. .login-code-img {
  148. height: 38px;
  149. position: absolute;
  150. margin-left: 10px;
  151. width: 200rpx;
  152. }
  153. }
  154. }
  155. }
  156. </style>