Selaa lähdekoodia

feat(commonTab): 优化分类组件点击交互

- 新增 handleLeftChange 方法处理左侧分类点击事件
- 点击时显示加载状态提升用户体验
- 将原来的 handleChange 调用封装到新方法中
- 保持原有的滚动定位和分类切换功能
zhangtao 1 viikko sitten
vanhempi
commit
7686443d8c
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      src/subPack-xsb/commonTab/components/classfiy.vue

+ 5 - 1
src/subPack-xsb/commonTab/components/classfiy.vue

@@ -91,6 +91,10 @@ function handleChange({ value }: { value: string }) {
   leftActive.value = value
   getProductList()
 }
+function handleLeftChange(item: Api.xsbCategories) {
+  goodsLoading.value = 'loading'
+  handleChange({ value: item.code })
+}
 async function getProductList() {
   const res = await Apis.xsb.getCategoryProductList({
     data: {
@@ -437,7 +441,7 @@ function handlePay() {
     </view>
     <view class="wraper">
       <scroll-view class="w200rpx" :scroll-into-view-offset="-150" enable-passive scroll-with-animation scroll-y :scroll-into-view="`id${leftActive}`">
-        <view v-for="item in categories" :id="`id${item.code}`" :key="item.code" :class="[item.code == leftActive ? 'bg-white' : '']" class="relative h100rpx flex items-center justify-center whitespace-nowrap text-28rpx" @click="handleChange({ value: item.code })">
+        <view v-for="item in categories" :id="`id${item.code}`" :key="item.code" :class="[item.code == leftActive ? 'bg-white' : '']" class="relative h100rpx flex items-center justify-center whitespace-nowrap text-28rpx" @click="handleLeftChange(item)">
           {{ item.name }}
           <view v-if="item.code == leftActive" class="absolute left-0 top-20rpx h60rpx w8rpx rounded-4rpx bg-[var(--them-color)]" />
         </view>