浏览代码

commit -m

zhengjinyi 4 年之前
父节点
当前提交
4e8313bf12
共有 4 个文件被更改,包括 125 次插入109 次删除
  1. 118 94
      pages/goods/goods-classify.vue
  2. 2 2
      services/ajax.env.js
  3. 4 0
      services/common.service.js
  4. 1 13
      services/product.service.js

+ 118 - 94
pages/goods/goods-classify.vue

@@ -39,49 +39,61 @@
 				<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="container-list" :style="{'height':scrollHeight+'px'}" 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.mainImage"  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>
-						<view class="list-details-price">
-							<template v-if="userIdentity == 3">
-								<view class="floor-item-act" v-if="item.actStatus==1">
-									<view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
-										{{item.promotions.name}}<text v-if="item.price1TextFlag != '1' && item.supplierId === shopId">:¥{{ item.price | NumFormat }}</text>
+			<template v-else>
+				<view class="container-list" :style="{'height':scrollHeight+'px'}">
+					<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.mainImage"  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>
+							<view class="list-details-price">
+								<template v-if="userIdentity == 3">
+									<view class="floor-item-act" v-if="item.actStatus==1">
+										<view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
+											{{item.promotions.name}}<text v-if="item.price1TextFlag != '1' && item.supplierId === shopId">:¥{{ item.price | NumFormat }}</text>
+										</view>
+										<view class="floor-tags" v-else>{{item.promotions.name}}</view>	
 									</view>
-									<view class="floor-tags" v-else>{{item.promotions.name}}</view>	
-								</view>
-								<view class="floor-item-act" v-if="item.actStatus ==0  &&  item.ladderPriceFlag==1">
-									<view class="floor-tags">阶梯价格</view>	
-								</view>
-							</template>
-							<template v-else>
-								<view class="floor-item-act" v-if="item.actStatus==1">
-									<view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
-										{{item.promotions.name}}<text v-if="hasLogin && item.price1TextFlag != '1'">:¥{{ item.price | NumFormat }}</text>
+									<view class="floor-item-act" v-if="item.actStatus ==0  &&  item.ladderPriceFlag==1">
+										<view class="floor-tags">阶梯价格</view>	
 									</view>
-									<view class="floor-tags" v-else>{{item.promotions.name}}</view>	
-								</view>
-								<view class="floor-item-act" v-if="item.actStatus ==0  &&  item.ladderPriceFlag==1">
-									<view class="floor-tags">阶梯价格</view>	
-								</view>
-							</template>
-							<view v-if="hasLogin" class="list-price">
-								<view v-if="userIdentity == 1">
-									<text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
-									  ¥{{ (PromotionsFormat(item.promotions) ? item.price1 : item.retailPrice) | NumFormat }}
-									</text>
-								</view>	
-								<view v-if="userIdentity == 4">
-									<view class="price-larger" v-if="item.price1TextFlag == '1'">
-										<text class="txt">¥未公开价格</text>
+								</template>
+								<template v-else>
+									<view class="floor-item-act" v-if="item.actStatus==1">
+										<view class="floor-tags" v-if="PromotionsFormat(item.promotions)">
+											{{item.promotions.name}}<text v-if="hasLogin && item.price1TextFlag != '1'">:¥{{ item.price | NumFormat }}</text>
+										</view>
+										<view class="floor-tags" v-else>{{item.promotions.name}}</view>	
+									</view>
+									<view class="floor-item-act" v-if="item.actStatus ==0  &&  item.ladderPriceFlag==1">
+										<view class="floor-tags">阶梯价格</view>	
+									</view>
+								</template>
+								<view v-if="hasLogin" class="list-price">
+									<view v-if="userIdentity == 1">
+										<text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
+										  ¥{{ (PromotionsFormat(item.promotions) ? item.price1 : item.retailPrice) | NumFormat }}
+										</text>
+									</view>	
+									<view v-if="userIdentity == 4">
+										<view class="price-larger" v-if="item.price1TextFlag == '1'">
+											<text class="txt">¥未公开价格</text>
+										</view>
+										<view v-else>
+											<view class="price-larger" v-if="item.price1TextFlag == '2'">
+												<text class="txt">¥价格仅会员可见</text>
+											</view>
+											<template v-else>
+												<text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
+												  ¥{{ (PromotionsFormat(item.promotions) ? item.price1 : item.retailPrice) | NumFormat }}
+												</text>
+											</template>
+										</view>
 									</view>
-									<view v-else>
-										<view class="price-larger" v-if="item.price1TextFlag == '2'">
-											<text class="txt">¥价格仅会员可见</text>
+									<view v-if="userIdentity == 2">
+										<view class="price-larger" v-if="item.price1TextFlag == '1'">
+											<text class="txt">¥未公开价格</text>
 										</view>
 										<template v-else>
 											<text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
@@ -89,30 +101,20 @@
 											</text>
 										</template>
 									</view>
+								</view>	
+								<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>
 								</view>
-								<view v-if="userIdentity == 2">
-									<view class="price-larger" v-if="item.price1TextFlag == '1'">
-										<text class="txt">¥未公开价格</text>
-									</view>
-									<template v-else>
-										<text class="price-larger" :class="PromotionsFormat(item.promotions) ? 'none' : ''">
-										  ¥{{ (PromotionsFormat(item.promotions) ? item.price1 : item.retailPrice) | NumFormat }}
-										</text>
-									</template>
-								</view>
-							</view>	
-							<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>
 							</view>
 						</view>
 					</view>
 				</view>
-			</view>
-			<!--加载loadding-->
-			<tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
-			<tui-nomore :visible="!pullUpOn" bgcolor="#F7F7F7" :text='nomoreText'></tui-nomore>
-			<!--加载loadding-->
+				<!--加载loadding-->
+				<tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
+				<tui-nomore :visible="!pullUpOn" bgcolor="#F7F7F7" :text='nomoreText'></tui-nomore>
+				<!--加载loadding-->
+			</template>
 		</template>
 		<!--右抽屉-->
 		<tui-drawer mode="right" :visible="rightDrawer" @close="closeDrawer">
@@ -170,7 +172,7 @@
 				loadding: false,
 				pullUpOn: true,
 				pullFlag: true,
-				hasNextPage: false,
+				totalPage: 0,
 				nomoreText: '上拉显示更多',
 				rightDrawer: false,
 				setNavigationBarTitle:'',
@@ -192,69 +194,83 @@
 		methods:{
 			initOption(option) {
 				this.listQuery.id = option.id;
-				this.listQuery.idType = Number(option.classType);
+				this.listQuery.idType = this.classifyType = Number(option.classType);
 				this.setNavigationBarTitle = option.title
 				uni.setNavigationBarTitle({title:option.title});
 				this.$api.getComStorage('userInfo').then((resolve) =>{
-					this.userID = resolve.userID ? resolve.userID :0;
+					this.userID = resolve.userID ? resolve.userID : 0
 					this.userIdentity = resolve.userIdentity
 					this.isRequest = true
 					this.GetProductListInfo()
+					this.GetProductOneClassly()
 				}).catch(error =>{
 					this.GetProductListInfo()
+					this.GetProductOneClassly()
 				})
 				console.log(this.classifyID)
 			},
-			InfoSecondClassly(){//根据一级分类ID 查询二三级分类
-				
+			GetProductOneClassly(){//根据分类ID 查询二三级分类
+				this.CommonService.GetProductOneClassly({typeId:this.listQuery.id,idType:this.classifyType,source :'crm'}).then(response =>{
+					console.log(response.data)
+				}).catch(error =>{
+					this.$util.msg(error.msg,2000)
+				})
 			},
 			GetProductListInfo(){//查询分类商品列表
-				this.listQuery.pageNum = 1
 				this.ProductService.GetSearchProductTypeData(this.listQuery).then(response =>{
-					let data = response.data.productPage
-					this.hasNextPage = data.hasNextPage
-					if(data.results && data.results.length > 0){
-						this.isEmpty = false;
-						this.dataList = data.results;
-						if(this.hasNextPage){
+					const resData = JSON.parse(response.data);
+					const resList = resData.items;
+					if(resList && resList.length > 0){
+						this.showEmpty = false
+						this.totalPage = resData.total;
+						this.listData = [...resList];
+						this.GetProductPrice()
+						this.showSkeleton = false
+						// 防上拉暴滑
+						this.pullFlag = false;
+						setTimeout(()=>{ this.pullFlag = true; },500)
+						// 底部提示文案
+						if(this.totalPage>this.listData.length) {
 							this.pullUpOn = false
 							this.nomoreText = '上拉显示更多'
-						}else{
-							if(this.dataList.length < 5){
-								this.pullUpOn = true
-							}else{
-								this.pullUpOn = false
-								this.nomoreText = '已至底部'
-							}
+						} else {
+							this.pullUpOn = false
+							this.loadding = false
+							this.nomoreText = '已至底部'
 						}
-					}else{
-						this.dataList = []
-						this.isEmpty = true
-						this.pullUpOn = true
+					} else {
+						this.showEmpty = true;
 					}
 				}).catch(error =>{
 					this.$util.msg(error.msg,2000);
 				})
 			}, 
-			GetOnReachBottomData(index){//上拉加载
+			GetOnReachBottomData(){//上拉加载
 				this.listQuery.pageNum += 1
-				this.ProductService.GetProductListByTypeID(this.listQuery).then(response =>{
-					let data = response.data.productPage
-					this.hasNextPage = data.hasNextPage;
-					this.dataList = this.dataList.concat(data.results)
-					this.pullFlag = false;// 防上拉暴滑
-					setTimeout(()=>{this.pullFlag = true;},500)
-					if(this.hasNextPage){
+				this.ProductService.GetSearchProductTypeData(this.listQuery).then(response =>{
+					const resData = JSON.parse(response.data);
+					const resList = resData.items;
+					this.totalPage = resData.total;
+					this.listData = [...this.listData,...resList];
+					this.GetProductPrice()
+					this.showSkeleton = false
+					// 防上拉暴滑
+					this.pullFlag = false;
+					setTimeout(()=>{ this.pullFlag = true; },500)
+					// 底部提示文案
+					if(this.totalPage>this.listData.length) {
 						this.pullUpOn = false
 						this.nomoreText = '上拉显示更多'
-					}else{
-						this.loadding = false
+					} else {
 						this.pullUpOn = false
+						this.loadding = false
 						this.nomoreText = '已至底部'
 					}
-				})	
+				}).catch(error =>{
+					this.$util.msg(error.msg,2000);
+				})
 			},	
-			getProductPrice(){//获取价格
+			GetProductPrice(){//获取价格
 				let productIdArr = [];
 				this.listData.map(item=>{// 0公开价格 1不公开价格 2仅对会员机构公开
 					productIdArr.push(item.productID)
@@ -373,9 +389,17 @@
 		onPullDownRefresh() {
 			setTimeout(() => {
 				this.listQuery.pageNum = 1
+				this.GetProductListInfo()
 				uni.stopPullDownRefresh()
 			}, 200)
 		},
+		onReachBottom() {
+			if(this.totalPage>this.listData.length) {
+				this.loadding = true
+				this.pullUpOn = true
+				this.GetOnReachBottomData()
+			}	
+		},
 		onShow() {
 			
 		}

+ 2 - 2
services/ajax.env.js

@@ -1,8 +1,8 @@
 let URL_CONFIG = ""
 if(process.env.NODE_ENV === 'development'){
     // 开发环境
-	// URL_CONFIG = 'http://192.168.2.68:8008'	 //涛涛联调地址
-	URL_CONFIG = 'http://192.168.2.67:8008'	 //裴裴联调地址
+	URL_CONFIG = 'http://192.168.2.68:8008'	 //涛涛联调地址
+	// URL_CONFIG = 'http://192.168.2.67:8008'	 //裴裴联调地址
 	// URL_CONFIG = 'http://192.168.2.75:8008'	 //超超联调地址
     // URL_CONFIG = 'https://spi-b.caimei365.com'	 //采美测试地址
 	// URL_CONFIG = 'https://spi.caimei365.com'

+ 4 - 0
services/common.service.js

@@ -62,5 +62,9 @@ export default class CommonService {
 	GetProductChildrenClassly (data = {}) {
 		return this.AjaxService.get({ url:'/product/bigType/classify', data, isLoading: false })
 	}
+	/* 根据一、二、三级分类ID查询单条分类 */
+	GetProductOneClassly (data = {}) {
+		return this.AjaxService.get({ url:'/product/typeId/classify', data, isLoading: false })
+	}
 	
 }

+ 1 - 13
services/product.service.js

@@ -142,19 +142,7 @@ export default class ProductService {
 	GetProductSearchList (data = {}) {
 		return this.AjaxService.get({ url:'/search/query/product', data, isLoading: true })
 	}
-	/* 搜索一级分类商品列表 */
-	GetSearchProductBigType (data = {}) {
-		return this.AjaxService.get({ url:'/search/query/product/bigType', data, isLoading: true })
-	}
-	/* 搜索二级分类商品列表 */
-	GetSearchProductSmallType (data = {}) {
-		return this.AjaxService.get({ url:'/search/query/product/smallType', data, isLoading: true })
-	}
-	/* 搜索三级分类商品列表 */
-	GetSearchProductTinyType (data = {}) {
-		return this.AjaxService.get({ url:'/search/query/product/tinyType', data, isLoading: true })
-	}
-	/* 搜索三级分类商品列表 */
+	/* 搜索分类商品列表 */
 	GetSearchProductTypeData (data = {}) {
 		return this.AjaxService.get({ url:'/search/query/product/type', data, isLoading: true })
 	}