Forráskód Böngészése

新增新增商品列表

hwb0 3 éve
szülő
commit
74c44dc95d

+ 19 - 0
packageGoods/goods/category.vue

@@ -0,0 +1,19 @@
+<template>
+	<view>
+		<u-navbar title="商品分类" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				
+			};
+		}
+	}
+</script>
+
+<style lang="scss">
+
+</style>

+ 280 - 0
packageGoods/goods/list.vue

@@ -0,0 +1,280 @@
+<template>
+	<view>
+		<u-navbar title="商品列表" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
+		<!-- 固定nav -->
+		<view class="fixed-top">
+			<!-- 搜索 -->
+			<view class="fixed-top-search flex">
+				<u--input v-model="title" @blur="pageList()" placeholder="请输入商品名称" border="none" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" />
+			</view>
+			<!-- 选择 -->
+			<view class="fixed-top-choice flex">
+				<view class="fixed-top-choice-item" :class="{ 'action': choiceIndex == 1 }" @click="changeChice(1)">
+					<text>综合</text>
+				</view>
+				<view class="fixed-top-choice-item" :class="{ 'action': choiceIndex == 2 }" @click="changeChice(2)">
+					<text>销量</text>
+				</view>
+				<view class="fixed-top-choice-item flex" :class="{ 'action': choiceIndex == 3 }" @click="changeChice(3)">
+					<text>价格</text>
+					<view class="icon flex" v-if="choiceIndex == 3">
+						<image src="../static/list_up.png" mode="" v-if="priceShow" />
+						<image src="../static/list_down.png" mode="" v-else />
+					</view>
+					<view class="icon flex" v-else>
+						<image src="../static/list_null.png" mode="" />
+					</view>
+				</view>
+			</view>
+		</view>
+		<view class="none"></view>
+		<!-- 列表 -->
+		<view class="goods">
+			<view class="goods-list flex">
+				<view class="goods-list-item flex" v-for="(item, index) in list" :key="index" @click="toGoodsDetail(item)">
+					<view class="image-wrap flex">
+						<image :src="item.picUrl" mode="aspectFit"></image>
+					</view>
+					<view class="content">
+						<view class="content-title ells-one">{{ item.title }}</view>
+						<view class="content-coin flex">
+							<view class="content-coin__left flex">
+								<image src="../../static/public/goods_coin.png" mode=""></image>
+								<view class="num">×{{ item.exchangePrice }}</view>
+							</view>
+							<view class="content-coin__right" v-if="item.originPrice">原价:{{ item.originPrice }}</view>
+						</view>
+						<view class="content-price">¥{{ $numberFormat(item.value) }}</view>
+					</view>
+				</view>
+				<view class="goods-list-item"></view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script>
+	import env from '../../config/env.js'
+	import $http from '@/utils/request.js'
+	export default {
+		data() {
+			return {
+				pageNum: 1,
+				total: 0,
+				list: [],
+				title: '',
+				choiceIndex: 1,
+				priceSort: null,
+				saleSort: null,
+				priceShow: false
+			};
+		},
+		
+		onLoad(opthios) {
+			console.log(opthios);
+			this.title = opthios.title
+		},
+		
+		onShow() {
+			this.pageList()
+		},
+		
+		methods: {
+			pageList() {
+				this.pageNum = 1
+				this.total = 0
+				this.list = []
+				this.getList()
+			},
+			
+			// 商品列表
+			getList() {
+				uni.showLoading({
+					title: '加载中'
+				});
+				let data = {
+					goodsName: this.title,
+					priceSort: this.priceSort,
+					saleSort: this.saleSort,
+					noToken: true
+				}
+				$http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`,data).then(
+					res => {
+						uni.hideLoading();
+						if (res.code == 0) {
+							console.log("res: ",res);
+							res.rows.forEach(item => {
+								item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/340'
+							})
+							this.total = res.total
+							this.list = this.list.concat(res.rows)
+						}
+					}).catch(() => {
+					uni.hideLoading();
+				})
+			},
+			
+			// 商品详情
+			toGoodsDetail(item) {
+				uni.navigateTo({
+					url: `/packageGoods/goods/detail?id=${ item.goodsId }`
+				})
+			},
+			
+			// 筛选
+			changeChice(num) {
+				this.choiceIndex = num
+				if(num == 1) {
+					this.priceSort = null
+					this.saleSort = null
+				} else if (num == 2) {
+					this.saleSort = 2
+					this.priceSort = null
+				} else if (num == 3) {
+					this.saleSort = null
+					this.priceShow = !this.priceShow
+					this.priceSort = this.priceShow ? 1 : 2
+				}
+				this.pageList()
+			},
+		},
+		
+		onReachBottom() {
+			// 判断是否有数据
+			if (this.total > this.pageNum * 20) {
+				setTimeout(() => {
+					++this.pageNum
+					this.getList()
+				}, 500)
+			} else {
+				uni.$u.toast('已经到底了')
+			}
+		},
+	}
+</script>
+
+<style lang="scss" scoped>
+	// 固定
+	.fixed-top {
+		position: fixed;
+		width: 100%;
+		background-color: #fff;
+		padding: 34rpx;
+		z-index: 100;
+		box-shadow: 0 5rpx 5rpx #ececec;
+		
+		// 搜索
+		&-search {
+			height: 72rpx;
+			background: #F7F7F7;
+			border-radius: 34px;
+			padding-left: 24rpx;
+			margin-bottom: 32rpx;
+		}
+		
+		// 选择
+		&-choice {
+			justify-content: space-around;
+			
+			&-item {
+				color: #666;
+				
+				.icon {
+					flex-direction: column;
+					
+					image {
+						width: 18rpx;
+						height: 20rpx;
+						margin-left: 6rpx;
+					}
+				}
+			}
+			
+			.action {
+				color: #FA822C;
+			}
+		}
+	}
+	
+	.none {
+		height: 240rpx;
+	}
+	
+	// 列表
+	.goods {
+		padding: 0 34rpx;
+		
+		&-list {
+			width: 100%;
+			justify-content: space-between;
+			flex-wrap: wrap;
+			
+			&-item {
+				flex-direction: column;
+				justify-content: flex-start;
+				width: 48%;
+				padding-bottom: 36rpx;
+				background: #FFFFFF;
+				box-shadow: 0px 0px 3px 0px rgba(100, 100, 100, 0.1);
+				border-radius: 16rpx;
+				margin-bottom: 30rpx;
+				
+				.image-wrap {
+					width: 100%;
+					height: 320rpx;
+					margin-bottom: 18rpx;
+					
+					image {
+						width: 100%;
+						height: 100%;
+						border-radius: 16rpx 16rpx 0 0;
+					}
+				}
+				
+				.content {
+					width: 100%;
+					padding: 0 22rpx;
+					
+					&-title {
+						height: 28rpx;
+						font-size: 28rpx;
+						line-height: 28rpx;
+						font-weight: bold;
+						margin-bottom: 40rpx;
+					}
+					
+					&-coin {
+						height: 30rpx;
+						font-size: 24rpx;
+						justify-content: flex-start;
+						margin-bottom: 34rpx;
+						
+						&__left {
+							margin-right: 24rpx;
+							
+							image {
+								width: 34rpx;
+								height: 30rpx;
+							}
+						}
+						
+						&__right {
+							color: #666666;
+							text-decoration: line-through;
+						}
+					}
+					
+					&-price {
+						font-size: 24rpx;
+						color: #666666;
+					}
+				}
+			}
+			
+			&-item:last-child {
+				box-shadow: none;
+				background: none;
+			}
+		}
+	}
+</style>

BIN
packageGoods/static/list_down.png


BIN
packageGoods/static/list_null.png


BIN
packageGoods/static/list_up.png


+ 11 - 2
pages.json

@@ -18,7 +18,10 @@
 			"path": "pages/login/code"
 		},
 		{
-			"path": "pages/lucky/index"
+			"path": "pages/lucky/index",
+			"style": {
+				"navigationBarTextStyle": "white"
+			}
 		},
 		{
 			"path": "pages/ticketBox/detail"
@@ -41,6 +44,12 @@
 				{
 					"path": "goods/detail"
 				},
+				{
+					"path": "goods/list"
+				},
+				{
+					"path": "goods/category"
+				},
 				{
 					"path": "order/index"
 				},
@@ -62,7 +71,7 @@
 				{
 					"path": "recovery/detail"
 				}
-			]
+            ]
 		},
 		{
 			"root": "packagePrize",

+ 33 - 16
pages/core/index.vue

@@ -11,10 +11,10 @@
 			<!-- 搜索 -->
 			<view class="fixed-top-search flex">
 				<view class="fixed-top-search__input flex">
-					<u--input placeholder="请输入关键词进行搜索" border="none" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" />
-					<view class="fixed-top-search__input__btn">搜索</view>
+					<u--input v-model="goodsTitle" placeholder="请输入关键词进行搜索" border="none" prefixIcon="search" prefixIconStyle="font-size: 22px;color: #909399" />
+					<view class="fixed-top-search__input__btn" @click="toGoodsList()">搜索</view>
 				</view>
-				<image src="../../static/core/core_block.png" mode="scaleToFill" />
+				<image src="../../static/core/core_block.png" mode="scaleToFill" @click="toGoodsCategroy"/>
 			</view>
 			<view class="fixed-top-classify">
 				<u-tabs @change="changeClassify" :scrollable="true" :list="classifyList" lineWidth="20" lineHeight="2"
@@ -29,10 +29,11 @@
 			</view>
 		</view>
 		<view class="core-none"></view>
+		
 		<!-- 轮播 -->
 		<view class="core-swiper">
 			<swiper class="core-swiper-centent" circular :indicator-dots="true" :autoplay="true" :interval="3000" indicator-active-color="#fff">
-				<swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index">
+				<swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index" @click="toCoreRange(item)">
 					<image :src="item.picUrl" mode=""></image>
 				</swiper-item>
 			</swiper>
@@ -105,8 +106,8 @@
 
 <script>
 	import env from '../../config/env.js'
-	import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
 	import $http from '@/utils/request.js'
+	import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
 	export default {
 		components: {
 			CustomTabBar,
@@ -126,6 +127,7 @@
 				classifyIndex: 0, // 分类选中下标
 				classifyListFilter: [],
 				swiperList: [], // 轮播图
+				goodsTitle: '',
 			};
 		},
 		onLoad() {
@@ -265,23 +267,38 @@
 			},
 
 			// 跳转点击事件
-			toCoreRange(type, data, name) {
-				if (type == "link") {
-					uni.navigateTo({
-						url: `/packageOperate/webview/index?url=${ data }`,
-					})
-				} else {
-					uni.navigateTo({
-						url: `/packageGoods/core/index?type=${ type }&data=${ data }&name=${ name }`,
-					})
-				}
+			toCoreRange(item) {
+				console.log(item);
+				// if (type == "link") {
+				// 	uni.navigateTo({
+				// 		url: `/packageOperate/webview/index?url=${ data }`,
+				// 	})
+				// } else {
+				// 	uni.navigateTo({
+				// 		url: `/packageGoods/core/index?type=${ type }&data=${ data }&name=${ name }`,
+				// 	})
+				// }
 			},
 
+			// 商品详情
 			toGoodsDetail(item) {
 				uni.navigateTo({
 					url: `/packageGoods/goods/detail?id=${ item.goodsId }`
 				})
 			},
+			
+			// 商品列表
+			toGoodsList() {
+				console.log(this.goodsTitle);
+				uni.navigateTo({
+					url: `/packageGoods/goods/list?title=${ this.goodsTitle }`
+				})
+			},
+			
+			// 商品分类
+			toGoodsCategroy() {
+				
+			},
 		},
 		onReachBottom() {
 			// 判断是否有数据
@@ -506,7 +523,6 @@
 				flex-direction: column;
 				justify-content: flex-start;
 				width: 48%;
-				// height: 520rpx;
 				padding-bottom: 36rpx;
 				background: #FFFFFF;
 				box-shadow: 0px 0px 3px 0px rgba(100, 100, 100, 0.1);
@@ -521,6 +537,7 @@
 					image {
 						width: 100%;
 						height: 100%;
+						border-radius: 16rpx 16rpx 0 0;
 					}
 				}
 				

+ 1 - 1
pages/lucky/index.vue

@@ -57,7 +57,7 @@
 						<navigator open-type="exit" target="miniProgram" hover-class="none" class="luck-info-close-content flex">
 							<u-icon name="close" color="#fff" size="20"></u-icon>
 						</navigator>
-					</view> -->
+					</view>
 				</view>
 			</view>
 		</u-overlay>

BIN
static/icon/lucky_bg.png


BIN
static/icon/lucky_bg2.png


BIN
static/public/goods_coin.png