AuthorizePopup.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <wd-popup v-model="localShow" position="bottom" closable safe-area-inset-bottom custom-class="popup-wrapper-auth" @close="emits('close', false)">
  3. <view class="content">
  4. <view class="title">
  5. <view>欢迎使用</view>
  6. <view class="font-bold">墨轩校团</view>
  7. </view>
  8. <image class="img" src="https://school.meiyishuo.cn/20250822/1/09/1958704126647894017_logo.png" mode="aspectFill"></image>
  9. <view class="btns">
  10. <view class="btn_box">手机号快速验证</view>
  11. <button class="auth_box" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" />
  12. </view>
  13. </view>
  14. </wd-popup>
  15. </template>
  16. <script setup>
  17. import { ref, watch } from 'vue'
  18. import { myRequest } from '@/utils/api.ts'
  19. defineOptions({
  20. options: {
  21. styleIsolation: 'shared'
  22. }
  23. })
  24. const props = defineProps({
  25. show: {
  26. type: Boolean,
  27. default: false
  28. }
  29. })
  30. const emits = defineEmits(['update:show', 'close'])
  31. const localShow = ref(props.show)
  32. const info = ref({
  33. nickname: '微信用户',
  34. code1: '',
  35. code2: ''
  36. })
  37. watch(
  38. () => props.show,
  39. (val) => {
  40. localShow.value = val
  41. }
  42. )
  43. watch(localShow, (val) => {
  44. if (val !== props.show) {
  45. emits('update:show', val)
  46. }
  47. })
  48. const isRead = ref(false)
  49. function getPhoneNumber(e) {
  50. // console.log(e)
  51. if (e.detail.code) {
  52. info.value.code2 = e.detail.code
  53. uni.login({
  54. provider: 'weixin',
  55. success: (loginRes) => {
  56. // console.log(loginRes)
  57. if (loginRes.code) {
  58. info.value.code1 = loginRes.code
  59. // console.log(info.value)
  60. authorize()
  61. }
  62. }
  63. })
  64. }
  65. }
  66. // 授权接口
  67. const authorize = async () => {
  68. const res = await myRequest({
  69. url: '/tAppgetOpenid.action',
  70. data: info.value
  71. })
  72. // console.log(res)
  73. if (res.code == 200) {
  74. uni.setStorageSync('carUserInfo', res.data)
  75. emits('close', true)
  76. }
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .content {
  81. display: flex;
  82. flex-direction: column;
  83. align-items: center;
  84. padding: 32rpx;
  85. height: 500rpx;
  86. background: #fff;
  87. .title {
  88. }
  89. .img {
  90. margin-top: 96rpx;
  91. margin-bottom: 48rpx;
  92. width: 200rpx;
  93. height: 200rpx;
  94. }
  95. .btns {
  96. position: relative;
  97. height: 72rpx;
  98. width: 100%;
  99. .btn_box {
  100. position: absolute;
  101. top: 0;
  102. left: 0;
  103. bottom: 0;
  104. height: 100%;
  105. width: 100%;
  106. display: flex;
  107. align-items: center;
  108. justify-content: center;
  109. color: #fff;
  110. border-radius: 20rpx;
  111. background-color: #ff8205;
  112. }
  113. .auth_box {
  114. position: absolute;
  115. top: 0;
  116. left: 0;
  117. bottom: 0;
  118. height: 100%;
  119. width: 100%;
  120. opacity: 0;
  121. }
  122. }
  123. }
  124. // .auth-box {
  125. // position: absolute;
  126. // top: 0;
  127. // left: 0;
  128. // bottom: 0;
  129. // height: 72rpx;
  130. // width: 100%;
  131. // // background-color: salmon;
  132. // // @apply absolute top-0 left-0 h-full w-full rounded-full opacity-0;
  133. // }
  134. // .auth-checkbox-wrapper {
  135. // display: flex !important;
  136. // align-items: baseline;
  137. // /* stylelint-disable-next-line selector-class-pattern */
  138. // :deep(.wd-checkbox__shape) {
  139. // // @apply shrink-0;
  140. // }
  141. // }
  142. </style>