index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view>
  3. <uni-popup class="" ref="popup">
  4. <view class="popup-box">
  5. <view class="img">
  6. <image src="/static/image/img29.png" mode=""></image>
  7. </view>
  8. <view class="mian">
  9. <view class="delivery">
  10. <view class="title">已经为您定制专属客服</view>
  11. <image src="/static/image/img30.png" mode=""></image>
  12. </view>
  13. <view class="nocancel">客服VX:{{ kefu }}</view>
  14. <view class="comfirm-box">
  15. <view class="cancel" @click="close">取消</view>
  16. <view class="comfirm" @click="comfirm(kefu)">复制微信</view>
  17. </view>
  18. </view>
  19. </view>
  20. </uni-popup>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. props: [],
  26. data() {
  27. return{
  28. kefu:'vx458562',
  29. show:false
  30. };
  31. },
  32. mounted() {},
  33. methods: {
  34. open(){
  35. this.$refs.popup.open('center')
  36. },
  37. close(){
  38. this.$refs.popup.close()
  39. },
  40. comfirm(text) {
  41. console.log(text);
  42. const result = this.uniCopy(text);
  43. if (result === false) {
  44. uni.showToast({
  45. title: "不支持",
  46. });
  47. } else {
  48. uni.showToast({
  49. title: "复制成功",
  50. icon: "none",
  51. });
  52. }
  53. this.close();
  54. },
  55. uniCopy(content) {
  56. /**
  57. * 小程序端 和 app端的复制逻辑
  58. */
  59. //#ifndef H5
  60. uni.setClipboardData({
  61. data: content,
  62. success: function () {
  63. console.log("success");
  64. return true;
  65. },
  66. });
  67. //#endif
  68. /**
  69. * H5端的复制逻辑
  70. */
  71. // #ifdef H5
  72. if (!document.queryCommandSupported("copy")) {
  73. //为了兼容有些浏览器 queryCommandSupported 的判断
  74. // 不支持
  75. return false;
  76. }
  77. let textarea = document.createElement("textarea");
  78. textarea.value = content;
  79. textarea.readOnly = "readOnly";
  80. document.body.appendChild(textarea);
  81. textarea.select(); // 选择对象
  82. textarea.setSelectionRange(0, content.length); //核心
  83. let result = document.execCommand("copy"); // 执行浏览器复制命令
  84. textarea.remove();
  85. return result;
  86. // #endif
  87. },
  88. },
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. .popup-box {
  93. position: relative;
  94. background-color: #ffffff;
  95. border-radius: 25rpx;
  96. .img {
  97. position: relative;
  98. top: -60rpx;
  99. left: 10%;
  100. width: 80%;
  101. height: 150rpx;
  102. display: flex;
  103. justify-content: center;
  104. image {
  105. border-radius: 20rpx 20rpx 0 0;
  106. height: 150rpx;
  107. }
  108. }
  109. .mian {
  110. margin-top: -44rpx;
  111. display: flex;
  112. flex-direction: column;
  113. align-items: center;
  114. // padding: 32rpx 32rpx;
  115. background-color: #ffffff;
  116. border-radius: 0 0 20rpx 20rpx;
  117. text-align: center;
  118. .delivery {
  119. font-size: 40rpx;
  120. color: #333333;
  121. display: flex;
  122. align-items: center;
  123. flex-direction: column;
  124. .title {
  125. }
  126. image {
  127. margin-top: 48rpx;
  128. width: 172rpx;
  129. height: 160rpx;
  130. }
  131. }
  132. .nocancel {
  133. font-size: 32rpx;
  134. color: #333333;
  135. margin-top: 14rpx;
  136. }
  137. .comfirm-box {
  138. margin: 52rpx 0rpx;
  139. display: flex;
  140. .cancel {
  141. display: flex;
  142. align-items: center;
  143. justify-content: center;
  144. width: 197rpx;
  145. height: 74rpx;
  146. border: 1px solid #dcc786;
  147. border-radius: 38rpx;
  148. font-size: 32rpx;
  149. color: #605128;
  150. }
  151. .comfirm {
  152. margin-left: 32rpx;
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. width: 197rpx;
  157. height: 74rpx;
  158. background: linear-gradient(
  159. -90deg,
  160. #d1ba77 0%,
  161. #f7e8ad 100%
  162. );
  163. border-radius: 38px;
  164. font-size: 32rpx;
  165. color: #605128;
  166. }
  167. }
  168. }
  169. }
  170. </style>