Browse Source

添加验证避免没有数据报错

xiaohaizhao 1 year ago
parent
commit
4bd1264f38
1 changed files with 19 additions and 17 deletions
  1. 19 17
      Eservice/components/signName/index.js

+ 19 - 17
Eservice/components/signName/index.js

@@ -5,9 +5,9 @@ Component({
    * 组件的属性列表
    */
   properties: {
-    bindData:{
-      value:{},
-      type:Object
+    bindData: {
+      value: {},
+      type: Object
     }
   },
 
@@ -17,8 +17,8 @@ Component({
   data: {
 
   },
-  lifetimes:{
-    attached () {
+  lifetimes: {
+    attached() {
       setTimeout(() => {
         this.fileData()
       }, 1000);
@@ -28,18 +28,20 @@ Component({
    * 组件的方法列表
    */
   methods: {
-    async fileData () {
+    async fileData() {
       let page = getCurrentPages()[getCurrentPages().length - 1]
-      const res = await api._post({
-        "classname": "system.attachment.Attachment",
-        "method": "queryFileLink",
-        "content": page.data.bindSignNameData
-      })
-      this.setData({
-        originFiles:res.data
-      })
+      if (page.data.bindSignNameData) {
+        const res = await api._post({
+          "classname": "system.attachment.Attachment",
+          "method": "queryFileLink",
+          "content": page.data.bindSignNameData
+        })
+        this.setData({
+          originFiles: res.data
+        })
+      }
     },
-    async deleteFile (data) {
+    async deleteFile(data) {
       let item = data.detail.file
       const res = await api._post({
         "classname": "system.attachment.Attachment",
@@ -51,11 +53,11 @@ Component({
       this.fileData()
     },
     // 签字
-    signName () {
+    signName() {
 
       wx.navigateTo({
         url: '/Eservice/signName/index?id=' + this.data.bindData.ownerid,
       })
     },
   }
-})
+})