Explorar el Código

素材分享二维码

wjj hace 3 semanas
padre
commit
f66093dd85
Se han modificado 2 ficheros con 50 adiciones y 1 borrados
  1. 8 0
      src/api/qw/companyCustomer.js
  2. 42 1
      src/views/qw/companyCustomer/index.vue

+ 8 - 0
src/api/qw/companyCustomer.js

@@ -193,3 +193,11 @@ export function importCustomer(data) {
     headers: { 'Content-Type': 'multipart/form-data' }
   })
 }
+
+
+export function getShareMaterialWxCode(shareMaterialId) {
+  return request({
+    url: '/qw/companyCustomer/getShareMaterialWxCode/' + shareMaterialId,
+    method: 'get'
+  });
+}

+ 42 - 1
src/views/qw/companyCustomer/index.vue

@@ -504,6 +504,13 @@
       @pagination="getList"
     />
 
+    <el-dialog :title="shareMaterialWxCodeForm.title" v-if="shareMaterialWxCodeForm.open" :visible.sync="shareMaterialWxCodeForm.open"
+               width="450px" append-to-body>
+      <div style="padding-bottom:15px;">
+        <img :src="shareMaterialWxCodeImage" width="400px">
+      </div>
+    </el-dialog>
+
     <el-dialog
       :title="shareMaterial.title"
       :visible.sync="shareMaterial.open"
@@ -1620,6 +1627,7 @@ import {
   improve,
   getScrmPrescribeInfo,
   importCustomer,
+  getShareMaterialWxCode,
 } from "@/api/qw/companyCustomer";
 import { treeselect } from "@/api/company/companyDept";
 import { parseTime } from "@/utils/common";
@@ -1959,7 +1967,10 @@ export default {
         shareMaterialId: [
           { required: true, message: "请选择素材", trigger: "change" },
         ],
-      }
+      },
+
+      shareMaterialWxCodeForm:{open: false, title: "素材分享二维码"},
+      shareMaterialWxCodeImage: null,
     };
   },
   created() {
@@ -1990,8 +2001,38 @@ export default {
   },
   methods: {
 
+    downloadShareMaterialWxCodeImage(imageSrc, fileName) {
+      const link = document.createElement('a');
+      link.href = imageSrc;
+      link.download = fileName || '分享素材.png';
+      document.body.appendChild(link);
+      link.click();
+      document.body.removeChild(link);
+    },
+
     shareMaterialSubmitForm(){
+      this.$refs.shareMaterialForm.validate(valid => {
+        if (valid) {
+          this.generateShareMaterialWxCode(this.shareMaterialForm.shareMaterialId);
+        }
+      })
+    },
 
+    generateShareMaterialWxCode(shareMaterialId) { 
+      let loadingRock = this.$loading({
+        lock: true,
+        text: '生成二维码中~~请不要刷新页面!!',
+        spinner: 'el-icon-loading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      });
+      getShareMaterialWxCode(shareMaterialId).then(response => { 
+        this.shareMaterialCancel();
+        this.shareMaterialWxCodeImage = response.url;
+        this.shareMaterialWxCodeForm.open = true;
+        loadingRock.close();
+      }).finally(res => { 
+        loadingRock.close();
+      })
     },
     shareMaterialCancel() { 
       this.shareMaterial.open = false;