index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <popup v-if="show" :key="Math.random()" :zIdx="'1100'">
  3. <div
  4. class="ui-message ui-message-confirm"
  5. :class="{
  6. dark
  7. }"
  8. >
  9. <div class="ui-message-header">
  10. <span>{{work_preview}}</span>
  11. <span @click="$emit('close')">
  12. <i class="iconfont icon_close"></i>
  13. </span>
  14. </div>
  15. <div class="ui-message-main">
  16. <iframe :src="ifr" frameborder="0"></iframe>
  17. </div>
  18. <div class="ui-message-footer">
  19. <button
  20. class="ui-button ui-button-rect"
  21. :class="{
  22. deepcancel: dark,
  23. }"
  24. @click="$emit('close')"
  25. >
  26. {{cancel}}
  27. </button>
  28. <button class="ui-button submit ui-button-rect" @click="copy">{{copy_link}}</button>
  29. <button class="ui-button submit ui-button-rect" @click="openBlank">{{new_blank}}</button>
  30. </div>
  31. </div>
  32. </popup>
  33. </template>
  34. <script>
  35. import Popup from "@/components/shared/popup";
  36. import {i18n} from "@/lang"
  37. export default {
  38. props: {
  39. show: {
  40. },
  41. ifr: {
  42. },
  43. name: {
  44. },
  45. dark: {
  46. type: Boolean,
  47. default: true
  48. }
  49. },
  50. components:{
  51. Popup,
  52. },
  53. data(){
  54. return {
  55. copy_link: i18n.t("material.works.copy_link"),
  56. work_preview: i18n.t("material.works.work_preview"),
  57. new_blank: i18n.t("material.works.new_blank"),
  58. cancel: i18n.t("material.works.cancel"),
  59. }
  60. },
  61. methods:{
  62. copy() {
  63. var textArea = document.createElement("textarea");
  64. textArea.style.position = "fixed";
  65. textArea.style.top = 0;
  66. textArea.style.left = 0;
  67. textArea.style.width = "2em";
  68. textArea.style.height = "2em";
  69. textArea.style.padding = 0;
  70. textArea.style.border = "none";
  71. textArea.style.outline = "none";
  72. textArea.style.boxShadow = "none";
  73. textArea.style.background = "transparent";
  74. textArea.value = new URL(this.ifr, location.href);
  75. document.body.appendChild(textArea);
  76. textArea.select();
  77. try {
  78. document.execCommand("copy")
  79. ? this.$msg.success(this.$i18n.t('gather.scene_link_copy_tips'))
  80. : this.$msg.error(this.$i18n.t('gather.scene_link_copy_failed'))
  81. } catch (err) {
  82. this.$msg.error(this.$i18n.t('gather.scene_link_copy_failed'))
  83. }
  84. document.body.removeChild(textArea);
  85. },
  86. openBlank(){
  87. window.open(this.ifr,'_blank')
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="less" scoped>
  93. .ui-message-confirm{
  94. width: 1250px;
  95. height: 838px;
  96. border-radius: 4px;
  97. .icon_close{
  98. color: #969799;
  99. }
  100. .ui-message-header{
  101. font-size: 18px;
  102. margin-bottom: 40px;
  103. }
  104. .ui-message-main{
  105. width: 100%;
  106. height: 646px;
  107. margin-bottom: 40px;
  108. iframe{
  109. width: 100%;
  110. height: 100%;
  111. }
  112. }
  113. .ui-message-footer{
  114. display: flex;
  115. justify-content: center;
  116. }
  117. }
  118. </style>