authorization.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="content">
  3. <view class="logo">
  4. <img class="img" src="../../static/logo.png">
  5. </view>
  6. <button class="button" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
  7. <img class="img" src="../../static/weixin.svg">
  8. <span>微信一键授权</span>
  9. </button>
  10. </view>
  11. </template>
  12. <script setup>
  13. import {
  14. ref
  15. } from 'vue'
  16. import {
  17. myRequest
  18. } from '../../util/api.js'
  19. const code = ref('')
  20. const getPhoneNumber = async (e) => {
  21. code.value = e.detail.code
  22. if (code.value) {
  23. const res = await myRequest({
  24. url: "/wx/getPhone",
  25. data: {
  26. code: code.value
  27. }
  28. })
  29. // console.log(res);
  30. if (res.success && res.code == 1) {
  31. uni.setStorageSync('wxPhone', res.data)
  32. uni.redirectTo({
  33. url:"/pages/index/index"
  34. })
  35. } else {
  36. uni.showToast({
  37. title: res.message,
  38. icon:'none'
  39. })
  40. }
  41. }
  42. }
  43. </script>
  44. <style lang="scss" scoped>
  45. .content {
  46. width: 100vw;
  47. height: 100vh;
  48. overflow: hidden;
  49. .logo {
  50. margin: 300rpx auto 0;
  51. width: 150rpx;
  52. height: 150rpx;
  53. border-radius: 20rpx;
  54. box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
  55. .img {
  56. width: 100%;
  57. height: 100%;
  58. border-radius: 20rpx;
  59. }
  60. }
  61. .button {
  62. display: flex;
  63. justify-content: center;
  64. align-items: center;
  65. margin: 150rpx auto 0;
  66. width: 600rpx;
  67. height: 100rpx;
  68. font-size: 32rpx;
  69. color: #fff;
  70. border-radius: 50rpx;
  71. background-color: #1E7DFB;
  72. .img {
  73. margin-right: 20rpx;
  74. width: 50rpx;
  75. height: 50rpx;
  76. color: #fff;
  77. }
  78. }
  79. }
  80. </style>