diff --git a/src/mixins/share.js b/src/mixins/share.js new file mode 100644 index 0000000..fbca792 --- /dev/null +++ b/src/mixins/share.js @@ -0,0 +1,35 @@ +import config from '@/config.js' + +const SHARE_HOME = '/pages/login' +const SHARE_TITLES = { + 'intc-invest-app': '智聪记账管理平台', + 'intc-health-app': '暖康档案管理平台' +} + +function getShareTitle() { + return SHARE_TITLES[config.appInfo?.name] || config.appInfo?.name || '智聪管理平台' +} + +function showShareMenu() { + // #ifdef MP-WEIXIN + uni.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage'] + }) + // #endif +} + +export default { + onLoad() { + showShareMenu() + }, + onShow() { + showShareMenu() + }, + onShareAppMessage() { + return { + title: getShareTitle(), + path: SHARE_HOME + } + } +} diff --git a/src/pages_mine/pages/about/index.vue b/src/pages_mine/pages/about/index.vue index 528765b..48c8c36 100644 --- a/src/pages_mine/pages/about/index.vue +++ b/src/pages_mine/pages/about/index.vue @@ -36,7 +36,23 @@ import { computed } from 'vue' import config from '@/config.js' const url = config.appInfo.site_url -const version = config.appInfo.version +// 动态获取版本号 +// - 微信小程序:优先读取小程序后台提交发布时填写的版本号,为空时回退到 config +// 注:在微信开发者工具中调用时 miniProgram.version 通常为空字符串, +// 只有体验版/正式版发布后才有真实值 +// - 其他端(H5/APP):使用 config 中的版本号 +let version = config.appInfo.version +// #ifdef MP-WEIXIN +try { + const accountInfo = uni.getAccountInfoSync() + const mpVersion = accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.version + if (mpVersion) { + version = mpVersion + } +} catch (e) { + console.warn('getAccountInfoSync 调用失败,使用 config 中的版本号:', e) +} +// #endif // 动态显示当前年份 const currentYear = new Date().getFullYear()