123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <template>
- <!-- pay 支付按钮 -->
- <div class="pay-wrapper">
- <slot name="balance"></slot>
- <div class="pay-btn">
- <div class="iframe-pay"
- v-show="currentCurrencyInfo.currencyCode == 'USD'">
- <div class="token-pay"
- @click="clickPayUSD">
- Pay ${{finalAmountData.rechargeAmountValue > 0 && USDepositStatus != 'SUCCESS' ? finalAmountData.rechargeAmountValue : finalAmountData.orderAmountValue}}
- </div>
- <!-- <iframe
- class="iframe-pay"
- ref="iframe"
- :src="`${payConfig.paypalHtml}?paypalClientId=${payConfig.paypalClientId}&amount=${props.finalAmountData.finalAmountValue}`"></iframe> -->
- </div>
- <div class="token-pay"
- :class="{ disabled: Number(currentCurrencyInfo.balance) < Number(payConfig.amount) }"
- v-if="currentCurrencyInfo.currencyCode != 'USD'"
- @click="balancePay">
- Pay {{payConfig.amount || 0}} {{currentCurrencyInfo.tokenSymbol}}
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import { onMounted, ref, defineProps, defineEmits, watch, defineExpose } from "vue";
- import { PlayType } from '@/types';
- import {payTaskLuckdropWithBalance} from "@/http/publishApi"
- import Report from "@/log-center/log"
- import {setChromeStorage, getChromeStorage} from "@/uilts/chromeExtension"
- const props = defineProps({
- finalAmountData: {
- type: Object,
- default: () => {
- return {
- balance: "",
- feeAmountValue: 0,
- feeDesc: 0,
- orderAmountValue: 0,
- rechargeAmountValue: 0
- }
- },
- },
- payConfig: {
- type: Object,
- default: () => {
- return {
- paypalClientId: '',
- paypalHtml: 'https://d1mcov78iir8kk.cloudfront.net/website/paypal_1.html'
- }
- }
- },
- currentCurrencyInfo: {
- type: Object,
- default: () => {
- }
- },
- USDepositStatus: {
- type: String,
- default: 'DEFAULT'
- },
- bizType: {
- type: String,
- default: PlayType.treasure
- }
- });
- let iframe = ref(null);
- let payIng = false;
- watch(
- () => props.finalAmountData.finalAmountValue,
- (newVal) => {
- // iframe.value.contentWindow.postMessage({
- // actionType: "setAmount", amount: newVal
- // },
- // "*"
- // );
- },
- {
- deep: true
- }
- );
- const emits = defineEmits(["payFinish"]);
- const balancePay = () => {
- Report.reportLog({
- pageSource: Report.pageSource.previewPage,
- businessType: Report.businessType.buttonClick,
- objectType: Report.objectType.confirmButton
- }, {
- type: Report.getCurrentBizType(props.bizType)
- });
- if(payIng) {
- return;
- }
- payIng = true;
- payTaskLuckdropWithBalance({
- params: {
- currencyCode: props.currentCurrencyInfo.currencyCode,
- postId: props.payConfig.postId
- }
- }).then(res => {
- if(res.code == 0) {
- emits("payFinish", {...res.data});
- }
- payIng = false;
- }).catch(() => {
- payIng = false;
- })
- }
- const clickPayUSD = () => {
- if(props.finalAmountData.rechargeAmountValue > 0 && props.USDepositStatus != 'SUCCESS') {
- setTimeout(() => {
- emits("showDepositMask", {});
- }, 1000)
- chrome.tabs.getCurrent(tab =>{
- let achPayInfo = {
- amountValue: props.finalAmountData.rechargeAmountValue,
- tab: tab
- };
- let guideUrl = chrome.runtime.getURL('/iframe/ach-cashier.html');
- setChromeStorage({ achPayInfo : JSON.stringify(achPayInfo)});
- chrome.tabs.create({
- url: guideUrl
- });
- })
- } else {
- balancePay();
- }
- }
- onMounted(() => {
- // window.addEventListener("message", function (event) {
- // if (event.data && event.data.actionType) {
- // switch (event.data.actionType) {
- // case "payCallBack":
- // console.log(
- // "payCallBack",
- // event.data.orderData,
- // event.data.transaction
- // );
- // emits("payFinish", {...event.data, payNetwork: 'pay'});
- // break;
- // }
- // }
- // });
- });
- defineExpose({
- balancePay
- })
- </script>
- <style lang="scss" scoped>
- .pay-wrapper {
- width: 100%;
- height: 80px;
- background-color: #fff;
- position: absolute;
- left: 0;
- bottom: 0;
- box-shadow: 0px -1px 0px #ECECEC;
- border-bottom-right-radius: 16px;
- padding: 12px 30px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- border-bottom-left-radius: 16px;
- z-index: 999;
- .pay-msg {
- text-align: right;
- margin-right: 25px;
- .row {
- font-weight: 600;
- font-size: 16px;
- color: #1D9BF0;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- margin-bottom: 6px;
- span {
- display: inline-block;
- color: #000000;
- margin-left: 6px;
- }
- .icon {
- width: 14px;
- margin-left:6px;
- }
- .desc {
- margin-right:6px
- }
- }
- .msg {
- font-size: 13px;
- color: #898989;
- }
- }
- .pay-btn {
- height: 48px;
- .token-pay {
- height: 100%;
- background: #1D9BF0;
- border-radius: 10000px;
- display: flex;
- align-items: center;
- justify-content: center;
- font-weight: 600;
- font-size: 18px;
- color: #fff;
- padding: 0 30px;
- word-break: break-all;
- cursor: pointer;
- &.disabled {
- background: #DEDEDE;
- }
- }
- .iframe-pay {
- width: 100%;
- height: 100%;
- }
- iframe {
- border: medium none;
- width: 100%;
- height: 100%;
- }
- }
- }
- </style>
|