tab-editor-new.vue 1.79 KB
<template>
  <div>
     <Input :value="tabName" @input="onUpdateTitle" placeholder="Tab名称"/>
     <Input :value="channelCode"  @input="onUpdateCode" placeholder="资源位Code码"/>
     <Input :value="productPool"  @input="onUpdateProductPool" placeholder="商品池ID"/>
  </div>
</template>

<script>

import util from '@/libs/util'

export default {
  props: ['value'],
  data() {
    return {
      pagename: util.getUrlQueryString(this.value, 'pagename') || 'home',
      tabName: util.getUrlQueryString(this.value, 'tabName'),
      channelCode: util.getUrlQueryString(this.value, 'channelCode'),
      productPool: util.getUrlQueryString(this.value, 'productPool'),
      link: util.getLink(this.value) || 'https://m.yohobuy.com/',
    }
  },
  watch: {
    value(newVal)  {
      this.pagename = util.getUrlQueryString(this.value, 'pagename') || 'home';
      this.tabName = util.getUrlQueryString(this.value, 'tabName');
      this.channelCode = util.getUrlQueryString(this.value, 'channelCode');
      this.productPool = util.getUrlQueryString(this.value, 'productPool');
      this.link = util.getLink(this.value) || 'https://m.yohobuy.com/';
    }
  },
  methods: {
    onUpdateTitle(val) {
      this.tabName = val;
      this.$emit('input', this.getUrl());
    },

    onUpdateCode(val) {
      this.channelCode = val;
      this.$emit('input', this.getUrl());
    },
    onUpdateProductPool(val) {
      this.productPool = val;
      this.$emit('input', this.getUrl());
    },

    getUrl() {
      let params = new URLSearchParams();

      params.append('pagename', this.pagename);
      params.append('tabName', this.tabName);
      params.append('channelCode', this.channelCode);
      params.append('productPool', this.productPool);

      return `${this.link}?${params}`
    }
  }
}
</script>

<style>

</style>