login.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="page-bg container">
  3. <view class="back-container">
  4. <navigator url="/pages/index/index">
  5. <uni-icons type="back" size="40" color="#FFFFFF"></uni-icons>
  6. </navigator>
  7. </view>
  8. <view class="login-container">
  9. <view class="avator-container">
  10. <uni-icons type="person" size="130" color="#FFFFFF"></uni-icons>
  11. </view>
  12. <view class="btn-container" @click="login">登录</view>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import { loginApi } from '@/service/apis.js';
  18. const login = () => {
  19. uni.getProvider({
  20. service: 'oauth'
  21. }).then((res) => {
  22. return uni.login({
  23. provider: res.provider[0]
  24. });
  25. }).then((res) => {
  26. return loginApi.login({"code": res.code});
  27. }).then((res) => {
  28. uni.setStorageSync('token', res);
  29. // uni.setStorageSync('userInfo', res.data.userInfo);
  30. // uni.switchTab({
  31. // url: '/pages/index/index'
  32. // });
  33. }).catch((err) => {
  34. console.log(err);
  35. });
  36. }
  37. </script>
  38. <style lang="scss" scoped>
  39. .container {
  40. width: 100vw;
  41. height: 100vh;
  42. padding: 16rpx;
  43. .back-container {
  44. left: 16rpx;
  45. top: 39px;
  46. width: 90rpx;
  47. height: 90rpx;
  48. border-radius: 50%;
  49. background-color: rgba(0, 0, 0, 0.1);
  50. display: flex;
  51. justify-content: center;
  52. align-items: center;
  53. }
  54. .login-container {
  55. width: 100%;
  56. height: 100%;
  57. display: flex;
  58. justify-content: center;
  59. align-items: center;
  60. flex-direction: column;
  61. .avator-container {
  62. left: 222rpx;
  63. top: 254rpx;
  64. width: 307rpx;
  65. height: 307rpx;
  66. background: #D2EFF3;
  67. border-radius: 50%;
  68. box-shadow: 0px 2px 2px 0px #DBDBDB;
  69. display: flex;
  70. justify-content: center;
  71. align-items: center;
  72. }
  73. .btn-container {
  74. margin-top: 57rpx;
  75. width: 500rpx;
  76. height: 100rpx;
  77. border-radius: 20rpx;
  78. background: #2A82E4;
  79. font-size: 48rpx;
  80. font-weight: 700;
  81. letter-spacing: 0rpx;
  82. line-height: 69.5rpx;
  83. color: #FFFFFF;
  84. display: flex;
  85. justify-content: center;
  86. align-items: center;
  87. }
  88. }
  89. }
  90. </style>