product-detail.js
1.33 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import api from '@/api/api'
import {
httpGet,
httpPost
} from '@/api/fetch-api.js'
export default {
data() {
return {
key: 'value',
product: {},
store: {},
params: {},
imageUrls: [],
active: 0,
sticky: true,
}
},
components: {},
methods: {
onNavHandler(index, title) {
document.getElementById("scroll" + index).scrollIntoView({
behavior: "smooth",
});
},
toTop() {
document.getElementById("scroll0").scrollIntoView({
behavior: "smooth",
});
},
// 进入店铺
toShopDetail() {
let c = this.store.storeCode || "";
if (c) {
this.$router.push({
path: "/shop/detail",
query: {
c: c,
}
})
}
},
// 请求产品详情
queryProductDetail() {
let c = this.$route.query.c;
httpGet({
url: api.productDetail,
data: {
productCode: c,
}
}).then((result) => {
this.product = result.product || {};
this.store = result.store || {};
this.params = result.params || {};
this.imageUrls = result && result.product && result.product.imageUrls || [];
})
},
initData() {
this.queryProductDetail();
}
},
mounted() {},
created() {
this.initData();
}
}