//允许分享的页面路由 var showShareUrls = ['pages/index/index', //首页 'pages/index/blindBoxPage', //盲盒活动 'pages/index/blindBoxPageOpen2', //盲盒活动 'pages/product/index', //项目首页 'pages/product/list', //项目列表 'pages/product/detalis', //项目详情 'pages/product/searchlis', //项目搜索 'pages/school/index', //学堂 'pages/school/content', 'pages/other/QuestionAndAnswer', //常见问题 'pages/report/checkingIndex', //报告验真 'pages/invitation/InvitationIndex', //邀请好友 'pages/other/howToSample', //如何采样 'pages/other/orderprocess', //下单流程 'pages/other/aboutUs', //关于我们 'pages/breed/breedhome',//繁育计算器 ]; //无需登录页面 var noLogins = [ 'pages/my/bind', ]; noLogins = noLogins.concat(showShareUrls); ! function () { //获取页面配置并进行页面分享配置 var PageTmp = Page Page = function (pageConfig) { //全局关闭分享 var pageOnLoad = pageConfig.onLoad; var pageOnShow = pageConfig.onShow; pageConfig = Object.assign(pageConfig, { //暂存页面加载事件 pageOnLoad: pageOnLoad, //重写页面加载事件和onShow onLoad: function (options) { var that = this; //获取当前页面路由 let pages = getCurrentPages(); let currPage = null; if (pages.length) { currPage = pages[pages.length - 1]; } // console.log("新onLoad"); //当前页面是否不允许分享 if (!showShareUrls.some(function (url) { return currPage.route.includes(url); })) { //禁止分享 wx.hideShareMenu(); } if (that.pageOnLoad) that.pageOnLoad(options); // //在线静态图片存放位置 // that.setData({ImgDomain:"https://api.catdogtest.com"}); }, pageOnShow: pageOnShow, onShow: function (options) { // console.log("新onShow"); var that = this; //获取当前页面路由 let pages = getCurrentPages(); let currPage = null; if (pages.length) { currPage = pages[pages.length - 1]; } if (that.pageOnShow) that.pageOnShow(options); } }); //在线静态图片存放位置 pageConfig.data.ImgDomain="https://api.catdogtest.com"; // 配置页面模板 PageTmp(pageConfig); } }();