App.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <script setup lang="ts">
  2. import { onLaunch, onShow, onHide, onReady } from "@dcloudio/uni-app";
  3. import {useAddressStore} from "~/stores/addressStore";
  4. import {useGlobalData} from "@uni-helper/uni-use";
  5. import {useUserStore} from "~/stores/userStore";
  6. const addressStore = useAddressStore()
  7. const that = this
  8. const privacyData = uni.getStorageSync('PRIVACY')
  9. const userStore = useUserStore()
  10. onLaunch(() => {
  11. console.log("App Launch");
  12. // that.globalData = {
  13. // privacyContractName: '' ,
  14. // showPrivacy: false,
  15. // }
  16. wx.getPrivacySetting({
  17. success(res) {
  18. // console.log('是否需要授权:', res.needAuthorization, '隐私协议的名称为:', res.privacyContractName);
  19. if (res.needAuthorization) {
  20. uni.setStorageSync('PRIVACY', { privacyContractName: res.privacyContractName, showPrivacy: true})
  21. // that.globalData.privacyContractName = res.privacyContractName
  22. // that.globalData.showPrivacy = true
  23. // globalData.privacyContractName = res.privacyContractName;
  24. // app.globalDatashowPrivacy = true;
  25. } else {
  26. // globalData.showPrivacy = false;
  27. // this.globalData.showPrivacy = false
  28. uni.setStorageSync('PRIVACY', { privacyContractName: res.privacyContractName, showPrivacy: false})
  29. }
  30. }
  31. });
  32. // #ifdef MP-WEIXIN
  33. wx.onAppRoute((res) => {
  34. // console.log('路由监听',res)
  35. if (res.openType === 'switchTab') {
  36. if (res.path === "pages/order_addcart/index") {
  37. }
  38. // console.log(res)
  39. // #ifdef MP-WEIXIN
  40. // wx.hideTabBar()
  41. // #endif
  42. }
  43. })
  44. // #endif
  45. });
  46. // useGlobalData()
  47. onShow(() => {
  48. console.log("App Show");
  49. addressStore.getCurrentAddress()
  50. });
  51. onHide(() => {
  52. console.log("App Hide");
  53. });
  54. onReady(() => {
  55. const app = getApp()
  56. app.globalData = {
  57. privacyContractName: '', //隐私协议的名字
  58. showPrivacy: false //控制隐私弹窗显隐
  59. }
  60. // const that = this;
  61. // wx.getPrivacySetting({
  62. // success(res) {
  63. // console.log('是否需要授权:', res.needAuthorization, '隐私协议的名称为:', res.privacyContractName);
  64. // if (res.needAuthorization) {
  65. // globalData.privacyContractName = res.privacyContractName;
  66. // app.globalDatashowPrivacy = true;
  67. // } else {
  68. // globalData.showPrivacy = false;
  69. // }
  70. // }
  71. // });
  72. })
  73. </script>
  74. <style lang="scss">
  75. @import 'nutui-uniapp/styles/index';
  76. </style>