许成详 6 年前
父节点
当前提交
546b3f6796
共有 4 个文件被更改,包括 33 次插入18 次删除
  1. 8
    0
      package-lock.json
  2. 1
    0
      package.json
  3. 21
    18
      src/pages/system/cardAndCouponManager/bodyBuildingCardManager/index.vue
  4. 3
    0
      src/store/index.js

+ 8
- 0
package-lock.json 查看文件

15248
         "uppercamelcase": "1.1.0"
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
     "vue-cookie": {
15259
     "vue-cookie": {
15252
       "version": "1.1.4",
15260
       "version": "1.1.4",
15253
       "resolved": "https://registry.npmjs.org/vue-cookie/-/vue-cookie-1.1.4.tgz",
15261
       "resolved": "https://registry.npmjs.org/vue-cookie/-/vue-cookie-1.1.4.tgz",

+ 1
- 0
package.json 查看文件

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

+ 21
- 18
src/pages/system/cardAndCouponManager/bodyBuildingCardManager/index.vue 查看文件

82
               size="mini"
82
               size="mini"
83
               type="danger"
83
               type="danger"
84
               @click="sendCard(scope.$index, scope.row)">赠送客户</el-button>
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
           </template>
92
           </template>
87
         </el-table-column>
93
         </el-table-column>
88
       </el-table>
94
       </el-table>
201
           v-model="currentCopyUrl"
207
           v-model="currentCopyUrl"
202
           clearable>
208
           clearable>
203
         </el-input>
209
         </el-input>
204
-        <!-- <a :data-clipboard-text="currentCopyUrl" ref="copy" @click="toCopy">复制链接</a> -->
205
       </div>
210
       </div>
206
       <span slot="footer" class="dialog-footer">
211
       <span slot="footer" class="dialog-footer">
207
         <el-button type="primary" @click="copyDialogVisible = false">确 定</el-button>
212
         <el-button type="primary" @click="copyDialogVisible = false">确 定</el-button>
211
 </template>
216
 </template>
212
 
217
 
213
 <script>
218
 <script>
214
-import Clipboard from 'clipboard'
215
 import { mapState, createNamespacedHelpers } from 'vuex'
219
 import { mapState, createNamespacedHelpers } from 'vuex'
216
 const { mapState: mapGymCardState, mapActions: mapGymCardActions } = createNamespacedHelpers('gymcard')
220
 const { mapState: mapGymCardState, mapActions: mapGymCardActions } = createNamespacedHelpers('gymcard')
217
 const { mapState: mapCustomerState, mapActions: mapCustomerActions } = createNamespacedHelpers('customer')
221
 const { mapState: mapCustomerState, mapActions: mapCustomerActions } = createNamespacedHelpers('customer')
220
   name: '',
224
   name: '',
221
   data () {
225
   data () {
222
     return {
226
     return {
227
+      clipboardArr: [],
223
       currentCopyUrl: '',
228
       currentCopyUrl: '',
224
       copyDialogVisible: false,
229
       copyDialogVisible: false,
225
       selectCustomer: [],
230
       selectCustomer: [],
293
     },
298
     },
294
     toSendCard () { // 赠送卡
299
     toSendCard () { // 赠送卡
295
       if (this.selectCustomer.length) {
300
       if (this.selectCustomer.length) {
296
-        console.log(this.selectCustomer)
297
         this.selectCustomer = this.selectCustomer.map(x => x.CustomerId).join(',')
301
         this.selectCustomer = this.selectCustomer.map(x => x.CustomerId).join(',')
298
         this.giveCard({
302
         this.giveCard({
299
           id: this.currentCardId,
303
           id: this.currentCardId,
338
         caseid: this.CaseId || this.defaultCaseId
342
         caseid: this.CaseId || this.defaultCaseId
339
       }).then((res) => {
343
       }).then((res) => {
340
         this.total = res.pagenum
344
         this.total = res.pagenum
341
-        // console.log(JSON.stringify(res))
342
       })
345
       })
343
     },
346
     },
344
     handleCurrentChange (val) { // 跳转到分页
347
     handleCurrentChange (val) { // 跳转到分页
347
     handleEdit (index, row) { // 编辑
350
     handleEdit (index, row) { // 编辑
348
       this.$router.push({ name: 'editBodyBuildingCard', query: { id: row.GymCardId } })
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
 </script>
370
 </script>
382
     }
385
     }
383
   }
386
   }
384
 }
387
 }
385
-.copyBtn{
388
+.copyBtn {
386
   line-height: 29px;
389
   line-height: 29px;
387
   border-radius: 3px;
390
   border-radius: 3px;
388
   color: #fff;
391
   color: #fff;

+ 3
- 0
src/store/index.js 查看文件

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