wuguojie 11 mesi fa
parent
commit
2128bafec5
1 ha cambiato i file con 18 aggiunte e 2 eliminazioni
  1. 18 2
      src/views/commodityCenter/commodityManage/list.vue

+ 18 - 2
src/views/commodityCenter/commodityManage/list.vue

@@ -30,8 +30,8 @@
     <el-dialog title="生成推广链接" :visible.sync="linkShareShow" width="40%">
       <div class="flex a-c">
         <span>推广链接</span>
-            <el-input v-model="queryform.productName" placeholder="请输入推广链接" clearable style="width: 70%;margin: 0 20px;"></el-input>
-          <el-button   @click="linkShare(row)">复制</el-button>
+            <el-input v-model="productLink" placeholder="请输入推广链接" clearable style="width: 70%;margin: 0 20px;"></el-input>
+          <el-button   @click="linkCopy()">复制</el-button>
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="linkShareShow = false">取 消</el-button>
@@ -82,6 +82,7 @@ export default {
         { prop: "soldQuantity", label: "已售", minWidth: 180 },
         { prop: "productStatus", label: "状态", minWidth: 180,formatter: this.productStatusFormatter },
       ],
+        productLink: '',
     }
   },
   // 生命周期函数
@@ -109,6 +110,21 @@ export default {
      */
     linkShare(row) {
         this.linkShareShow=true;
+        if(row.type == 1) {
+            this.productLink = `https://test.baoxianzhanggui.com/custh5/#/pages/mall/detail/details-food?productId=${row.productId}&merchantId=${row.merchantId}&categoryId=${row.categoryId}`
+        } else if(row.type == 2) {
+            this.productLink = `https://test.baoxianzhanggui.com/custh5/#/pages/mall/detail/details-service?productId=${row.productId}&merchantId=${row.merchantId}&categoryId=${row.categoryId}`
+        }
+    },
+    linkCopy() {
+        let inputs=document.createElement("input")     //创建节点
+        inputs.value=this.productLink //给节点赋值
+        document.body.appendChild(inputs) //渲染节点(要不然不起作用,可以添加隐藏属性)
+        inputs.select() //选中节点
+        let  actions =  document.execCommand("Copy") //指定复制命令(返回的是一个boolean类型)
+        if(this.productLink && actions) {
+            this.$message.success('复制成功!')
+        }
     },
     async findPage(data) {
       if (data && data.pageRequest) {