فهرست منبع

我的库存接口

wangxiaoying 4 سال پیش
والد
کامیت
3e07eaf1e0
2فایلهای تغییر یافته به همراه296 افزوده شده و 78 حذف شده
  1. 199 43
      pages/home/my-stock/my-stock.vue
  2. 97 35
      pages/me/agent-stock/agent-stock.vue

+ 199 - 43
pages/home/my-stock/my-stock.vue

@@ -1,95 +1,251 @@
 <template>
-	<view >
+	<view class="page">
 		<!-- 我的库存 -->
 		<view class="content-top">
 			<u-navbar :background="background" back-icon-color="#ffffff" is-fixed>
-				<u-search placeholder="请输入轮胎规格" :show-action="false" v-model="keyword" style="margin-right: 26rpx;" @change="handleSearch"></u-search>
+				<u-search placeholder="请输入轮胎规格" v-model="keyword" style="margin-right: 26rpx;" @custom="handleSearch"></u-search>
 			</u-navbar>
-			<u-tabs ref="tabs" :list="list" bg-color="#0094FE" active-color="#ffffff" inactive-color="#ffffff" font-size="30" :current="current" @change="handleFilterBrand"></u-tabs>
+			<u-tabs ref="tabs" name="brandName" :list="brandlLst" bg-color="#0094FE" active-color="#ffffff" inactive-color="#ffffff"
+			 font-size="30" :current="current" @change="handleFilterBrand"></u-tabs>
 		</view>
-		<view class="content-center">
-			<view class="list-row u-flex list-title">
-				<view class="list-left">轮胎规格</view>
-				<view class="list-right">库存</view>
+		<scroll-view scroll-y @scrolltolower="scrollBottom" class="scroll-view-container">
+			<view class="content-center">
+				<view class="list-row u-flex list-title">
+					<view class="list-left">轮胎规格</view>
+					<view class="list-right">库存</view>
+				</view>
+				<template v-if="datalist&&datalist.length">
+					<view class="list-row u-flex" v-for="item in datalist" :key="item.matDescribe">
+						<view class="list-left">{{item.matDescribe}}</view>
+						<view class="list-right">{{item.stock}}</view>
+					</view>
+				</template>
+				<u-empty v-else text="暂无数据" mode="list"></u-empty>
 			</view>
-			<view class="list-row u-flex">
-				<view class="list-left">赛轮 12R22.5 152/149K 18PR S838</view>
-				<view class="list-right">160</view>
-			</view>
-			<view class="list-row u-flex">
-				<view class="list-left">赛轮 12R22.5 152/149K 18PR S838</view>
-				<view class="list-right">160</view>
-			</view>
-		</view>
+			<u-loadmore v-if="datalist&&datalist.length" :status="loadStatus" bgColor="#f2f2f2" :load-text="loadText"></u-loadmore>
+		</scroll-view>
 	</view>
 </template>
 
 <script>
+	import {
+		request
+	} from '@/common/request/request';
+	require("promise.prototype.finally").shim();
 	export default {
 		data() {
 			return {
 				background: {
 					backgroundColor: "#0291FD",
 				},
-				keyword: "",
 				current: 0,
-				list: [{
-					name: "全部"
-				},{
-					name: "黑骑士"
-				},{
-					name: "路极"
-				},{
-					name: "黑盾"
-				},{
-					name: "赛轮"
-				}]
+				// 筛选条件
+				keyword: "", //搜索规格
+				currentBrand: "", //选中的品牌
+				brandlLst: [{
+					brandName: "全部"
+				}],
+				// 分页信息
+				first: 0,
+				pageSize: 20, //每页条数
+				currentPage: 1, //当前页码
+				totalPage: 0, //总页码数
+				loadStatus: "loadmore",
+				loadText: {
+					loadmore: '轻轻上拉',
+					loading: '努力加载中',
+					nomore: '实在没有了'
+				},
+				// 数据信息
+				datalist: []
 			}
 		},
+		onLoad() {
+			uni.showLoading({
+				title: "加载中"
+			});
+			this.handleGetFilterData();
+			this.handleGetData();
+		},
 		methods: {
-			handleSearch: function(v){
+			scrollBottom(v) {
+				console.log(v);
+				if (this.loadStatus == "loadmore") {
+					this.loadStatus = 'loading';
+					uni.showLoading({
+						title: "加载中"
+					});
+					// 模拟数据加载
+					this.first += 1;
+					this.currentPage += 1;
+					this.handleGetData();
+					this.loadStatus = 'loadmore';
+				}
+
+			},
+
+			handleSearch: function(v) {
 				console.log(v)
+				this.handleGetData();
 			},
-			handleFilterBrand: function(v2){
-				this.current = v2
+			handleFilterBrand: function(v2) {
+				this.current = v2;
+				this.currentBrand = this.brandlLst[this.current].brandName;
+				this.handleGetData();
 				console.log(arguments);
-				console.log(v2)
-			}
+				console.log(this.brandlLst[this.current].brandName)
+			},
+			handleGetFilterData: function() {
+				var _this = this;
+				request({
+					url: '/baseReq/getBrandListByStoreId',
+					method: 'Post',
+					data: {
+						storeId: 1000,
+						userId: "1"
+					}
+				}).then(res => {
+					if (res.data.code == 0) {
+						console.log(res)
+						// 获取品牌列表
+						_this.brandlLst = res.data.data;
+						_this.brandlLst.unshift({
+							brandName: "全部",
+							brandCode: "all"
+						});
+					} else {
+						console.log(res)
+						uni.showToast({
+							title: res.data.msg,
+							icon: "none",
+							duration: _this.$store.state.showToastDuration
+						});
+					}
+				}).catch(err => {
+					console.log(err)
+					uni.showToast({
+						title: _this.$store.state.showServerErrorMsg,
+						icon: "none",
+						duration: _this.$store.state.showToastDuration
+					});
+					this.currentPage -= 1;
+				}).finally(() => {
+					setTimeout(() => {
+						uni.hideLoading();
+						this.loading = false;
+					}, 1000)
+				});
+			},
+			// 获取数据
+			handleGetData() {
+				uni.showLoading({
+					title: "加载中"
+				});
+				var _this = this;
+				request({
+					url: '/homepage/storeGetStock',
+					method: 'post',
+					data: {
+						storeId: "990289",
+						userId: "1",
+						current: _this.currentPage,
+						pageSize: _this.pageSize,
+						brandCode: _this.currentBrand,
+						specKey: _this.keyword
+					}
+				}).then(res => {
+					if (res.data.code == 0) {
+						console.log(res)
+						// 获取数据列表
+						if (_this.first == 0) {
+							_this.datalist = res.data.data;
+							_this.total = parseInt(res.data.data.count);
+							_this.totalPage = Math.ceil(_this.total / _this.pageSize);
+							console.log(_this.totalPage)
+						} else {
+							console.log(_this.currentPage);
+							console.log(_this.totalPage)
+							_this.datalist = _this.datalist.concat(res.data.data);
+							console.log(_this.datalist.length)
+						};
+						// 分页
+						if (_this.currentPage < _this.totalPage) {
+							_this.loadStatus = "loadmore"
+						} else {
+							console.log("nomore")
+							_this.loadStatus = "nomore"
+						}
+					} else {
+						console.log(res)
+						uni.showToast({
+							title: res.data.msg,
+							icon: "none",
+							duration: _this.$store.state.showToastDuration
+						});
+					}
+				}).catch(err => {
+					console.log(err)
+					uni.showToast({
+						title: _this.$store.state.showServerErrorMsg,
+						icon: "none",
+						duration: _this.$store.state.showToastDuration
+					});
+					this.currentPage -= 1;
+				}).finally(() => {
+					setTimeout(() => {
+						uni.hideLoading();
+						this.loading = false;
+					}, 1000)
+				});
+			},
 		}
 	}
 </script>
 
 <style lang="scss" scoped>
-	.content-top{
+	.page{
+		width: 100%;
+		height: 100%;
+	}
+	.content-top {
 		background-color: #0094FE;
 		padding-bottom: 119rpx;
 	}
-	.content-center{
+
+	.scroll-view-container {
+		margin-top: -106rpx;
+		height: calc(100% - 206rpx);
+	}
+
+	.content-center {
 		width: 712rpx;
-		margin: -106rpx auto 0 auto;
+		margin: 0 auto 0 auto;
 		border-radius: 20rpx;
 		background-color: #FFFFFF;
-		height: 335rpx;
+	
 		padding: 26rpx;
-		.list-row{
+
+		.list-row {
 			justify-content: space-between;
 			border-bottom: 1px solid #E8E8E8;
 			padding: 32rpx 0;
-			.list-right{
+
+			.list-right {
 				color: #149EE2;
 				text-decoration: underline;
 			}
 		}
-		.list-row.list-title{
+
+		.list-row.list-title {
 			padding-top: 0;
 			font-weight: 600;
-			.list-right{
+
+			.list-right {
 				color: #4D4D4D;
 				font-weight: 400;
 				text-decoration: none;
 			}
 		}
-		
+
 	}
-	
 </style>

+ 97 - 35
pages/me/agent-stock/agent-stock.vue

@@ -15,11 +15,11 @@
 				<u-search :show-action="true" v-model="currentSpec" :animation="true" @custom="searchSpec" @search="searchSpec"
 				 :style="inputCustomStyle" @focus="inputFocus" @blur="inputBlur" placeholder="请输入规格"></u-search>
 			</view>
-			
+
 		</view>
 		<view class="content-one">
 			<template v-if="datalist&&datalist.length">
-				<view class="content-two" v-for="(item,index) in datalist" :key="index">
+				<view class="content-two" v-for="(item,index) in datalist" :key="index" v-cloak>
 					<view>
 						{{ item.brand }}
 					</view>
@@ -31,9 +31,9 @@
 					</view>
 				</view>
 			</template>
-			<view class="nodata" v-else>暂无数据</view>
+			<u-empty v-else text="暂无数据" mode="list"></u-empty>
 		</view>
-		<u-loadmore v-if="datalist&&datalist.length" :status="loadStatus" bgColor="#f2f2f2"></u-loadmore>
+		<u-loadmore v-if="datalist&&datalist.length" :status="loadStatus" bgColor="#f2f2f2" :load-text="loadText"></u-loadmore>
 	</scroll-view>
 </template>
 
@@ -68,25 +68,40 @@
 				// showDate: false,
 				// mode: 'date',
 				// 分页信息
-				pageSize: 10, //每页条数
+				first: 0,
+				pageSize: 20, //每页条数
 				currentPage: 1, //当前页码
 				totalPage: 0, //总页码数
-				loadStatus: "loadmore"
+				loadStatus: "loadmore",
+				loadText: {
+					loadmore: '轻轻上拉',
+					loading: '努力加载中',
+					nomore: '实在没有了'
+				}
 			};
 		},
 		onLoad() {
+			uni.showLoading({
+				title: "加载中"
+			});
+			this.handleGetFilterData();
 			this.handleGetData();
 		},
 		methods: {
 			scrollBottom(v) {
 				console.log(v);
-				this.loadStatus = 'loading';
-				// 模拟数据加载
-				setTimeout(() => {
+				if (this.loadStatus == "loadmore") {
+					this.loadStatus = 'loading';
+					uni.showLoading({
+						title: "加载中"
+					});
+					// 模拟数据加载
+					this.first += 1;
 					this.currentPage += 1;
 					this.handleGetData();
 					this.loadStatus = 'loadmore';
-				}, 1000)
+				}
+
 			},
 			changeTab(index) {
 				this.currentTab = index;
@@ -102,29 +117,22 @@
 					this.showpattern = true
 				}
 			},
-			// 获取数据
-			handleGetData() {
-				uni.showLoading({
-					title: "加载中"
-				});
+			// 获取筛选条件
+			handleGetFilterData: function() {
+				
 				var _this = this;
 				request({
-					url: '/app/appAgent/getStoreAgentStock',
-					method: 'post',
+					url: '/app/appAgent/getStoreAgentCondition',
+					method: 'get',
 					data: {
-						storeId: "990289",
-						pageSize: _this.pageSize,
-						page: _this.currentPage,
-						brand: _this.currenBrand,
-						spec: _this.currentSpec,
-						pattern: _this.currentPattern
+
 					}
 				}).then(res => {
 					if (res.data.code == 0) {
 						console.log(res)
 						// 获取品牌列表
 						_this.brandList = [];
-						res.data.data.brandList.forEach(function(val, index) {
+						res.data.data.brands.forEach(function(val, index) {
 							_this.brandList.push({
 								value: index,
 								label: val
@@ -132,20 +140,72 @@
 						});
 						// 获取花纹列表
 						_this.patternList = [];
-						res.data.data.patternList.forEach(function(val, index) {
+						res.data.data.patterns.forEach(function(val, index) {
 							_this.patternList.push({
 								value: index,
 								label: val
 							});
 						});
+					} else {
+						console.log(res)
+						uni.showToast({
+							title: res.data.msg,
+							icon: "none",
+							duration: _this.$store.state.showToastDuration
+						});
+					}
+				}).catch(err => {
+					console.log(err)
+					uni.showToast({
+						title: _this.$store.state.showServerErrorMsg,
+						icon: "none",
+						duration: _this.$store.state.showToastDuration
+					});
+					this.currentPage -= 1;
+				}).finally(() => {
+					setTimeout(() => {
+						uni.hideLoading();
+						this.loading = false;
+					}, 1000)
+				});
+			},
+			// 获取数据
+			handleGetData() {
+				uni.showLoading({
+					title: "加载中"
+				});
+				var _this = this;
+				request({
+					url: '/app/appAgent/getStoreAgentStock',
+					method: 'post',
+					data: {
+						storeId: "990289",
+						pagesize: _this.pageSize,
+						page: _this.currentPage,
+						brand: _this.currenBrand,
+						spec: _this.currentSpec,
+						pattern: _this.currentPattern
+					}
+				}).then(res => {
+					if (res.data.code == 0) {
+						console.log(res)
 						// 获取数据列表
-						_this.datalist = res.data.data.list;
-						_this.total = res.data.data.stock;
-						_this.totalPage = res.data.data.totalPage;
+						if (_this.first == 0) {
+							_this.datalist = res.data.data.stockInfo;
+							_this.total = parseInt(res.data.data.count);
+							_this.totalPage = Math.ceil(_this.total / _this.pageSize);
+							console.log(_this.totalPage)
+						} else {
+							console.log(_this.currentPage);
+							console.log(_this.totalPage)
+							_this.datalist = _this.datalist.concat(res.data.data.stockInfo);
+							console.log(_this.datalist.length)
+						};
 						// 分页
-						if(_this.currentPage<_this.totalPage){
-							_this.loadStatus = "loadMore"
-						}else{
+						if (_this.currentPage < _this.totalPage) {
+							_this.loadStatus = "loadmore"
+						} else {
+							console.log("nomore")
 							_this.loadStatus = "nomore"
 						}
 					} else {
@@ -184,12 +244,12 @@
 				this.handleGetData();
 			},
 			searchSpec: function() {
-				if(this.currentSpec){
+				if (this.currentSpec) {
 					this.currentPage = 1;
 					this.handleGetData();
 				}
 				console.log(this.currentSpec)
-				
+
 			},
 			inputFocus() {
 				console.log(111);
@@ -223,9 +283,10 @@
 </script>
 
 <style lang="scss" scoped>
-	.scroll-view-container{
+	.scroll-view-container {
 		height: 100%;
 	}
+
 	.header {
 		height: 400rpx;
 		width: 100%;
@@ -302,7 +363,8 @@
 	.wrap-flex {
 		display: flex;
 	}
-	.nodata{
+
+	.nodata {
 		padding: 48rpx;
 	}
 </style>