/* 自动续费 */ const autoRenew = { template: `
{{calcTitle}}

ID: {{host.id}}

{{lang.auto_renew_name}}: {{host.name}}

{{lang.auto_renew_area}}: {{host.country}}-{{host.city}}-{{host.area}}

IP: {{host.dedicate_ip}}

{{item}}

({{host.ip_num}})

{{lang.auto_renew_cycle}}: {{commonData.currency_prefix}}{{host.renew_amount}}/{{host.billing_cycle_name}}

{{lang.auto_renew_due}}: {{host.due_time | formateTime}}

`, data() { return { showRenewDialog: false, submitLoading: false, calcTitle: "", is_auto_renew: 0, host: {}, loading: false, commonData: JSON.parse(localStorage.getItem("common_set_before")) || {}, }; }, props: { isAutoRenew: { type: Number, required: true, default: 0, }, id: { type: Number | String, required: true, default: null, }, }, filters: { formateTime(time) { if (time && time !== 0) { return formateDate(time * 1000); } else { return "--"; } }, }, methods: { copyIp(ip) { if (typeof ip !== "string") { ip = ip.join(","); } const textarea = document.createElement("textarea"); textarea.value = ip.replace(/,/g, "\n"); document.body.appendChild(textarea); textarea.select(); document.execCommand("copy"); document.body.removeChild(textarea); this.$message.success(lang.index_text32); }, async handleAutoRenew() { try { const params = { id: this.host.id, status: this.is_auto_renew, }; this.submitLoading = true; const res = await rennewAuto(params); this.$message.success(res.data.msg); this.showRenewDialog = false; this.submitLoading = false; this.$emit("update"); } catch (error) { this.submitLoading = false; this.showRenewDialog = false; this.$message.error(error.data.msg); } }, async autoRenewChange(val) { try { this.showRenewDialog = true; this.is_auto_renew = val ? 1 : 0; this.loading = true; const res = await getHostSpecific({id: this.id}); this.host = res.data.data; this.host.allIp = ( this.host.dedicate_ip + "," + this.host.assign_ip ).split(","); this.calcTitle = lang.auto_renew_tip1 + (this.isAutoRenew ? lang_obj.auto_renew_tip3 : lang_obj.auto_renew_tip2); this.loading = false; } catch (error) { this.loading = false; this.$message.error(error.data.msg); } }, }, };