ソースを参照

improve: 复制

From-wh 2 年 前
コミット
81c7c4e8d2
1 ファイル変更11 行追加18 行削除
  1. 11 18
      template/admin/src/pages/kefu/mobile/orderList/orderDetail.vue

+ 11 - 18
template/admin/src/pages/kefu/mobile/orderList/orderDetail.vue

@@ -59,7 +59,7 @@
         <div>订单编号:</div>
         <div>订单编号:</div>
         <div class="conter acea-row row-middle row-right">
         <div class="conter acea-row row-middle row-right">
           {{ orderInfo.order_id }}
           {{ orderInfo.order_id }}
-          <span class="copy copy-data" :data-clipboard-text="orderInfo.order_id">复制</span>
+          <span class="copy copy-data" @click="copyText(orderInfo.order_id)">复制</span>
         </div>
         </div>
       </div>
       </div>
       <div class="item acea-row row-between">
       <div class="item acea-row row-between">
@@ -115,8 +115,7 @@
         <div v-if="orderInfo.delivery_type === 'express'">快递单号:</div>
         <div v-if="orderInfo.delivery_type === 'express'">快递单号:</div>
         <div v-if="orderInfo.delivery_type === 'send'">送货人电话:</div>
         <div v-if="orderInfo.delivery_type === 'send'">送货人电话:</div>
         <div class="conter">
         <div class="conter">
-          {{ orderInfo.delivery_id
-          }}<span class="copy copy-data" :data-clipboard-text="orderInfo.delivery_id">复制</span>
+          {{ orderInfo.delivery_id }}<span class="copy copy-data" @click="copyText(orderInfo.delivery_id)">复制</span>
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
@@ -147,7 +146,6 @@
 </template>
 </template>
 <script>
 <script>
 import PriceChange from '../../components/PriceChange';
 import PriceChange from '../../components/PriceChange';
-import ClipboardJS from 'clipboard';
 import { orderInfo } from '@/api/kefu';
 import { orderInfo } from '@/api/kefu';
 import { required, num } from '@/utils/validate';
 import { required, num } from '@/utils/validate';
 import { validatorDefaultCatch } from '@/libs/dialog';
 import { validatorDefaultCatch } from '@/libs/dialog';
@@ -182,13 +180,6 @@ export default {
   mounted: function () {
   mounted: function () {
     // this.orderId = this.$route.params.id;
     // this.orderId = this.$route.params.id;
     this.getIndex();
     this.getIndex();
-    this.$nextTick(function () {
-      var copybtn = document.getElementsByClassName('copy-data');
-      const clipboard = new ClipboardJS(copybtn);
-      clipboard.on('success', () => {
-        this.$dialog.success('复制成功');
-      });
-    });
   },
   },
   methods: {
   methods: {
     more: function () {
     more: function () {
@@ -205,6 +196,15 @@ export default {
     closeChange(msg) {
     closeChange(msg) {
       this.change = msg;
       this.change = msg;
     },
     },
+    copyText(text) {
+      this.$copyText(text)
+        .then((message) => {
+          this.$Message.success('复制成功');
+        })
+        .catch((err) => {
+          this.$Message.error('复制失败');
+        });
+    },
     getIndex: function () {
     getIndex: function () {
       let that = this;
       let that = this;
       orderInfo(this.$route.params.id).then(
       orderInfo(this.$route.params.id).then(
@@ -212,13 +212,6 @@ export default {
           that.orderInfo = res.data.orderInfo;
           that.orderInfo = res.data.orderInfo;
           that.types = res.data.orderInfo._status._type;
           that.types = res.data.orderInfo._status._type;
           that.title = res.data.orderInfo._status._title;
           that.title = res.data.orderInfo._status._title;
-          this.$nextTick(function () {
-            let copybtn = document.getElementsByClassName('copy-data');
-            const clipboard = new ClipboardJS(copybtn);
-            clipboard.on('success', () => {
-              this.$dialog.success('复制成功');
-            });
-          });
         },
         },
         (err) => {
         (err) => {
           that.$dialog.error(err.msg);
           that.$dialog.error(err.msg);