diff --git a/src/components/domainBind.vue b/src/components/domainBind.vue index cb497f9..9ba87da 100644 --- a/src/components/domainBind.vue +++ b/src/components/domainBind.vue @@ -62,21 +62,9 @@ export default { isShowAddDomainDialog: false, } }, - watch: { - defaultPrefix(newVal) { - if(newVal){ - this.data.prefix = newVal - } - }, - defaultDomain(newVal) { - if(newVal){ - this.data.domain = newVal - } - } - }, mounted(){ - this.data.prefix = this.defaultPrefix - this.data.domain = this.defaultDomain + this.data.prefix = this.defaultPrefix ? this.defaultPrefix : '' + this.data.domain = this.defaultDomain ? this.defaultDomain : '' this.getDomainList() }, methods:{ @@ -90,8 +78,8 @@ export default { value: '.'+item })); - let domain = this.data.domain.startsWith('.') ? this.data.domain.slice(1) : this.data.domain; - if(!response.data.includes(domain) || !domain) this.data.domain = '.'+response.data[0] + let domain = that.data.domain.startsWith('.') ? that.data.domain.slice(1) : that.data.domain; + if(!response.data.includes(domain) || !domain) that.data.domain = '.'+response.data[0] } else { if(!this.data.domain) this.data.domain = '暂无域名' } diff --git a/src/components/site/serviceSetting/domainSet.vue b/src/components/site/serviceSetting/domainSet.vue index 847f536..37214ed 100644 --- a/src/components/site/serviceSetting/domainSet.vue +++ b/src/components/site/serviceSetting/domainSet.vue @@ -9,13 +9,14 @@
域名来源
- +
当前服务域名:{{info.domain}}
- +
@@ -55,17 +56,20 @@ export default { borderRadius: '4px', background: '#006AFF', }, - domainFrom: '0', - domainFromOptions: { - '0': '平台免费域名', - '1': '我自己有域名' - }, - newDomain: {} + domain_type: '', + domain_types: {}, + newDomain: { + prefix: '', + domain: '' + } } }, mounted() { this.info = JSON.parse(JSON.stringify(this.serviceInfo)) - if(this.info.ser_domain) this.domainFrom = '1' + this.domain_type = String(this.info.domain_type) + this.domain_types = this.info.domain_types + this.newDomain.prefix = this.info.domain_prefix + this.newDomain.domain = this.info.domain_name }, methods:{ handleEvent(data){ @@ -75,35 +79,37 @@ export default { let obj = {} obj.uid = this.info.uid obj.type = this.info.type - if(this.domainFrom === '1'){ - if(!this.newDomain.prefix || !this.newDomain.domain) return false - obj.domain = this.newDomain.prefix + this.newDomain.domain - }else{ - obj.domain = '' - } + obj.domain = '' + if(this.domain_type === '2') obj.domain = this.newDomain.prefix + this.newDomain.domain const that = this - this.$http('POST', '/agentnew/ajax_update_service_domain', obj).then(response => { - if(response.status){ - that.$message.success('保存成功'); + let domainValid = true; + if(that.domain_type === '2'){ + that.$refs.domainBind.$refs.bindFormRef.validate(valid => { + domainValid = valid + }) + } + if (domainValid) { + that.$http('POST', '/agentnew/ajax_update_service_domain', obj).then(response => { + if (response.status) { + that.$message.success('保存成功'); - //替换域名 - const protocol = new URL(that.info.domain).protocol; - if(this.domainFrom === '1'){ - that.info.domain = protocol + "//" +obj.domain; - that.info.ser_domain = protocol + "//" +obj.domain; - }else{ - that.info.domain = that.info.site_domain; - that.info.ser_domain = ''; - } + //替换域名 + const protocol = new URL(that.info.domain).protocol; + if (that.domain_type === '2') { + that.info.domain = protocol + "//" + obj.domain; + } else { + that.info.domain = that.info.site_domain; + } - that.$emit('saveEvent', that.info) - return true; - } - that.$message.error(response.info); - }).catch(error => { - console.error(error, 'error') - }) + that.$emit('saveEvent', that.info) + return true; + } + that.$message.error(response.info); + }).catch(error => { + console.error(error, 'error') + }) + } }, } }