许成详 před 6 roky
rodič
revize
546b3f6796

+ 8
- 0
package-lock.json Zobrazit soubor

@@ -15248,6 +15248,14 @@
15248 15248
         "uppercamelcase": "1.1.0"
15249 15249
       }
15250 15250
     },
15251
+    "vue-clipboard2": {
15252
+      "version": "0.2.1",
15253
+      "resolved": "https://registry.npmjs.org/vue-clipboard2/-/vue-clipboard2-0.2.1.tgz",
15254
+      "integrity": "sha512-n6ie/0g0bKohmLlC/5ja1esq2Q0jQ5hWmhNSZcvCsWfDeDnVARjl6cBB9p72XV1nlVfuqsZcfV8HTjjZAIlLBA==",
15255
+      "requires": {
15256
+        "clipboard": "2.0.1"
15257
+      }
15258
+    },
15251 15259
     "vue-cookie": {
15252 15260
       "version": "1.1.4",
15253 15261
       "resolved": "https://registry.npmjs.org/vue-cookie/-/vue-cookie-1.1.4.tgz",

+ 1
- 0
package.json Zobrazit soubor

@@ -24,6 +24,7 @@
24 24
     "js-md5": "^0.7.3",
25 25
     "vue": "^2.5.2",
26 26
     "vue-amap": "^0.5.8",
27
+    "vue-clipboard2": "^0.2.1",
27 28
     "vue-cookie": "^1.1.4",
28 29
     "vue-fullcalendar": "^1.0.9",
29 30
     "vue-morris": "0.0.13",

+ 21
- 18
src/pages/system/cardAndCouponManager/bodyBuildingCardManager/index.vue Zobrazit soubor

@@ -82,7 +82,13 @@
82 82
               size="mini"
83 83
               type="danger"
84 84
               @click="sendCard(scope.$index, scope.row)">赠送客户</el-button>
85
-            <a v-if="scope.row.SendType === 'channel'" class="copyBtn" :data-clipboard-text="'www.baidu.com'" :ref="'copy' + scope.$index" @click="toCopy(scope.$index, scope.row)">点击复制链接</a>
85
+            <el-button
86
+              size="mini"
87
+              type="success"
88
+              v-clipboard:copy="'www.baidu.com' + scope.$index"
89
+              v-clipboard:success="onCopy"
90
+              v-clipboard:error="onError"
91
+              >点击复制链接</el-button>
86 92
           </template>
87 93
         </el-table-column>
88 94
       </el-table>
@@ -201,7 +207,6 @@
201 207
           v-model="currentCopyUrl"
202 208
           clearable>
203 209
         </el-input>
204
-        <!-- <a :data-clipboard-text="currentCopyUrl" ref="copy" @click="toCopy">复制链接</a> -->
205 210
       </div>
206 211
       <span slot="footer" class="dialog-footer">
207 212
         <el-button type="primary" @click="copyDialogVisible = false">确 定</el-button>
@@ -211,7 +216,6 @@
211 216
 </template>
212 217
 
213 218
 <script>
214
-import Clipboard from 'clipboard'
215 219
 import { mapState, createNamespacedHelpers } from 'vuex'
216 220
 const { mapState: mapGymCardState, mapActions: mapGymCardActions } = createNamespacedHelpers('gymcard')
217 221
 const { mapState: mapCustomerState, mapActions: mapCustomerActions } = createNamespacedHelpers('customer')
@@ -220,6 +224,7 @@ export default {
220 224
   name: '',
221 225
   data () {
222 226
     return {
227
+      clipboardArr: [],
223 228
       currentCopyUrl: '',
224 229
       copyDialogVisible: false,
225 230
       selectCustomer: [],
@@ -293,7 +298,6 @@ export default {
293 298
     },
294 299
     toSendCard () { // 赠送卡
295 300
       if (this.selectCustomer.length) {
296
-        console.log(this.selectCustomer)
297 301
         this.selectCustomer = this.selectCustomer.map(x => x.CustomerId).join(',')
298 302
         this.giveCard({
299 303
           id: this.currentCardId,
@@ -338,7 +342,6 @@ export default {
338 342
         caseid: this.CaseId || this.defaultCaseId
339 343
       }).then((res) => {
340 344
         this.total = res.pagenum
341
-        // console.log(JSON.stringify(res))
342 345
       })
343 346
     },
344 347
     handleCurrentChange (val) { // 跳转到分页
@@ -347,21 +350,21 @@ export default {
347 350
     handleEdit (index, row) { // 编辑
348 351
       this.$router.push({ name: 'editBodyBuildingCard', query: { id: row.GymCardId } })
349 352
     },
350
-    toCopy (index, row) { // 复制
351
-      console.log(1)
352
-      var clipboard = new Clipboard(this.$refs['copy' + index])
353
-      clipboard.on('success', e => {
354
-        console.log('复制成功')
355
-        clipboard.destroy()
353
+    addCard () {
354
+      this.$router.push({ name: 'editBodyBuildingCard', query: {} })
355
+    },
356
+    onCopy () {
357
+      this.$message({
358
+        type: 'success',
359
+        message: '复制成功!'
356 360
       })
357
-      clipboard.on('error', e => {
358
-        console.log('该浏览器不支持自动复制')
359
-        clipboard.destroy()
361
+    },
362
+    onError () {
363
+      this.$message({
364
+        type: 'error',
365
+        message: '复制失败!'
360 366
       })
361 367
     },
362
-    addCard () {
363
-      this.$router.push({ name: 'editBodyBuildingCard', query: {} })
364
-    }
365 368
   }
366 369
 }
367 370
 </script>
@@ -382,7 +385,7 @@ export default {
382 385
     }
383 386
   }
384 387
 }
385
-.copyBtn{
388
+.copyBtn {
386 389
   line-height: 29px;
387 390
   border-radius: 3px;
388 391
   color: #fff;

+ 3
- 0
src/store/index.js Zobrazit soubor

@@ -2,7 +2,10 @@ import Vue from 'vue'
2 2
 import Vuex from 'vuex'
3 3
 import Ajax from '../util/ajax'
4 4
 import api from '../util/api'
5
+import VueClipboard from 'vue-clipboard2'
6
+
5 7
 Vue.use(Vuex)
8
+Vue.use(VueClipboard)
6 9
 
7 10
 const store = new Vuex.Store({
8 11
   state: {