authorization.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.setStorageSync('accredit', true)
  33. uni.redirectTo({
  34. url:"/pages/index/index"
  35. })
  36. } else {
  37. uni.showToast({
  38. title: res.message,
  39. icon:'none'
  40. })
  41. }
  42. }
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .content {
  47. width: 100vw;
  48. height: 100vh;
  49. overflow: hidden;
  50. .logo {
  51. margin: 300rpx auto 0;
  52. width: 150rpx;
  53. height: 150rpx;
  54. border-radius: 20rpx;
  55. box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
  56. .img {
  57. width: 100%;
  58. height: 100%;
  59. border-radius: 20rpx;
  60. }
  61. }
  62. .button {
  63. display: flex;
  64. justify-content: center;
  65. align-items: center;
  66. margin: 150rpx auto 0;
  67. width: 600rpx;
  68. height: 100rpx;
  69. font-size: 32rpx;
  70. color: #fff;
  71. border-radius: 50rpx;
  72. background-color: #1E7DFB;
  73. .img {
  74. margin-right: 20rpx;
  75. width: 50rpx;
  76. height: 50rpx;
  77. color: #fff;
  78. }
  79. }
  80. }
  81. </style>