Browse Source

1、tower-42362-变更3-处理照片回显

bruce 5 years ago
parent
commit
004cb8f2a3
1 changed files with 25 additions and 1 deletions
  1. 25 1
      components/works/editor.vue

+ 25 - 1
components/works/editor.vue

@@ -111,12 +111,36 @@
             if (res.status == 1) {
               this.workName = res.data.name || "";
               this.content = res.data.description || "";
-              this.workImages = res.data.images || [];
+              this.setWorkImages(res.data);
               this.workUrl = res.data.url || ""
             }
           });
         // this.content = "123";
       },
+
+      setWorkImages(data) {
+        let images = data.images;
+        if (images && images.length > 0) {
+          images.forEach((image, index) => {
+            let imageName = this.getImageName(image.url);
+            console.log("imageName", imageName);
+            this.workImages.push({name: imageName + index, url: image.url});
+          })
+        }
+        console.log(this.workImages);
+      },
+      getImageName(imageName) {
+        if (imageName) {
+          try {
+            const lastquotaIndex = imageName.lastIndexOf("/");
+            const lastDotIndex = imageName.lastIndexOf('.');
+            return imageName.substring(lastquotaIndex + 1, lastDotIndex);
+          } catch (e) {
+            console.log(e);
+          }
+        }
+        return "";
+      },
       getHejiList() {
         this.$axios.post("/api/jishuquan/get_collections", {uid: this.$store.state.userinfo.uid, page: 1, size: 200}).then(res => {
           if (res.data.status === 1) {