invite-friends.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. try {
  64. chrome.management.get('ophjlpahpchlmihnnnihgmmeilfjmjjc', (res) => {
  65. let linePluginInstalled = 0
  66. if (res) {
  67. linePluginInstalled = 1
  68. }
  69. inviteChannel({
  70. params: {
  71. linePluginInstalled,
  72. postId: state.postId
  73. }
  74. }).then((res) => {
  75. if (res.code == 0) {
  76. state.share_list = res.data
  77. }
  78. })
  79. })
  80. } catch (error) {
  81. console.error(error)
  82. }
  83. })
  84. const clickBtn = () => {
  85. state.treasureOpen()
  86. }
  87. const clickShare = (item) => {
  88. var clipboard = new ClipboardJS('.share-item');
  89. clipboard.on('success', function (e) {
  90. state.toast.txt = 'Copy Successfully'
  91. state.toast.has_icon = true
  92. state.toast.show = true
  93. setTimeout(() => {
  94. state.toast.show = false
  95. }, 2000)
  96. e.clearSelection();
  97. })
  98. chrome.tabs.create({
  99. url: item.redirectPath
  100. })
  101. }
  102. const clickCopy = () => {
  103. var clipboard = new ClipboardJS('.copy-btn');
  104. clipboard.on('success', function (e) {
  105. state.toast.txt = 'Copy Successfully'
  106. state.toast.has_icon = true
  107. state.toast.show = true
  108. setTimeout(() => {
  109. state.toast.show = false
  110. }, 2000)
  111. e.clearSelection();
  112. })
  113. clipboard.on('error', function (e) {
  114. state.toast.txt = 'Copy Error'
  115. state.toast.has_icon = false
  116. state.toast.show = true
  117. setTimeout(() => {
  118. state.toast.show = false
  119. }, 2000)
  120. })
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .invite-friends {
  125. padding: 18px 16px 25px 16px;
  126. background: #fff;
  127. .txt {
  128. font-style: normal;
  129. font-weight: 500;
  130. font-size: 13px;
  131. line-height: 18px;
  132. /* or 129% */
  133. margin-bottom: 18.5px;
  134. letter-spacing: 0.3px;
  135. color: #000000;
  136. }
  137. .area-url {
  138. height: 70px;
  139. background: rgba(29, 155, 240, 0.01);
  140. border: 1px solid #1D9BF0;
  141. border-radius: 5px;
  142. display: flex;
  143. align-items: center;
  144. padding-left: 15px;
  145. padding-right: 11px;
  146. justify-content: space-between;
  147. .url {
  148. display: -webkit-box;
  149. -webkit-box-orient: vertical;
  150. -webkit-line-clamp: 3;
  151. overflow: hidden;
  152. width: 194px;
  153. color: #737373;
  154. font-weight: 400;
  155. font-size: 13px;
  156. white-space: normal;
  157. word-wrap: break-word;
  158. word-break: break-all;
  159. }
  160. .btn {
  161. user-select: none;
  162. background: #1D9BF0;
  163. border-radius: 35px;
  164. width: 100px;
  165. text-align: center;
  166. line-height: 37px;
  167. height: 37px;
  168. font-weight: 700;
  169. font-size: 15px;
  170. color: #fff;
  171. cursor: pointer;
  172. }
  173. }
  174. .share-list {
  175. margin-top: 20px;
  176. text-align: center;
  177. margin-bottom: 14px;
  178. img {
  179. user-select: none;
  180. cursor: pointer;
  181. width: 33px;
  182. height: 33px;
  183. margin-right: 14px;
  184. border-radius: 100px;
  185. }
  186. }
  187. }
  188. </style>