Browse Source

对接完成

sunran 3 years ago
parent
commit
420be5611a

+ 1 - 1
.env.production

@@ -4,7 +4,7 @@ ENV = 'development'
 # base api
 VUE_APP_BASE_API = 'https://test.poteviohealth.com/pmgw'
 VUE_APP_ZL_JF = 'https://jifen.tjpoteviohealth.com/blade-api'
-VUE_APP_ZL_HEALTH = 'https://test.poteviohealth.com/zhylsia/'
+VUE_APP_ZL_HEALTH = 'https://web.poteviohealth.com/zhylsia/'
 VUE_APP_ZL_WSS = 'https://cdbwss.poteviohealth.com'
 # VUE_APP_ZL_WSS_ZP = 'https://test.poteviohealth.com/prod-api'
 VUE_APP_ZL_WSS_ZP = 'https://web.poteviohealth.com/prod-api'

+ 1 - 1
public/index.html

@@ -10,7 +10,7 @@
         content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
 
     <!-- 开启顶部安全区适配 -->
-    <van-nav-bar safe-area-inset-top />
+    <!-- <van-nav-bar safe-area-inset-top /> -->
 
     <!-- 开启底部安全区适配 -->
     <van-number-keyboard safe-area-inset-bottom />

+ 5 - 1
src/utils/zprequest.js

@@ -29,7 +29,11 @@ service.interceptors.request.use(
             // config.headers['Content-Type'] = 'application/x-www-form-urlencoded'
         }
         if (config.requestBase == 'VUE_APP_ZL_HEALTH') {
-            config.headers['authToken'] = 'DXxTtBm3yhBCsmykpDCjW422A8D7epTAd41ef403-8135-4f2e-bb96-1771062d2637'
+            console.log(JSON.parse(sessionStorage.getItem('healthUser')), 'healthUser')
+            if (JSON.parse(sessionStorage.getItem('healthUser'))) {
+                config.headers['authToken'] = JSON.parse(sessionStorage.getItem('healthUser')).authToken
+            }
+
             config.baseURL = process.env.VUE_APP_ZL_HEALTH;
         }
         if (config.type === 'change') {

+ 149 - 4
src/views/zhulao/components/Tabbar.vue

@@ -11,6 +11,7 @@
   </div>
 </template>
 <script>
+import { userApi } from '../api/index.js'
 export default {
   data() {
     return {
@@ -52,22 +53,45 @@ export default {
           text: '健康管理',
         },
       ],
+      appmark: 'sdzwapp',
     }
   },
   created() {},
   methods: {
     beforeChange(e) {
-      console.log(e, '切换前')
       if (e == 3) {
-        this.getUserInfo()
+        if (!sessionStorage.getItem('userInfo')) {
+          this.getUserInfo()
+        } else {
+          return true
+        }
       } else {
         return true
       }
     },
+    async userApi() {
+      var userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
+      //   var mobile = '13895651855'
+      const res = await userApi({
+        command: 'reguserbyweixinphone',
+        contactsPhone: userInfo.mobile,
+        // contactsPhone: mobile,
+        terminalType: 5,
+      })
+      sessionStorage.setItem('healthUser', JSON.stringify(res))
+      //   this.$toast(userInfo.name + '接口')
+      //   this.$dialog
+      //     .alert({
+      //       message: res.uname + '--------' + userInfo.name,
+      //     })
+      //     .then(() => {})
+      this.$router.push({ path: '/healthAssessmen' })
+    },
     /**
      * 通过jssdk方法获取APP本地用户票据
      */
     getUserInfo() {
+      var that = this
       lightAppJssdk.user.getTicket({
         success: function (data) {
           //成功回调
@@ -80,7 +104,7 @@ export default {
               var dataValueObj = JSON.parse(jsonData.data)
               var ticket = dataValueObj.ticket //解析出用户票据信息
               userType = dataValueObj.usertype //解析保存用户类型(个人法人)
-              getUserToken(ticket)
+              that.getUserToken(ticket)
             }
           }
         },
@@ -95,6 +119,7 @@ export default {
      * 使用jssdk调用登录页面
      */
     onLoginApp() {
+      var that = this
       lightAppJssdk.user.loginapp({
         success: function (data) {
           if (data == '未登录') {
@@ -105,7 +130,7 @@ export default {
             if (dataObj.retcode == '000000') {
               //登录成功,返回用户的票据和用户类型
               var dataValueObj = JSON.parse(dataObj.data)
-              getUserToken(dataValueObj.ticket) //解析出用户票据信息
+              that.getUserToken(dataValueObj.ticket) //解析出用户票据信息
               userType = jsonData.usertype //解析保存用户类型(个人法人)
             } else {
               //关闭页面
@@ -119,6 +144,126 @@ export default {
         },
       })
     },
+    /**
+     * 通过用户票据获取用户的令牌数据,票据使用一次后失效,token时效性较长
+     */
+    getUserToken(ticket) {
+      var that = this
+      var params = '{"ticket":"' + ticket + '"}'
+      const interfaceContent = {
+        app_id: that.appmark,
+        servicename: 'ticketValidate',
+        params: params,
+      }
+
+      vaildInterfacefn(
+        'jisnzjk',
+        'ticketvalidate',
+        JSON.stringify(interfaceContent),
+        '2',
+        'https://' + urlCreatesign,
+        'https://' + urlGateway
+      ).then((value) => {
+        const data = JSON.parse(value)
+        if (data.retcode == '000000') {
+          const userToken = JSON.parse(data.data).token
+          if (userType == '1') {
+            //个人类型获取用户信息
+            that.getUserInfoByToken(userToken)
+          } else {
+            //法人类型获取用户信息
+            that.findCorUserByToken(userToken)
+          }
+        } else {
+          lightAppJssdk.notification.alert({
+            title: '提示', //可传空
+            message: data.msg,
+            buttonName: '确认',
+            success: function (data) {
+              oncloseWindow()
+            },
+          })
+        }
+      })
+    },
+
+    /**
+     * 根据令牌获取个人完整信息
+     */
+    getUserInfoByToken(userToken) {
+      var that = this
+      const params = '{"token":"' + userToken + '"}'
+      const interfaceContent = {
+        app_id: that.appmark,
+        servicename: 'findOutsideUserByToken',
+        params: params,
+      }
+
+      try {
+        vaildInterfacefn(
+          'jisnzjk',
+          'findoutsideuserbytoken',
+          JSON.stringify(interfaceContent),
+          '2',
+          'https://' + urlCreatesign,
+          'https://' + urlGateway
+        ).then((value) => {
+          const data = JSON.parse(value)
+          if (data.retcode == '000000') {
+            const userInfo = data.data
+            sessionStorage.setItem('userInfo', userInfo)
+            // that.$toast('调用接口getUserInfoByToken')
+            that.userApi()
+          } else {
+          }
+        })
+      } catch (error) {}
+    },
+
+    /**
+     * 根据令牌获取完整法人信息
+     */
+    findCorUserByToken(userToken) {
+      var that = this
+      try {
+        const params = '{"token":"' + userToken + '"}'
+        const interfaceContent = {
+          app_id: that.appmark,
+          servicename: 'findCorUserByToken',
+          params: params,
+        }
+        vaildInterfacefn(
+          'jisnzjk',
+          'findcoruserytoken',
+          JSON.stringify(interfaceContent),
+          '2',
+          'https://' + urlCreatesign,
+          'https://' + urlGateway
+        ).then((value) => {
+          const data = JSON.parse(value)
+
+          if (data.retcode == '000000') {
+            const userInfo = JSON.stringify(data.data)
+            // const userObj = JSON.parse(userInfo)
+            sessionStorage.setItem('userInfo', userInfo)
+            // document.getElementById('userinfo').innerText = userInfo
+            // that.$toast('调用接口findCorUserByToken')
+            that.userApi()
+          } else {
+          }
+        })
+      } catch (err) {}
+    },
+
+    /**
+     * 关闭容器
+     */
+    oncloseWindow() {
+      lightAppJssdk.navigation.close({
+        success: function (data) {},
+        fail: function (data) {},
+      })
+    },
   },
 }
 </script>

+ 1 - 1
src/views/zhulao/views/healthAssessmen/details.vue

@@ -80,7 +80,7 @@ export default {
     async queryaction() {
       const res = await queryaction({
         command: 'gethealthyAscvdUltrasonic',
-        uid: 2121,
+        uid: JSON.parse(sessionStorage.getItem('healthUser')).uid,
         id: this.id,
       })
       console.log(res, '111')

+ 1 - 1
src/views/zhulao/views/healthAssessmen/estimate.vue

@@ -103,7 +103,7 @@ export default {
       }
       const res = await queryaction({
         command: 'gethealthsascvdchistory',
-        uid: 2121,
+        uid: JSON.parse(sessionStorage.getItem('healthUser')).uid,
         startDate: startTime,
         endDate: endTime,
         extra: 0,

+ 6 - 2
src/views/zhulao/views/healthAssessmen/index.vue

@@ -7,7 +7,7 @@
       </div>
       <div class="right">
         <div class="name">
-          <span>姓名</span>
+          <span>{{userInfo.name}}</span>
           <div class="btn" @click="$router.push({path:'/estimate'})">健康评估</div>
         </div>
         <div class="testing">
@@ -42,9 +42,13 @@ export default {
     return {
       healthType: healthType,
       healthData: '',
+      userInfo: '',
+      healthUser: '',
     }
   },
   created() {
+    this.userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
+    this.healthUser = JSON.parse(sessionStorage.getItem('healthUser'))
     this.userApi()
     this.queryaction()
   },
@@ -59,7 +63,7 @@ export default {
     async queryaction() {
       const res = await queryaction({
         command: 'getlastheathdata',
-        uid: 2121,
+        uid: this.healthUser.uid,
       })
       this.healthData = res
       this.healthType.forEach((item) => {

+ 1 - 1
src/views/zhulao/views/healthAssessmen/typeDetails/typemain.vue

@@ -536,7 +536,7 @@ export default {
       }
       const res = await queryaction({
         command: this.command,
-        uid: 2121,
+        uid: JSON.parse(sessionStorage.getItem('healthUser')).uid,
         startDate: startTime,
         endDate: endTime,
         extra: 0,

+ 2 - 1
vue.config.js

@@ -112,7 +112,8 @@ module.exports = {
                 }
             },
             [process.env.VUE_APP_ZL_HEALTH]: {
-                target: 'http://web.poteviohealth.com:8080/',
+                // https://web.poteviohealth.com/zhylsia/
+                target: 'https://web.poteviohealth.com/zhylsia',
                 // target: 'http://localhost:12017/',
                 changeOrigin: true,
                 secure: false,