mall-uniapp/pages/index/page.vue

52 lines
1.3 KiB
Vue
Raw Normal View History

2023-12-20 15:01:16 +00:00
<!-- 自定义页面支持装修 -->
2022-11-22 07:45:36 +00:00
<template>
<s-layout
2024-01-11 03:55:24 +00:00
:title="state.name"
2022-11-22 07:45:36 +00:00
navbar="custom"
2024-01-11 03:55:24 +00:00
:bgStyle="state.page"
:navbarStyle="state.navigationBar"
2022-11-22 07:45:36 +00:00
onShareAppMessage
showLeftButton
2022-11-22 07:45:36 +00:00
>
2024-01-11 03:55:24 +00:00
<s-block v-for="(item, index) in state.components" :key="index" :styles="item.property.style">
<s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
2022-11-22 07:45:36 +00:00
</s-block>
</s-layout>
</template>
<script setup>
2024-01-11 03:55:24 +00:00
import { reactive } from 'vue';
2022-11-22 07:45:36 +00:00
import { onLoad, onPageScroll } from '@dcloudio/uni-app';
2024-01-20 09:28:04 +00:00
import DiyApi from '@/sheep/api/promotion/diy';
2022-11-22 07:45:36 +00:00
2024-01-11 03:55:24 +00:00
const state = reactive({
2022-11-22 07:45:36 +00:00
name: '',
2024-01-11 03:55:24 +00:00
components: [],
navigationBar: {},
page: {},
2022-11-22 07:45:36 +00:00
});
onLoad(async (options) => {
2024-01-11 03:55:24 +00:00
let id = options.id
2022-11-22 07:45:36 +00:00
// #ifdef MP
// 小程序预览自定义页面
if (options.scene) {
const sceneParams = decodeURIComponent(options.scene).split('=');
id = sceneParams[1];
}
// #endif
2024-01-20 09:28:04 +00:00
const { code, data } = await DiyApi.getDiyPage(id);
2024-01-11 03:55:24 +00:00
if (code === 0) {
state.name = data.name;
state.components = data.property?.components;
state.navigationBar = data.property?.navigationBar;
state.page = data.property?.page;
2022-11-22 07:45:36 +00:00
}
});
onPageScroll(() => {});
</script>
<style></style>