authorization.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. background-color: #fff;
  51. .logo {
  52. margin: 300rpx auto 0;
  53. width: 150rpx;
  54. height: 150rpx;
  55. border-radius: 20rpx;
  56. box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
  57. .img {
  58. width: 100%;
  59. height: 100%;
  60. border-radius: 20rpx;
  61. }
  62. }
  63. .button {
  64. display: flex;
  65. justify-content: center;
  66. align-items: center;
  67. margin: 150rpx auto 0;
  68. width: 600rpx;
  69. height: 100rpx;
  70. font-size: 32rpx;
  71. color: #fff;
  72. border-radius: 50rpx;
  73. background-color: #1E7DFB;
  74. .img {
  75. margin-right: 20rpx;
  76. width: 50rpx;
  77. height: 50rpx;
  78. color: #fff;
  79. }
  80. }
  81. }
  82. </style>