Parcourir la source

爬虫表单绑定

martin.ma il y a 4 ans
Parent
commit
9fcf5cb7cd

+ 36 - 8
components/bind_wechat_article/index.vue

@@ -30,9 +30,8 @@
             <div class="form-bind-area">
               <div class="band-wechat-btn">微信公众号</div>
               <div class="form-input">
-                <el-input v-model="input" placeholder="账户ID"></el-input>
+                <el-input v-model="bandId" placeholder="账户ID"></el-input>
               </div>
-              <a href="">如何获取?</a>
             </div>
             <div class="form-bind-tips">
               打开微信公众号后台>设置与开发>公开信息>微信号
@@ -44,14 +43,15 @@
           <div class="form-content">
             <multi-uploader
               v-model="certPic"
-              :limit="1"
+              :limit="9"
               tips="请上传JPG、PNG、JPEG格式图片,文件大小不超过1M"
+              :file-size="1"
             ></multi-uploader>
           </div>
         </div>
       </div>
 
-      <div class="submit-btn">提交申请</div>
+      <div class="submit-btn" @click="submit">提交申请</div>
     </el-dialog>
   </div>
 </template>
@@ -66,13 +66,13 @@ export default {
   data() {
     return {
       formVisible: false,
-      uid: "1",
-      name: "水电费水电费",
-      input: "",
+      uid: "",
+      name: "",
       avatar:
         "https://inn.proginn.com/test/useralbum/10468/avatar104681620985269.jpg",
       bandId: "",
-      certPic: []
+      certPic: [],
+      loading: false
     };
   },
   methods: {
@@ -84,6 +84,34 @@ export default {
       this.bandId = "";
       this.certPic = [];
       this.formVisible = true;
+    },
+    async submit() {
+      if (this.loading) {
+        return;
+      }
+      if (this.bandId == "") {
+        this.$message.error("请填写账户ID");
+        return;
+      }
+      if (this.certPic.length == 0) {
+        this.$message.error("请填写上传后台登录截图");
+        return;
+      }
+      this.loading = true;
+      let fileParams = this.certPic.map(item => item.url).join(",");
+      let params = {
+        type: 1,
+        file: fileParams,
+        account: this.bandId
+      };
+      let res = await this.$axios.$post("/uapi/enterprise/user_spider/add", {
+        ...params
+      });
+      this.loading = false;
+      if (Number(res.status) == 1) {
+        this.$message.success("添加成功");
+        this.formVisible = false;
+      }
     }
   }
 };

+ 40 - 19
components/multi-uploader.vue

@@ -1,5 +1,8 @@
 <template>
-  <div class="multi-uploader" :class="fileList && fileList.length >= limit ? 'multi-uploader-limit' : ''">
+  <div
+    class="multi-uploader"
+    :class="fileList && fileList.length >= limit ? 'multi-uploader-limit' : ''"
+  >
     <el-upload
       action="/upload_image"
       list-type="picture-card"
@@ -16,9 +19,16 @@
       <i class="el-icon-plus"></i>
     </el-upload>
     <el-dialog :visible.sync="dialogVisible">
-      <img width="100%" :src="dialogImageUrl" alt/>
+      <img width="100%" :src="dialogImageUrl" alt />
     </el-dialog>
-    <div slot="tip" v-if="showTips" class="el-upload__tip" :class="fileList.length ? 'el-upload__tip-active' : ''">{{tips}}</div>
+    <div
+      slot="tip"
+      v-if="showTips"
+      class="el-upload__tip"
+      :class="fileList.length ? 'el-upload__tip-active' : ''"
+    >
+      {{ tips }}
+    </div>
   </div>
 </template>
 
@@ -37,9 +47,13 @@ export default {
       type: Number,
       default: 9
     },
-    tips:{
-      type:String,
-      default:"最多添加9张作品图片"
+    tips: {
+      type: String,
+      default: "最多添加9张作品图片"
+    },
+    fileSize: {
+      type: Number,
+      default: 5
     }
   },
   model: {
@@ -56,16 +70,18 @@ export default {
     };
   },
   watch: {
-    value: {//深度监听,可监听到对象、数组的变化
+    value: {
+      //深度监听,可监听到对象、数组的变化
       handler(val, oldVal) {
-        console.log('watch1:', val)
-        this.fileList = val
+        console.log("watch1:", val);
+        this.fileList = val;
       },
       deep: true //true 深度监听
     },
-    fileList: {//深度监听,可监听到对象、数组的变化
+    fileList: {
+      //深度监听,可监听到对象、数组的变化
       handler(val, oldVal) {
-        console.log('watch2:', val)
+        console.log("watch2:", val);
         this.$emit("change", val);
       },
       deep: true //true 深度监听
@@ -79,12 +95,17 @@ export default {
     beforeUpload(file) {
       console.log("beforeUpload", file);
       console.log("before", this.$refs.multiUploader);
-      let fileType = file.type ? file.type : (file.raw ? file.raw.type : "");
-      if (fileType !== "image/png" && fileType !== "image/jpg" && fileType !== "image/jpeg" && fileType !== "image/gif") {
+      let fileType = file.type ? file.type : file.raw ? file.raw.type : "";
+      if (
+        fileType !== "image/png" &&
+        fileType !== "image/jpg" &&
+        fileType !== "image/jpeg" &&
+        fileType !== "image/gif"
+      ) {
         this.$message.error("请上传png,jp(e)g,gif格式的图片");
         return false;
       }
-      if (file.size / 1024 / 1024 > 5) {
+      if (file.size / 1024 / 1024 > this.fileSize) {
         this.$message.error("图片大小不可超过5M");
         return false;
       }
@@ -109,8 +130,8 @@ export default {
             url: fileItem.response ? fileItem.response.filename : fileItem.url,
             uid: fileItem.uid,
             status: "success"
-          })
-        })
+          });
+        });
         this.fileList = list;
       } else {
         this.$refs.multiUploader.abort(file);
@@ -122,13 +143,13 @@ export default {
               url: tmpFile.response ? tmpFile.response.filename : tmpFile.url,
               uid: tmpFile.uid,
               status: "success"
-            })
+            });
           }
-        })
+        });
         this.fileList = list;
         console.log("上传失败 abort");
       }
-    },
+    }
   }
 };
 </script>

+ 3 - 4
pages/frontend/personal/index.vue

@@ -144,9 +144,8 @@
 
           <Empty v-if="list.length == 0 && !pageLoading">
             <div v-if="isSelf" class="auto-bind-wechat">
-              <!-- <span @click="callBindWeChat">绑定社交账号</span>,自动抓取更新 -->
-
-               已绑定XXX账号<span @click="unbindWeChat">解绑</span>
+              <span @click="callBindWeChat">绑定社交账号</span>,自动抓取更新
+               <!-- 已绑定XXX账号<span @click="unbindWeChat">解绑</span> -->
             </div>
           </Empty>
 
@@ -317,7 +316,7 @@ export default {
   computed: {
     ...mapState(["deviceType"]),
     isSelf() {
-      let myuid = 681042 || this.userinfouid;
+      let myuid = this.userinfouid;
       let pageuid = this.$route.params.uid;
       if (myuid && myuid == pageuid) {
         return true;