invite-friends.vue 6.4 KB

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