jifenshop.vue 4.4 KB
<template>
	<view class="content">
		<view class="navmiddle flexone jifennav">
			<view class="middleleft">
				<image src="../../static/search.png" mode=""></image>
			</view>
			<view class="middleenter">
				<input type="text" placeholder="请输入商品,店铺搜索" placeholder-class="enterk" @input="enterword" @confirm="finish"/>
			</view>
		</view>
		<view class="tapnav flextwo">
			<view class="tapnavitem" :class="order==0?'tapnavactive':''" @click="kindlist" :data-id="0">分类</view>
			<view class="tapnavitem" :class="order==1?'tapnavactive':''" @click="orderrange" :data-id="1">综合</view>
			<view class="tapnavitem" :class="order==2?'tapnavactive':''" @click="orderrange" :data-id="2">销量</view>
			<view class="tapnavitem flexone" :class="order==3||order==4?'tapnavactive':''" @click="selprice">
				<view class="tapprice">价格</view>
				<view class="tapbox flexfour">
					<view class="tapboxtop">
						<image src="../../static/shangsan.png" mode="" v-if="order==3"></image>
						<image src="../../static/toprow.png" mode="" v-else></image>
					</view>
					<view class="tapboxtop">
						<image src="../../static/xiasan.png" mode="" v-if="order==4"></image>
						<image src="../../static/xiarow.png" mode="" v-else></image>
					</view>
				</view>
			</view>
		
		
		</view>
		<view class="nodata" v-if="show">暂无数据</view>
		<view class="homeshoplist flexone goodboxlist" v-else>
			<view class="homeshopitem goodboxitem" v-for="(item,index) in shoplist" :key="index" @click="goodtail" :data-id="item.id">
				<view class="gooditemimg goodboximg">
					<image :src="item.image" mode=""></image>
					<!-- <view class="sale boxsale">已售76件</view> -->
				</view>
				<view class="goodname hidden boxgoodname">{{item.name}}</view>
				<view class="saleprice">¥{{item.price}}</view>
				<view class="flextwo">
					<view class="huiyuanprice dikou">抵扣:¥200</view>
					<view class="goodshou">已售{{item.sales}}</view>
				</view>
			</view>

		</view>



	</view>
</template>

<script>
	import app from "../../App.vue";
	export default {
		data() {
			return {
				page: 1,
				keyword: '',
				shoplist: [],
				order: -1,
				score_category_id:'',
				show:false,
				moreshow:false

			}
		},
		onLoad() {
			uni.setStorageSync("selectId","")
		},
		methods: {
			// 输入文字
			enterword(e){
				console.log(e)
				this.keyword=e.detail.value;
				console.log(this.keyword)
			},
			finish(){
				this.shoplist=[],
				this.page=1;
				this.getfoodlist()
			},
			// 分类
			kindlist(e){
				this.order=e.currentTarget.dataset.id;
				uni.setStorageSync("selectId","")
				
				uni.navigateTo({
					url: '/pages/homepage/goodkind?kindtype='+2
				})
			},
			// 排序
			orderrange(e) {
				this.order = e.currentTarget.dataset.id;
				this.shoplist = [],
					this.page = 1;
				this.getfoodlist()
			},
			selprice() {
				this.price = !this.price;
				if (this.price == true) {
					this.order = 3
				} else {
					this.order = 4
				}
				this.shoplist = [],
					this.page = 1;
				this.getfoodlist()
			},
			// 获取积分商城商品列表
			getfoodlist() {
				let that = this;
				var url = 'score_goods/get_score_goods';
				var params = {
					score_category_id: this.score_category_id,
					keyword: that.keyword,
					order: that.order,
					page: that.page,
					pageNum: 10
				}
				console.log('7766554', params)
				app.post(url, params).then((res) => {
					console.log(res)
					that.shoplist = that.shoplist.concat(res.data.data);
					if(that.shoplist.length==0){
						that.show=true
					}
					if(that.page>1){
						if(res.data.data.length==0){
							uni.showToast({
								title:'没有更多了~',
								icon:"none"
							})
							that.moreshow=true
						}
						
					}

				}).catch((err) => {

				})
			},

			goodtail(e) {
				let id = e.currentTarget.dataset.id;
				// type 1 面访商品 2积分商城商品
				uni.navigateTo({
					url: '/pages/nearshop/goodtail?id=' + id + '&type=' + 2
				})
			}
		},
		onShow:function(){
			   // 从上一页带数据
			   this.score_category_id=uni.getStorageSync("selectId")!=''?uni.getStorageSync("selectId"):''
			   this.shoplist=[];
			   this.page=1;
			   this.getfoodlist();
		},
		onReachBottom() {
			let newpage=this.page;
			newpage++;
			this.page=newpage;
			if(this.moreshow==false){
				this.getfoodlist()
			}
		}

	}
</script>

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

	.huiyuanprice {
		color: #FF9417;
		font-size: 22rpx;
	}
</style>