const withdrawDialog = { template: /*html */ `
{{lang.withdraw_title}}
{{lang.withdraw_btn3}}
{{lang.withdraw_title2}}
{{lang.withdraw_text1}} {{lang.withdraw_text2}}{{currency_prefix}}{{ruler.withdraw_min}} , {{lang.withdraw_text3}}{{currency_prefix}}{{ruler.withdraw_max}}
{{lang.withdraw_text4}} {{ruler.withdraw_handling_fee}} {{lang.withdraw_text5}}{{currency_prefix}}{{ruler.percent_min}} {{lang.withdraw_text6}}
{{lang.withdraw_text7}}
{{lang.withdraw_btn1}} {{lang.withdraw_btn2}}
`, data() { return { // 提现弹窗开始 // 是否显示提现弹窗 currency_prefix: "¥", withdrawVisible: false, withdrawForm: { source: "", method_id: "", amount: "", card_number: "", name: "", account: "", notes: "", }, isBank: false, withdrawLoading: false, errText: "", ruler: { // 提现来源 source: "", // 提现方式 method: [], // 第一个提现方式 method_id: "", // 可提现金额 withdrawable_amount: "", // 单次提现最提金额 withdraw_min: "", // 单次提现最高金额 withdraw_max: "", // 提现手续费 百分比的带上“%” 固定金额 保留两位数 withdraw_handling_fee: "", // 最低提现手续费 percent_min: "", }, }; }, created() { this.currency_prefix = JSON.parse( localStorage.getItem("common_set_before") ).currency_prefix; }, methods: { // 提现弹窗开始 // 提现方式变化 methodChange(e) { const method = this.ruler.method; this.isBank = false; method.forEach((item) => { if (item.id == e && item.name == "银行卡") { this.isBank = true; } }); }, // 显示提现弹窗 shwoWithdrawal(ruler) { this.withdrawForm = { source: ruler.source, method_id: ruler.method_id, amount: "", card_number: "", name: "", account: "", notes: "", }; // 默认选择第一个 // this.withdrawForm.method_id = ruler.method[0].id this.methodChange(this.withdrawForm.method_id); this.ruler = ruler; this.withdrawVisible = true; this.errText = ""; }, // 申请提现 doApplyWithdraw() { let isPass = true; this.errText = ""; const params = { ...this.withdrawForm, }; if (this.isBank && !params.card_number) { this.errText = lang.withdraw_placeholder3; isPass = false; return; } if (!params.method_id && params.method_id != 0) { this.errText = lang.withdraw_placeholder1; isPass = false; return; } if (!params.amount) { this.errText = lang.withdraw_placeholder6; isPass = false; return; } else { // 提现金额小于最小金额 if ( this.ruler.withdraw_min && Number(this.ruler.withdraw_min) > Number(params.amount) ) { this.errText = lang.withdraw_tips1 + this.currency_prefix + this.ruler.withdraw_min; isPass = false; return; } if (Number(params.amount) > Number(this.ruler.withdrawable_amount)) { this.errText = lang.withdraw_tips2; isPass = false; return; } if ( this.ruler.withdraw_max && Number(this.ruler.withdraw_max) < Number(params.amount) ) { this.errText = lang.withdraw_tips3 + this.currency_prefix + this.ruler.withdraw_max; isPass = false; return; } } if (isPass) { this.withdrawLoading = true; this.errText = ""; this.$emit("dowithdraw", params); } }, oninput(value) { let str = value; let len1 = str.substr(0, 1); let len2 = str.substr(1, 1); //如果第一位是0,第二位不是点,就用数字把点替换掉 if (str.length > 1 && len1 == 0 && len2 != ".") { str = str.substr(1, 1); } //第一位不能是. if (len1 == ".") { str = ""; } if (len1 == "+") { str = ""; } if (len1 == "-") { str = ""; } //限制只能输入一个小数点 if (str.indexOf(".") != -1) { let str_ = str.substr(str.indexOf(".") + 1); if (str_.indexOf(".") != -1) { str = str.substr(0, str.indexOf(".") + str_.indexOf(".") + 1); } } //正则替换 str = str.replace(/[^\d^\.]+/g, ""); // 保留数字和小数点 str = str.replace(/^\D*([0-9]\d*\.?\d{0,2})?.*$/, "$1"); // 小数点后只能输 2 位 return str; }, withdrawCancel() { this.withdrawVisible = false; this.withdrawLoading = false; }, }, };