page.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!-- 自定义页面:支持装修 -->
  2. <template>
  3. <s-layout
  4. :title="state.name"
  5. navbar="custom"
  6. :bgStyle="state.page"
  7. :navbarStyle="state.navigationBar"
  8. onShareAppMessage
  9. showLeftButton
  10. >
  11. </s-layout>
  12. </template>
  13. <script setup>
  14. import { reactive } from 'vue';
  15. import { onLoad, onPageScroll } from '@dcloudio/uni-app';
  16. import DiyApi from '@/common/api/promotion/diy';
  17. const state = reactive({
  18. name: '',
  19. components: [],
  20. navigationBar: {},
  21. page: {},
  22. });
  23. onLoad(async (options) => {
  24. let id = options.id
  25. // #ifdef MP
  26. // 小程序预览自定义页面
  27. if (options.scene) {
  28. const sceneParams = decodeURIComponent(options.scene).split('=');
  29. id = sceneParams[1];
  30. }
  31. // #endif
  32. const { code, data } = await DiyApi.getDiyPage(id);
  33. if (code === 0) {
  34. state.name = data.name;
  35. state.components = data.property?.components;
  36. state.navigationBar = data.property?.navigationBar;
  37. state.page = data.property?.page;
  38. }
  39. });
  40. onPageScroll(() => {});
  41. </script>
  42. <style></style>