信达小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.4 KiB

5 months ago
/**
* 使
* 1app.js const page = require('xx/xx/page);
* 2app.js onLaunch Page = page
*/
5 months ago
const originalPage = Page;
5 months ago
function page(config: WechatMiniprogram.Page.Instance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>) {
5 months ago
const originalOnLoad = config.onLoad;
5 months ago
config.onLoad = function (options) {
5 months ago
setImageParams(this);
setNavBar(this);
5 months ago
if (originalOnLoad) {
5 months ago
originalOnLoad.call(this, options);
5 months ago
}
5 months ago
};
5 months ago
5 months ago
const originalOnPageScroll = config.onPageScroll;
5 months ago
config.onPageScroll = function (options): void {
5 months ago
const scrollTop = options?.scrollTop;
let background = 'transparent';
5 months ago
if (Number(scrollTop) > 20) {
5 months ago
background = '#ffffff';
5 months ago
}
this.setData({
background,
5 months ago
});
5 months ago
if (originalOnPageScroll) {
5 months ago
originalOnPageScroll.call(this, options);
5 months ago
}
5 months ago
};
5 months ago
5 months ago
const originalOnShareAppMessage = config.onShareAppMessage;
5 months ago
config.onShareAppMessage = function (options) {
if (originalOnShareAppMessage) {
5 months ago
return originalOnShareAppMessage.call(this, options);
5 months ago
} else {
5 months ago
const date = new Date();
const Timestamp = date.getTime();
5 months ago
5 months ago
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const url = currentPage.route;
const options = currentPage.options;
let urlWithArgs = `${url}?`;
5 months ago
for (const key in options) {
5 months ago
const value = options[key];
urlWithArgs += `${key}=${value}&`;
5 months ago
}
5 months ago
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1);
5 months ago
return {
5 months ago
title: '甲状腺眼病TED规范化诊治中心',
5 months ago
path: url,
5 months ago
// imageUrl: `${getApp().globalData.imageUrl}1/1.png?t=${Timestamp}`,
5 months ago
};
5 months ago
}
5 months ago
};
5 months ago
5 months ago
config.handleMakePhoneCall = function () {
wx.makePhoneCall({
phoneNumber: '4008102299',
5 months ago
});
};
return originalPage(config);
5 months ago
}
function setImageParams(
currPage: WechatMiniprogram.Page.Instance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>,
) {
5 months ago
const date = new Date();
const Timestamp = date.getTime();
5 months ago
currPage.setData({
imageUrl: getApp().globalData.imageUrl,
Timestamp,
5 months ago
});
5 months ago
}
function setNavBar(
currPage: WechatMiniprogram.Page.Instance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>,
) {
currPage.setData({
background: 'transparent',
pageTop: wx.getMenuButtonBoundingClientRect().bottom,
5 months ago
});
5 months ago
}
5 months ago
export default page;