index.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <view class="page">
  3. <navBar title="隐私弹窗" :back="true" color="white" background="green" />
  4. <button v-if="showPrivacy" class="btn" @click="getPrivacy">获取头像</button>
  5. <!-- <button v-else class="btn" open-type="getPhoneNumber" @getphonenumber="onGetPhoneNumber">手机号快捷登录</button> -->
  6. <button v-else class="btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
  7. 获取头像
  8. </button>
  9. <privacy-popup ref="privacyPopup" @confirm="confirm"></privacy-popup>
  10. </view>
  11. </template>
  12. <script>
  13. import PrivacyPopup from "@/components/privacyPopup/index.vue";
  14. export default {
  15. components: {
  16. PrivacyPopup
  17. },
  18. data() {
  19. return {
  20. showPrivacy: getApp().globalData.showPrivacy,
  21. // showPrivacy: true,
  22. }
  23. },
  24. onLoad(options) {},
  25. methods: {
  26. confirm() {
  27. this.showPrivacy = false;
  28. },
  29. getPrivacy() {
  30. if (getApp().globalData.showPrivacy) {
  31. // if (true) {
  32. this.$refs.privacyPopup.$refs.popup.open();
  33. return;
  34. }
  35. },
  36. // 获取手机号
  37. onGetPhoneNumber(e) {
  38. // 用户拒绝授权
  39. if (e.detail.errMsg == "getPhoneNumber:fail:user deny") {
  40. uni.showToast({
  41. icon: 'none',
  42. title: '用户拒绝'
  43. });
  44. } else if (e.detail.code) { // 允许授权
  45. this.loginWeiXin(e.detail.code);
  46. }
  47. },
  48. }
  49. }
  50. </script>
  51. <style lang="scss" scoped>
  52. @import "./index.scss";
  53. </style>