|
@@ -9,6 +9,7 @@
|
|
</route>
|
|
</route>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
|
+import { getConfigByCode } from '@/api/common'
|
|
import { pendingRedDots } from '@/api/order'
|
|
import { pendingRedDots } from '@/api/order'
|
|
import { getWalletAccountInfo } from '@/api/wallet'
|
|
import { getWalletAccountInfo } from '@/api/wallet'
|
|
import { t } from '@/locale'
|
|
import { t } from '@/locale'
|
|
@@ -45,38 +46,64 @@ const menuList = ref([
|
|
{ name: t('mine.menu.address'), url: '/pages/mine/addressBook', icon: '/static/icons/address-book.png' },
|
|
{ name: t('mine.menu.address'), url: '/pages/mine/addressBook', icon: '/static/icons/address-book.png' },
|
|
{ name: t('mine.menu.share'), url: '/pages/mine/share', icon: '/static/icons/share.png' },
|
|
{ name: t('mine.menu.share'), url: '/pages/mine/share', icon: '/static/icons/share.png' },
|
|
{ name: t('mine.menu.favorite'), url: '/pages/mine/myFavorite', icon: '/static/icons/my-favorite.png' },
|
|
{ name: t('mine.menu.favorite'), url: '/pages/mine/myFavorite', icon: '/static/icons/my-favorite.png' },
|
|
- { name: t('mine.menu.chat'), icon: '/static/icons/live-chat.png' },
|
|
|
|
- { name: t('mine.menu.activity'), url: '/pages/referEarn/referEarn', icon: '/static/icons/activity-group.png' },
|
|
|
|
|
|
+ { name: t('mine.menu.chat'), config: 'live_chat', icon: '/static/icons/live-chat.png' },
|
|
|
|
+ { name: t('mine.menu.activity'), config: 'activity_group', icon: '/static/icons/activity-group.png' },
|
|
])
|
|
])
|
|
-function menuClick(item: any) {
|
|
|
|
|
|
+async function getConfig(code: string) {
|
|
|
|
+ try {
|
|
|
|
+ let value = ''
|
|
|
|
+ const res = await getConfigByCode({ code })
|
|
|
|
+ if (res.code === '200') {
|
|
|
|
+ switch (code) {
|
|
|
|
+ case 'live_chat':
|
|
|
|
+ value = res.data.valueInfo
|
|
|
|
+ break
|
|
|
|
+ case 'activity_group':
|
|
|
|
+ value = res.data.valueInfo
|
|
|
|
+ break
|
|
|
|
+ default:
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return value
|
|
|
|
+ }
|
|
|
|
+ catch {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+async function menuClick(item: any) {
|
|
if (item.url) {
|
|
if (item.url) {
|
|
toPage({ url: item.url })
|
|
toPage({ url: item.url })
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- openWhatsApp()
|
|
|
|
|
|
+ const res = await getConfig(item.config)
|
|
|
|
+ openWhatsApp(item.config, res)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// 跳转whatsapp
|
|
// 跳转whatsapp
|
|
-function openWhatsApp() {
|
|
|
|
|
|
+function openWhatsApp(config: string, value: string = '') {
|
|
// 判断手机是否安装whatsapp
|
|
// 判断手机是否安装whatsapp
|
|
// pname:Android 需要查询的包名 action:ios 需要查询的 URL Scheme
|
|
// pname:Android 需要查询的包名 action:ios 需要查询的 URL Scheme
|
|
|
|
+ const pname = 'com.whatsapp'
|
|
|
|
+
|
|
// installed ture:安装 false:未安装
|
|
// installed ture:安装 false:未安装
|
|
const installed = plus.runtime.isApplicationExist({
|
|
const installed = plus.runtime.isApplicationExist({
|
|
- pname: 'com.whatsapp',
|
|
|
|
|
|
+ pname,
|
|
action: 'whatsapp://',
|
|
action: 'whatsapp://',
|
|
})
|
|
})
|
|
- // 电话号码
|
|
|
|
- const phoneNumber = '+8615058371889'
|
|
|
|
- // whatsapp 联系人聊天页面链接
|
|
|
|
- const whatsappUrl = `whatsapp://send?phone=${phoneNumber}`
|
|
|
|
|
|
+
|
|
// whatsapp包名
|
|
// whatsapp包名
|
|
- const pname = 'com.whatsapp'
|
|
|
|
|
|
|
|
// 判断手机系统,走不同方法
|
|
// 判断手机系统,走不同方法
|
|
if (plus.os.name === 'Android') {
|
|
if (plus.os.name === 'Android') {
|
|
if (installed) {
|
|
if (installed) {
|
|
// 手机已安装 直接跳转
|
|
// 手机已安装 直接跳转
|
|
- plus.runtime.openURL(whatsappUrl)
|
|
|
|
|
|
+ if (config === 'live_chat') {
|
|
|
|
+ plus.runtime.openURL(`whatsapp://send?phone=${value}`)
|
|
|
|
+ }
|
|
|
|
+ else if (config === 'activity_group') {
|
|
|
|
+ plus.runtime.openURL(`https://chat.whatsapp.com/${value}`)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
// 手机未安装,跳转到手机商城并搜索whatsapp (国内目前搜不到)
|
|
// 手机未安装,跳转到手机商城并搜索whatsapp (国内目前搜不到)
|