Jelajahi Sumber

增加换货流程

ext.liuqiwen3 3 minggu lalu
induk
melakukan
7a1fd4e561

+ 6 - 1
pages/merchantCenters/productCate/productCate.vue

@@ -56,7 +56,7 @@
 				</view>
 				<view class="pop-ipt">
 					<textarea class="item-textarea" @confirm="ensureAttrHandle" maxlength="100" :focus="iptFocus"
-						v-model="cipt" placeholder="请输入规格类型" />
+						v-model="cipt" cursorSpacing="100" :placeholder="ciptPlaceholder" />
 				</view>
 				<view class="action-btn" @click="ensureAttrHandle"> 确定 </view>
 			</view>
@@ -122,6 +122,8 @@
 	// 当前变更类型,0代表规格值,1代表规格子值
 	const cType = ref(0)
 
+  const ciptPlaceholder = ref('请输入规格类型');
+
 	const ensureClickHandle = () => {
 		console.log("ensure")
 
@@ -173,6 +175,7 @@
 
 	// 添加规格
 	const addAttr = () => {
+    ciptPlaceholder.value = '请输入规格类型';
 		attr.value.push({
 			attrName: '',
 			attrValue: []
@@ -199,6 +202,8 @@
 
 	// 新增规格子项值
 	const addSub = (index) => {
+    ciptPlaceholder.value = '请输入规格项';
+
 		cType.value = 1;
 		cIndex.value = index
 		cipt.value = '';

+ 39 - 8
pages/merchantCenters/productManagement.vue

@@ -128,7 +128,7 @@
 </template>
 
 <script setup>
-import {computed, ref,watch} from 'vue'
+import {computed, ref,watch,onUnmounted} from 'vue'
 import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";
 import { productsList, productPutOnShell, productOffShell, productDelete, batchStatus } from "@/api/merchant.js";
 import { useAppStore } from "@/stores/app";
@@ -147,6 +147,11 @@ const tabList = ref([
 const searchVal = ref('')
 const goodsList = ref([]);
 const goodType = ref(1);
+
+// 防抖定时器和请求状态
+const searchTimer = ref(null);
+const isLoading = ref(false); // 防止重复请求
+
 // Pagination
 const params = ref({
   page: 1,
@@ -331,7 +336,23 @@ const tabChange = (item) => {
   resetSelection();
 }
 
-const onSearch = () => {
+const onSearch = (e) => {
+  console.log(e)
+  // 如果是input事件,只处理键盘输入,不直接触发搜索
+  if (e && e.type === 'input') {
+    clearTimeout(searchTimer.value);
+    searchTimer.value = setTimeout(() => {
+      doSearch();
+    }, 500); // 防抖500ms
+  } else {
+    // 如果是confirm事件,立即搜索
+    clearTimeout(searchTimer.value);
+    doSearch();
+  }
+}
+const doSearch = () => {
+  if (isLoading.value) return; // 防止重复请求
+
   goodsList.value = [];
   loading.value = false;
   goodScroll.value = true;
@@ -341,17 +362,18 @@ const onSearch = () => {
   footerswitch.value = true;
   resetSelection();
 }
-
 // 清除搜索内容
 const onClear = () => {
   console.log('清除搜索内容');
   searchVal.value = '';
-  onSearch();
+  clearTimeout(searchTimer.value);
+  doSearch(); // 直接搜索,不需要防抖
 }
-
 const getGroomList = async () => {
   if (!goodScroll.value) return;
+  if (isLoading.value) return; // 防止重复请求
   try {
+    isLoading.value = true;
     loading.value = true;
     params.value.merchantId = merchantInfo.value.id;
     params.value.keyword = searchVal.value;
@@ -370,6 +392,7 @@ const getGroomList = async () => {
     console.error(err);
   } finally {
     loading.value = false;
+    isLoading.value = false;
   }
 };
 
@@ -430,14 +453,22 @@ const goDetail = async (item) => {
     isAllSelect.value = goodsList.value.length === selectValue.value.length;
     return
   }
-  uni.navigateTo({
-    url: "/pages/goods/goods_details/index?id="+item.id
-  })
+  if(item.isShow){
+    uni.navigateTo({
+      url: "/pages/goods/goods_details/index?id="+item.id
+    })
+  }else{
+    uni.showToast({title:'商品已下架',icon:'none'})
+  }
+
 };
 
 onReachBottom(() => {
   getGroomList();
 });
+onUnmounted(() => {
+  clearTimeout(searchTimer.value);
+});
 </script>
 
 <style scoped>