Переглянути джерело

修改证书相关为动态路由

zweizhao 7 роки тому
батько
коміт
41d72030f0
3 змінених файлів з 16 додано та 23 видалено
  1. 2 10
      pages/cert/index.vue
  2. 9 9
      pages/cert/detail.vue
  3. 5 4
      pages/cert/apply.vue

+ 2 - 10
pages/cert/index.vue

@@ -29,7 +29,7 @@
                   v-if="item.end_date && item.is_cert_validate && item.cert_no"
                 >
                   有效期至{{item.end_date}}
-                  <nuxt-link :to="`/cert/detail?no=${item.cert_no}`">查看证书</nuxt-link>
+                  <nuxt-link :to="`/cert/no/${item.cert_no}`">查看证书</nuxt-link>
                 </span>
               </section>
             </section>
@@ -53,9 +53,6 @@ export default {
   head() {
     return {
       title: this.title,
-      meta: [
-        // { hid: 'description', name: 'description', content: 'My custom description' }
-      ]
     }
   },
   mounted() {
@@ -63,12 +60,7 @@ export default {
   },
   methods: {
     clickLancer({ id }) {
-      this.$router.push({
-        path: '/cert/apply',
-        query: {
-          type: id,
-        }
-      })
+      this.$router.push(`/cert/type/${id}`)
     },
     btnDisabled(item) {
       return item.btn_name !== "申请认证" || !item.can_click

+ 9 - 9
pages/cert/detail.vue

@@ -26,17 +26,17 @@ import bg from '@/assets/img/cert/bg.png'
 import { mapState } from 'vuex'
 
 let canvas = null
-  , ctx = null
-  , img = null
-  , interval = null
-  , qrLoaded = false
-  , imgLoaded = false
-  , detailLoaded = false
+let ctx = null
+let img = null
+let interval = null
+let qrLoaded = false
+let imgLoaded = false
+let detailLoaded = false
 
 export default {
-  async asyncData(ctx) {
-    let res = await http.post(`/api/cert/getCertDetail`, { cert_no: ctx.query.no })
-      , detail = {}
+  async asyncData({ params }) {
+    let res = await http.post(`/api/cert/getCertDetail`, { cert_no: params.no })
+    let detail = {}
     if(res) {
       detail = res.data
     }

+ 5 - 4
pages/cert/apply.vue

@@ -1,3 +1,4 @@
+
 <template>
   <proginn-page>
     <section class="apply">
@@ -33,7 +34,7 @@
             v-if="detail.end_date && detail.is_cert_validate && detail.cert_no"
           >
             有效期至{{detail.end_date}}
-            <nuxt-link :to="`/cert/detail?no=${detail.cert_no}`">查看证书</nuxt-link>
+            <nuxt-link :to="`/cert/no/${detail.cert_no}`">查看证书</nuxt-link>
           </span>
         </section>
       </section>
@@ -54,10 +55,10 @@
 import http from '@/plugins/http'
 
 export default {
-  async asyncData({ query, req }) {
+  async asyncData({ params, req }) {
     let headers = req && req.headers
-    let type = query.type
-      , { data } = await http.post(`/api/cert/getDetail`, { id: type }, { config: { headers }, neverLogout: true })
+    let id = params.id
+    let { data } = await http.post(`/api/cert/getDetail`, { id }, { config: { headers }, neverLogout: true })
     return {
       detail: data,
     }