xjc 4 years ago
parent
commit
f8f22bddba

+ 3 - 0
src/api.js

@@ -510,4 +510,7 @@ export default {
 	sendMsg: params => {
 		return axios.post(`${baseURL}/api/admin/activity/msg`, params);
 	},
+	syncToMP: params => {
+		return axios.post(`${baseURL}/api/admin/article/synctomp`, params);
+	},
 }

+ 2 - 2
src/views/article/AddArticle.vue

@@ -184,8 +184,8 @@
             <img v-if="form.img" :src="form.img" class="avatar" />
             <i v-else class="el-icon-plus avatar-uploader-icon"></i>
           </el-upload>
-          <span style="font-size: 12px; color: #999999"
-            >建议图片尺寸为:210*160</span
+          <span style="font-size: 12px; color: red"
+            >建议图片尺寸为:210*160, 图片大小请控制在2M以内!</span
           >
         </el-form-item>
         <el-form-item label="文章详情:">

+ 41 - 6
src/views/article/Article.vue

@@ -172,12 +172,12 @@ a {
         <!-- <div>
           <img :src="journalLogo" alt="">
         </div> -->
-        <div>
-          <div v-if="multipleSelection" style="position:relative;">
+        <div v-loading="loading1">
+          <div v-if="multipleSelection.length" style="position:relative;">
             <img :src="multipleSelection[0].img" alt="" width="310px" height="157px">
             <p style="position:absolute;bottom:20px;left:20px;font-weight:bold;color:#ffffff;">{{multipleSelection[0].name}}</p>
           </div>
-          <div  v-if="multipleSelection">
+          <div  v-if="multipleSelection.length">
             <div class="syncitem" v-for="(item,index) in multipleSelection" :key="index">
               <p>{{item.name.substring(0,20)}}</p>
               <img :src="item.img" alt="" width="48px" height="48px">
@@ -186,7 +186,7 @@ a {
         </div>
         <div class="syncbtn">
           <el-button type="normal" size="small" @click="dialogVisible=false">取消</el-button>
-          <el-button type="primary" size="small">确定</el-button>
+          <el-button type="primary" size="small" @click="saveSyncToMP()">确定</el-button>
         </div>
       </el-dialog>
     </div>
@@ -202,6 +202,8 @@ export default {
   },
   data() {
     return {
+      loading: false,
+      loading1: false,
       form: { name: "", page: 1, page_size: 20 },
       total: 1,
       list: [{ name: "2333" }],
@@ -211,7 +213,7 @@ export default {
       },
       dialogVisible:false,
       journalLogo:"",
-      multipleSelection:''
+      multipleSelection:[]
     };
   },
   methods: {
@@ -220,10 +222,43 @@ export default {
         this.$message.error("请勾选需要同步到公众号的文章!")
         return 
       }
-      console.log(this.multipleSelection)
       this.dialogVisible = true;
     },
+    saveSyncToMP(){
+      let ids = ""
+      this.multipleSelection.forEach((item,index)=>{
+        if(index==0){
+          ids += item.id.toString()
+        }else{
+          ids += ","+item.id.toString()
+        }
+      })
+      this.loading1 = true;
+      this.$api.syncToMP({ids:ids}).then((res)=>{
+        this.loading1 = false;
+        if(res.data.code==0){
+          this.$confirm("同步成功,已发送到微信公众号图文消息,即可可前往微信公众号预览!", "提示", {
+            confirmButtonText: "确定",
+            showCancelButton: false,
+            type: "success",
+          }).then(()=>{
+            this.dialogVisible = false
+          });
+        }else{
+          this.$confirm(
+            "同步失败!"+res.data.message,
+            "提示",
+            {
+              confirmButtonText: "确定",
+              showCancelButton: false,
+              type: "error",
+            }
+          );
+        }
+      })
+    },
     handleSelectionChange(val) {
+      console.log(val)
       this.multipleSelection = val;
     },
     search() {

+ 19 - 0
src/views/journalQun/AddJournal.vue

@@ -276,6 +276,25 @@
                 ></el-input>
               </el-form-item>
           </el-col>
+          <el-col :span="6">
+              <el-form-item label="appid" prop="appid">
+                <el-input
+                  placeholder="请输入微信公众号appid"
+                  v-model="form.appid"
+                  clearable
+                ></el-input>
+              </el-form-item>
+          </el-col>
+          <el-col :span="6">
+              <el-form-item label="appsecret" prop="appsecret">
+                <el-input
+                  type="password"
+                  placeholder="请输入微信公众号appsecret"
+                  v-model="form.appsecret"
+                  clearable
+                ></el-input>
+              </el-form-item>
+          </el-col>
           <el-col :span="24">
               <el-form-item label="编辑部地址:" prop="editorialAddress">
                 <el-input