goodkind.vue
2.3 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
<view class="content">
<view class="commnonpadding flexone kindbox">
<view class="goodlinditem flexfour" v-for="(item,index) in kindlist" :key="index" @click="selectgood" :data-id="item.id">
<view class="goodkindimg">
<image :src="item.image" mode=""></image>
</view>
<view class="goodkindname hidden">{{item.name}}</view>
</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
showbanben: false,
kindlist:[],
score_category_id:'',
store_id:''
}
},
onLoad(options) {
console.log(options,'34788374893484398')
// goodtype 1 店铺商品 2 积分商品
if(options.store_id){
this.store_id=options.store_id
}
console.log(this.store_id)
if(options.kindtype==1){
this.getshopgoodkind()
}else{
this.getgoodkind()
}
},
methods: {
// 获取积分商品的分类
getgoodkind(){
let that = this;
console.log('积分商品')
var url = 'score_goods/get_score_category';
var params = {
}
app.post(url, params).then((res) => {
console.log(res);
that.kindlist=res.data.data
}).catch((err) => {
console.log(err)
})
},
// 获取店铺商品的分类
getshopgoodkind(){
console.log('店铺商品')
let that = this;
var url = 'store_goods/get_store_category';
var params = {
store_id:that.store_id
}
console.log(params)
app.post(url, params).then((res) => {
console.log(res);
that.kindlist=res.data.data
}).catch((err) => {
console.log(err)
})
},
selectgood(e){
let id=e.currentTarget.dataset.id;
// let pages = getCurrentPages();
// let prevPage = pages[pages.length - 2]; //上一个页面
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
uni.setStorageSync("selectId",id)
// prevPage.setData({
// selectId: id,
// });
uni.navigateBack({
checked:true
})
}
}
}
</script>
<style>
@import url('../../base/homepage');
</style>