Преглед на файлове

查询证书失败提示

zweizhao преди 7 години
родител
ревизия
45b569f40e
променени са 2 файла, в които са добавени 21 реда и са изтрити 16 реда
  1. 20 15
      pages/index/cert/id.vue
  2. 1 1
      plugins/axios.js

+ 20 - 15
pages/index/cert/id.vue

@@ -1,16 +1,19 @@
 <template>
   <section class="cert-id">
     <section class="cert-id-box">
-      <h1>{{detail.name}}证书</h1>
-      <div class="hr"></div>
-      <canvas ref="canvas" width="850" height="520">对不起, 您的浏览器不支持绘图功能, 请更新浏览器.</canvas>
-      <img ref="img" class="img" src="~@/assets/img/cert/bg.png" alt="img">
-      <img ref="qrImg" class="img" src="/api/cert/certQrCode" alt="qrImg">
-      <section style="width: 850px;">
-        <a :href="userinfo.seo_uri">开发者个人主页 ></a>
-        <br>
-        <a :href="`/cert/freelancer?id=${detail.id}`">{{detail.name}}认证标准 ></a>
-      </section>
+      <template v-if="detail.name">
+        <h1>{{detail.name}}证书</h1>
+        <div class="hr"></div>
+        <canvas ref="canvas" width="850" height="520">对不起, 您的浏览器不支持绘图功能, 请更新浏览器.</canvas>
+        <img ref="img" class="img" src="~@/assets/img/cert/bg.png" alt="img">
+        <img ref="qrImg" class="img" src="/api/cert/certQrCode" alt="qrImg">
+        <section style="width: 850px;">
+          <a :href="userinfo.seo_uri">开发者个人主页 ></a>
+          <br>
+          <a :href="`/cert/freelancer?id=${detail.id}`">{{detail.name}}认证标准 ></a>
+        </section>
+      </template>
+      <h1 v-else>未查询到证书</h1>
     </section>
   </section>
 </template>
@@ -31,25 +34,27 @@ let canvas = null
 export default {
   async asyncData(ctx) {
     let res = await http.post(`/api/cert/getCertDetail`, { cert_no: ctx.query.no })
+      , detail = {}
+    if(res) {
+      detail = res.data
+    }
     return {
-      detail: res.data
+      detail
     }
   },
   head() {
     return {
       title: `${this.detail.name}证书-程序员客栈`,
-      meta: [
-        // { hid: 'description', name: 'description', content: 'My custom description' }
-      ]
     }
   },
   data() {
-    return {}
+    return { detail: {} }
   },
   computed: {
     ...mapState(['userinfo']),
   },
   mounted() {
+    if(!this.detail.name) return
     this.initCanvas()
     this.checkInfoFull()
     interval = setInterval(this.checkInfoFull, 500)

+ 1 - 1
plugins/axios.js

@@ -1,5 +1,5 @@
 import axios from 'axios'
 
 export default axios.create({
-  baseURL: process.env.BASE_URL
+  baseURL: process.env.BASE_URL || 'http://local-rooter.proginn.com:3000'
 })