zs 1 سال پیش
والد
کامیت
e143d0b3d3
1فایلهای تغییر یافته به همراه12 افزوده شده و 10 حذف شده
  1. 12 10
      pages/home/index.vue

+ 12 - 10
pages/home/index.vue

@@ -2,7 +2,7 @@
 	<view class="content">
 		<view class="one">
 			<view class="one_1" v-if="!focus">
-				<input type='text' v-model="searchInfo.name" @focus="focusHandler" placeholder='搜索商品'></input>
+				<input type='text' v-model="searchInfo.name" @input="focusHandler" placeholder='搜索商品'></input>
 			</view>
 			<view class="one_2" v-if="focus">
 				<view class="left">
@@ -153,16 +153,18 @@
 			// 点击查看商品名称列表
 			async focusHandler(e) {
 				const that = this;
-				let res;
-				let info = {
-					is_use: '0'
+				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)
 				}
-				if (e.detail.value) info.name = e.detail.value
-				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) {