banner-detail.vue
1.06 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
<template>
<div>
<Input :value="productId" @input="onUpdateProductId" placeholder="商品编码"/>
</div>
</template>
<script>
import util from '@/libs/util'
export default {
props: ['value'],
data() {
return {
pagename: util.getUrlQueryString(this.value, 'pagename') || 'productDetail',
productId: util.getUrlQueryString(this.value, 'productId'),
link: util.getLink(this.value) || 'https://m.yohobuy.com/',
}
},
watch: {
value(newVal) {
this.pagename = util.getUrlQueryString(this.value, 'pagename') || 'productDetail';
this.productId = util.getUrlQueryString(this.value, 'productId');
this.link = util.getLink(this.value) || 'https://m.yohobuy.com/';
}
},
methods: {
onUpdateProductId(val) {
this.productId = val;
this.$emit('input', this.getUrl());
},
getUrl() {
let params = new URLSearchParams();
params.append('pagename', this.pagename);
params.append('productId', this.productId);
return `${this.link}?${params}`
}
}
}
</script>
<style>
</style>