index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <route lang="yaml">
  2. style:
  3. navigationBarTitleText: 登录
  4. </route>
  5. <script lang="ts" setup>
  6. import { weixinMiniAppLogin } from '@/core/libs/requests'
  7. import { logo } from '@/core/libs/svgs'
  8. import { useUserStore } from '@/store'
  9. import { loginAccountIcon, loginPswIcon, loginPswEye } from '@designer-hub/assets/src/svgs'
  10. const userStore = useUserStore()
  11. const { setUserInfo } = userStore
  12. const loginCode = ref('')
  13. const phoneCode = ref('')
  14. const loginType = ref('weixin')
  15. const loginTypeOption = ref([
  16. {
  17. value: 'weixin',
  18. text: '微信',
  19. },
  20. {
  21. value: 'univerify',
  22. text: '一键登录',
  23. },
  24. {
  25. value: 'username',
  26. text: '账号密码',
  27. },
  28. {
  29. value: 'smsCode',
  30. text: '手机验证码',
  31. },
  32. ])
  33. const toLogin = () => {
  34. if (loginType.value === 'username') {
  35. uni.navigateTo({
  36. url: '/uni_modules/uni-id-pages/pages/login/login-withpwd',
  37. })
  38. } else {
  39. uni.navigateTo({
  40. url: '/pages/login/login-withoutpwd?type=' + loginType.value,
  41. animationType: 'none',
  42. animationDuration: 0,
  43. })
  44. }
  45. }
  46. const toUserInfoPage = () => {
  47. uni.navigateTo({
  48. url: '/uni_modules/uni-id-pages/pages/userinfo/userinfo?showLoginManage=true',
  49. })
  50. }
  51. const getPhoneNumber = async ({ detail: { code: phoneCode } }) => {
  52. const { code } = await uni.login()
  53. console.log(code, phoneCode)
  54. const { data } = await weixinMiniAppLogin(phoneCode, code, '9b2ffbc1-7425-4155-9894-9d5c08541d62')
  55. setUserInfo({
  56. token: data.accessToken,
  57. userId: data.userId,
  58. accessToken: data.accessToken,
  59. refreshToken: data.refreshToken,
  60. expiresTime: data.expiresTime,
  61. openid: data.openid,
  62. })
  63. uni.switchTab({
  64. url: '/pages/mine/index',
  65. })
  66. }
  67. const getTestCode = async ({ detail }) => {
  68. phoneCode.value = detail.code
  69. const { code } = await uni.login()
  70. loginCode.value = code
  71. }
  72. </script>
  73. <template>
  74. <div class="flex-grow flex flex-col items-center justify-start px-7.5 bg-[#ffffff] pt-[100px]">
  75. <div class="flex flex-col justify-start mb-[57px] title">
  76. <div class="text-black text-2xl font-normal font-['PingFang SC']">你好!</div>
  77. <div class="text-black text-2xl font-normal font-['PingFang SC'] mt-[9px]">
  78. 欢迎来到筑巢荟
  79. </div>
  80. </div>
  81. <div class="w-full form">
  82. <div class="bg-[#F6F6F6] item mb-[10px] flex items-center">
  83. <wd-img :src="loginAccountIcon" mode="widthFix" width="19px" class="mr-[16px]" />
  84. <wd-input type="number" placeholder="请输入手机号" />
  85. </div>
  86. <div class="bg-[#F6F6F6] item flex items-center">
  87. <wd-img :src="loginPswIcon" mode="widthFix" width="19px" class="mr-[16px]" />
  88. <wd-input type="number" placeholder="请输入密码" />
  89. </div>
  90. </div>
  91. <div class="w-full flex items-center justify-between mt-[19px]">
  92. <wd-checkbox :modelValue="true" shape="square">记住密码</wd-checkbox>
  93. <div class="text-[#2357e9] text-xs font-normal font-['PingFang SC']">忘记密码?</div>
  94. </div>
  95. <div class="w-full mt-[50px]"><wd-button block :round="false">登录</wd-button></div>
  96. <div class="mt-8">
  97. <span class="text-black/40 text-xs font-normal font-['PingFang SC'] leading-tight">
  98. 登录即代表您已阅读并同意筑巢荟的
  99. </span>
  100. <span class="text-[#2357e9] text-xs font-normal font-['PingFang SC'] leading-tight">
  101. 《服务使用协议》
  102. </span>
  103. </div>
  104. </div>
  105. </template>
  106. <style lang="scss">
  107. .title {
  108. width: 100%;
  109. }
  110. .form {
  111. .item {
  112. border-radius: 10px;
  113. // height: 50px;
  114. padding: 10px;
  115. :deep(.wd-input) {
  116. background: transparent;
  117. height: 100%;
  118. border: none;
  119. width: 100%;
  120. }
  121. }
  122. }
  123. </style>