Jelajahi Sumber

【搜索页,分类搜索调整!】

zhengjinyi 5 tahun lalu
induk
melakukan
be74f8d134

+ 53 - 1
api/product.js

@@ -8,7 +8,7 @@ import request from '@/common/config/caimeiApi.js'
 import $reg from '@/common/config/common.js'
 
 /**
- * 获取商品分类
+ * 获取分类导航
  */
 export function queryGoodscategory() {
 	return new Promise(function(resolve,reject) {
@@ -38,6 +38,23 @@ export function queryGoodslist(url,params) {
 		})
 	});
 }
+/**
+ * @新分类下的商品列表
+ * @param:tinyTypeID 三级分类ID
+ * @param:pageNum	页码
+ * @param:pageSize	每页显示条数
+ */
+export function searchQueryTinyType(url,params) {
+	return new Promise(function(resolve,reject) {
+		request.lodingGet(url,params, res => {
+			if(res.code == 0){
+				resolve(res);
+			}else{
+				reject(res)
+			}
+		})
+	});
+}
 /**
  * @商品搜索
  * @param:userId 用户ID
@@ -56,6 +73,41 @@ export function querySearchProduct(params) {
 		})
 	});
 }
+/**
+ * @新商品搜索
+ * @param:keyword 关键词
+ * @param:pageNum	页码
+ * @param:pageSize	每页显示条数
+ * @param:sortField	价格排序
+ * @param:sortType	类型排序
+ */
+export function queryNewSearchProduct(params) {
+	return new Promise(function(resolve,reject) {
+		request.lodingGet("/search/query/product",params, res => {
+			if(res.code == 0){
+				resolve(res);
+			}else{
+				reject(res)
+			}
+		})
+	});
+}
+/**
+ * @新商品搜索重新请求价格
+ * @param:productIds 商品ID
+ * @param:userId	用户ID
+ */
+export function querySearchProductPrice(params) {
+	return new Promise(function(resolve,reject) {
+		request.get("/search/query/product/price",params, res => {
+			if(res.code == 0){
+				resolve(res);
+			}else{
+				reject(res)
+			}
+		})
+	});
+}
 /**
  * @搜索历史记录
  * @param:userId 用户ID

+ 2 - 2
common/config/config.js

@@ -3,8 +3,8 @@ if(process.env.NODE_ENV === 'development'){
     // 开发环境
 	// URL_CONFIG = 'http://192.168.1.24:8008'	 //俊俊联调地址
 	// URL_CONFIG = 'http://192.168.1.22:8008'	 //裴裴联调地址
-	// URL_CONFIG = 'http://192.168.1.26:8008'	 //超超联调地址
-    URL_CONFIG = 'https://spi-b.caimei365.com'	 //采美测试地址
+	URL_CONFIG = 'http://192.168.1.26:8008'	 //超超联调地址
+    // URL_CONFIG = 'https://spi-b.caimei365.com'	 //采美测试地址
 	// URL_CONFIG = 'https://spi.caimei365.com'
 }else{
     // 生产环境

+ 94 - 93
components/cm-module/listTemplate/commodityList.vue

@@ -1,65 +1,56 @@
 <template>
 	<view class="container commodity-list-wrapper" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
 		<list-skeleton v-if="showSkeleton" :listType='0'></list-skeleton>
-		<scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="toLower" scroll-y v-if="commodityList.length > 0">
-			<view v-for="(item,index) in commodityList" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">
-				<image mode='widthFix' :src="item.mainImage"  class="list-img" alt="list-img"></image>
+		<scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="toLower" scroll-y v-if="listData.length > 0">
+			<view v-for="(item,index) in listData" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.pid)">
+				<image mode='widthFix' :src="item.image"  class="list-img" alt="list-img"></image>
 				<view class="list-details-info">
 					<text class="list-details-title">{{item.name}}</text>
 					<text class="list-details-specs">规格:{{item.unit}}</text>
 					<view class="list-details-specs" v-if="item.productCode!=''&&item.productCode!=null">商品编码:{{item.productCode}}</view>
-					<text class="list-details-miniQuantity" v-if="fromRegularPurchasePage">起订量:{{item.minBuyNumber}}</text>
 					<view class="list-details-price">
 						<view v-if="hasLogin"class="list-price">
 							<view v-if="userIdentity == 1">
-								<text>¥<text class="price-larger">{{item.retailPrice?item.retailPrice.toFixed(2):'0.00'}}</text></text>
+								<text v-if="priceLoading" class="price-larger small">正在获取价格...</text>
+								<text v-else>¥<text class="price-larger">{{item.price?item.price :'0.00'}}</text></text>
 							</view>	
 							<view v-if="userIdentity == 4">
-								<view class="price-larger" v-if="item.price1TextFlag == '1'">
+								<view class="price-larger" v-if="item.priceflag == '1'">
 									<text class="txt">未公开价格</text>
 								</view>
-								<view class="price-larger" v-if="item.price1TextFlag == '2'">
-									<text class="txt">价格仅会员可见</text>
-									<text class="btn" @click.stop="this.$api.navigateTo(`/pages/login/apply?clubStatus=${clubStatus}`)">去升级</text>
+								<text v-else-if="priceLoading" class="price-larger small">正在获取价格...</text>
+								<view v-else>
+									<view class="price-larger" v-if="item.priceflag == '2'">
+										<text class="txt">价格仅会员可见</text>
+										<text class="btn" @click.stop="this.$api.navigateTo(`/pages/login/apply?clubStatus=${clubStatus}`)">去升级</text>
+									</view>
+									<text v-else>¥<text class="price-larger">{{item.price ?item.price :'0.00'}}</text></text>
 								</view>
-								<text v-if="item.price1TextFlag == '0'">¥<text class="price-larger">{{item.retailPrice?item.retailPrice.toFixed(2):'0.00'}}</text></text>
 							</view>
 							<view v-if="userIdentity == 2">
-								<view class="price-larger" v-if="item.price1TextFlag == '1'">
+								<view class="price-larger" v-if="item.priceflag == '1'">
 									<text class="txt">未公开价格</text>
 								</view>
-								<text v-else>¥<text class="price-larger">{{item.retailPrice?item.retailPrice.toFixed(2):'0.00'}}</text></text>
+								<text v-else-if="priceLoading" class="price-larger small">正在获取价格...</text>
+								<text v-else>¥<text class="price-larger">{{item.price ? item.price :'0.00'}}</text></text>
 							</view>
 						</view>	
-						<view  class="list-login-now"  v-else>
+						<view  v-else class="list-login-now">
 							<text class="p-no">价格:</text>
-							<uni-stars :stars="parseInt(item.price1Grade)" :font-size='36' :width-info="180"></uni-stars>
+							<uni-stars :stars="parseInt(item.pricegrade)" :font-size='36' :width-info="180"></uni-stars>
 						</view>
-						<button v-if="fromRegularPurchasePage" class="add-cart-btn" @click.stop="operationHanld(item)">选择数量</button>
 					</view>
 				</view>
 			</view>
-			<button class="show-more-btn" v-if="showRegularBtn" @click="getListFromServer(true)">查看更多</button>
-			<view v-if="showLoading && commodityList.length > 4 && !showRegularBtn">
+			<view v-if="showLoading && listData.length > 4">
 				<view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
 				<view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
 			</view>
 		</scroll-view>
-		<view class="cart-icon" v-if="fromRegularPurchasePage" @click="toCartPage">
-			<text v-if="cartNum > 0" class="uni-badge uni-badge-error uni-small uni-badge--small icon-num">
-				{{cartNum}}
-			</text>
-			<image src='../../../static/icon-cart-active@3x.png' mode="widthFix"></image>
-		</view>
-		<view class="empty-container" v-if="showEmpty && !fromRegularPurchasePage">
+		<view class="empty-container" v-if="showEmpty">
 			<image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AY2ZjAABpmnBICH4247.png"></image>
 			<text class="error-text">{{emptyText}}</text>
 		</view>
-		<view class="empty-container" v-if="showEmpty && fromRegularPurchasePage">
-			<image class="empty-container-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AWdWzAAGlgAP0das422.png" mode="aspectFit"></image>
-			<text class="error-text">您还没有购买过任何商品哟~</text>
-			<button class="submit-btn toIndexPage" @click="toIndexPage">去逛逛</button>
-		</view>
 		<!-- 透明模态层 -->
 		<modal-layer v-if='isModallayer'></modal-layer>
 	</view>
@@ -69,7 +60,7 @@
 	import listSkeleton from '@/components/cm-module/listTemplate/listSkeleton'
 	import modalLayer from "@/components/modal-layer"
 	import uniStars from '@/components/uni-stars/uni-stars.vue'
-	import { queryGoodslist } from "@/api/product.js"
+	import { searchQueryTinyType,querySearchProductPrice} from "@/api/product.js"
 	import { mapState,mapMutations } from 'vuex';
 	export default{
 		name:'CommodityList',
@@ -82,6 +73,12 @@
 			emptyText: {
 				type: String
 			},
+			serverUrl: {
+				type: String
+			},
+			typeId: {
+				type:Number
+			}
 		},
 		data(){
 			return{
@@ -92,43 +89,44 @@
 				showEmpty: false,
 				userID: '',
 				userIdentity:'',
+				priceLoading:true,
 				scrollHeight: '',
-				commodityList: [],
+				listData: [],
 				showLoading: false,
 				loadingNow: true,
 				loadingText: '上拉加载更多',
 				pageSize: 10,
 				pageNum: 1,
-				hasNextPage: false,
 				totalPage: 1,
 				pullFlag: true,
-				fromRegularPurchasePage: false,
 				cartNum: 0,
-				showRegularBtn: false
+				identity:2,
 			}
 		},
 		created() {		
+			console.log(this.typeId)
 			this.setScrollHeight();		
-			this.$api.getStorage().then((resolve) =>{
+			this.$api.getComStorage('userInfo').then((resolve) =>{
 				this.clubStatus = resolve.clubStatus
+				this.userID = resolve.userID ? resolve.userID : '';
+				this.userIdentity = resolve.userIdentity
+				if(this.userIdentity = 1){
+					this.identity = 1
+				}else{
+					this.identity = 2
+				}
+				this.getListFromServer();
+			}).catch(error =>{
+				console.log(error)
 			})
 		},
 		computed: {
 			...mapState(['hasLogin','userInfo'])
 		},
 		methods:{
-			toLoginPage() {
-				const {lastPageType, lastPageVal} = this.$parent;
-				uni.navigateTo({
-					url:`/pages/login/login?listType=${lastPageType}&listVal=${lastPageVal}`
-				})
-			},
 			toLower() {
-				// 第一次加载排除常用商品
-				if(!this.showRegularBtn) {
-					if(this.hasNextPage && this.pullFlag) {
-						this.getListFromServer(true);
-					}
+				if(this.totalPage>this.pageNum && this.pullFlag) {
+					this.getListFromServer(true);
 				}
 			},
 			setScrollHeight() {
@@ -137,83 +135,83 @@
 				this.scrollHeight = windowHeight - 1;
 			},
 			getListFromServer(loadMore) {
-				this.$api.getStorage().then((resolve) =>{
-					this.userID = resolve.userID ? resolve.userID : '';
-					this.userIdentity = resolve.userIdentity
-					this.getQueryGoodslist(loadMore)
-				}).catch(error =>{
-					this.getQueryGoodslist(loadMore)
-				})
+				this.getQueryGoodslist(loadMore)
 			},
 			getQueryGoodslist(loadMore){
-				const thisServerurl = this.$parent.serverUrl;
 				this.showLoading = true;
 				this.loadingNow = true;
 				this.loadingText = '加载中';
-				if(loadMore) {
-					this.pageNum += 1;
-				}
-				if(this.$parent.lastPageType === '再次购买') {
-					this.fromRegularPurchasePage = true;
+				if(loadMore) { this.pageNum += 1; }
+				let params ={
+						id:this.typeId,
+						identity:this.identity,
+						pageNum:this.pageNum,
+						pageSize:this.pageSize,
+						sortField:'',
+						sortType:''
 				}
-				queryGoodslist(thisServerurl,{userId:this.userID,pageNum:this.pageNum,pageSize:this.pageSize}).then(response=>{
-					const resData = this.fromRegularPurchasePage ?response.data.page :response.data;
-					const resList = resData.results,
-						  getCartNum = response.data.count;
-					this.cartNum = getCartNum > 99 ?'99+' :getCartNum;
-					if(!loadMore && this.fromRegularPurchasePage && resData.hasNextPage) {
-						this.showRegularBtn = true;
-					}
+				searchQueryTinyType(this.serverUrl,params).then(response=>{
+					const resData = JSON.parse(response.data);
+					const resList = resData.items;
 					if(resList && resList.length > 0){
-						this.hasNextPage = resData.hasNextPage;
-						this.totalPage = resData.totalPage;
+						this.showEmpty = false
+						this.totalPage = resData.total;
 						if(loadMore) {
-							this.commodityList = [...this.commodityList,...resList];
-							this.showRegularBtn = false;
+							this.listData = [...this.listData,...resList];
+							this.setProductPrice()
+							this.showSkeleton = false
 						} else {
-							this.commodityList = [...resList];
-							this.showSkeleton = false;
+							this.listData = [...resList];
+							this.setProductPrice()
+							this.showSkeleton = false
 						}
 						// 防上拉暴滑
 						this.pullFlag = false;
-						setTimeout(()=>{
-							this.pullFlag = true;
-						},500)
+						setTimeout(()=>{ this.pullFlag = true; },500)
 						// 底部提示文案
-						if(this.hasNextPage) {
+						if(this.totalPage>this.pageNum) {
 							this.loadingText = '上拉加载更多';
 						} else {
 							this.showLoading = true;
 							this.loadingNow = false;
 						}
 					} else {
-						if(!loadMore) {
-							this.showEmpty = true;
-						}
+						if(!loadMore) { this.showEmpty = true; }
 					}
 				}).catch(error =>{
 					this.$util.msg(error.msg,2000);
 				})
 			},
-			operationHanld(prop){
-				this.$emit('operationConfim',prop)
+			setProductPrice(){//获取价格
+				if (!this.userID) {return false;}
+				let productIdArr = [];
+				this.listData.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
+					if (item.priceflag != 1){ productIdArr.push(item.pid) }
+				})
+				this.productIds = productIdArr.join(",");
+				querySearchProductPrice({userId: this.userID,productIds:this.productIds}).then(response =>{
+					if (response.data) {
+						let ids = Object.keys(response.data.prices);
+						this.listData.map(item=>{
+							for (let i = 0; i < ids.length; i++) {
+								let id = ids[i];
+								let price = response.data.prices[id];
+								if (item.priceflag != 1 && item.pid == id){
+									item.price = Number(price).toFixed(2);
+								}
+							}
+						});
+					}
+					this.priceLoading = false;
+				}).catch(error =>{
+					this.$util.msg(error.msg,2000)
+				})
 			},
 			navToDetailPage(id) {
 				this.isModallayer = true;
 				this.$api.navigateTo(`/pages/goods/product?id=${id}`);
 				this.isModallayer = false;
-			},
-			toCartPage() {
-				uni.switchTab({
-					url: '/pages/tabBar/cart/cart'
-				})
-			},
-			toIndexPage() {
-				uni.switchTab({
-					url: '/pages/tabBar/home/home' 
-				})
 			}
-				
 		}
 	}
 </script>
@@ -323,6 +321,9 @@
 				width: 100%;
 				height: 44rpx;
 				font-size: 32rpx;
+				&.small{
+					font-size: $font-size-24;
+				}
 				.txt{
 					font-size: $font-size-24;
 					display: inline-block;

+ 100 - 60
components/cm-module/listTemplate/immediatelyList.vue

@@ -30,9 +30,9 @@
 		<!-- 单一商品 -->
 		<view class="product-container" v-else >
 			<view :class="tabIndex" v-if="tabIndex === 0"  :style="{paddingTop:searchStatus?'128rpx':''}">
-				<scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower(tabIndex)" scroll-y v-if="productList.length > 0">
-					<view v-for="(item,index) in productList" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)"  >
-					    <image mode='widthFix' :src="item.mainImage"  class="list-img" alt="list-img"></image>
+				<scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower(tabIndex)" scroll-y v-if="listData.length > 0">
+					<view v-for="(item,index) in listData" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)"  >
+					    <image mode='widthFix' :src="item.image"  class="list-img" alt="list-img"></image>
 						<view class="list-details-info">
 							<text class="list-details-title">{{item.name}}</text>
 							<text class="list-details-specs">规格:{{item.unit?item.unit:''}}</text>
@@ -41,10 +41,11 @@
 								<view>商品编码:{{item.productCode}}</view>
 							</view>
 							<view class="list-details-price">
-								<view class="list-shop">
-									<view class="list-price" >
+								<view v-if="priceLoading" class="list-price-loding">正在获取价格...</view>
+								<view v-else class="list-shop">
+									<view class="list-price">
 										<text class="price-view activity" v-if="item.isShowActFlg">活动价</text>
-										<text class="price-larger"  >¥{{item.retailPrice.toFixed(2)}}</text>
+										<text class="price-larger">¥{{item.price}}</text>
 										<text class="price-view ladder" v-if="item.ladderPriceFlag == '1'" @click.stop="alertjieti(item)">阶</text>
 									</view>
 									<view class="list-price-none" v-if="item.repurchasePriceState">
@@ -56,7 +57,7 @@
 							</view>
 						</view>
 					</view>
-					<view v-if="showLoading && productList.length > 4 && !showRegularBtn">
+					<view v-if="showLoading && listData.length > 4 && !showRegularBtn">
 						<view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
 						<view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
 					</view>
@@ -132,6 +133,7 @@
 	import modalLayer from "@/components/modal-layer"
 	import uniStars from '@/components/uni-stars/uni-stars.vue'
 	import cmDrag from '@/components/cm-custom/cm-drag.vue'
+	import { queryNewSearchProduct,querySearchProductPrice} from "@/api/product.js"
 	import { getSellerProduct,getcombinationProduct } from "@/api/seller.js"
 	import { mapState,mapMutations } from 'vuex';
 	export default{
@@ -154,12 +156,13 @@
 				searchInputVal:'',
 				isModallayer:false,
 				windowHeight: '',
-				showSkeleton: false,
+				showSkeleton: false,
+				priceLoading:true,
 				isShowEmpty: false,
 				isShowEmptyText: '搜索相关商品',
 				clubUserId: '',
 				scrollHeight: '',
-				productList: [],
+				listData: [],
 				combinationProduct:[],
 				zuheProductList:[],//组合商品列表
 				showLoading: false,
@@ -167,7 +170,8 @@
 				loadingText: '上拉加载更多',
 				pageSize: 10,
 				zuhepageSize:5,
-				pageNum: 1,
+				pageNum: 1,
+				totalPage:1,
 				hasNextPage: false,
 				pullFlag: true,
 				fromRegularPurchasePage: false,
@@ -195,13 +199,15 @@
 		},
 		methods:{
 			scrolltolower(tabIndex) {
-				if(this.hasNextPage && this.pullFlag) {
-					if(tabIndex ==0){
+				if(tabIndex ==0){
+					if(this.totalPage>this.pageNum && this.pullFlag) {
 						this.getProductAgainInfo(true);
-					}else if(tabIndex==1){
+					}
+				}else if(tabIndex==1){
+					if(this.hasNextPage && this.pullFlag) {
 						this.getcombinationProduct(true);
-					}
-				}
+					}
+				}
 			},
 			setScrollHeight() {
 				const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
@@ -214,52 +220,82 @@
 				this.loadingText = '加载中';
 				this.isShowEmpty = false;				
 				if(loadMore) {this.pageNum += 1;}
-				let params = {clubUserId:this.clubUserId,pageNum:this.pageNum,pageSize:this.pageSize,searchWord:this.searchInputVal}
-				getSellerProduct(params).then(response =>{
+				let params = {keyword:this.searchInputVal,pageNum:this.pageNum,pageSize:this.pageSize,sortField:'',sortType:''}
+				queryNewSearchProduct(params).then(response =>{
 					this.isShowWrapper = true
-					const responseData = response.data;
-					if(responseData.results && responseData.results.length > 0){
-						this.hasNextPage = responseData.hasNextPage;
-						this.isShowEmpty = false;
-						if(loadMore) {
-							this.productList = [...this.productList,...responseData.results];
-						} else {
-							this.productList = [...responseData.results];
-							this.showSkeleton = false;
-						}
-						//价格显示处理
-						let isActFlg,newProductList=[];
-						this.productList.map((item, index)=> {
-							if(item.actStatus == 1){
-								isActFlg = true
-							}else if(item.actStatus == 1 && item.ladderPriceFlag == '1'){
-								isActFlg = true
-							}else{
-								isActFlg = false
-							}
-							newProductList.push(Object.assign({},item,{isShowActFlg:isActFlg}))
-						})
-						this.productList = newProductList
-						// 防上拉暴滑
-						this.pullFlag = false;
-						setTimeout(()=>{
-							this.pullFlag = true;
-						},500)
-						// 底部提示文案
-						if(this.hasNextPage) {
-							this.loadingText = '上拉加载更多';
-						} else {
-							this.showLoading = true;
-							this.loadingNow = false;
-						}
+					const resData = JSON.parse(response.data);
+					console.log(resData)
+					const resList = resData.items;
+					if(resList && resList.length > 0){
+						this.totalPage = resData.total;
+						this.showEmpty = false;
+						if(loadMore) {
+							this.listData = [...this.listData,...resList];
+							console.log(this.listData)
+							this.setProductPrice()
+						} else {
+							this.listData = [...resList];
+							this.setProductPrice()
+							this.showSkeleton = false;
+						}
+						//价格显示处理
+						let isActFlg,newlistData=[];
+						this.listData.map((item, index)=> {
+							if(item.actStatus == 1){
+								isActFlg = true
+							}else if(item.actStatus == 1 && item.ladderPriceFlag == '1'){
+								isActFlg = true
+							}else{
+								isActFlg = false
+							}
+							newlistData.push(Object.assign({},item,{isShowActFlg:isActFlg}))
+						})
+						this.listData = newlistData
+						// 防上拉暴滑
+						this.pullFlag = false;
+						setTimeout(()=>{ this.pullFlag = true; },500)
+						// 底部提示文案
+						if(this.totalPage>this.pageNum) {
+							this.loadingText = '上拉加载更多';
+						} else {
+							this.showLoading = true;
+							this.loadingNow = false;
+						}
 					} else {
-						console.log('111111111')
-						this.isShowEmpty = true;
-						this.isShowEmptyText ='暂无相关商品'
-					}
+						if(!loadMore) {
+							this.isShowEmpty = true;
+							this.isShowEmptyText ='暂无相关商品'
+						}
+					}
 				}).catch(error =>{
 					this.$util.msg(error.msg,2000);
 				})
+			},
+			setProductPrice(){//获取价格
+				let productIdArr = [];
+				this.listData.map(item=>{
+					productIdArr.push(item.pid) 
+				})
+				console.log(productIdArr)
+				this.productIds = productIdArr.join(",");
+				querySearchProductPrice({userId: this.clubUserId,productIds:this.productIds}).then(response =>{
+					if (response.data) {
+						let ids = Object.keys(response.data.prices);
+						this.listData.map(item=>{
+							for (let i = 0; i < ids.length; i++) {
+								let id = ids[i];
+								let price = response.data.prices[id];
+								if (item.priceflag != 1 && item.pid == id){
+									item.price = Number(price).toFixed(2);
+								}
+							}
+						});
+						console.log(this.listData)
+					}
+					this.priceLoading = false;
+				}).catch(error =>{
+					this.$util.msg(error.msg,2000)
+				})
 			},
 			searchOpertor(tabIndex){//搜索商品
 				if(tabIndex == 0){
@@ -288,7 +324,6 @@
 					const responseData = response.data;
 					if(responseData.results && responseData.results.length > 0){
 						this.hasNextPage = responseData.hasNextPage;
-						
 						this.isShowEmpty = false;
 						if(loadMore) {
 							this.combinationProduct = [...this.combinationProduct,...responseData.results];
@@ -438,7 +473,7 @@
 			delInputText(tabIndex){//清除输入框内容
 				if(tabIndex==0){
 					this.searchInputVal = '';
-					this.productList =[];
+					this.listData =[];
 					this.isShowClose = false;
 					this.loadingNow = false;
 					this.isShowEmpty = true;
					this.isShowEmptyText ='暂无相关商品'
@@ -733,7 +768,12 @@
 				color: #FF2A2A;
 			}
 		}
-		
+		.list-price-loding{
+			flex: 6;
+			font-size:$font-size-24;
+			line-height: 64rpx;
+			color: #FF2A2A;
+		}
 		.list-shop{
 			width: 100%;
 			height: auto;
@@ -745,7 +785,7 @@
 				float: left;
 				line-height:36rpx ;
 				align-items: center;
-				justify-content: center;
+				justify-content: center;
 				.price-larger {
 					margin-top: 20rpx;
 					font-size: $font-size-30;

+ 26 - 11
pages/goods/goods.vue

@@ -1,6 +1,6 @@
 <template>
 	<view class="container all-type-list-wrapper">
-		<commodity-list ref="childList" :empty-text="emptyText"></commodity-list>
+		<commodity-list ref="childList" :empty-text="emptyText" :serverUrl="serverUrl" :typeId="typeId" v-if="isRequest"></commodity-list>
 	</view>
 </template>
 
@@ -17,52 +17,67 @@
 				emptyText: '',
 				lastPageType: '',
 				lastPageVal: '',
+				isRequest:false,
+				typeId:null
 			}
 		},		
 		onLoad(option) {
-			let self = this;
-			self.setServerUrl(option);
+			this.setServerUrl(option);
 		},
 		methods:{
 			setServerUrl(option) {
+				console.log(option)
 				let self = this;
 				const {type, from: value} = option;
 				this.lastPageType = type;
 				this.lastPageVal = value;
+				console.log(this.lastPageType)
+				console.log(this.lastPageVal)
 				uni.setNavigationBarTitle({title:value});
 				uni.getStorage({
 					key: 'commodity_id',
 					success: function (res) {
-					    const id = res.data;
+					   
 						const emptyTxt = '正在上架中,敬请期待~';
-						const otherTypeUrl = '/product/preferred';
+						console.log(self.listData);
 						/**
 						 *@商品分类列表传参类型
 						 *@type  首页分类:0,首页商品模块1:1,首页商品模块2:2,首页商品模块3:3,底部导航分类:4
 						 **/
 						switch(type){
 							case '0':
-								self.serverUrl = `/home/classify?classifyId=${id}`;
+								self.typeId = res.data;
+								self.serverUrl = '/search/query/product/classify';
 								self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
+								console.log(self.serverUrl)
 								break;
 							case '1':	
-								self.serverUrl = `${otherTypeUrl}?preferredFlag=001`;
+								self.typeId = 1;
+								self.serverUrl = '/search/query/product/preferred';
 								self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
+								console.log(self.serverUrl)
 								break;
 							case '2':
-								self.serverUrl = `${otherTypeUrl}?preferredFlag=010`;
+								self.typeId = 10;
+								self.serverUrl = '/search/query/product/preferred';
 								self.emptyText = `${self.lastPageVal}商品${emptyTxt}`;
+								console.log(self.serverUrl)
 								break;
 							case '3':
-								self.serverUrl = `${otherTypeUrl}?preferredFlag=100`;
+								self.typeId = 100;
+								self.serverUrl = '/search/query/product/preferred';
 								self.emptyText = `${self.lastPageVal}${emptyTxt}`;
+								console.log(self.serverUrl)
 								break;
 							case '4':
-								self.serverUrl = `/product/listByTinyTypeID?tinyTypeID=${id}`;
+								self.typeId = res.data;
+								self.serverUrl = '/search/query/product/tinyType';
 								self.emptyText = '该分类暂时还没有商品哟,去逛逛别的吧~';
+								console.log(self.serverUrl)
 								break;
 						}
-						self.$refs.childList.getListFromServer();
+						console.log(self.serverUrl)
+						self.isRequest = true
 					}
 				})
 			}

+ 91 - 35
pages/search/search.vue

@@ -20,36 +20,51 @@
 			</view>
 		</view>
 		<!-- <go-search :theme="themeClass" @subMitSearch="subMitSearch"></go-search> -->
-		<view v-else class="commodity-list-wrapper"  :style="{'overflow':'auto','height':(commodityList.length>4? windowHeight + 'px' : 'auto')}">
-			<scroll-view :style="{'height':(commodityList.length>4? scrollHeight+'px' : 'auto')}" @scrolltolower="scrolltolower" scroll-y v-if="!showEmpty">
-				<view v-for="(item,index) in commodityList" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">
-					<image mode='widthFix' :src="item.mainImage"  class="list-img" alt="list-img"></image>
+		<view v-else class="commodity-list-wrapper"  :style="{'overflow':'auto','height':(listData.length>4? windowHeight + 'px' : 'auto')}">
+			<scroll-view :style="{'height':(listData.length>4? scrollHeight+'px' : 'auto')}" @scrolltolower="scrolltolower" scroll-y v-if="!showEmpty">
+				<view v-for="(item,index) in listData" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.pid)">
+					<image mode='widthFix' :src="item.image"  class="list-img" alt="list-img"></image>
 					<view class="list-details-info">
 						<text class="list-details-title">{{item.name}}</text>
 						<text class="list-details-specs">规格:{{item.unit}}</text>
-						<text class="list-details-miniQuantity" v-if="fromRegularPurchasePage">起订量:{{item.minBuyNumber}}</text>
-						<view class="list-details-specs" v-if="item.productCode!=''&&item.productCode!=null">
+						<view class="list-details-specs" v-if="item.productcode!=''&&item.productCode!=null">
 							<view>商品编码:{{item.productCode}}</view>
 						</view>
 						<view class="list-details-price">
-							<view v-if="!hasLogin" class="list-login-now">
-								<text class="p-no">价格:</text>
-								<uni-stars :stars="parseInt(item.price1Grade)" :font-size='36' :width-info="180"></uni-stars>
-							</view>
-							<view class="list-price" v-else>
-								<view class="price-larger" v-if="item.price1TextFlag == '1'">
-									<text class="txt">该未公开价格</text>
+							<view v-if="hasLogin"class="list-price">
+								<view v-if="userIdentity == 1">
+									<text v-if="priceLoading" class="price-larger small">正在获取价格...</text>
+									<text v-else>¥<text class="price-larger">{{item.price?item.price :'0.00'}}</text></text>
+								</view>	
+								<view v-if="userIdentity == 4">
+									<view class="price-larger" v-if="item.priceflag == '1'">
+										<text class="txt">未公开价格</text>
+									</view>
+									<text v-else-if="priceLoading" class="price-larger small">正在获取价格...</text>
+									<view v-else>
+										<view class="price-larger" v-if="item.priceflag == '2'">
+											<text class="txt">价格仅会员可见</text>
+											<text class="btn" @click.stop="this.$api.navigateTo(`/pages/login/apply?clubStatus=${clubStatus}`)">去升级</text>
+										</view>
+										<text v-else>¥<text class="price-larger">{{item.price ?item.price :'0.00'}}</text></text>
+									</view>
 								</view>
-								<view class="price-larger" v-if="item.price1TextFlag == '2'">
-									<text class="txt">价格仅会员可见</text>
-									<text class="btn" @click.stop="this.$api.navigateTo(`/pages/login/apply?clubStatus=${clubStatus}`)">去升级</text>
+								<view v-if="userIdentity == 2">
+									<view class="price-larger" v-if="item.priceflag == '1'">
+										<text class="txt">未公开价格</text>
+									</view>
+									<text v-else-if="priceLoading" class="price-larger small">正在获取价格...</text>
+									<text v-else>¥<text class="price-larger">{{item.price ? item.price :'0.00'}}</text></text>
 								</view>
-								<text v-if="item.price1TextFlag == '0'">¥<text class="price-larger">{{item.retailPrice?item.retailPrice.toFixed(2):'0.00'}}</text></text>
+							</view>	
+							<view  v-else class="list-login-now">
+								<text class="p-no">价格:</text>
+								<uni-stars :stars="parseInt(item.pricegrade)" :font-size='36' :width-info="180"></uni-stars>
 							</view>
 						</view>
 					</view>
 				</view>
-				<view v-if="showLoading && commodityList.length > 4">
+				<view v-if="showLoading && listData.length > 4">
 					<view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
 					<view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
 				</view>
@@ -71,7 +86,12 @@
 	import modalLayer from "@/components/modal-layer"
 	import uniStars from '@/components/uni-stars/uni-stars.vue'
 	import authorize from '@/common/config/authorize.js'
-	import { querySearchProduct , querySearchHistory,clearSearchHistory } from "@/api/product.js" 
+	import { 
+		queryNewSearchProduct , 
+		querySearchHistory,
+		clearSearchHistory,
+		querySearchProductPrice
+	} from "@/api/product.js" 
 	
 	export default {
 		components: {
@@ -82,17 +102,20 @@
 		data() {
 			return {
 				userID:'',
+				userIdentity:'',
 				themeClass: 'block',
-				searchInputVal:'',							//搜索关键词
-				isShowClose:false,							//是否显示清空输入框图标
-				isSearchHistory:false,						//是都显示搜索历史
-				serachRecordList:[],						//历史搜索记录
+				searchInputVal:'',	//搜索关键词
+				isShowClose:false,	//是否显示清空输入框图标
+				isSearchHistory:false,//是都显示搜索历史
+				serachRecordList:[],//历史搜索记录
 				isShowWrapper:false,
 				isModallayer:false,
+				priceLoading:true,
 				windowHeight: '',
 				showEmpty: false,
 				scrollHeight: '',
-				commodityList: [],
+				listData: [],
+				productIds:'',//查询价格的商品ID
 				showLoading: false,
 				loadingNow: true,
 				loadingText: '上拉加载更多',
@@ -113,6 +136,7 @@
 			initGetSerachRecord(){
 				this.$api.getStorage().then((resolve) =>{
 					this.userID = resolve.userID ? resolve.userID : '';
+					this.userIdentity = resolve.userIdentity ? resolve.userIdentity : '';
 				    querySearchHistory({userId:this.userID}).then(response =>{
 						if(response.code == 0){
 							this.serachRecordList = response.data
@@ -124,12 +148,12 @@
 				if (this.searchInputVal == '') {
 					this.$util.msg('请输入商品关键词',2000);
 				}else{
-					this.commodityList =[]
+					this.listData =[]
 					this.getListFromServer(false)
 				}
 			},
 			scrolltolower() {
-				if(this.hasNextPage && this.pullFlag) {
+				if(this.totalPage>this.pageNum && this.pullFlag) {
 					this.getListFromServer(true);
 				}
 			},
@@ -141,19 +165,21 @@
 				if(loadMore) {
 					this.pageNum += 1;
 				}
-				let params = {userId:this.userID,searchWord:this.searchInputVal,pageNum:this.pageNum,pageSize:this.pageSize}
-				querySearchProduct(params).then(response =>{
+				let params = {keyword:this.searchInputVal,pageNum:this.pageNum,pageSize:this.pageSize,sortField:'',sortType:''}
+				queryNewSearchProduct(params).then(response =>{
+					console.log(JSON.parse(response.data))
 					this.isShowWrapper = true
-					const resData = response.data;
-					const resList = resData.results;
+					const resData = JSON.parse(response.data);
+					const resList = resData.items;
 					if(resList && resList.length > 0){
-						this.hasNextPage = resData.hasNextPage;
-						this.totalPage = resData.totalPage;
+						this.totalPage = resData.total;
 						this.showEmpty = false;
 						if(loadMore) {
-							this.commodityList = [...this.commodityList,...resList];
+							this.listData = [...this.listData,...resList];
+							this.setProductPrice()
 						} else {
-							this.commodityList = [...resList];
+							this.listData = [...resList];
+							this.setProductPrice()
 						}
 						// 防上拉暴滑
 						this.pullFlag = false;
@@ -161,7 +187,7 @@
 							this.pullFlag = true;
 						},500)
 						// 底部提示文案
-						if(this.hasNextPage) {
+						if(this.totalPage>this.pageNum) {
 							this.loadingText = '上拉加载更多';
 						} else {
 							this.showLoading = true;
@@ -176,6 +202,33 @@
 					this.$util.msg(error.msg,2000);
 				})
 			},
+			setProductPrice(){//获取价格
+				if (!this.userID) {return false;}
+				let productIdArr = [];
+				this.listData.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
+					if (item.priceflag != 1){
+						productIdArr.push(item.pid)
+					}
+				})
+				this.productIds = productIdArr.join(",");
+				querySearchProductPrice({userId: this.userID,productIds:this.productIds}).then(response =>{
+					if (response.data) {
+						let ids = Object.keys(response.data.prices);
+						this.listData.map(item=>{
+							for (let i = 0; i < ids.length; i++) {
+								let id = ids[i];
+								let price = response.data.prices[id];
+								if (item.priceflag != 1 && item.pid == id){
+									item.price = Number(price).toFixed(2);
+								}
+							}
+						});
+					}
+					this.priceLoading = false;
+				}).catch(error =>{
+					this.$util.msg(error.msg,2000)
+				})
+			},
 			onShowClose () {//输入框失去焦点时触发
 				this.inputEmpty(this.searchInputVal)
 			},
@@ -524,6 +577,9 @@
 			.price-larger {
 				width: 100%;
 				font-size: 32rpx;
+				&.small{
+					font-size: $font-size-24;
+				}
 				.txt{
 					font-size: $font-size-24;
 					display: inline-block;

+ 16 - 18
seller/pages/cart/immediately.vue

@@ -215,24 +215,22 @@
 				}
 			},
 			getzuheCart(){//组合商品加入购物车
-			let productInfo=[];
-			let setGoodsList ={};
-			let productID = '';
-			let productNum ='';
-			this.handleData.combinationProductList.forEach(item =>{
-				if(item.initProductNum >0){
-					setGoodsList.productId = item.productID
-					setGoodsList.productNum =item.initProductNum
-					productInfo.push(JSON.parse(JSON.stringify(setGoodsList)))
-				}
-			})
-			
-			let params ={
-					clubId:this.clubID,
-					serviceProviderId:this.serviceProviderId,
-					productInfo
-				}
-				console.log(params)
+				let productInfo=[];
+				let setGoodsList ={};
+				let productID = '';
+				let productNum ='';
+				this.handleData.combinationProductList.forEach(item =>{
+					if(item.initProductNum >0){
+						setGoodsList.productId = item.productID
+						setGoodsList.productNum =item.initProductNum
+						productInfo.push(JSON.parse(JSON.stringify(setGoodsList)))
+					}
+				})
+				let params ={
+						clubId:this.clubID,
+						serviceProviderId:this.serviceProviderId,
+						productInfo:productInfo
+					}
 				getCartAddCart({'params':JSON.stringify(params)}).then(response => {
 					this.specClasszuhe = 'hide';
 					this.$util.msg('加入购物车成功',1500,true,'success');

+ 0 - 1
seller/pages/search/search.vue

@@ -19,7 +19,6 @@
 				</view>
 			</view>
 		</view>
-		<!-- <go-search :theme="themeClass" @subMitSearch="subMitSearch"></go-search> -->
 		<view v-else class="commodity-list-wrapper"  :style="{'overflow':'auto','height':(commodityList.length>4? windowHeight + 'px' : 'auto')}">
 			<scroll-view :style="{'height':(commodityList.length>4? scrollHeight+'px' : 'auto')}" @scrolltolower="scrolltolower" scroll-y v-if="!showEmpty">
 				<view v-for="(item,index) in commodityList" :key="index" :id="item.id" class="all-type-list-content commodity-list" @click.stop="navToDetailPage(item.productID)">