Ver Fonte

健康检测获取customerid

“hanlingqiang há 1 ano atrás
pai
commit
9db8ec4f77
6 ficheiros alterados com 45 adições e 4 exclusões
  1. 2 0
      .env.development
  2. 1 0
      .env.production
  3. 11 0
      src/api/home.ts
  4. 6 0
      src/utils/request.ts
  5. 19 4
      src/views/index.vue
  6. 6 0
      vite.config.ts

+ 2 - 0
.env.development

@@ -6,6 +6,8 @@ VITE_APP_ENV = 'development'
 
 # 开发环境
 VITE_APP_BASE_API = '/dev-api'
+VITE_APP_HEALTH_API = '/zhylsia'
+
 
 # 应用访问路径 例如使用前缀 /admin/
 VITE_APP_CONTEXT_PATH = '/'

+ 1 - 0
.env.production

@@ -15,6 +15,7 @@ VITE_APP_XXL_JOB_ADMIN = '/xxl-job-admin'
 
 # 生产环境
 VITE_APP_BASE_API = '/prod-api'
+VITE_APP_HEALTH_API = '/zhylsia'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip

+ 11 - 0
src/api/home.ts

@@ -5,6 +5,7 @@ enum Api {
   deviceList = '/home/device', //设备
   deviceCategory = '/home/deviceCategory', //设备数量统计
   deviceStates = '/home/deviceStates', //设备状态统计
+  customerApi = '/zhylsia/userApi.action',
 }
 
 // 获取品类
@@ -47,3 +48,13 @@ export const deviceStates = (data) => {
     data,
   })
 }
+
+// 拿着用户信息转customerid
+export const customerApi = (params) => {
+  return request({
+    url: Api.customerApi,
+    method: 'get',
+    params,
+    type: 'health',
+  })
+}

+ 6 - 0
src/utils/request.ts

@@ -30,6 +30,12 @@ service.interceptors.request.use(
     // 对应国际化资源文件后缀
     config.headers['Content-Language'] = getLanguage()
 
+    if (config.type === 'health') {
+      config.baseURL = import.meta.env.VITE_APP_HEALTH_API
+    } else {
+      config.baseURL = import.meta.env.VITE_APP_BASE_API
+    }
+
     const isToken = (config.headers || {}).isToken === false
     // 是否需要防止数据重复提交
     const isRepeatSubmit = (config.headers || {}).repeatSubmit === false

+ 19 - 4
src/views/index.vue

@@ -78,7 +78,7 @@
 </template>
 
 <script setup name="Index" lang="ts">
-import { categoryList, productList, deviceList, deviceCategory,deviceStates } from '@/api/home'
+import { categoryList, productList, deviceList, deviceCategory,deviceStates,customerApi} from '@/api/home'
 import * as echarts from 'echarts'
 import { md5Encrypt } from '@/utils/jsencrypt'
 import home_1 from '@/assets/images/home/home_1.png'
@@ -446,7 +446,7 @@ const getDataList = async () => {
 const goTarget = (url: string) => {
   window.open(url, '__blank')
 }
-const jumpweb =(type) => {
+const jumpweb = async (type: any) => {
   let md5Txt = md5Encrypt(String(getName()).toLowerCase())
   let paraStr = `user=${getName()}&token=${md5Txt}`
   switch (type) {
@@ -457,18 +457,33 @@ const jumpweb =(type) => {
       break
     case TypeApi.health:
       {
-        window.open(`https://web.poteviohealth.com/r/daping/health/index.html?${paraStr}`,'_blank')
+        let customerData = await customerApiF(md5Txt)
+        if(customerData['status'] == 0) {
+            // https://web.poteviohealth.com/r/daping/health/index.html?customerId=160
+            window.open(`https://web.poteviohealth.com/r/daping/health/index.html?customerId=${customerData.customerId}`,'_blank')
+        }else {
+            ElMessage.error('跳转出错:'+ JSON.stringify(customerData))
+        }
       }
       break
     case TypeApi.bed:
       {
-        window.open(`https://web.poteviohealth.com/boss/daping/data.html?${paraStr}`,'_blank')
+        window.open(`http://web.poteviohealth.com/boss/daping/data.html?${paraStr}`,'_blank')
       }
       break
     default:
       break
   }
 }
+const customerApiF = async (md5Txt: string) => {
+  const customerData = await customerApi({
+    command:'customerloginiot',
+    account:'iot'+getName(),
+    password: md5Txt,
+    terminalType: 'health'
+  })
+  return customerData
+}
 onMounted(() => {
   getDataList()
 })

+ 6 - 0
vite.config.ts

@@ -31,6 +31,12 @@ export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
           changeOrigin: true,
           rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), ''),
         },
+        [env.VITE_APP_HEALTH_API]: {
+          target: 'https://web.poteviohealth.com',
+          changeOrigin: true,
+          secure: false, //http跨域
+          rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_HEALTH_API), ''),
+        },
       },
     },
     css: {