From 25b2ba1cf86bc3439e7ad2acf2cd4a9ea7e4b0ed Mon Sep 17 00:00:00 2001
From: dcc <dcc@163.com>
Date: Fri, 28 Jun 2024 09:28:04 +0800
Subject: [PATCH] 123
---
src/page/myAd/editAd.vue | 402 +++++++++++++++++++++++++++++++++-----------------------
1 files changed, 236 insertions(+), 166 deletions(-)
diff --git a/src/page/myAd/editAd.vue b/src/page/myAd/editAd.vue
index d906767..5e35bb3 100644
--- a/src/page/myAd/editAd.vue
+++ b/src/page/myAd/editAd.vue
@@ -54,8 +54,10 @@
<span class="mr-20">$</span>
<span>{{ info.symbol_value }}</span>
</div>
- <img @click="showKeyboard = true; cachePrice = ''" class="w-39 h-39 ml-27"
+ <span @click="showKeyboard = true; cachePrice = ''">
+ <img class="w-39 h-39 ml-27"
src="@/assets/image/otc/buy/price_icon.png" alt="">
+ </span>
</div>
<div class=" font-700 font-48">
<span class="mr-20">$</span>
@@ -209,77 +211,102 @@
<script>
import payPwdInput from "@/components/payPwdInput";
import OrderNav from "@/components/order-nav/OrderNav";
-import { Step, Steps, DropdownMenu, DropdownItem, Icon, Field, Checkbox, CheckboxGroup, Popup, RadioGroup, Radio, Cell, CellGroup, NumberKeyboard, Toast } from 'vant';
-import { c2cGetCurrencyList, c2cGetPayCurrencyList, countAdParams, getCtcAdvertToken, getTimeList, editAd, placeAd } from "@/API/otc";
+import {
+ Step,
+ Steps,
+ DropdownMenu,
+ DropdownItem,
+ Icon,
+ Field,
+ Checkbox,
+ CheckboxGroup,
+ Popup,
+ RadioGroup,
+ Radio,
+ Cell,
+ CellGroup,
+ NumberKeyboard,
+ Toast,
+} from "vant";
+import {
+ c2cGetCurrencyList,
+ c2cGetPayCurrencyList,
+ countAdParams,
+ getCtcAdvertToken,
+ getTimeList,
+ editAd,
+ placeAd,
+} from "@/API/otc";
export default {
name: "editAd",
created() {
- console.log(this.$route.query)
- this.pageType = this.$route.query.type
- if (this.pageType === '1') {
- this.info = { ...this.info, ...this.$route.query }
+ console.log(this.$route.query);
+ this.pageType = this.$route.query.type;
+ if (this.pageType === "1") {
+ this.info = { ...this.info, ...this.$route.query };
}
- if (this.info.pay_type) { // choose(value, key)
- let a = this.info.pay_type.split(',')
- let b = this.info.pay_type_name.split(',')
+ if (this.info.pay_type) {
+ // choose(value, key)
+ let a = this.info.pay_type.split(",");
+ let b = this.info.pay_type_name.split(",");
for (let i = 0; i < a.length; i++) {
- this.choose(b[i], a[i])
+ this.choose(b[i], a[i]);
}
-
}
- getTimeList().then(res => {
+ getTimeList().then((res) => {
//console.log('支付时效列表', res)
- this.timeList = res
+ this.timeList = res;
if (!this.info.expire_time) {
- this.info.expire_time = Object.keys(res)[0]
+ this.info.expire_time = Object.keys(res)[0];
}
- })
+ });
- Promise.all([this.getCurrencyList(), this.getPayCurrencyList()]).then(res => {
- //console.log('Promise.all', res)
- this.getCountAdParams()
- this.getSessionToken()
- })
-
+ Promise.all([this.getCurrencyList(), this.getPayCurrencyList()]).then(
+ (res) => {
+ //console.log('Promise.all', res)
+ this.getCountAdParams();
+ this.getSessionToken();
+ }
+ );
},
data() {
return {
showInput: false,
timeList: null, // 支付时效列表
adParams: {}, // 计算过的广告相关参数 如市场最高价等
- cachePrice: '', // 数字键盘缓存价格
+ cachePrice: "", // 数字键盘缓存价格
showKeyboard: false, // 数字键盘
info: {
- id: '', // 修改的时候
- safeword: '', // 资金密码
- payment_method1: '',
- payment_method2: '',
- payment_method3: '',
- direction: 'buy', // 买卖方式:buy买/sell卖
- currency: '', // 支付币种
- symbol: '', // 上架币种
- coin_amount: '', // 交易数量
- symbol_value: '', // 币种单价
- investment_min: '', // 订单最低限额
- investment_max: '', // 订单最高限额
+ id: "", // 修改的时候
+ safeword: "", // 资金密码
+ payment_method1: "",
+ payment_method2: "",
+ payment_method3: "",
+ direction: "buy", // 买卖方式:buy买/sell卖
+ currency: "", // 支付币种
+ symbol: "", // 上架币种
+ coin_amount: "", // 交易数量
+ symbol_value: "", // 币种单价
+ investment_min: "", // 订单最低限额
+ investment_max: "", // 订单最高限额
on_sale: 0, // 是否上架(立即上線) 0 下架 1上架
closed: 0, // 是否关闭 0 否 1 是
- expire_time: '', // 支付时效(分钟)
- transaction_terms: '', // 交易条款
- order_msg: '', // 订单自动消息
- remark: '', // 备注
+ expire_time: "", // 支付时效(分钟)
+ transaction_terms: "", // 交易条款
+ order_msg: "", // 订单自动消息
+ remark: "", // 备注
},
- pageType: '0', // 0 发布广告 1 编辑广告
+ pageType: "0", // 0 发布广告 1 编辑广告
show: false,
active: 0,
buy: 1,
type: "1",
- num: '1',
- value1: 0, // 上架币种
+ num: "1",
+ value1: 0, // 上架币种
value2: 0, // 法币
- price: '1',
+ price: "1",
showT: false,
showQ: false,
showP: false,
@@ -288,15 +315,17 @@
checking: false,
select: false,
selected: false,
- message: '',
- radio: '1',
- radio2: '1',
- activeIcon: require('@/assets/image/成功.png'),
- option1: [ // 上架币种
+ message: "",
+ radio: "1",
+ radio2: "1",
+ activeIcon: require("@/assets/image/成功.png"),
+ option1: [
+ // 上架币种
],
- option2: [ // 法币
+ option2: [
+ // 法币
],
- }
+ };
},
components: {
payPwdInput,
@@ -318,170 +347,208 @@
},
computed: {
title1() {
- return this.pageType === '0' ? this.$t('发布广告') : this.$t('编辑广告')
+ return this.pageType === "0" ? this.$t("发布广告") : this.$t("编辑广告");
},
pay_type_name() {
- let a = this.info.payment_method1 ? this.method_config_map[this.info.payment_method1] : ''
- let b = this.info.payment_method2 ? this.method_config_map[this.info.payment_method2] : ''
- let c = this.info.payment_method3 ? this.method_config_map[this.info.payment_method3] : ''
- console.log(a, b, c)
- let arr = []
+ let a = this.info.payment_method1
+ ? this.method_config_map[this.info.payment_method1]
+ : "";
+ let b = this.info.payment_method2
+ ? this.method_config_map[this.info.payment_method2]
+ : "";
+ let c = this.info.payment_method3
+ ? this.method_config_map[this.info.payment_method3]
+ : "";
+ console.log(a, b, c);
+ let arr = [];
if (a) {
- arr.push(a)
+ arr.push(a);
}
if (b) {
- arr.push(b)
+ arr.push(b);
}
if (c) {
- arr.push(c)
+ arr.push(c);
}
- return arr.join(',')
+ return arr.join(",");
},
},
watch: {
- 'info.symbol'(val) {
- this.getCountAdParams()
- }
+ "info.symbol"(val) {
+ this.getCountAdParams();
+ },
},
methods: {
getCurrencyList() {
- return c2cGetCurrencyList().then(res => {
+ return c2cGetCurrencyList().then((res) => {
//console.log('上架币种列表', res)
- Object.keys(res).forEach(key => {
+ Object.keys(res).forEach((key) => {
this.option1.push({
text: res[key],
- value: key
- })
- })
+ value: key,
+ });
+ });
if (!this.info.symbol) {
- this.info.symbol = this.option1[0].value
+ this.info.symbol = this.option1[0].value;
}
- })
+ });
},
getPayCurrencyList() {
- return c2cGetPayCurrencyList().then(res => {
+ return c2cGetPayCurrencyList().then((res) => {
//console.log('法币列表', res)
- res.forEach(item => {
+ res.forEach((item) => {
this.option2.push({
text: item.currency,
- value: item.currency
- })
- })
+ value: item.currency,
+ });
+ });
if (!this.info.currency) {
- this.info.currency = this.option2[0].value
+ this.info.currency = this.option2[0].value;
} else {
this.info.currency = res.find((item) => {
- return item.currency === this.info.currency
- }).currency
+ return item.currency === this.info.currency;
+ }).currency;
}
- })
+ });
},
handleClosePwd() {
- this.showInput = false
+ this.showInput = false;
},
handPwd(pwd) {
- this.handleClosePwd()
- this.info.safeword = pwd
- this.handleAd()
+ this.handleClosePwd();
+ this.info.safeword = pwd;
+ this.handleAd();
},
handleAd() {
// this.$router.push('/saveAd')
if (!this.info.safeword) {
- this.showInput = true
- return
+ this.showInput = true;
+ return;
}
- if (this.info.type === '1') { // 编辑广告
- Toast.loading()
+ if (this.info.type === "1") {
+ // 编辑广告
+ Toast.loading();
editAd({
session_token: this.session_token,
- ...this.info
- }).then(res => {
- //console.log('编辑广告', res)
- Toast(this.$t('修改成功'))
- // this.getSessionToken()
- this.$router.push({
- path: '/saveAd',
- query: {
- ...this.info,
- pay_type_name: this.pay_type_name
- }
- })
- }).catch(err => {
- this.info.safeword = ''
- this.getSessionToken()
+ ...this.info,
})
- } else { // 发布新广告
- Toast.loading()
+ .then((res) => {
+ //console.log('编辑广告', res)
+ Toast(this.$t("修改成功"));
+ // this.getSessionToken()
+ this.$router.push({
+ path: "/saveAd",
+ query: {
+ ...this.info,
+ pay_type_name: this.pay_type_name,
+ },
+ });
+ })
+ .catch((err) => {
+ this.info.safeword = "";
+ this.getSessionToken();
+ });
+ } else {
+ // 发布新广告
+ Toast.loading();
placeAd({
session_token: this.session_token,
- ...this.info
- }).then(res => {
- //console.log('编辑广告', res)
- Toast(this.$t('提交成功'))
- this.$router.push({
- path: '/saveAd',
- query: {
- ...this.info
- }
- })
- }).catch(err => {
- this.info.safeword = ''
- this.getSessionToken()
+ ...this.info,
})
+ .then((res) => {
+ //console.log('编辑广告', res)
+ Toast(this.$t("提交成功"));
+ this.$router.push({
+ path: "/saveAd",
+ query: {
+ ...this.info,
+ },
+ });
+ })
+ .catch((err) => {
+ this.info.safeword = "";
+ this.getSessionToken();
+ });
}
-
},
findActive(key) {
- return key === this.info.payment_method1 || key === this.info.payment_method2 || key === this.info.payment_method3;
+ return (
+ key === this.info.payment_method1 ||
+ key === this.info.payment_method2 ||
+ key === this.info.payment_method3
+ );
},
getSessionToken() {
getCtcAdvertToken({
currency: this.info.currency,
symbol: this.info.symbol,
- language: this.$i18n.locale
- }).then(res => {
+ language: this.$i18n.locale,
+ }).then((res) => {
//console.log('token', res)
- this.session_token = res.session_token
- this.method_config_map = res.method_config_map // 支付方式列表
- })
+ this.session_token = res.session_token;
+ this.method_config_map = res.method_config_map; // 支付方式列表
+ });
},
- getCountAdParams() { // 获取计算的广告参数
+ getCountAdParams() {
+ // 获取计算的广告参数
countAdParams({
currency: this.info.currency,
symbol: this.info.symbol,
coin_amount: this.info.coin_amount,
- symbol_value: this.info.symbol_value
+ symbol_value: this.info.symbol_value,
}).then((res) => {
//console.log('计算广告参数', res)
- this.adParams = res
- })
+ this.adParams = res;
+ });
},
tabClick(type) {
this.info.direction = type;
},
ClickNum(num) {
- if (num === '2') {
- if (!this.info.symbol || !this.info.currency || !this.info.symbol_value) {
- Toast(this.$t('上架币种,法币或价格不能为空'))
- return
+ if (num === "2") {
+ if (
+ !this.info.symbol ||
+ !this.info.currency ||
+ !this.info.symbol_value
+ ) {
+ Toast(this.$t("上架币种,法币或价格不能为空"));
+ return;
}
-
}
- if (num === '3') {
- if (!this.info.coin_amount || !this.info.investment_min || !this.info.investment_max || (!this.info.payment_method1 && !this.info.payment_method2 && !this.info.payment_method3)) {
- Toast(this.$t('交易数量,单笔限额,付款方式都不能为空'))
- return
+ if (num === "3") {
+ if (
+ !this.info.coin_amount ||
+ !this.info.investment_min ||
+ !this.info.investment_max ||
+ (!this.info.payment_method1 &&
+ !this.info.payment_method2 &&
+ !this.info.payment_method3)
+ ) {
+ Toast(this.$t("交易数量,单笔限额,付款方式都不能为空"));
+ return;
}
if (this.info.coin_amount / 1 > this.adParams.coin_amount_max / 1) {
- Toast(this.$t('最大交易币种数量不能超过') + this.adParams.coin_amount_max);
+ Toast(
+ this.$t("最大交易币种数量不能超过") + this.adParams.coin_amount_max
+ );
return;
}
- if (this.info.investment_max / 1 > this.adParams.investment_max_limit / 1) {
- Toast(this.$t('最大支付金额不能超过') + this.adParams.investment_max_limit);
+ if (
+ this.info.investment_max / 1 >
+ this.adParams.investment_max_limit / 1
+ ) {
+ Toast(
+ this.$t("最大支付金额不能超过") + this.adParams.investment_max_limit
+ );
return;
}
- if (this.info.investment_min / 1 < this.adParams.investment_min_limit / 1) {
- Toast(this.$t('最小支付金额不能低于') + this.adParams.investment_min_limit);
+ if (
+ this.info.investment_min / 1 <
+ this.adParams.investment_min_limit / 1
+ ) {
+ Toast(
+ this.$t("最小支付金额不能低于") + this.adParams.investment_min_limit
+ );
return;
}
}
@@ -491,33 +558,35 @@
this.price = price;
},
choose(val, key) {
- if (key === this.info.payment_method1) { // 取消
- this.info.payment_method1 = ''
- return
+ if (key === this.info.payment_method1) {
+ // 取消
+ this.info.payment_method1 = "";
+ return;
} else if (key === this.info.payment_method2) {
- this.info.payment_method2 = ''
- return
+ this.info.payment_method2 = "";
+ return;
} else if (key === this.info.payment_method3) {
- this.info.payment_method3 = ''
- return
+ this.info.payment_method3 = "";
+ return;
}
if (!this.info.payment_method1) {
- this.info.payment_method1 = key
+ this.info.payment_method1 = key;
} else if (this.info.payment_method1 && !this.info.payment_method2) {
- this.info.payment_method2 = key
- } else if (this.info.payment_method1 && this.info.payment_method2 && !this.info.payment_method3) {
- this.info.payment_method3 = key
+ this.info.payment_method2 = key;
+ } else if (
+ this.info.payment_method1 &&
+ this.info.payment_method2 &&
+ !this.info.payment_method3
+ ) {
+ this.info.payment_method3 = key;
}
-
},
showPopup() {
this.show = true;
},
- }
-
-
-}
+ },
+};
</script>
<style lang="scss" scoped>
@@ -540,11 +609,11 @@
}
.left-enter-active {
- animation: left-in .2s;
+ animation: left-in 0.2s;
}
.left-leave-active {
- animation: left-in .2s reverse;
+ animation: left-in 0.2s reverse;
}
@keyframes left-in {
@@ -574,13 +643,13 @@
}
.bg-wh {
- background: #FFFFFF;
- border: 1px solid #B8BCC5;
+ background: #ffffff;
+ border: 1px solid #b8bcc5;
}
.bg-bl {
- background: #2C78F8;
- color: #FFFFFF;
+ background: #2c78f8;
+ color: #ffffff;
}
.width {
@@ -596,6 +665,7 @@
}
.border_top {
- border-top: 1px solid #C8CAD2;
+ border-top: 1px solid #c8cad2;
}
-}</style>
+}
+</style>
--
Gitblit v1.9.3