import { createPublish } from "applet-page-component"; import { queryToUrl } from "./index"; const getOptions = () => ({ ...createPublish(), data: { pageType: undefined, componentData: undefined, query: {}, title: "", header: "show", background: "#1677FF", color: "#fff", backBtnColor: "#000000", }, onReadyHeader({ height }) { const { componentData = {} } = this.data; componentData.headerHeight = height; this.setData({ componentData: { ...componentData }, }); }, onLoad(query) { const { title, pageType, header = "show", background, color, backBtnColor, ...other } = query; title && my.setNavigationBar({ title, backgroundColor: background || "#1677FF", }); const { globalData } = getApp(); const { pageTemp = {} } = globalData; const componentData = pageTemp[pageType] || {}; this.setData({ title, header, pageType, componentData, query: other, background: background || "#1677FF", color: color || "#fff", backBtnColor: backBtnColor || false, }); }, onUnload() { if (getApp().globalData.pageTemp) { delete getApp().globalData.pageTemp[this.data.pageType]; } }, // 分享 onShareAppMessage() { const { pageType, query, title } = this.data; return { title, path: `${this.route}?pageType=${pageType}&title=${title}${queryToUrl( query )}`, }; }, }); export default getOptions;