xiongzhu 3 lat temu
rodzic
commit
480eb54a9b
1 zmienionych plików z 11 dodań i 18 usunięć
  1. 11 18
      src/App.vue

+ 11 - 18
src/App.vue

@@ -31,11 +31,11 @@
                         <img class="bg" src="@/assets/bg_customer.png" />
                         <div class="item-content">
                             <img src="@/assets/icon_customer.png" class="icon" />
-                            <div class="info" @click="copyText(item.phone)">
+                            <div class="info" @click="copyText(item.account)">
                                 <div class="name">{{ $t('common.customerService') }}</div>
-                                <div class="num">WhatsApp: {{ item.phone }}</div>
+                                <div class="num">{{ item.type }}: {{ item.account }}</div>
                             </div>
-                            <div class="btn-open" @click="open(item.phone)">{{ $t('common.open') }}</div>
+                            <div class="btn-open" @click="open(item)">{{ $t('common.open') }}</div>
                         </div>
                     </div>
                     <div class="tips">{{ $t('common.serviceTime') }}</div>
@@ -100,19 +100,8 @@ onMounted(() => {
     useSystemStore().getSysConfigs()
     emitter.on('promptLogin', promptLogin)
     emitter.on('customer', customer)
-    http.get('/sysConfig/get/CUSTOMER_SERVICE').then(res => {
-        customers.value = res.value
-            .replace(/:/g, ':')
-            .replace(/,/g, ',')
-            .split(',')
-            .map(i => {
-                if (i.includes(':')) {
-                    const [name, phone] = i.split(':')
-                    return { name, phone }
-                } else {
-                    return { name: t('common.customerService'), phone: i }
-                }
-            })
+    http.get('/sysConfig/get/customer_json').then(res => {
+        customers.value = JSON.parse(res.value)
     })
 })
 onBeforeUnmount(() => {
@@ -134,8 +123,12 @@ async function copyText(text) {
     }
     taost(t('common.copied'))
 }
-async function open(phone) {
-    await AppLauncher.openUrl({ url: `whatsapp://send?phone=${phone}` })
+async function open(item) {
+    if (item.type === 'WhatsApp') {
+        await AppLauncher.openUrl({ url: `https://wa.me/${item.account}` })
+    } else if (item.type === 'Telegram') {
+        await AppLauncher.openUrl({ url: `https://t.me/${item.account}` })
+    }
 }
 provide('showCS', () => {
     showCustmer.value = true