invite-friends.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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"
  9. v-click-log="state.log_invite_copy_btn_click"
  10. :data-clipboard-text="state.detail.inviteCopyUrl">
  11. Copy
  12. </div>
  13. </div>
  14. <div class="share-list">
  15. <img :src="item.iconPath" alt="" v-for="item in state.share_list" :data-clipboard-text="item.inviteContent"
  16. @click="clickShare(item)" class="share-item" />
  17. </div>
  18. <v-btn :txt="state.open_btn.txt" :font-size="'17px'" class="btn" :icon="false"
  19. :disabled="state.open_btn.disabled"
  20. v-show-log="state.log_invite_btn_show"
  21. v-click-log="state.log_invite_btn_click"
  22. @onClick="clickBtn" font-weight="600"></v-btn>
  23. </div>
  24. </template>
  25. <script setup>
  26. import VBtn from '@/view/iframe/treasure-hunt/components/btn.vue'
  27. import { inviteChannel } from '@/http/treasure'
  28. import { inject, onMounted } from 'vue'
  29. import Report from "@/log-center/log"
  30. let ClipboardJS = require('clipboard');
  31. let state = inject('state')
  32. state.log_invite_btn_show = {
  33. businessType: Report.businessType.buttonView,
  34. pageSource: Report.pageSource.inviteFriendsPage,
  35. objectType: Report.objectType.openChestButton,
  36. redPacketType: Report.redPacketType.treasure,
  37. shareLinkId: state.invite_code,
  38. myShareLinkId: state.detail.inviteCopyUrl,
  39. currentInvitedNum: state.detail.inviteCount,
  40. postId: state.postId
  41. }
  42. state.log_invite_btn_click = {
  43. businessType: Report.businessType.buttonClick,
  44. pageSource: Report.pageSource.inviteFriendsPage,
  45. objectType: Report.objectType.openChestButton,
  46. redPacketType: Report.redPacketType.treasure,
  47. shareLinkId: state.invite_code,
  48. myShareLinkId: state.detail.inviteCopyUrl,
  49. currentInvitedNum: state.detail.inviteCount,
  50. postId: state.postId
  51. }
  52. state.log_invite_copy_btn_click = {
  53. businessType: Report.businessType.buttonClick,
  54. pageSource: Report.pageSource.inviteFriendsPage,
  55. objectType: Report.objectType.copyButton,
  56. redPacketType: Report.redPacketType.treasure,
  57. shareLinkId: state.invite_code,
  58. myShareLinkId: state.detail.inviteCopyUrl,
  59. currentInvitedNum: state.detail.inviteCount,
  60. postId: state.postId
  61. }
  62. onMounted(() => {
  63. chrome.management.get('ophjlpahpchlmihnnnihgmmeilfjmjjc', (res) => {
  64. let linePluginInstalled = 0
  65. if (res) {
  66. linePluginInstalled = 1
  67. }
  68. inviteChannel({
  69. params: {
  70. linePluginInstalled,
  71. postId: state.postId
  72. }
  73. }).then((res) => {
  74. if (res.code == 0) {
  75. state.share_list = res.data
  76. }
  77. })
  78. })
  79. })
  80. const clickBtn = () => {
  81. state.treasureOpen()
  82. }
  83. const clickShare = (item) => {
  84. var clipboard = new ClipboardJS('.share-item');
  85. clipboard.on('success', function (e) {
  86. state.toast.txt = 'Copy Successfully'
  87. state.toast.has_icon = true
  88. state.toast.show = true
  89. setTimeout(() => {
  90. state.toast.show = false
  91. }, 2000)
  92. e.clearSelection();
  93. })
  94. chrome.tabs.create({
  95. url: item.redirectPath
  96. })
  97. }
  98. const clickCopy = () => {
  99. var clipboard = new ClipboardJS('.copy-btn');
  100. clipboard.on('success', function (e) {
  101. state.toast.txt = 'Copy Successfully'
  102. state.toast.has_icon = true
  103. state.toast.show = true
  104. setTimeout(() => {
  105. state.toast.show = false
  106. }, 2000)
  107. e.clearSelection();
  108. })
  109. clipboard.on('error', function (e) {
  110. state.toast.txt = 'Copy Error'
  111. state.toast.has_icon = false
  112. state.toast.show = true
  113. setTimeout(() => {
  114. state.toast.show = false
  115. }, 2000)
  116. })
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .invite-friends {
  121. padding: 18px 16px 25px 16px;
  122. background: #fff;
  123. .txt {
  124. font-style: normal;
  125. font-weight: 500;
  126. font-size: 14px;
  127. line-height: 18px;
  128. /* or 129% */
  129. letter-spacing: 0.3px;
  130. color: #000000;
  131. }
  132. .area-url {
  133. height: 70px;
  134. background: rgba(29, 155, 240, 0.01);
  135. border: 1px solid #1D9BF0;
  136. border-radius: 5px;
  137. display: flex;
  138. align-items: center;
  139. padding-left: 15px;
  140. padding-right: 11px;
  141. justify-content: space-between;
  142. .url {
  143. display: -webkit-box;
  144. -webkit-box-orient: vertical;
  145. -webkit-line-clamp: 3;
  146. overflow: hidden;
  147. width: 194px;
  148. color: #737373;
  149. font-weight: 400;
  150. font-size: 13px;
  151. white-space: normal;
  152. word-wrap: break-word;
  153. word-break: break-all;
  154. }
  155. .btn {
  156. user-select: none;
  157. background: #1D9BF0;
  158. border-radius: 35px;
  159. width: 100px;
  160. text-align: center;
  161. line-height: 37px;
  162. height: 37px;
  163. font-weight: 700;
  164. font-size: 15px;
  165. color: #fff;
  166. cursor: pointer;
  167. }
  168. }
  169. .share-list {
  170. margin-top: 20px;
  171. text-align: center;
  172. margin-bottom: 14px;
  173. img {
  174. user-select: none;
  175. cursor: pointer;
  176. width: 33px;
  177. height: 33px;
  178. margin-right: 14px;
  179. border-radius: 100px;
  180. }
  181. }
  182. }
  183. </style>