index.js
1.5 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
68
69
70
71
72
73
74
75
76
77
78
import api from '@/api/api'
import {
httpGet,
httpPost
} from '@/api/fetch-api.js'
export default {
data() {
return {
key: 'value',
page: 1,
size: 10,
total: 0,
typeCode: "",
bannerList: [],
typeList: [],
productList: [],
}
},
components: {},
methods: {
toProduct(item) {
this.$router.push({
path: "/product/detail",
query: {
c: item.productCode
}
})
},
toMyFavorite() {
this.$router.push({
path: "/favorite"
})
},
// 请求banner列表
queryBannerList() {
httpGet({
url: api.bannerList,
data: {}
}).then((result) => {
this.bannerList = result && result.bannerImages || [];
})
},
// 请求type列表
queryTypeList() {
httpGet({
url: api.typeList,
data: {}
}).then((result) => {
this.typeList = result;
})
},
// 请求产品列表
queryProductList() {
httpGet({
url: api.productList,
data: {
page: this.page,
size: this.size,
typeCode: this.typeCode
}
}).then((result) => {
this.productList = result.list;
this.total = result.total;
console.log("this.productList:", this.productList);
})
},
initData() {
this.queryBannerList();
this.queryTypeList();
this.queryProductList();
}
},
mounted() {},
created() {
this.initData();
}
}