banner-hotlist.vue
1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<template>
<div>
<Input :value="title" @input="onUpdateTitle" placeholder="标题"/>
</div>
</template>
<script>
import util from '@/libs/util';
export default {
props: ['value'],
data() {
return {
pagename: util.getUrlQueryString(this.value, 'pagename'),
title: util.getUrlQueryString(this.value, 'title'),
link: util.getLink(this.value) || 'https://m.yohobuy.com/'
};
},
watch: {
value(newVal) {
console.log('newVal:', newVal);
this.pagename = util.getUrlQueryString(this.value, 'pagename') || 'hotSale';
this.title = util.getUrlQueryString(newVal, 'title');
this.link = util.getLink(newVal) || 'https://m.yohobuy.com/';
}
},
methods: {
onUpdateTitle(val) {
this.title = val;
this.$emit('input', this.getUrl());
},
onUpdateLink(val) {
this.link = val;
this.$emit('input', this.getUrl());
},
getUrl() {
let params = new URLSearchParams();
params.append('pagename', this.pagename);
params.append('title', this.title);
return `${this.link}?${params}`;
}
}
}
</script>
<style>
</style>