index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view :style="viewColor">
  3. <view class='copy-list-window' :class='isCopy==true?"on":""'>
  4. <button class="iconfont icon-guanbi" @click='close'></button>
  5. <view class="title">
  6. <text class="iconfont icon-xuanzhong11"></text>
  7. {{title}}
  8. </view>
  9. <view class="copy-url">
  10. <!-- #ifdef H5 -->
  11. <text class="copy copy-data" :data-clipboard-text="copyUrl">{{copyUrl}}</text>
  12. <!-- #endif -->
  13. <!-- #ifndef H5 -->
  14. <text>{{copyUrl}}</text>
  15. <!-- #endif -->
  16. </view>
  17. <!-- #ifdef H5 -->
  18. <button class="button copy-data" :data-clipboard-text="copyUrl">点击复制口令</button>
  19. <!-- #endif -->
  20. <!-- #ifndef H5 -->
  21. <button class="button" @click="copyText">点击复制口令</button>
  22. <!-- #endif -->
  23. </view>
  24. <view class='mask' catchtouchmove="true" :hidden='isCopy==false' @click='close'></view>
  25. </view>
  26. </template>
  27. <script>
  28. // +----------------------------------------------------------------------
  29. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  30. // +----------------------------------------------------------------------
  31. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  32. // +----------------------------------------------------------------------
  33. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  34. // +----------------------------------------------------------------------
  35. // | Author: CRMEB Team <admin@crmeb.com>
  36. // +----------------------------------------------------------------------
  37. // #ifdef H5
  38. import ClipboardJS from "@/plugin/clipboard/clipboard.js";
  39. // #endif
  40. import { mapGetters } from "vuex";
  41. export default {
  42. props: {
  43. isCopy: {
  44. type: Boolean,
  45. default: false,
  46. },
  47. copyUrl: {
  48. type: String,
  49. default: '',
  50. }
  51. },
  52. computed: mapGetters(['viewColor']),
  53. data() {
  54. return {
  55. title: '复制以下口令'
  56. };
  57. },
  58. mounted(){
  59. let that = this
  60. // #ifdef H5
  61. that.$nextTick(function() {
  62. var clipboard = new ClipboardJS('.copy-data');
  63. clipboard.on('success', function(e) {
  64. that.$util.Tips({
  65. title:'复制成功'
  66. })
  67. setTimeout(()=>{
  68. that.$emit('close');
  69. },500)
  70. });
  71. clipboard.on('error', function(e) {
  72. that.$util.Tips({
  73. title:'复制失败'
  74. })
  75. });
  76. });
  77. // #endif
  78. },
  79. methods: {
  80. //#ifndef H5
  81. copyText:function(){
  82. let that = this;
  83. uni.setClipboardData({ data: this.copyUrl });
  84. setTimeout(()=>{
  85. that.$emit('close');
  86. },500)
  87. },
  88. // #endif
  89. close: function(){
  90. this.$emit('close');
  91. }
  92. }
  93. }
  94. </script>
  95. <style scoped lang="scss">
  96. .copy-list-window {
  97. position: fixed;
  98. bottom: 0;
  99. left: 0;
  100. width: 100%;
  101. background-color: #fff;
  102. border-radius: 16rpx 16rpx 0 0;
  103. z-index: 555;
  104. transform: translate3d(0, 100%, 0);
  105. transition: all .1s cubic-bezier(.25, .5, .5, .9);
  106. padding: 50rpx 30rpx 30rpx;
  107. .icon-guanbi{
  108. position: absolute;
  109. top: 20rpx;
  110. right: 20rpx;
  111. color: #8A8A8A;
  112. }
  113. .button{
  114. height: 76rpx;
  115. border-radius: 38rpx;
  116. margin: 30rpx 30rpx 0;
  117. background-color: var(--view-theme);
  118. font-size: 30rpx;
  119. line-height: 76rpx;
  120. color: #FFFFFF;
  121. }
  122. }
  123. .copy-list-window.on {
  124. transform: translate3d(0, 0, 0);
  125. }
  126. .copy-list-window .title {
  127. width: 100%;
  128. text-align: center;
  129. font-size: 32rpx;
  130. font-weight: bold;
  131. font-family: 'PingFang SC';
  132. .iconfont {
  133. font-size: 30rpx;
  134. color: #FBB324;
  135. margin-right: 12rpx;
  136. }
  137. }
  138. .copy-url{
  139. margin-top: 30rpx;
  140. background: #F5F5F5;
  141. padding: 20rpx 25rpx;
  142. color: #BBBBBB;
  143. font-size: 28rpx;
  144. }
  145. </style>