+

修改
@@ -83,6 +86,7 @@ import GuipInput from "@/components/GuipInput.vue";
import GuipRadio from "@/components/GuipRadio.vue";
import GuipFormItem from "@/components/GuipFormItem.vue";
import domainBind from "@/components/domainBind.vue";
+import db from '@/utils/indexedDBUtil'
export default {
name: 'domainSet',
@@ -101,11 +105,24 @@ export default {
return {
formData: {
short_name: '',
- domain:'',
sale_channel: '',
+ sale_channel_label: '',
site_type: '',
- site_tpl: '1',
+ site_tpl: '',
+ site_tpl_name: '',
+ site_tpl_ico: '',
+ site_tpl_logo: '',
+ picture:'',
not_finished_uid: '',
+ plat_domain: '',
+ domain_type: '',
+ domain_prefix: '',
+ domain_name: '',
+ sale_channels:{},
+ sale_channels_label:{},
+ domain_types:{},
+ site_types:{},
+ site_type_tpl:{},
},
formRules: {
short_name: [
@@ -114,79 +131,100 @@ export default {
sale_channel: [
{ required: true, message: '请选择销售渠道', trigger: 'blur' }
],
- domain: [
+ domain_prefix: [
{ required: true, message: '请设置站点域名', trigger: 'blur' }
],
site_type: [
{ required: true, message: '请选择站点类型', trigger: 'blur' }
],
},
-
- channel_options: [
- { label: '淘系平台售卖', value: '0', selectedLabel: ''},
- { label: '非电商平台销售', value: '1', selectedLabel: '适用于搜索推广,如360、百度、微信售卖等渠道' },
- { label: '自用不出售', value: '2', selectedLabel: '适用于不需要对外售卖,专用于自己检测的用户' },
- { label: '拼多多平台售卖', value: '3', selectedLabel: '' }
- ],
-
- sale_channels:{},
- domain_types:{},
- site_types:{},
- domainType: '1',
- domainPrefix: '',
- domainName: '',
- platDomain: '',
}
},
- watch:{
- domainPrefix() {
- this.checkFormDataDomain();
- },
- domainName() {
- this.checkFormDataDomain();
- }
- },
computed: {
- channel_label() {
- const labels = this.sale_channels_label;
- const value = this.formData.sale_channel;
- return labels && labels[value] ? labels[value] : '';
- }
+ submitData() {
+ return {
+ short_name: this.formData.short_name,
+ domain: this.formData.domain_prefix + this.formData.domain_name,
+ sale_channel: this.formData.sale_channel,
+ site_type: this.formData.site_type,
+ site_tpl: this.formData.site_tpl,
+ not_finished_uid: this.formData.not_finished_uid,
+ ico: this.formData.site_tpl_ico,
+ logo: this.formData.site_tpl_logo,
+ }
+ },
},
mounted() {
+ const formData = JSON.parse(localStorage.getItem('formData'))
+ if(formData){
+ this.formData = formData;
+ localStorage.removeItem('formData')
+ this.getSiteTplSet()
+ return true;
+ }
+
this.getAddInfo()
},
methods:{
+ async getSiteTplSet(){
+ const siteTplInfo = JSON.parse(localStorage.getItem('site_tpl_info'))
+ if(siteTplInfo){
+ this.formData.site_tpl = siteTplInfo.site_tpl
+ this.formData.site_tpl_name = siteTplInfo.site_tpl_name
+ this.formData.picture = siteTplInfo.picture
+ localStorage.removeItem('site_tpl_info')
+ }
+
+ const ico = await db.get('ico')
+ if(ico){
+ this.formData.site_tpl_ico = ico
+ await db.remove('ico')
+ }
+ const logo = await db.get('logo')
+ if(logo){
+ this.formData.site_tpl_logo = logo
+ await db.remove('logo')
+ }
+ },
getAddInfo() {
const that = this
- that.payList = []
this.$http('POST', '/agentnew/ajax_get_site_add_info', {}).then(response => {
if(response.status){
const addInfo = response.data
- that.sale_channels = addInfo.sale_channels
- that.sale_channels_label = addInfo.sale_channels_label
- that.domain_types = addInfo.domain_types
- that.site_types = addInfo.site_types
- that.platDomain = addInfo.plat_domain
+ that.formData.sale_channels = addInfo.sale_channels
+ that.formData.sale_channels_label = addInfo.sale_channels_label
+
+ that.formData.domain_type = String(addInfo.domain_type)
+ that.formData.domain_types = addInfo.domain_types
+ that.formData.plat_domain = addInfo.plat_domain
+ that.formData.domain_name = addInfo.plat_domain
+
+ that.formData.site_type = String(addInfo.site_type)
+ that.formData.site_types = addInfo.site_types
+ that.formData.site_type_tpl = addInfo.site_type_tpl
+ if(that.formData.site_type){
+ that.formData.site_tpl = this.formData.site_type_tpl[this.formData.site_type].site_tpl
+ that.formData.site_tpl_name = this.formData.site_type_tpl[this.formData.site_type].site_tpl_name
+ that.formData.picture = this.formData.site_type_tpl[this.formData.site_type].picture
+ }
if(Object.keys(that.siteInfo).length>0){
that.$nextTick(() => {
that.formData.short_name = that.siteInfo.short_name
- that.formData.domain = that.siteInfo.domain
- that.formData.sale_channel = that.siteInfo.sale_channel
- that.formData.site_type = that.siteInfo.site_type
+ that.formData.sale_channel = String(that.siteInfo.sale_channel)
+ that.formData.site_type = String(that.siteInfo.site_type)
that.formData.site_tpl = that.siteInfo.site_tpl
+ that.formData.site_tpl_name = that.siteInfo.site_tpl_name
+ that.formData.picture = that.siteInfo.picture
that.formData.not_finished_uid = that.siteInfo.uid
//域名存在且不是平台主域名
- if(that.formData.domain){
- that.domainType = String(that.siteInfo.domain_type)
- that.domainPrefix = that.siteInfo.domain_prefix;
- that.domainName = that.siteInfo.domain_name;
+ if(that.siteInfo.domain){
+ that.formData.domain_type = String(that.siteInfo.domain_type)
+ that.formData.domain_prefix = that.siteInfo.domain_prefix;
+ that.formData.domain_name = that.siteInfo.domain_name;
}
})
- }else{
- that.domainName = that.platDomain
}
return true
}
@@ -195,45 +233,47 @@ export default {
console.error(error, 'error')
})
},
- radioChange(val){
- this.formData.sale_channel = val
+ radioChange(){
+ const labels = this.formData.sale_channels_label;
+ const value = this.formData.sale_channel;
+ this.formData.sale_channel_label = labels && labels[value] ? labels[value] : '';
},
- radioDomainChange(val){
- this.domainType = val
- this.domainName = val === '1' ? this.platDomain : ''
+ radioDomainChange(){
+ this.formData.domain_name = this.formData.domain_type === '1' ? this.formData.plat_domain : ''
},
- radioTypeChange(val){
- this.formData.site_type = val
+ radioTypeChange(){
+ if(this.formData.site_type){
+ this.formData.site_tpl = this.formData.site_type_tpl[this.formData.site_type].site_tpl
+ this.formData.site_tpl_name = this.formData.site_type_tpl[this.formData.site_type].site_tpl_name
+ this.formData.picture = this.formData.site_type_tpl[this.formData.site_type].picture
+ }
},
handleClear() {
- this.domainPrefix = '';
+ this.formData.domain_prefix = '';
},
handleChangeDomain(data) {
- this.domainPrefix = data.prefix
- this.domainName = data.domain
+ this.formData.domain_prefix = data.prefix
+ this.formData.domain_name = data.domain
},
- checkFormDataDomain(){
- if (this.domainPrefix && this.domainName) {
- this.formData.domain = this.domainPrefix + this.domainName;
- }
- },
- lookTemImg(){
-
+ previewTpl(){
+ window.open('http://'+this.siteInfo.domain, '_blank');
},
- editTemImg(){
-
+ changeTpl(){
+ if(this.formData.site_type === ''){
+ this.$message.warning('请选择站点类型');
+ return false;
+ }
+ localStorage.setItem('formData', JSON.stringify(this.formData))
+ this.$router.push(`/agent/siteTemplate?site_type=${this.formData.site_type}`)
},
saveConfirm() {
const that = this
that.$refs.formRef.validate((valid) => {
if (valid) {
const that = this
- that.$http('POST', '/agentnew/ajax_add_new_site', that.formData).then(response => {
+ that.$http('POST', '/agentnew/ajax_add_new_site', that.submitData).then(response => {
if(response.status && response.data.uid){
that.formData.uid = response.data.uid
- that.formData.domain_type = that.domainType
- that.formData.domain_prefix = that.domainPrefix
- that.formData.domain_name = that.domainName
that.$emit('handelSiteInfo', that.formData)
if(that.formData.sale_channel === '2'){
@@ -278,6 +318,11 @@ export default {
.tem-home-top {
width: 100%;
+ height: 255px;
+ overflow: hidden;
+ img{
+ width: 100%;
+ }
}
.tem-home-bottom {
diff --git a/src/utils/indexedDBUtil.js b/src/utils/indexedDBUtil.js
new file mode 100644
index 0000000..ec904fc
--- /dev/null
+++ b/src/utils/indexedDBUtil.js
@@ -0,0 +1,79 @@
+const indexedDBUtil = (() => {
+ const dbName = 'MyDB'
+ const storeName = 'files'
+ let db = null
+
+ // 打开数据库
+ function openDB() {
+ return new Promise((resolve, reject) => {
+ if (db) return resolve(db)
+
+ const request = indexedDB.open(dbName, 1)
+ request.onupgradeneeded = (event) => {
+ const db = event.target.result
+ if (!db.objectStoreNames.contains(storeName)) {
+ db.createObjectStore(storeName)
+ }
+ }
+ request.onsuccess = (event) => {
+ db = event.target.result
+ resolve(db)
+ }
+ request.onerror = (event) => {
+ reject(event.target.error)
+ }
+ })
+ }
+
+ // 保存数据
+ async function set(key, value) {
+ const db = await openDB()
+ return new Promise((resolve, reject) => {
+ const tx = db.transaction(storeName, 'readwrite')
+ const store = tx.objectStore(storeName)
+ const request = store.put(value, key)
+ request.onsuccess = () => resolve(true)
+ request.onerror = (e) => reject(e)
+ })
+ }
+
+ // 获取数据
+ async function get(key) {
+ const db = await openDB()
+ return new Promise((resolve, reject) => {
+ const tx = db.transaction(storeName, 'readonly')
+ const store = tx.objectStore(storeName)
+ const request = store.get(key)
+ request.onsuccess = () => resolve(request.result)
+ request.onerror = (e) => reject(e)
+ })
+ }
+
+ // 删除某个 key
+ async function remove(key) {
+ const db = await openDB()
+ return new Promise((resolve, reject) => {
+ const tx = db.transaction(storeName, 'readwrite')
+ const store = tx.objectStore(storeName)
+ const request = store.delete(key)
+ request.onsuccess = () => resolve(true)
+ request.onerror = (e) => reject(e)
+ })
+ }
+
+ // 清空全部
+ async function clear() {
+ const db = await openDB()
+ return new Promise((resolve, reject) => {
+ const tx = db.transaction(storeName, 'readwrite')
+ const store = tx.objectStore(storeName)
+ const request = store.clear()
+ request.onsuccess = () => resolve(true)
+ request.onerror = (e) => reject(e)
+ })
+ }
+
+ return { set, get, remove, clear }
+})()
+
+export default indexedDBUtil
diff --git a/src/views/agent/sitePersonalization.vue b/src/views/agent/sitePersonalization.vue
index fa2de99..cd6d72b 100644
--- a/src/views/agent/sitePersonalization.vue
+++ b/src/views/agent/sitePersonalization.vue
@@ -11,9 +11,11 @@