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
- }
- });
- },
- 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;
|