Browse Source

vaildInterfacefn二次封装

sunran 3 năm trước cách đây
mục cha
commit
187ebec909

+ 2 - 1
public/index.html

@@ -16,6 +16,7 @@
     <van-number-keyboard safe-area-inset-bottom />
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
     <!-- <title><%= htmlWebpackPlugin.options.title %></title> -->
+    <script type="text/javascript" src="https://isdapp.shandong.gov.cn/jmopen/jssdk/index.js"></script>
 </head>
 
 <body>
@@ -26,7 +27,7 @@
     <div id="app"></div>
     <!-- built files will be auto injected -->
 </body>
-<script type="text/javascript" src="https://isdapp.shandong.gov.cn/jmopen/jssdk/index.js"></script>
+
 <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
 <script src="./js/aes.js"></script>
 <script src="./js/index.js"></script>

+ 6 - 1
public/js/index.js

@@ -1,5 +1,10 @@
+// import Vue from 'vue'
+
 let urlCreatesign = urldomaincreatesign
 let urlGateway = urldomaingateway
+localStorage.setItem('urlCreatesign',urldomaincreatesign)
+localStorage.setItem('urlGateway',urldomaingateway)
+// Vue.prototype.$urlCreatesign = urlCreatesign
 const appmark = "sdzwapp"
 const appword = "aKd20dbGdFvmuwrt"
 let userType = "1" //用户类型  1个人   2法人
@@ -59,7 +64,7 @@ function onLoginApp() {
         }
     })
 }
-
+// alert(urldomaincreatesign+'呵呵')
 
 /**
  * 通过用户票据获取用户的令牌数据,票据使用一次后失效,token时效性较长

+ 33 - 0
src/utils/vaildInterfacefn.js

@@ -0,0 +1,33 @@
+let urlCreatesign = urldomaincreatesign
+let urlGateway = urldomaingateway
+console.log(urlCreatesign, 'urlCreatesign')
+console.log(urlGateway, 'urlGateway')
+// let urlCreatesign = localStorage.getItem('urlCreatesign')
+// let urlGateway = localStorage.getItem('urlGateway')
+export function serverAPI(serverName, data) {
+    console.log(data)
+    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) {
+            reject(error)
+            // this.$dialog.alert({
+            //         message: serverName + '--------' + error,
+            //     })
+            //     .then(() => {})
+        }
+    })
+}

+ 3 - 1
src/views/zhulao/api/index.js

@@ -6,6 +6,8 @@ export function getArticleList(params) {
         url: '/cms/portal/article/list',
         method: 'get',
         requestBase: 'VUE_APP_ZL_WSS_ZP',
+        // appid: 'zpsmzjyycsfteev',
+        // interfaceid: 'zpsmzxxqjk',
         params
     })
 }
@@ -65,7 +67,7 @@ export function institutions_search(params) {
     })
 }
 // 获取养老机构管理详细信息 /cms/portal/institutions/{id}
-export function institutions_detail(id,params) {
+export function institutions_detail(id, params) {
     return request({
         url: '/cms/portal/institutions/' + id,
         method: 'get',

+ 6 - 0
src/views/zhulao/main.js

@@ -14,6 +14,12 @@ Vue.config.productionTip = false
 Vue.use(Vant)
 Vue.use(Lazyload)
 Vue.prototype.$echarts = echarts
+let urlCreatesign = localStorage.getItem('urlCreatesign')
+let urlGateway = localStorage.getItem('urlGateway')
+// let urlGateway = urldomaingateway
+Vue.prototype.$urlCreatesign = urlCreatesign
+Vue.prototype.$urlGateway = urlGateway
+Vue.prototype.$appId = 'zpylgzwgt'
 new Vue({
     router,
     store,

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

@@ -68,6 +68,7 @@
 </template>
 <script>
 import { getTags, getArticleList } from '../../api/index.js'
+import { serverAPI } from '../../../../utils/vaildInterfacefn.js'
 import Tabbar from '../../components/Tabbar.vue'
 export default {
   components: { Tabbar },
@@ -98,7 +99,7 @@ export default {
       } else if (type == 'dynamic') {
         data.columnCode = 'dynamic'
       }
-      const res = await getArticleList(data)
+      const res = await serverAPI('zpsmzjlbtcxjk', data)
       if (type == 'image') {
         this.banner = res.rows
       } else if (type == 'dynamic') {
@@ -114,6 +115,40 @@ export default {
         }
         this.loading = false
       }
+      console.log(res, '拿到的数据')
+      return
+      try {
+        vaildInterfacefn(
+          this.$appId,
+          'zpsmzjlbtcxjk',
+          JSON.stringify(data),
+          '2',
+          'https://' + this.$urlCreatesign,
+          'https://' + this.$urlGateway
+        ).then((value) => {
+          const res = JSON.parse(value)
+          console.log(res, 'res')
+          if (res.code == '200') {
+            if (type == 'image') {
+              this.banner = res.rows
+            } else if (type == 'dynamic') {
+              if (this.pageNum == 1) {
+                this.info = res.rows
+              } else {
+                this.info = this.info.concat(res.rows)
+              }
+              if (this.info.length >= res.total) {
+                this.finished = true
+              } else {
+                this.pageNum++
+              }
+              this.loading = false
+            }
+          } else {
+          }
+        })
+      } catch (error) {}
+      //   const res = await getArticleList(data)
     },
     onLoad() {
       this.getList('dynamic')