App.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <script setup>
  2. import {
  3. onLaunch,
  4. onShow,
  5. onError,
  6. onHide
  7. } from '@dcloudio/uni-app';
  8. import {
  9. ShoproInit
  10. } from './sheep';
  11. import {
  12. autoSign,
  13. cancelAutoSign,
  14. resetSignStatusIfNeeded
  15. } from './sheep/hooks/useModal';
  16. onShow((options) => {
  17. const cacheCleared = uni.getStorageSync('cacheCleared');
  18. const appLaunched = uni.getStorageSync('appLaunched');
  19. const returnedFromWeChat = uni.getStorageSync('returnedFromWeChat');
  20. if (!cacheCleared && appLaunched && !returnedFromWeChat) {
  21. // 清除缓存
  22. uni.removeStorageSync('linkId');
  23. // 设置标志位,表示缓存已清除
  24. uni.setStorageSync('cacheCleared', true);
  25. // 设置标志位,表示缓存已清除,避免后续清除
  26. uni.setStorageSync('returnedFromWeChat', true);
  27. }
  28. autoSign()
  29. // #ifdef APP-PLUS
  30. // 获取urlSchemes参数
  31. const args = plus.runtime.arguments;
  32. if (args) {}
  33. // 获取剪贴板
  34. uni.getClipboardData({
  35. success: (res) => {},
  36. });
  37. // #endif
  38. // #ifdef MP-WEIXIN
  39. // 确认收货回调结果
  40. // console.log(options, 'options');
  41. // #endif
  42. });
  43. onHide(() => {
  44. // console.log("页面隐藏了,取消自动签到");
  45. cancelAutoSign()
  46. });
  47. onLaunch(() => {
  48. // 设置标志位,表示应用已启动
  49. uni.setStorageSync('appLaunched', true);
  50. // 每次启动时,清除从微信页面返回的标志位
  51. uni.removeStorageSync('returnedFromWeChat');
  52. // 隐藏原生导航栏 使用自定义底部导航
  53. uni.hideTabBar();
  54. // 加载Shopro底层依赖
  55. ShoproInit();
  56. // 每天凌晨重置签到状态
  57. resetSignStatusIfNeeded();
  58. });
  59. onError((err) => {
  60. console.log('AppOnError:', err);
  61. });
  62. </script>
  63. <style lang="scss">
  64. @import '@/sheep/scss/index.scss';
  65. </style>