Просмотр исходного кода

首页 老年课堂 健康管理

sunran 3 лет назад
Родитель
Сommit
0f26c1d6b1

+ 45 - 20
src/utils/vaildInterfacefn.js

@@ -1,28 +1,53 @@
 let urlCreatesign = urldomaincreatesign
 let urlGateway = urldomaingateway
-export function serverAPI(serverName, data) {
-    console.log(data)
+export function serverAPI(serverName, data, ifheader) {
     return new Promise(function (resolve, reject) {
         try {
-            vaildInterfacefn(
-                'zpylgzwgt',
-                serverName,
-                JSON.stringify(data),
-                '2',
-                'https://' + urlCreatesign,
-                'https://' + urlGateway
-            ).then((value) => {
-                const res = JSON.parse(value)
-                console.log(res, 'res')
-                if (res.code == '200') {
-                    resolve(res)
-                } else {}
-            })
-        } catch (error) {
-            this.$dialog.alert({
-                    message: serverName + '--------' + error,
+            if (!ifheader) {
+                // 不含有header的调用方法
+                vaildInterfacefn(
+                    'zpylgzwgt',
+                    serverName,
+                    JSON.stringify(data),
+                    '2',
+                    'https://' + urlCreatesign,
+                    'https://' + urlGateway
+                ).then((value) => {
+                    const res = JSON.parse(value)
+                    console.log(res, '爱山东返回数据')
+                    if (res.code == '200' || res.status == '0') {
+                        resolve(res)
+                    } else {
+                        this.$dialog.alert({
+                                message: serverName + '--------' + res.status,
+                            })
+                            .then(() => {})
+                    }
+                })
+            } else {
+                // 含有header的调用方法
+                var header = JSON.stringify({
+                    authToken: JSON.parse(sessionStorage.getItem('healthUser')).authToken
+                })
+                console.log(JSON.parse(sessionStorage.getItem('healthUser')).authToken)
+                vaildInterfaceWithHeadersfn(
+                    'zpylgzwgt',
+                    serverName,
+                    JSON.stringify(data),
+                    '2',
+                    header,
+                    'https://' + urlCreatesign,
+                    'https://' + urlGateway
+                ).then((value) => {
+                    const res = JSON.parse(value)
+                    console.log(res, '爱山东返回数据headers')
+                    if (res.code == '200' || res.status == '0') {
+                        resolve(res)
+                    } else {}
                 })
-                .then(() => {})
+            }
+
+        } catch (error) {
             reject(error)
 
         }

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

@@ -11,6 +11,7 @@
   </div>
 </template>
 <script>
+import { serverAPI } from '../../../utils/vaildInterfacefn.js'
 import { userApi } from '../api/index.js'
 export default {
   data() {
@@ -60,9 +61,18 @@ export default {
   methods: {
     beforeChange(e) {
       if (e == 3) {
+        console.log(sessionStorage.getItem('userInfo'), '-------')
+        sessionStorage.setItem('userInfo', '')
         if (!sessionStorage.getItem('userInfo')) {
-          this.getUserInfo()
-          //   this.userApi()
+          //   this.getUserInfo()
+          var testdata = {
+            mobile: '13811330231',
+            name: '测试',
+          }
+          sessionStorage.setItem('userInfo', JSON.stringify(testdata))
+          //   var userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
+          //   console.log(userInfo, 'userInfo')
+          this.userApi()
         } else {
           return true
         }
@@ -72,13 +82,14 @@ export default {
     },
     async userApi() {
       var userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
-      //   var mobile = '13811330231'
-      const res = await userApi({
+      console.log(userInfo, 'userInfo')
+      const res = await serverAPI('zpsmzjjkglcxjk', {
         command: 'reguserbyweixinphone',
         contactsPhone: userInfo.mobile,
         // contactsPhone: mobile,
         terminalType: 5,
       })
+      console.log(res, '接口')
       sessionStorage.setItem('healthUser', JSON.stringify(res))
       //   this.$toast(userInfo.name + '接口')
       //   this.$dialog

+ 3 - 2
src/views/zhulao/views/classRoom/index.vue

@@ -28,6 +28,7 @@
   </div>
 </template>
 <script>
+import { serverAPI } from '../../../../utils/vaildInterfacefn.js'
 import { getColumnList, getArticleList } from '../../api/index.js'
 import Tabbar from '../../components/Tabbar.vue'
 export default {
@@ -53,7 +54,7 @@ export default {
   },
   methods: {
     async getColumnList() {
-      const res = await getColumnList({})
+      const res = await serverAPI('zpsmzjlnktcxjk', {})
       this.columnList = res.data
       this.active = this.columnList[0].columnCode
       this.getList()
@@ -66,7 +67,7 @@ export default {
         pageSize: this.pageSize,
         columnCode: this.active,
       }
-      const res = await getArticleList(data)
+      const res = await serverAPI('zpsmzjlbtcxjk', data)
 
       if (this.pageNum == 1) {
         this.info = res.rows

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

@@ -61,6 +61,7 @@
   </div>
 </template>
 <script>
+import { serverAPI } from '../../../../utils/vaildInterfacefn.js'
 import { queryaction } from '../../api/index.js'
 export default {
   data() {
@@ -78,7 +79,7 @@ export default {
   },
   methods: {
     async queryaction() {
-      const res = await queryaction({
+      const res = await serverAPI('zpsmzjkgllxcxjk',{
         command: 'gethealthyAscvdUltrasonic',
         uid: JSON.parse(sessionStorage.getItem('healthUser')).uid,
         id: this.id,

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

@@ -36,6 +36,7 @@
   </div>
 </template>
 <script>
+import { serverAPI } from '../../../../utils/vaildInterfacefn.js'
 import { queryaction } from '../../api/index.js'
 
 export default {
@@ -101,7 +102,7 @@ export default {
           startTime = this.getStartTimeStr(1095)
           break
       }
-      const res = await queryaction({
+      const res = await serverAPI('zpsmzjkgllxcxjk',{
         command: 'gethealthsascvdchistory',
         uid: JSON.parse(sessionStorage.getItem('healthUser')).uid,
         startDate: startTime,

+ 17 - 12
src/views/zhulao/views/healthAssessmen/index.vue

@@ -33,6 +33,7 @@
   </div>
 </template>
 <script>
+import { serverAPI } from '../../../../utils/vaildInterfacefn.js'
 import { healthType } from './term.js'
 import { userApi, queryaction } from '../../api/index.js'
 import Tabbar from '../../components/Tabbar.vue'
@@ -49,22 +50,26 @@ export default {
   created() {
     this.userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
     this.healthUser = JSON.parse(sessionStorage.getItem('healthUser'))
-    this.userApi()
+    // this.userApi()
     this.queryaction()
   },
   methods: {
-    async userApi() {
-      const res = await userApi({
-        command: 'getDefaultHealthRange',
-        terminalType: 1,
-      })
-      console.log(res)
-    },
+    // async userApi() {
+    //   const res = await userApi({
+    //     command: 'getDefaultHealthRange',
+    //     terminalType: 1,
+    //   })
+    //   console.log(res)
+    // },
     async queryaction() {
-      const res = await queryaction({
-        command: 'getlastheathdata',
-        uid: this.healthUser.uid,
-      })
+      const res = await serverAPI(
+        'zpsmzjkgllxcxjk',
+        {
+          command: 'getlastheathdata',
+          uid: this.healthUser.uid,
+        },
+        true
+      )
       this.healthData = res
       this.healthType.forEach((item) => {
         //   判断type进行赋值

+ 16 - 11
src/views/zhulao/views/healthAssessmen/typeDetails/typemain.vue

@@ -470,6 +470,7 @@
   </div>
 </template>
 <script>
+import { serverAPI } from '../../../../../utils/vaildInterfacefn.js'
 import { queryaction, userApi } from '../../../api/index.js'
 import Header from './header.vue'
 export default {
@@ -533,16 +534,20 @@ export default {
           startTime = this.getStartTimeStr(730)
           break
       }
-      const res = await queryaction({
-        command: this.command,
-        uid: JSON.parse(sessionStorage.getItem('healthUser')).uid,
-        startDate: startTime,
-        endDate: endTime,
-        extra: 0,
-        terminalType: 3,
-        pageNum: 1,
-        pageSize: 10,
-      })
+      const res = await serverAPI(
+        'zpsmzjkgllxcxjk',
+        {
+          command: this.command,
+          uid: JSON.parse(sessionStorage.getItem('healthUser')).uid,
+          startDate: startTime,
+          endDate: endTime,
+          extra: 0,
+          terminalType: 3,
+          pageNum: 1,
+          pageSize: 10,
+        },
+        true
+      )
 
       if (this.name == '血脂' || this.name == '血红蛋白') {
         this.healths = res.data.list
@@ -706,7 +711,7 @@ export default {
       echarts.setOption(option)
     },
     async userApi() {
-      const res = await userApi({
+      const res = await serverAPI('zpsmzjjkglcxjk', {
         command: 'getDefaultHealthRange',
         terminalType: 1,
       })

+ 1 - 1
src/views/zhulao/views/home/index.vue

@@ -67,7 +67,7 @@
   </div>
 </template>
 <script>
-import { getTags, getArticleList } from '../../api/index.js'
+// import { getTags, getArticleList } from '../../api/index.js'
 import { serverAPI } from '../../../../utils/vaildInterfacefn.js'
 import Tabbar from '../../components/Tabbar.vue'
 export default {