invite-friends.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div class="invite-friends">
  3. <div class="txt">To open the treasure chest you need to share the URL to your friends. Make sure they finish
  4. the
  5. tasks.</div>
  6. <div class="area-url">
  7. <div class="url">{{ state.detail.inviteUrl }}</div>
  8. <div class="btn copy-btn" @click="clickCopy" :data-clipboard-text="state.detail.inviteCopyUrl">
  9. Copy
  10. </div>
  11. </div>
  12. <div class="share-list">
  13. <img :src="item.iconPath" alt="" v-for="item in state.share_list" @click="clickShare(item)" />
  14. </div>
  15. <v-btn :txt="state.open_btn.txt" :font-size="'17px'" class="btn" :icon="false"
  16. :disabled="state.open_btn.disabled" @onClick="clickBtn"></v-btn>
  17. <v-toast :show="state.toast.show" :txt="state.toast.txt"></v-toast>
  18. <open-box v-if="state.open_box.show"></open-box>
  19. </div>
  20. </template>
  21. <script setup>
  22. import VBtn from '@/view/iframe/treasure-hunt/components/btn.vue'
  23. import VToast from '@/view/iframe/treasure-hunt/components/toast.vue'
  24. import OpenBox from '@/view/iframe/treasure-hunt/components/dialog.vue'
  25. import { inviteChannel } from '@/http/treasure'
  26. import { treasureOpen } from '@/http/treasure'
  27. import { inject, onMounted } from 'vue'
  28. let ClipboardJS = require('clipboard');
  29. let state = inject('state')
  30. state.toast = {}
  31. onMounted(() => {
  32. inviteChannel({
  33. params: {
  34. postId: state.postId
  35. }
  36. }).then((res) => {
  37. if (res.code == 0) {
  38. state.share_list = res.data
  39. }
  40. })
  41. })
  42. const clickBtn = () => {
  43. treasureOpen({
  44. params: {
  45. postId: state.postId,
  46. treasureId: state.treasureId,
  47. }
  48. }).then((res) => {
  49. if (res.code == 0) {
  50. state.open_box.show = true
  51. state.open_box = res.data
  52. }
  53. })
  54. }
  55. const clickShare = (item) => {
  56. window.open(item.redirectPath)
  57. }
  58. var clipboard = new ClipboardJS('.copy-btn');
  59. const clickCopy = () => {
  60. clipboard.on('success', function (e) {
  61. state.toast.txt = 'Copy Successfully'
  62. state.toast.show = true
  63. setTimeout(() => {
  64. state.toast.show = false
  65. }, 2000)
  66. e.clearSelection();
  67. });
  68. clipboard.on('error', function (e) {
  69. state.toast.txt = 'Copy Error'
  70. state.toast.show = true
  71. setTimeout(() => {
  72. state.toast.show = false
  73. }, 2000)
  74. });
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .invite-friends {
  79. padding: 18px 16px 25px 16px;
  80. background: #fff;
  81. .txt {
  82. font-style: normal;
  83. font-weight: 500;
  84. font-size: 14px;
  85. line-height: 18px;
  86. /* or 129% */
  87. letter-spacing: 0.3px;
  88. color: #000000;
  89. }
  90. .area-url {
  91. height: 70px;
  92. background: rgba(29, 155, 240, 0.01);
  93. border: 1px solid #1D9BF0;
  94. border-radius: 5px;
  95. display: flex;
  96. align-items: center;
  97. padding-left: 15px;
  98. padding-right: 11px;
  99. justify-content: space-between;
  100. .url {
  101. display: -webkit-box;
  102. -webkit-box-orient: vertical;
  103. -webkit-line-clamp: 3;
  104. overflow: hidden;
  105. width: 194px;
  106. color: #737373;
  107. font-weight: 400;
  108. font-size: 13px;
  109. white-space: normal;
  110. word-wrap: break-word;
  111. word-break: break-all;
  112. }
  113. .btn {
  114. user-select: none;
  115. background: #1D9BF0;
  116. border-radius: 35px;
  117. width: 100px;
  118. text-align: center;
  119. line-height: 37px;
  120. height: 37px;
  121. font-weight: 700;
  122. font-size: 15px;
  123. color: #fff;
  124. cursor: pointer;
  125. }
  126. }
  127. .share-list {
  128. margin-top: 20px;
  129. text-align: center;
  130. margin-bottom: 14px;
  131. img {
  132. user-select: none;
  133. cursor: pointer;
  134. width: 33px;
  135. height: 33px;
  136. margin-right: 14px;
  137. border-radius: 100px;
  138. }
  139. }
  140. }
  141. </style>