xinyuan.vue 6.0 KB
<template>
	<view class="container">
		<view class="searhtoppage">
			<view class="searchtop flextwo" @click="search">
				<view class='searchleft'>
					输入您搜索的内容
					<!-- <input type="text" placeholder="输入您搜索的内容" />  -->
				</view>
				<image src="../../static/search.png" mode="" class="search"></image>
			</view>
		</view>
		<view class="xinyuanbox">
			<view class="gookindpage flexone">
				<view class="goodkindleft" @click='all("")'>
					<view class="goodkindname">全部品类</view>
					<view class="secname allname">香奈儿奢华至臻</view>
					<view class="goodkindimgbox">
						<view class="gookindimg">
							<image src="../../static/goodimg.png" mode=""></image>
						</view>
					</view>
				</view>
				<view class="goodkindright">
					<view class="goodkindrighttop flexone" @click='all(kindlist[0].id)'>
						<view>
							<view class="goodkindname">{{kindlist[0].name}}</view>
							<view class="secname">{{kindlist[0].description}}</view>
						</view>

						<view class="gookindimgk">
							<image :src="kindlist[0].image" mode=""></image>
						</view>

					</view>
					<view class="goodkindrighttopge flexone" @click='all(kindlist[1].id)'>
						<view>
							<view class="goodkindname">{{kindlist[1].name}}</view>
							<view class="secname">{{kindlist[1].description}}</view>
						</view>


						<view class="gookindimgk">
							<image :src="kinlist[1].image" mode=""></image>
						</view>

					</view>
				</view>
			</view>
			<view class="xinyuanbotbox flextwo">
				<view class="xinyuanbotitem flexone" @click='all(kindlist[2].id)'>
					<view>
						<view class="goodkindnamek">{{kindlist[2].name}}</view>
						<view class="secnamek">{{kindlist[2].description}}</view>
					</view>

					<view class="goodkindimg">
						<image :src="kindlist[2].image" mode=""></image>
					</view>
				</view>
				<view class="xinyuanbotitem flexone" @click='all(kindlist[3].id)'>
					<view>
						<view class="goodkindnamek">{{kindlist[3].name}}</view>
						<view class="secnamek">{{kindlist[3].description}}</view>
					</view>

					<view class="goodkindimg">
						<image :src="kindlist[3].image" mode=""></image>
					</view>
				</view>
				<view class="xinyuanbotitem flexone" @click='all(kindlist[4].id)'>
					<view>
						<view class="goodkindnamek">{{kindlist[4].name}}</view>
						<view class="secnamek">{{kindlist[4].description}}</view>
					</view>

					<view class="goodkindimg">
						<image :src="kindlist[4].image" mode=""></image>
					</view>
				</view>

			</view>
			<!-- 直播好物推荐 -->
			<view class="goodbox flexone">
				<image src="../../static/today.png" mode="" class="todayimg"></image>
				<view class="todayname">直播好物推荐</view>
			</view>
			<!-- 商品列表 -->
			<goodlist :zhigoodlist="zhigoodlist" :notixing="notixing" @tixing='tixing' :dingyuenum="dingyuenum"></goodlist>
			<!-- 这里也有你想要的 -->
			<view class="want flextwo">
				<view class="wantleft flexone">
					<image src="../../static/like.png" mode="" class="likeimg"></image>
					也许这里也又你想要的
				</view>
				<view class="more flexone" @click="more">
					更多
					<img src="../../static/yourow.png" alt="" class="yourow">
				</view>
			</view>
			<goodkind :wantlist="wantlist"></goodkind>
		</view>

	</view>
</template>
<script>
	import app from "../../App.vue";
	import goodlist from "../../compontent/goodlist.vue";
	import goodkind from "../../compontent/goodkind.vue";
	import {
		Toast
	} from "../../utils/toast.js"
	var that
	export default {
		components: {
			goodlist,
			goodkind
		},
		data() {
			return {
				// 列表
				kindlist: [],
				showpull: true,
				wantlist: [],
				page: 1,
				zhigoodlist: [],
				notixing:'',
				dingyuenum:[]
			}
		},

		onReachBottom() {
			that = this
			let newpage = that.page;
			newpage++
			that.page = newpage;
			if (that.showpull == true) {
				console.log(38493409)
				Toast('没有更多了~')
			} else {
				that.getgoodlist()
			}
		},
		onShow() {
			let notixing = uni.getStorageSync("notixing");
			this.notixing = notixing;
			console.log(this.notixing)
			this.page=1;
			this.zhigoodlist=[]
			// 获取直播好物
			this.getgoodlist();
		},
		onLoad() {
			this.gettopkind();
			// 获取你想要的
			this.getwant()
		},
		methods: {
			// 接收子组件的值
			tixing(e) {
				this.zhigoodlist = e;
			},

			// 获取顶部列表
			gettopkind() {
				let that = this;
				var url = "category/getIndexCategory"
				app.post(url, {}, "post").then(res => {
					console.log('列表信息', res)
					that.kindlist = res;
					console.log(that.kindlist)

				}).catch(err => {
				})
			},
			// 获取直播好物推荐
			getgoodlist() {
				let that = this;
				var url = "goods/getAnchorTimeGoods"
				var param = {
					page: 1,
					per_page: 20
				}
				app.post(url, {}, "post").then(res => {
					console.log('商品列表', res)
					that.zhigoodlist = that.zhigoodlist.concat(res.data);
					if (that.page > 1) {
						if (res.data.length == 0) {
							that.showpull = false
						}
					}
					that.zhigoodlist.forEach(function(value,index,array){
						if(value.user_goods==1){
								if(that.dingyuenum.indexOf(value.id)==-1){
									that.dingyuenum.push(value.id);
									that.dingyuenum=that.dingyuenum
							}
						}
					})


				}).catch(err => {
					console.log(err)
				})
			},
			// 你想要的
			getwant() {
				let that = this;
				var url = "category/getRandCategory"
				let param = {
					type: 2,
					limit: 8
				}
				app.post(url, param, "post").then(res => {
					console.log('我想要的', res)
					that.wantlist = res


				}).catch(err => {
					console.log(err)
				})
			},
			// 更多分类
			more() {
				uni.navigateTo({
					url: "/pages/xinyuan/zhiboknow"
				})
			},
			// 进入搜索页面
			search() {
				uni.navigateTo({
					url: '/pages/xinyuan/search'
				})
			},
			// 进入分类页面
			all(id){
				uni.navigateTo({
					url:'/pages/xinyuan/zhiboknow?id='+id
				})
			}
				

		}

	}
</script>

<style>
	@import url('../../style/xinyuan');
</style>