zs 1 سال پیش
والد
کامیت
0b7e19bac6
3فایلهای تغییر یافته به همراه474 افزوده شده و 287 حذف شده
  1. 5 4
      pages/home/index.vue
  2. 369 275
      pagesGoods/sort/index.vue
  3. 100 8
      pagesMy/order/index.vue

+ 5 - 4
pages/home/index.vue

@@ -55,12 +55,9 @@
 	export default {
 		data() {
 			return {
-				focus: false, //控制是否显示带取消按钮的搜索框
 				config: {},
 				user: {},
-				searchInfo: {},
 				moduleList: [],
-				goodsList: [],
 				list: [],
 				total: 0,
 				skip: 0,
@@ -69,6 +66,10 @@
 				// 数据是否触底
 				is_bottom: false,
 				scrollTop: 0,
+				// 搜索
+				searchInfo: {},
+				focus: false, //控制是否显示带取消按钮的搜索框
+				goodsList: [],
 			}
 		},
 		async onLoad() {
@@ -144,7 +145,7 @@
 			// 输入框
 			toInput(e) {
 				const that = this;
-				if (e.name) that.$set(that.searchInfo, `name`, e.name)
+				if (e._id) that.$set(that.searchInfo, `_id`, e._id)
 				else that.$set(that, `searchInfo`, {})
 				that.clearPage();
 				that.search();

+ 369 - 275
pagesGoods/sort/index.vue

@@ -1,275 +1,369 @@
-<template>
-	<view class="content">
-		<view class="one">
-			<input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索商品">
-		</view>
-		<view class="two">
-			<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
-				<view class="list-scroll-view">
-					<view class="two_1">
-						<view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
-							<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
-								mode="aspectFill">
-							</image>
-							<view class="name textOver">{{item.name||'暂无'}}</view>
-							<view class="other">
-								<view class="left">¥{{item.money||'暂无'}}</view>
-								<view class="right">销量:{{item.sell_num||'0'}}</view>
-							</view>
-						</view>
-						<view class="is_bottom" v-if="is_bottom">
-							<text>{{config.bottom_title}}</text>
-						</view>
-					</view>
-				</view>
-			</scroll-view>
-		</view>
-	</view>
-</template>
-
-<script>
-	export default {
-		data() {
-			return {
-				// 系统设置
-				config: {},
-				user: {},
-				type: '',
-				searchInfo: {},
-				list: [],
-				total: 0,
-				skip: 0,
-				limit: 6,
-				page: 0,
-				// 数据是否触底
-				is_bottom: false,
-				scrollTop: 0,
-			}
-		},
-		onLoad: function(e) {
-			const that = this;
-			that.$set(that, `type`, e.type || '');
-			that.searchToken();
-			that.searchConfig();
-		},
-		onPullDownRefresh: async function() {
-			const that = this;
-			that.clearPage();
-			await that.search();
-			uni.stopPullDownRefresh();
-		},
-		methods: {
-			searchConfig() {
-				const that = this;
-				try {
-					const res = uni.getStorageSync('config');
-					if (res) that.$set(that, `config`, res);
-				} catch (e) {
-					uni.showToast({
-						title: err.errmsg,
-						icon: 'error',
-						duration: 2000
-					});
-				}
-			},
-			searchToken() {
-				const that = this;
-				try {
-					const res = uni.getStorageSync('token');
-					if (res) {
-						that.$set(that, `user`, res);
-						that.clearPage();
-						that.search();
-					}
-				} catch (e) {
-					uni.showToast({
-						title: err.errmsg,
-						icon: 'error',
-						duration: 2000
-					});
-				}
-			},
-			async search() {
-				const that = this;
-				let user = that.user;
-				let info = {
-					skip: that.skip,
-					limit: that.limit,
-					type: that.type,
-					is_use: '0'
-				};
-				let res;
-				res = await that.$api(`/Good`, 'GET', {
-					...info,
-					...that.searchInfo
-				});
-				if (res.errcode == '0') {
-					let list = [...that.list, ...res.data];
-					for (let val of list) {
-						const specs = await that.$api(`/Specs`, 'GET', {
-							goods: val._id
-						});
-						if (specs.errcode == 0) {
-							const arr = specs.data.sort((a, b) => {
-								return a.money - b.money
-							})
-							val.money = arr[0].money
-						}
-					}
-					that.$set(that, `list`, list);
-					that.$set(that, `total`, res.total)
-				} else {
-					uni.showToast({
-						title: res.errmsg,
-						icon: 'none'
-					})
-				}
-			},
-			// 购买
-			toBuy(e) {
-				const that = this;
-				uni.navigateTo({
-					url: `/pagesGoods/index/index?id=${e.id||e._id}`
-				})
-			},
-			// 分页
-			toPage(e) {
-				const that = this;
-				let list = that.list;
-				let limit = that.limit;
-				if (that.total > list.length) {
-					uni.showLoading({
-						title: '加载中',
-						mask: true
-					})
-					let page = that.page + 1;
-					that.$set(that, `page`, page)
-					let skip = page * limit;
-					that.$set(that, `skip`, skip)
-					that.search();
-					uni.hideLoading();
-				} else that.$set(that, `is_bottom`, true)
-			},
-			// 触底
-			toScroll(e) {
-				const that = this;
-				let up = that.scrollTop;
-				that.$set(that, `scrollTop`, e.detail.scrollTop);
-				let num = Math.sign(up - e.detail.scrollTop);
-				if (num == 1) that.$set(that, `is_bottom`, false);
-			},
-			// 输入框
-			toInput(e) {
-				const that = this;
-				if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
-				else that.$set(that, `searchInfo`, {})
-				that.clearPage();
-				that.search();
-			},
-			// 清空列表
-			clearPage() {
-				const that = this;
-				that.$set(that, `list`, [])
-				that.$set(that, `skip`, 0)
-				that.$set(that, `limit`, 6)
-				that.$set(that, `page`, 0)
-			}
-		}
-	}
-</script>
-
-<style lang="scss">
-	.content {
-		display: flex;
-		flex-direction: column;
-		width: 100vw;
-		height: 100vh;
-
-		.one {
-			padding: 2vw;
-
-			input {
-				padding: 2vw;
-				background-color: var(--f1Color);
-				font-size: var(--font14Size);
-				border-radius: 5px;
-			}
-		}
-
-		.two {
-			position: relative;
-			flex-grow: 1;
-			background-color: var(--f9Color);
-
-			.two_1 {
-				display: flex;
-				justify-content: space-between;
-				flex-wrap: wrap;
-				padding: 2vw;
-
-				.list {
-					display: flex;
-					flex-direction: column;
-					justify-content: inherit;
-					width: 43vw;
-					padding: 2vw;
-					margin: 0 0 2vw 0;
-					border-radius: 10px;
-					background-color: var(--mainColor);
-
-					.image {
-						width: 100%;
-						height: 40vw;
-						border-top-right-radius: 10px;
-						border-top-left-radius: 10px;
-					}
-
-					.name {
-						font-size: var(--font14Size);
-					}
-
-					.other {
-						padding: 1vw 0 0 0;
-						display: flex;
-						justify-content: space-between;
-
-						.left {
-							font-size: var(--font14Size);
-							color: var(--fF0Color);
-						}
-
-						.right {
-							font-size: var(--font12Size);
-							color: var(--f85Color);
-						}
-					}
-				}
-			}
-		}
-	}
-
-	.scroll-view {
-		position: absolute;
-		top: 0;
-		left: 0;
-		right: 0;
-		bottom: 0;
-
-		.list-scroll-view {
-			display: flex;
-			flex-direction: column;
-		}
-	}
-
-	.is_bottom {
-		width: 100%;
-		text-align: center;
-
-		text {
-			padding: 2vw 0;
-			display: inline-block;
-			color: var(--f85Color);
-			font-size: var(--font14Size);
-		}
-	}
-</style>
+<template>
+	<view class="content">
+		<view class="one">
+			<view class="one_1" v-if="!focus">
+				<input type='text' v-model="searchInfo.name" @input="focusHandler" placeholder='搜索商品'></input>
+			</view>
+			<view class="one_2" v-if="focus">
+				<view class="left">
+					<input type="text" v-model="searchInfo.name" @input="focusHandler" placeholder="搜索商品">
+				</view>
+				<view class="right">
+					<button size="mini" class="button" type="default" @click="cancelHandler">取消</button>
+				</view>
+			</view>
+			<!-- 搜索结果显示框 -->
+			<scroll-view v-if="focus" class="one_3" scroll-y="true">
+				<view class="list" v-for="(item, index) in goodsList" :index="index" :key="index"
+					@click="toInput(item)">
+					<text class="name"> {{item.name}}</text>
+				</view>
+			</scroll-view>
+		</view>
+		<view class="two">
+			<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
+				<view class="list-scroll-view">
+					<view class="two_1">
+						<view class="list" v-for="(item,index) in list" :key="index" @tap="toBuy(item)">
+							<image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
+								mode="aspectFill">
+							</image>
+							<view class="name textOver">{{item.name||'暂无'}}</view>
+							<view class="other">
+								<view class="left">¥{{item.money||'暂无'}}</view>
+								<view class="right">销量:{{item.sell_num||'0'}}</view>
+							</view>
+						</view>
+						<view class="is_bottom" v-if="is_bottom">
+							<text>{{config.bottom_title}}</text>
+						</view>
+					</view>
+				</view>
+			</scroll-view>
+		</view>
+	</view>
+</template>
+
+<script>
+	export default {
+		data() {
+			return {
+				// 系统设置
+				config: {},
+				user: {},
+				type: '',
+				list: [],
+				total: 0,
+				skip: 0,
+				limit: 6,
+				page: 0,
+				// 数据是否触底
+				is_bottom: false,
+				scrollTop: 0,
+				// 搜索
+				focus: false, //控制是否显示带取消按钮的搜索框
+				searchInfo: {},
+				goodsList: [],
+			}
+		},
+		onLoad: function(e) {
+			const that = this;
+			that.$set(that, `type`, e.type || '');
+			that.searchToken();
+			that.searchConfig();
+		},
+		async onShow() {
+			const that = this;
+			that.$set(that, `searchInfo`, {})
+			that.clearPage();
+			await that.search();
+		},
+		onPullDownRefresh: async function() {
+			const that = this;
+			that.clearPage();
+			await that.search();
+			uni.stopPullDownRefresh();
+		},
+		methods: {
+			searchConfig() {
+				const that = this;
+				try {
+					const res = uni.getStorageSync('config');
+					if (res) that.$set(that, `config`, res);
+				} catch (e) {
+					uni.showToast({
+						title: err.errmsg,
+						icon: 'error',
+						duration: 2000
+					});
+				}
+			},
+			searchToken() {
+				const that = this;
+				try {
+					const res = uni.getStorageSync('token');
+					if (res) {
+						that.$set(that, `user`, res);
+						that.clearPage();
+						that.search();
+					}
+				} catch (e) {
+					uni.showToast({
+						title: err.errmsg,
+						icon: 'error',
+						duration: 2000
+					});
+				}
+			},
+			async search() {
+				const that = this;
+				let user = that.user;
+				let info = {
+					skip: that.skip,
+					limit: that.limit,
+					type: that.type,
+					is_use: '0'
+				};
+				let res;
+				res = await that.$api(`/Good`, 'GET', {
+					...info,
+					...that.searchInfo
+				});
+				if (res.errcode == '0') {
+					let list = [...that.list, ...res.data];
+					for (let val of list) {
+						const specs = await that.$api(`/Specs`, 'GET', {
+							goods: val._id
+						});
+						if (specs.errcode == 0) {
+							const arr = specs.data.sort((a, b) => {
+								return a.money - b.money
+							})
+							val.money = arr[0].money
+						}
+					}
+					that.$set(that, `list`, list);
+					that.$set(that, `total`, res.total)
+				} else {
+					uni.showToast({
+						title: res.errmsg,
+						icon: 'none'
+					})
+				}
+			},
+			// 购买
+			toBuy(e) {
+				const that = this;
+				uni.navigateTo({
+					url: `/pagesGoods/index/index?id=${e.id||e._id}`
+				})
+			},
+			// 分页
+			toPage(e) {
+				const that = this;
+				let list = that.list;
+				let limit = that.limit;
+				if (that.total > list.length) {
+					uni.showLoading({
+						title: '加载中',
+						mask: true
+					})
+					let page = that.page + 1;
+					that.$set(that, `page`, page)
+					let skip = page * limit;
+					that.$set(that, `skip`, skip)
+					that.search();
+					uni.hideLoading();
+				} else that.$set(that, `is_bottom`, true)
+			},
+			// 触底
+			toScroll(e) {
+				const that = this;
+				let up = that.scrollTop;
+				that.$set(that, `scrollTop`, e.detail.scrollTop);
+				let num = Math.sign(up - e.detail.scrollTop);
+				if (num == 1) that.$set(that, `is_bottom`, false);
+			},
+			// 输入框
+			toInput(e) {
+				const that = this;
+				if (e._id) that.$set(that.searchInfo, `_id`, e._id)
+				else that.$set(that, `searchInfo`, {})
+				that.clearPage();
+				that.search();
+				that.$set(that, `focus`, false)
+			},
+			// 点击查看商品名称列表
+			async focusHandler(e) {
+				const that = this;
+				if (e.detail.value) {
+					let res;
+					let info = {
+						name: e.detail.value,
+						type: that.type,
+						is_use: '0'
+					}
+					res = await that.$api(`/Good/search`, 'GET', {
+						...info,
+					})
+					if (res.errcode == '0') that.$set(that, `goodsList`, res.data)
+					that.$set(that, `focus`, true)
+				}
+			},
+			// 取消搜索
+			cancelHandler(e) {
+				const that = this;
+				that.$set(that, `searchInfo`, {})
+				that.$set(that, `focus`, false)
+				that.clearPage();
+				that.search();
+			},
+			// 清空列表
+			clearPage() {
+				const that = this;
+				that.$set(that, `list`, [])
+				that.$set(that, `skip`, 0)
+				that.$set(that, `limit`, 6)
+				that.$set(that, `page`, 0)
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	.content {
+		display: flex;
+		flex-direction: column;
+		width: 100vw;
+		height: 100vh;
+
+		.one {
+			padding: 2vw;
+
+			.one_1 {
+				input {
+					padding: 2vw;
+					background-color: var(--f1Color);
+					font-size: var(--font14Size);
+					border-radius: 5px;
+				}
+			}
+
+			.one_2 {
+				display: flex;
+				justify-content: center;
+				align-items: center;
+
+				.left {
+					padding: 0 2vw;
+					width: 75vw;
+
+					input {
+						padding: 2vw;
+						background-color: var(--f1Color);
+						font-size: var(--font14Size);
+						border-radius: 5px;
+					}
+				}
+
+				.button {
+					background-color: var(--f3CColor);
+					color: var(--mainColor);
+				}
+			}
+
+			.one_3 {
+				height: 20vh;
+
+				.list {
+					padding: 2vw;
+					border-bottom: 1px solid var(--f5Color);
+
+					.name {
+						display: inline-block;
+						white-space: nowrap;
+						width: 100%;
+						overflow: hidden;
+						text-overflow: ellipsis;
+					}
+				}
+			}
+		}
+
+		.two {
+			position: relative;
+			flex-grow: 1;
+			background-color: var(--f9Color);
+
+			.two_1 {
+				display: flex;
+				justify-content: space-between;
+				flex-wrap: wrap;
+				padding: 2vw;
+
+				.list {
+					display: flex;
+					flex-direction: column;
+					justify-content: inherit;
+					width: 43vw;
+					padding: 2vw;
+					margin: 0 0 2vw 0;
+					border-radius: 10px;
+					background-color: var(--mainColor);
+
+					.image {
+						width: 100%;
+						height: 40vw;
+						border-top-right-radius: 10px;
+						border-top-left-radius: 10px;
+					}
+
+					.name {
+						font-size: var(--font14Size);
+					}
+
+					.other {
+						padding: 1vw 0 0 0;
+						display: flex;
+						justify-content: space-between;
+
+						.left {
+							font-size: var(--font14Size);
+							color: var(--fF0Color);
+						}
+
+						.right {
+							font-size: var(--font12Size);
+							color: var(--f85Color);
+						}
+					}
+				}
+			}
+		}
+	}
+
+	.scroll-view {
+		position: absolute;
+		top: 0;
+		left: 0;
+		right: 0;
+		bottom: 0;
+
+		.list-scroll-view {
+			display: flex;
+			flex-direction: column;
+		}
+	}
+
+	.is_bottom {
+		width: 100%;
+		text-align: center;
+
+		text {
+			padding: 2vw 0;
+			display: inline-block;
+			color: var(--f85Color);
+			font-size: var(--font14Size);
+		}
+	}
+</style>

+ 100 - 8
pagesMy/order/index.vue

@@ -1,7 +1,24 @@
 <template>
 	<view class="content">
 		<view class="one">
-			<input type="text" v-model="searchInfo.goods" @input="toInput" placeholder="搜索商品">
+			<view class="one_1" v-if="!focus">
+				<input type='text' v-model="name" @input="focusHandler" placeholder='搜索商品'></input>
+			</view>
+			<view class="one_2" v-if="focus">
+				<view class="left">
+					<input type="text" v-model="name" @input="focusHandler" placeholder="搜索商品">
+				</view>
+				<view class="right">
+					<button size="mini" class="button" type="default" @click="cancelHandler">取消</button>
+				</view>
+			</view>
+			<!-- 搜索结果显示框 -->
+			<scroll-view v-if="focus" class="one_3" scroll-y="true">
+				<view class="list" v-for="(item, index) in goodsList" :index="index" :key="index"
+					@click="toInput(item)">
+					<text class="name"> {{item.name}}</text>
+				</view>
+			</scroll-view>
 		</view>
 		<view class="two">
 			<tabs :tabs="tabs" @tabsChange="tabsChange">
@@ -75,7 +92,6 @@
 				config: {},
 				user: {},
 				status: '',
-				searchInfo: {},
 				tabs: {
 					active: '0',
 					menu: []
@@ -90,6 +106,11 @@
 				scrollTop: 0,
 				// 字典表
 				statusList: [],
+				// 搜索
+				focus: false, //控制是否显示带取消按钮的搜索框
+				searchInfo: {},
+				name: '',
+				goodsList: [],
 			}
 		},
 		onLoad: function(e) {
@@ -129,6 +150,8 @@
 					const res = uni.getStorageSync('token');
 					if (res) {
 						that.$set(that, `user`, res);
+						that.$set(that, `name`, '')
+						that.$set(that, `searchInfo`, {})
 						that.clearPage();
 						that.search();
 					}
@@ -313,8 +336,35 @@
 			// 输入框
 			toInput(e) {
 				const that = this;
-				if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
+				if (e.name) that.$set(that.searchInfo, `good`, e._id)
 				else that.$set(that, `searchInfo`, {})
+				that.$set(that, `name`, e.name)
+				that.clearPage();
+				that.search();
+				that.$set(that, `focus`, false)
+			},
+			// 点击查看商品名称列表
+			async focusHandler(e) {
+				const that = this;
+				if (e.detail.value) {
+					let res;
+					let info = {
+						name: e.detail.value,
+						is_use: '0'
+					}
+					res = await that.$api(`/Good/search`, 'GET', {
+						...info,
+					})
+					if (res.errcode == '0') that.$set(that, `goodsList`, res.data)
+					that.$set(that, `focus`, true)
+				}
+			},
+			// 取消搜索
+			cancelHandler(e) {
+				const that = this;
+				that.$set(that, `searchInfo`, {})
+				that.$set(that, `name`, '')
+				that.$set(that, `focus`, false)
 				that.clearPage();
 				that.search();
 			},
@@ -375,11 +425,53 @@
 		.one {
 			padding: 2vw;
 
-			input {
-				padding: 2vw;
-				background-color: var(--f1Color);
-				font-size: var(--font14Size);
-				border-radius: 5px;
+			.one_1 {
+				input {
+					padding: 2vw;
+					background-color: var(--f1Color);
+					font-size: var(--font14Size);
+					border-radius: 5px;
+				}
+			}
+
+			.one_2 {
+				display: flex;
+				justify-content: center;
+				align-items: center;
+
+				.left {
+					padding: 0 2vw;
+					width: 75vw;
+
+					input {
+						padding: 2vw;
+						background-color: var(--f1Color);
+						font-size: var(--font14Size);
+						border-radius: 5px;
+					}
+				}
+
+				.button {
+					background-color: var(--f3CColor);
+					color: var(--mainColor);
+				}
+			}
+
+			.one_3 {
+				height: 20vh;
+
+				.list {
+					padding: 2vw;
+					border-bottom: 1px solid var(--f5Color);
+
+					.name {
+						display: inline-block;
+						white-space: nowrap;
+						width: 100%;
+						overflow: hidden;
+						text-overflow: ellipsis;
+					}
+				}
 			}
 		}