/*** 用户点击右上角分享*/onShareAppMessage: function () {const pages = getCurrentPages();const currentPage = pages[pages.length - 1];return this.getPageShareInfo(currentPage);},onShareTimeline : function () {const pages = getCurrentPages();const currentPage = pages[pages.length - 1];return this.getPageShareInfo(currentPage);},getPageShareInfo(page) {return function (res) {// --- 步骤 1: 从页面 data 中读取分享信息 ---const { shareTitle, shareImage, sharePath, shareQuery } = page.data;// --- 步骤 2: 智能生成分享内容 ---const title = shareTitle || '默认分享标题';// 处理路径和参数const basePath = sharePath || `/${page.route}`; // 优先使用 sharePath,否则使用当前页面路径const queryParams = shareQuery || page.options; // 优先使用 shareQuery,否则使用页面跳转时的参数const fullPath = this._buildPathWithParams(basePath, queryParams);// 处理图片const imageUrl = shareImage || '/images/default-share.jpg';return {title: title,path: fullPath,imageUrl: imageUrl,};};},