bind-tweet.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div class="bind-tips-wrapper">
  3. <img :src="require('@/assets/svg/icon-close.svg')" class="icon-close" @click="close">
  4. <div class="top">
  5. <img :src="require('@/assets/svg/icon-giveaways-notice.svg')" class="icon-give-box">
  6. <div class="text">
  7. oops, you failed to send giveaway
  8. </div>
  9. </div>
  10. <div class="button-wrapper">
  11. <div class="re-send" @click="seSend">Resend</div>
  12. <div class="terminate" v-if="submitData.taskLuckdropId" @click="terminate">Terminate for a refund</div>
  13. </div>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { onMounted, ref } from "vue";
  18. import { getChromeStorage } from '@/uilts/chromeExtension.js'
  19. import { getQueryString } from '@/uilts/help.js'
  20. import { terminatedLuckdrop } from "@/http/redPacket";
  21. let submitData = ref({
  22. taskLuckdropId: ''
  23. });
  24. const close = () => {
  25. window.parent.postMessage({ actionType: "IFRAME_CLOSE_BIND_TWEET", data: {
  26. }}, "*");
  27. }
  28. const seSend = async () => {
  29. let publishData = await getChromeStorage('publishData');
  30. callEventPageMethod(
  31. "POPUP_PUBLISH_TWITTER_RED_PACK",
  32. {...publishData},
  33. function (response) {
  34. close();
  35. console.log("res", response);
  36. }
  37. );
  38. }
  39. const terminate = () => {
  40. terminatedLuckdrop({
  41. params: {
  42. luckdropId: submitData.value.taskLuckdropId
  43. }
  44. }).then(res => {
  45. close();
  46. });
  47. }
  48. /**
  49. * sendMessage
  50. */
  51. const callEventPageMethod = (actionType, data, callback) => {
  52. chrome.runtime.sendMessage(
  53. {
  54. actionType: actionType,
  55. data: data
  56. },
  57. function (response) {
  58. if (typeof callback === "function") callback(response);
  59. }
  60. );
  61. };
  62. onMounted(() => {
  63. let params = getQueryString('params');
  64. submitData.value = JSON.parse(params);
  65. })
  66. </script>
  67. <style scoped lang="scss">
  68. .bind-tips-wrapper {
  69. width: 100%;
  70. height: 100%;
  71. box-sizing: border-box;
  72. background: #FFFFFF;
  73. border-radius: 20px;
  74. padding: 15px;
  75. position: relative;
  76. box-shadow: 0px 4px 30px 0px #00000033;
  77. .icon-close {
  78. position: absolute;
  79. left: 14px;
  80. top: 14px;
  81. width: 24px;
  82. height: 24px;
  83. cursor: pointer;
  84. }
  85. .top {
  86. display: flex;
  87. align-items: center;
  88. flex-direction: column;
  89. margin-top: 35px;
  90. .icon-give-box {
  91. width: 60px;
  92. height: 60px;
  93. margin-bottom: 20px;
  94. }
  95. .text {
  96. font-weight: 590;
  97. font-size: 18px;
  98. }
  99. }
  100. .button-wrapper {
  101. margin-top: 26px;
  102. .re-send, .terminate {
  103. width: 360px;
  104. height: 43px;
  105. border-radius: 100px;
  106. font-weight: 500;
  107. font-size: 17px;
  108. display: flex;
  109. align-items: center;
  110. justify-content: center;
  111. cursor: pointer;
  112. }
  113. .re-send {
  114. background: #1D9BF0;
  115. margin-bottom: 12px;
  116. color: #FFFFFF;
  117. }
  118. .terminate {
  119. color: #1D9BF0;
  120. border: 1px solid #ECECEC;
  121. }
  122. }
  123. }
  124. </style>