product.vue 5.0 KB
<template>
	<view class="product_all">
		<view class="top">
			<image src="../../static/ic-back-false.png" mode="" @click="back"></image>
			<view class="search">
				<view class="tosear">
					<input type="text" value="" placeholder="搜索"
						placeholder-style="text-align: center;font-size: 28rpx; color: rgba(194,194,194,1);"
						v-model="keyword" @confirm="gosourch" />
					<image src="../../static/icon-search.png" mode="" v-if="!keyword"></image>
				</view>
			</view>
		</view>
		<u-empty marginTop="200" text="暂无数据" mode="data" v-if="!list.length"></u-empty>
		<scroll-view v-if="list.length" scroll-y="true" @scrolltolower="scrolltolower" style="height: 100vh">
			<view class="misslist">
				<custom-waterfalls-flow :value="list" @wapperClick="godetail" @imageClick="godetail">
					<template v-slot:default="item">
						<view class="item">
							<view class="title">{{item.name}}</view>
							<view class="types">
								所属分类:{{item.sort.name}}
							</view>
							<view class="desc">
								<text v-if="item.seller_name">{{item.seller_name}}</text>
								<view class="money">
									<text>¥</text>{{item.price}}
								</view>
							</view>
						</view>
					</template>
				</custom-waterfalls-flow>
			</view>
		</scroll-view>

	</view>
</template>

<script>
	import {
		product_list
	} from '@/api/index'
	export default {
		data() {
			return {
				//瀑布
				list: [],
				keyword: "",
				currentpage: 1,
				sort_id: "",
				sort_name:"",
			}
		},
		onLoad(options) {
			if (options.ktext) {
				this.keyword = options.ktext
				uni.setNavigationBarTitle({
					title: "产品" //这是修改后的导航栏文字
				})
			}
			if (options.sort_id) {
				this.sort_id = options.sort_id
				this.sort_name = options.sort_name
				let that =this
				uni.setNavigationBarTitle({
					title: that.sort_name //这是修改后的导航栏文字
				})
			}
			this.product_list(true)
		},
		methods: {
			gosourch() {
				this.product_list(true)
			},
			scrolltolower() {
				this.currentpage++
				this.product_list()
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			//产品列表
			async product_list(x) {
				let obj = {
					keyword: this.keyword,
					sort_id: this.sort_id,
					page: this.currentpage,
					pagenum: 15,
				}
				try {
					const res = await product_list(obj)
					console.log('产品列表', res)
					this.list = x ? res.list.data : this.list.concat(res.list.data)
					this.list.forEach((item, index) => {
						item.image = item.images_preview[0]
					})
					if (res.list.data.length == 0) {
						// uni.showToast({
						// 	title: "暂无更多数据",
						// 	icon: 'none'
						// })
						return
					}
					console.log('产品列表', this.list)
					// 保存数据
				} catch (err) {
					uni.showToast({
						title: err,
						icon: 'none'
					})
					console.log('product_list', err)
				}
			},
			//跳转详情
			godetail(item) {
				console.log(1)
				uni.navigateTo({
					url: "/pages/index/detail?id=" + item.id
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background: rgba(246, 246, 246, 1);
	}

	.product_all {
		.top {
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
			z-index: 99;
			height: 96rpx;
			opacity: 1;
			background: rgba(255, 255, 255, 1);
			padding: 16rpx 32rpx;
			display: flex;
			box-sizing: border-box;
			align-items: center;

			image {
				margin-right: 32rpx;
				width: 48rpx;
				height: 48rpx;
			}

			.search {
				flex: 1;
				display: flex;
				align-items: center;

				.tosear {
					position: relative;
					width: 522rpx;
					height: 64rpx;
					border-radius: 38rpx;
					opacity: 1;

					border: 0 solid rgba(0.5920000076293945, 0.5920000076293945, 0.5920000076293945, 1);
					background: rgba(245, 245, 245, 1);
					padding: 0 32rpx;

					input {
						text-align: center;
						width: 100%;
						height: 100%;
					}

					image {
						position: absolute;
						left: 280rpx;
						top: 50%;
						left: 36%;
						transform: translateY(-50%);
						width: 32rpx;
						height: 32rpx;
					}
				}
			}

		}

		.misslist {
			margin-top: 104rpx;

			.item {
				padding: 24rpx;
				box-sizing: border-box;

				.types {
					margin-top: 8rpx;
					color: rgba(0, 0, 0, 0.6);
					font-size: 24rpx;
					font-weight: 400;
					font-family: "PingFang SC";
				}

				.desc {
					margin-top: 14rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					color: rgba(0, 0, 0, 0.6);
					font-size: 20rpx;
					font-weight: 400;
					font-family: "PingFang SC";

					.money {

						color: rgba(248, 83, 23, 1);
						font-size: 32rpx;
						font-weight: 700;
						font-family: "Montserrat";

						text {
							font-size: 24rpx;
							font-weight: 500;
						}
					}
				}
			}

		}
	}
</style>