authorization.vue 1.5 KB

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