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
    }
  }
}
