butlogin.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view>
  3. <uni-popup ref="popup" type="bottom" :mask-click="false" >
  4. <view class="zheshow" >
  5. <view class="cen_ter">
  6. <view class="box_At">
  7. <view class="box_At_text">获取您的手机号</view>
  8. <view class="box_At_co">获取手机号信息,主要用于完善个人资料,向用户提供更好使用体验</view>
  9. <view class="Brn_S">
  10. <button class="btn_btns" @click="colse">取消</button>
  11. <button class="btn" open-type="getPhoneNumber" @getphonenumber="btns" >
  12. 登录
  13. </button>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. </uni-popup>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. props:['zheshow'],
  24. data() {
  25. return {
  26. on_zheshows:false,
  27. zheshow1:false
  28. }
  29. },
  30. watch:{
  31. zheshow() {
  32. this.$refs.popup.open('bottom')
  33. },
  34. },
  35. methods: {
  36. colse(){this.$refs.popup.close()},
  37. btns(e){
  38. // 用户拒绝授权
  39. if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
  40. uni.showToast({title:'已取消授权登录',icon:'none'})
  41. this.$refs.popup.close()
  42. return
  43. }
  44. // 微信返回其他错误(如 errorCode: -10000 系统错误)
  45. if (e.detail.errMsg && e.detail.errMsg.includes('fail')) {
  46. // 开发环境提示:继续登录但使用默认手机号
  47. uni.showModal({
  48. title: '提示',
  49. content: '获取手机号失败(开发环境可忽略)\n是否继续登录?',
  50. success: (res) => {
  51. if (res.confirm) {
  52. // 用户选择继续,使用空code(后端会使用mock手机号)
  53. this.proceedLogin(null)
  54. } else {
  55. this.$refs.popup.close()
  56. }
  57. }
  58. })
  59. return
  60. }
  61. // 成功获取到code,继续登录
  62. this.proceedLogin(e.detail.code)
  63. },
  64. // 执行登录流程
  65. proceedLogin(code) {
  66. // 将微信返回的手机号 code 一并传递给父组件
  67. this.$parent.loset({
  68. code: code || 'mock_dev_code' // 如果没有code,使用mock
  69. })
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .zheshow{
  76. width: 100%;height: 100%;background-color: rgba(0,0,0,0.3);position: fixed;top: 0;left: 0;
  77. display: flex;align-items: center;align-items: flex-end;
  78. .mast{margin-top: 6rpx;}
  79. .Brn_S{width: 100%;height: 100rpx;display: flex;align-items: center;justify-content: space-around;margin: 20rpx 0;}
  80. .btn_btns, .btn{width: 45%;max-width: 300rpx;height: 80rpx;display: flex;align-items: center;
  81. justify-content: center; border-radius: 10rpx;font-size: 30rpx;margin: 0 !important;box-sizing: border-box;}
  82. .btn_btns{background-color: #fafafa;color: #39B54A;}
  83. .btn{background-color: #39B54A;color: #FFFFFF;}
  84. .imgs{position: absolute;right: 6%;width: 32rpx;height: 32rpx;}
  85. .img{width: 90rpx;height: 90rpx;border-radius: 50%;margin-left: 80rpx;image{width: 100%;height: 100%;border-radius: 50%;}}
  86. .cen_ter{
  87. width: 100%;min-height: 300rpx;border-top-left-radius: 30rpx;border-top-right-radius: 30rpx;background-color: #FFFFFF;
  88. display: flex;align-items: center;justify-content: center;
  89. .box_At{width: 90%;padding: 40rpx 0;display: flex;flex-direction: column;.box_At_text{font-weight: bold;font-size: 30rpx}
  90. .box_At_co{font-size: 28rpx;color: #ababab;margin-top: 24rpx;}
  91. }}
  92. }
  93. button {
  94. border-radius: 10rpx;height: 80rpx !important;padding-left: 0!important ;
  95. padding-right: 0!important ;font-family: PingFang SC !important;
  96. }
  97. button:after {
  98. top: 0;left: 0; border: 1px solid rgba(0,0,0,0) !important; -webkit-transform: scale(.5);
  99. transform: scale(.5); -webkit-transform-origin: 0 0; transform-origin: 0 0; box-sizing: border-box; border-radius: 10px;
  100. }
  101. </style>