1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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 },
- });
- },
- async onLoad(query) {
- const {
- title,
- pageType,
- header = "show",
- background,
- color,
- backBtnColor,
- ...other
- } = query;
- title &&
- my.setNavigationBar({
- title,
- backgroundColor: background || "#1677FF",
- });
- const app = getApp();
- const { globalData } = app;
- const { pageTemp = {} } = globalData;
- const componentData = pageTemp[pageType] || {};
- this.setData({
- title,
- header,
- pageType,
- componentData,
- query: other,
- background: background || "#1677FF",
- color: color || "#fff",
- backBtnColor: backBtnColor || false,
- });
- if (!app.globalData.templateUUID) {
- // 如果没有页面配置,需要获取页面配置,否则下面bind的时候没有templateUUID
- await this.dispatch("init", query);
- title &&
- my.setNavigationBar({
- title,
- backgroundColor: background || "#1677FF",
- });
- }
- },
- 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;
|