goodkind.vue 2.3 KB
<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>