|
@@ -35,8 +35,9 @@
|
|
|
USD
|
|
|
</div>
|
|
|
<el-input
|
|
|
- v-model="baseFormData.amount"
|
|
|
+ v-model="baseFormData.amountValue"
|
|
|
placeholder="$0.00"
|
|
|
+ oninput = "value=value.replace(/[^\d]/g,'')"
|
|
|
:input-style="{ 'box-shadow': 'none' }"/>
|
|
|
</div>
|
|
|
<div class="item">
|
|
@@ -46,8 +47,9 @@
|
|
|
Quantity
|
|
|
</div>
|
|
|
<el-input
|
|
|
- v-model="baseFormData.quantity"
|
|
|
+ v-model="baseFormData.totalCount"
|
|
|
placeholder="Enter quantity"
|
|
|
+ oninput = "value=value.replace(/[^\d]/g,'')"
|
|
|
:input-style="{ 'box-shadow': 'none' }"/>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -67,7 +69,7 @@
|
|
|
v-for="(item, index) in optionsList"
|
|
|
:key="index"
|
|
|
@click="addOption(item)">
|
|
|
- {{ item.type }}
|
|
|
+ {{ item.label }}
|
|
|
</el-dropdown-item>
|
|
|
</el-dropdown-menu>
|
|
|
</template>
|
|
@@ -80,21 +82,28 @@
|
|
|
<div class="label">
|
|
|
<img class="icon"
|
|
|
:src="item.icon" />
|
|
|
- {{ item.type }}
|
|
|
+ {{ item.label }}
|
|
|
</div>
|
|
|
<div class="control">
|
|
|
<el-input
|
|
|
- v-model="formData[item.type]"
|
|
|
- v-if="item.type == 'Follow'"
|
|
|
+ :type="item.nodeType"
|
|
|
+ rows="2"
|
|
|
+ resize="none"
|
|
|
+ v-model="item.text"
|
|
|
+ v-if="item.nodeType == 'textarea'"
|
|
|
placeholder="Enter account number"
|
|
|
:input-style="{
|
|
|
'box-shadow': 'none',
|
|
|
+ 'padding': '1px',
|
|
|
+ 'line-height': '1'
|
|
|
}"/>
|
|
|
<div
|
|
|
class="inner"
|
|
|
v-else
|
|
|
@click="selectChange(item)">
|
|
|
- {{formData[item.type]? "✅": "❌"}}
|
|
|
+ <img class="icon"
|
|
|
+ v-if="item.checked"
|
|
|
+ :src="require('../../assets/svg/icon-option-checked.svg')" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<img class="icon-remove-button"
|
|
@@ -105,10 +114,10 @@
|
|
|
</div>
|
|
|
<div class="submit-btn" @click="confirm">NEXT</div>
|
|
|
</template>
|
|
|
- <template v-else>
|
|
|
+ <div v-show="showPreview">
|
|
|
<preview-card></preview-card>
|
|
|
- <paypal-button :amount="baseFormData.amount" @payPalFinsh="payPalFinsh"></paypal-button>
|
|
|
- </template>
|
|
|
+ <paypal-button :amount="baseFormData.amountValue" @payPalFinsh="payPalFinsh"></paypal-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -116,56 +125,53 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-/* eslint-disable */
|
|
|
-import { ref, watch, reactive, onMounted } from "vue";
|
|
|
+import { ref, watch, reactive, defineProps, defineEmits } from "vue";
|
|
|
+import {postPublish, verifyPaypalResult} from "../../http/publishApi"
|
|
|
+
|
|
|
import previewCard from "./preview-card";
|
|
|
import paypalButton from "./paypal-button";
|
|
|
|
|
|
+const paypalClientId = 'ASn7k0zqyS5AWYikVSfmamR-RFpjyU_QFJWSxOHHoWE04-RgHNO6nahn0GyHUaUAEBxj-aKgtSrq4O4G';
|
|
|
+
|
|
|
+let publishRes = reactive({})
|
|
|
+
|
|
|
let visible = ref(true);
|
|
|
let showPreview = ref(false);
|
|
|
let dialogHeight = ref(620);
|
|
|
let previewDialogHeight = ref(880)
|
|
|
|
|
|
let baseFormData = reactive({
|
|
|
- amount: "",
|
|
|
- quantity: "",
|
|
|
+ amountCurrencyCode: "USD",
|
|
|
+ amountValue: "",
|
|
|
+ totalCount: "",
|
|
|
});
|
|
|
|
|
|
-let formData = reactive({
|
|
|
- Follow: "",
|
|
|
- Like: false,
|
|
|
- Retweet: false,
|
|
|
-});
|
|
|
|
|
|
let optionsList = reactive([
|
|
|
{
|
|
|
- type: "Follow",
|
|
|
- icon: require('../../assets/svg/icon-follow.svg')
|
|
|
+ label: "Follow",
|
|
|
+ icon: require('../../assets/svg/icon-follow.svg'),
|
|
|
+ nodeType: 'textarea',
|
|
|
+ type: 1,
|
|
|
+ text: '',
|
|
|
},
|
|
|
{
|
|
|
- type: "Like",
|
|
|
- icon: require('../../assets/svg/icon-like.svg')
|
|
|
+ label: "Like",
|
|
|
+ icon: require('../../assets/svg/icon-like.svg'),
|
|
|
+ nodeType: 'div',
|
|
|
+ type: 2,
|
|
|
+ checked: false
|
|
|
},
|
|
|
{
|
|
|
- type: "Retweet",
|
|
|
- icon: require('../../assets/svg/icon-retweet.svg')
|
|
|
+ label: "Retweet",
|
|
|
+ icon: require('../../assets/svg/icon-retweet.svg'),
|
|
|
+ nodeType: 'div',
|
|
|
+ type: 3,
|
|
|
+ checked: false
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
-let formList = reactive([
|
|
|
- {
|
|
|
- type: "Follow",
|
|
|
- icon: require('../../assets/svg/icon-follow.svg')
|
|
|
- },
|
|
|
- {
|
|
|
- type: "Like",
|
|
|
- icon: require('../../assets/svg/icon-like.svg')
|
|
|
- },
|
|
|
- {
|
|
|
- type: "Retweet",
|
|
|
- icon: require('../../assets/svg/icon-retweet.svg')
|
|
|
- },
|
|
|
-]);
|
|
|
+let formList = reactive([]);
|
|
|
|
|
|
const props = defineProps({
|
|
|
dialogVisible: {
|
|
@@ -176,13 +182,13 @@ const props = defineProps({
|
|
|
|
|
|
watch(
|
|
|
() => props.dialogVisible,
|
|
|
- (newVal, oldVal) => {
|
|
|
+ (newVal) => {
|
|
|
console.log("watch", newVal);
|
|
|
visible.value = newVal;
|
|
|
}
|
|
|
);
|
|
|
|
|
|
-const emits = defineEmits(["close", "confirm"]);
|
|
|
+const emits = defineEmits(["close", "confirm", "payPalFinsh"]);
|
|
|
|
|
|
const close = () => {
|
|
|
if (showPreview.value) {
|
|
@@ -196,22 +202,66 @@ const setPreviewDialogHeight = () => {
|
|
|
let clientHeight = document.documentElement.clientHeight;
|
|
|
let gapSafe = 80;
|
|
|
|
|
|
- if(clientHeight - gapSafe >= previewDialogHeight.value) {
|
|
|
-
|
|
|
- } else {
|
|
|
+ if(previewDialogHeight.value > clientHeight - gapSafe) {
|
|
|
previewDialogHeight.value = clientHeight - gapSafe;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const confirm = () => {
|
|
|
- setPreviewDialogHeight();
|
|
|
- showPreview.value = true;
|
|
|
+ let {amountValue = 0, totalCount = 0, amountCurrencyCode} = baseFormData;
|
|
|
+ if(!amountValue || !totalCount) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ amountValue = amountValue * 100; // 元转分
|
|
|
+
|
|
|
+ let finishConditions = [];
|
|
|
+ for(let i = 0; i < formList.length; i++) {
|
|
|
+ let item = {};
|
|
|
+ item.type = formList[i]['type'];
|
|
|
+ if(item.type == 1 && formList[i]['text']) { // follow 参数
|
|
|
+ let relatedUsers = [];
|
|
|
+ let text = formList[i]['text'].replace(/\s*/g,""); // 删除空格
|
|
|
+ let textList = text.split('@');
|
|
|
+
|
|
|
+ for(let i = 0; i < textList.length; i++) {
|
|
|
+ let item = textList[i];
|
|
|
+ if(item) {
|
|
|
+ relatedUsers.push({name: item});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.relatedUsers = relatedUsers;
|
|
|
+ finishConditions.push(item);
|
|
|
+ } else if(formList[i]['checked']){
|
|
|
+ finishConditions.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('finishConditions', finishConditions);
|
|
|
+ let formData = {
|
|
|
+ amountCurrencyCode,
|
|
|
+ amountValue,
|
|
|
+ totalCount,
|
|
|
+ finishConditions
|
|
|
+ }
|
|
|
+ let data = {
|
|
|
+ params: {
|
|
|
+ postBizData: JSON.stringify(formData),
|
|
|
+ postSrc: 1, //1 twitter
|
|
|
+ postType: 1, //1 红包
|
|
|
+ }
|
|
|
+ }
|
|
|
+ postPublish(data).then((res) => {
|
|
|
+ if(res.code == 0) {
|
|
|
+ publishRes = res.data;
|
|
|
+ setPreviewDialogHeight();
|
|
|
+ showPreview.value = true;
|
|
|
+ }
|
|
|
+ })
|
|
|
};
|
|
|
|
|
|
const addOption = (params) => {
|
|
|
let hasItem = formList.find((item) => item.type == params.type);
|
|
|
if (!formList.length || !hasItem) {
|
|
|
- formList.push(params);
|
|
|
+ formList.push({...params});
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -219,17 +269,29 @@ const removeOption = (params, index) => {
|
|
|
formList.splice(index, 1);
|
|
|
};
|
|
|
|
|
|
-const selectChange = (params, index) => {
|
|
|
- formData[params.type] = !formData[params.type];
|
|
|
+const selectChange = (params) => {
|
|
|
+ params.checked = !params.checked;
|
|
|
};
|
|
|
|
|
|
-const payPalFinsh = () => {
|
|
|
- emits("close", false);
|
|
|
+const payPalFinsh = (params) => {
|
|
|
+ let transaction = params.transaction;
|
|
|
+ console.log('transaction', transaction)
|
|
|
+ verifyPaypalResult({
|
|
|
+ params: {
|
|
|
+ paypalTransactionId: transaction.id,
|
|
|
+ postId: publishRes.postId,
|
|
|
+ paypalClientId: paypalClientId
|
|
|
+ }
|
|
|
+ }).then((res) => {
|
|
|
+ if(res.code == 0) {
|
|
|
+ //支付状态 0:未支付,1:支付成功,2:支付失败,3:已关闭,4:已退款
|
|
|
+ if(res.data && res.data.payStatus == 1) {
|
|
|
+ emits("payPalFinsh", {publishRes});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
-});
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
@@ -412,7 +474,8 @@ onMounted(() => {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
box-sizing: border-box;
|
|
|
- padding-left: 10px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
}
|
|
|
}
|
|
|
|