Browse Source

首页添加医保电子凭证

lighter 3 năm trước cách đây
mục cha
commit
5def5758ab

+ 12 - 11
index.html

@@ -1,14 +1,15 @@
 <!DOCTYPE html>
 <html lang="en">
-<head>
-  <meta charset="UTF-8">
-  <link rel="icon" href="/favicon.ico" />
-  <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
-  <meta name="viewport" content="width=device-width, initial-scale=1.0">
-  <title>Vite App</title>
-</head>
-<body>
-  <div id="app"></div>
-  <script type="module" src="/src/main.js"></script>
-</body>
+  <head>
+    <meta charset="UTF-8" />
+    <link rel="icon" href="/favicon.ico" />
+    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <title>Vite App</title>
+  </head>
+  <body>
+    <div id="app"></div>
+    <script type="module" src="/src/main.js"></script>
+    <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
+  </body>
 </html>

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 214 - 569
package-lock.json


+ 2 - 1
src/main.js

@@ -9,4 +9,5 @@ import WindowSize from './components/window-size'
 import BackNav from './components/back-nav'
 import SelectCard from './components/select-card'
 
-createApp(App).use(Vant).use(router).use(store).use(WindowSize).use(BackNav).use(SelectCard).mount('#app')
+const app = createApp(App)
+app.use(Vant).use(router).use(store).use(WindowSize).use(BackNav).use(SelectCard).mount('#app')

+ 5 - 0
src/store/index.js

@@ -15,6 +15,7 @@ export default createStore({
     examIndexArray: [],
     currentBook: {},
     yjReqNo: null,
+    weappApiExist: false,
   },
   mutations: {
     SET_LOADING: (state, payload) => (state.loading = payload),
@@ -27,6 +28,7 @@ export default createStore({
     SET_EXAMINDEXARRAY: (state, payload) => (state.examIndexArray = payload),
     SET_CURRENTBOOK: (state, payload) => (state.currentBook = payload),
     SET_YJREQNO: (state, payload) => (state.yjReqNo = payload),
+    SET_WEAPPAPIEXIST: (state, payload) => (state.weappApiExist = payload),
   },
   actions: {
     SET_LOADING({ commit }, payload) {
@@ -59,5 +61,8 @@ export default createStore({
     SET_YJREQNO({ commit }, payload) {
       commit('SET_YJREQNO', payload)
     },
+    SET_WEAPPAPIEXIST({ commit }, payload) {
+      commit('SET_WEAPPAPIEXIST', payload)
+    },
   },
 })

+ 1 - 1
src/utils/dev-prod.js

@@ -2,4 +2,4 @@
 // export const apiUrl = 'http://172.16.30.26:8805/wxserver'
 
 // 线上
-export const apiUrl = 'http://218.104.151.241:8805/wxserver'
+export const apiUrl = 'http://218.104.151.241/wxserver'

+ 27 - 17
src/views/Home.vue

@@ -13,6 +13,7 @@ import { getOpenId, getPatientIdByOpenId } from '../api/patient-id-cards'
 import store from '../store'
 import { useRouter } from 'vue-router'
 import { computed, onMounted } from 'vue'
+import { Dialog } from 'vant'
 
 export default {
   name: 'Home',
@@ -35,26 +36,35 @@ export default {
         }
       }
     }
-    onMounted(() => {
-      if (cardSize.value === 0) {
-        const code = router.currentRoute.value.params.code
-        if (code) {
-          getOpenId(code).then((res) => {
-            Cookies.set('openId', res)
-            localStorage.openId = res
-            getPatientIdByOpenId(res).then((cards) => {
-              if (cards.length > 0) {
-                store.commit('SET_PATIENTCARDS', cards)
-              }
-              toFirstTab()
-            })
-          })
+
+    const getBoundPatientId = () => {
+      return new Promise((resolve, reject) => {
+        if (cardSize.value > 0) {
+          resolve()
         } else {
-          toFirstTab()
+          const code = router.currentRoute.value.params.code
+          if (code) {
+            getOpenId(code).then((res) => {
+              Cookies.set('openId', res)
+              localStorage.openId = res
+              getPatientIdByOpenId(res).then((cards) => {
+                if (cards.length > 0) {
+                  store.commit('SET_PATIENTCARDS', cards)
+                }
+                resolve()
+              })
+            })
+          } else {
+            resolve()
+          }
         }
-      } else {
+      })
+    }
+
+    onMounted(() => {
+      getBoundPatientId().then(() => {
         toFirstTab()
-      }
+      })
     })
     return {}
   },

+ 54 - 12
src/views/hospital-service/HospitalServiceHome.vue

@@ -14,10 +14,7 @@
         }}</span>
       </div>
     </div>
-    <div
-      class="yuyueguahao xinguanjiance"
-      @click="routeTo(filterPath('/selectCovidBranch/', '/selectOrderCovidPatient'))"
-    >
+    <div class="big-box xinguanjiance" @click="routeTo(filterPath('/selectCovidBranch/', '/selectOrderCovidPatient'))">
       <div>
         <img class="large-icon" src="../../assets/hospital-service/xinguanjiance2.png" />
       </div>
@@ -64,12 +61,36 @@
         </van-col>
       </van-row>
     </div>
-    <div class="yuyueguahao" @click="toVaccinateAppointment">
-      <div>
-        <img class="large-icon" src="../../assets/hospital-service/vaccinate.png" />
+
+    <div style="position: relative; width: 95%; margin-top: 10px; height: 70px">
+      <div
+        style="
+          margin-left: 5%;
+          height: 70px;
+          background-size: 100%;
+          border-radius: 8px;
+          display: flex;
+          align-items: center;
+          background-image: url('http://staticweb.hnthyy.cn/images/yuyueguahaobackground.png');
+        "
+      >
+        <div>
+          <img style="margin-left: 10px; margin-top: 11px" src="http://staticweb.hnthyy.cn/images/hospitalcross.png" />
+        </div>
+        <div style="min-width: max-content; color: white; font-size: 26px; font-weight: bold; padding-left: 12px">
+          医保电子凭证
+        </div>
       </div>
-      <div style="color: white; font-size: 18px; font-weight: bold; padding-left: 10px">预约新冠疫苗接种</div>
-      <img src="../../assets/hospital-service/click2.png" />
+      <wx-open-launch-weapp
+        username="gh_598eb49157c6"
+        appid="wxb032bc789053daf4"
+        path="yibao/pages/new_index/index/index.html?cityCode=430000&channel=AAFPgL4CyNqERXbiPt10sAv1"
+        :style="{ position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' }"
+      >
+        <div v-is="'script'" type="text/wxtag-template">
+          <div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0"></div>
+        </div>
+      </wx-open-launch-weapp>
     </div>
 
     <div style="width: 90%; margin-left: 5%; margin-top: 15px">
@@ -108,6 +129,7 @@ import { getDate } from '../../utils/date'
 import router from '../../router'
 import axios from 'axios'
 import { apiUrl } from '../../utils/dev-prod'
+import { getJsApiSHA1 } from '../../api/wx-jsapi'
 export default {
   setup() {
     const windowSize = store.state.windowSize
@@ -160,7 +182,9 @@ export default {
       fontWeight: 'normal',
       paddingRight: '15px',
     }
-
+    const weappApiExist = computed(() => {
+      return store.state.weappApiExist
+    })
     const cards = computed(() => {
       return store.state.patientCards
     })
@@ -219,6 +243,25 @@ export default {
           loading.value = false
         })
       }
+
+      if (!weappApiExist.value) {
+        setTimeout(() => {
+          getJsApiSHA1(encodeURI(location.href)).then((res) => {
+            wx.config({
+              debug: false,
+              appId: res.appId,
+              timestamp: res.timestamp,
+              nonceStr: res.noncestr,
+              signature: res.signature,
+              jsApiList: [],
+              openTagList: ['wx-open-launch-weapp'],
+            })
+            wx.ready(() => {
+              store.commit('SET_WEAPPAPIEXIST', true)
+            })
+          })
+        }, 300)
+      }
     })
     return {
       filterPath,
@@ -251,12 +294,11 @@ export default {
   display: flex;
   justify-content: space-between;
 }
-.yuyueguahao {
+.big-box {
   margin-top: 10px;
   width: 90%;
   margin-left: 5%;
   height: 70px;
-  background: url('../../assets/hospital-service/yuyueguahaobackground.png') no-repeat;
   background-size: 100%;
   border-radius: 8px;
   display: flex;

+ 3 - 1
src/views/mine/MineHome.vue

@@ -27,6 +27,7 @@
       <van-cell icon="friends" title="我的就诊人" is-link to="/myPatientIdCards"></van-cell>
       <van-cell icon="star" title="我的收藏" is-link to="/myCollection"></van-cell>
     </van-cell-group>
+
     <van-cell-group title="记录">
       <van-cell
         icon="label"
@@ -61,6 +62,7 @@ export default {
     const cards = computed(() => {
       return store.state.patientCards
     })
+
     const filterPath = (singleCardPath, multipleCardsPath) => {
       return cards.value.length === 1 ? singleCardPath + cards.value[0].patientId : multipleCardsPath
     }
@@ -163,4 +165,4 @@ export default {
 .qr-code-area > div {
   margin: 8px 0 0 8px;
 }
-</style>
+</style>

+ 9 - 1
vite.config.js

@@ -2,7 +2,15 @@ import { defineConfig } from 'vite'
 import vue from '@vitejs/plugin-vue'
 
 export default defineConfig({
-  plugins: [vue()],
+  plugins: [
+    vue({
+      template: {
+        compilerOptions: {
+          isCustomElement: (tag) => tag === 'wx-open-launch-weapp',
+        },
+      },
+    }),
+  ],
   server: {
     host: '0.0.0.0',
     port: 4000,

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác