index.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="app-page"></view>
  3. </template>
  4. <script>
  5. const homePagePath = '/pages/tabbar/home/home'
  6. const startPagePath = '/pagesA/start/start'
  7. const articleDetailPath = '/pagesA/article-detail/article-detail';
  8. export default {
  9. computed: {
  10. configs() {
  11. return this.$tm.vx.getters().getConfigs;
  12. }
  13. },
  14. onLoad: function (options) {
  15. uni.$tm.vx.actions('config/fetchConfigs').then(async (res) => {
  16. if (options.scene) {
  17. if ('' !== options.scene) {
  18. const postId = await this.getPostIdByQRCode(options.scene);
  19. if (postId) {
  20. uni.redirectTo({
  21. url: articleDetailPath + `?name=${postId}`,
  22. animationType: 'slide-in-right'
  23. });
  24. }
  25. }
  26. }
  27. // #ifdef MP-WEIXIN
  28. // uni.$tm.vx.commit('setWxShare', res.shareConfig);
  29. // #endif
  30. // 获取mockjson
  31. if (res.basicConfig.auditModeEnabled) {
  32. await uni.$tm.vx.actions('config/fetchMockJson')
  33. }
  34. // 进入检查
  35. this.fnCheckShowStarted();
  36. }).catch((err) => {
  37. uni.switchTab({
  38. url: homePagePath
  39. });
  40. })
  41. },
  42. methods: {
  43. fnCheckShowStarted() {
  44. if (!this.configs.appConfig.startConfig.enabled) {
  45. uni.switchTab({
  46. url: homePagePath
  47. });
  48. return;
  49. }
  50. // 是否每次都显示启动页
  51. if (this.configs.appConfig.startConfig.alwaysShow) {
  52. uni.removeStorageSync('APP_HAS_STARTED')
  53. uni.redirectTo({
  54. url: startPagePath
  55. });
  56. return;
  57. }
  58. // 只显示一次启动页
  59. if (uni.getStorageSync('APP_HAS_STARTED')) {
  60. uni.switchTab({
  61. url: homePagePath
  62. });
  63. } else {
  64. uni.redirectTo({
  65. url: startPagePath
  66. });
  67. }
  68. },
  69. async getPostIdByQRCode(key) {
  70. const response = await this.$httpApi.v2.getQRCodeInfo(key);
  71. if (response) {
  72. if (response && response.postId) {
  73. return response.postId;
  74. }
  75. }
  76. return null;
  77. }
  78. }
  79. };
  80. </script>