Browse Source

feat: 添加wd-loading组件声明

- 在components.d.ts中添加WdLoading组件类型声明
- 使组件可以被正确引用和使用

fix: 更新测试环境API地址

- 将测试环境地址从http://47.109.84.152:8081更换为https://smqjh.api.zswlgz.com
- 注释掉旧的API地址配置

fix: 修复分类页面功能跳转问题

- 移除分类页面中未开放功能的路由跳转逻辑
- 仅显示功能暂未开放的提示信息

fix: 调整首页商品列表加载逻辑

- 将商品列表shopId从2改为1
- 设置分页组件immediate为false,避免自动加载
- 在onShow生命周期中调用reload方法重新加载数据
- 修复页面底部图片引用错误

feat: 优化分类组件功能

- 添加goodsInTo响应式变量用于滚动定位
- 修复scrollTop类型定义,设置为number | undefined
- 优化滚动加载逻辑,处理边界情况
- 添加滚动到指定商品ID的功能
- 优化加载状态显示和底部内容展示

fix: 完善商品详情价格权限提示

- 修复商品详情接口shopId参数默认值逻辑
- 将商品异常提示改为更准确的"该商品没有价格权限"提示
zhangtao 1 tuần trước cách đây
mục cha
commit
6e8f79d25b

+ 1 - 0
src/components.d.ts

@@ -25,6 +25,7 @@ declare module 'vue' {
     WdIcon: typeof import('wot-design-uni/components/wd-icon/wd-icon.vue')['default']
     WdInput: typeof import('wot-design-uni/components/wd-input/wd-input.vue')['default']
     WdInputNumber: typeof import('wot-design-uni/components/wd-input-number/wd-input-number.vue')['default']
+    WdLoading: typeof import('wot-design-uni/components/wd-loading/wd-loading.vue')['default']
     WdLoadmore: typeof import('wot-design-uni/components/wd-loadmore/wd-loadmore.vue')['default']
     WdMessageBox: typeof import('wot-design-uni/components/wd-message-box/wd-message-box.vue')['default']
     WdNavbar: typeof import('wot-design-uni/components/wd-navbar/wd-navbar.vue')['default']

+ 2 - 1
src/config/index.ts

@@ -23,7 +23,8 @@ const mapEnvVersion = {
    */
   // trial: "http://192.168.1.166:8080/jeecg-boot",
   // trial: 'http://192.168.0.157:8080',
-  trial: 'http://47.109.84.152:8081',
+  // trial: 'http://47.109.84.152:8081',
+  trial: 'https://smqjh.api.zswlgz.com',
   /**
    * 正式版
    */

+ 0 - 3
src/pages/classfiy/index.vue

@@ -1,5 +1,4 @@
 <script setup lang="ts">
-import router from '@/router'
 import { StaticUrl } from '@/config'
 
 definePage({
@@ -28,8 +27,6 @@ const rightList = computed(() => {
 })
 function handleClick() {
   useGlobalToast().show('此功能暂未开放!')
-  return
-  router.push({ name: 'smqjh-goodsList' })
 }
 </script>
 

+ 4 - 2
src/pages/index/index.vue

@@ -22,13 +22,14 @@ const { name } = storeToRefs(addressStore)
 const { userInfo } = storeToRefs(useUserStore())
 const { getTotalNum } = storeToRefs(useSmqjhCartStore())
 const { data: goodsList, isLastPage, page, reload, error, loading } = usePagination((pageNum, pageSize) =>
-  Apis.xsb.getSearchProductList({ data: { pageNum, pageSize, salesNum: 'DESC', shopId: 2, channelId: userInfo.value.channelId || 1 } }), {
+  Apis.xsb.getSearchProductList({ data: { pageNum, pageSize, salesNum: 'DESC', shopId: 1, channelId: userInfo.value.channelId || 1 } }), {
   data: resp => resp.data?.list,
   initialData: [],
   initialPage: 1,
   initialPageSize: 10,
   append: true,
   middleware: createGlobalLoadingMiddleware(),
+  immediate: false,
 })
 const state = computed(() => {
   return error.value ? 'error' : !isLastPage.value ? 'loading' : 'finished'
@@ -36,6 +37,7 @@ const state = computed(() => {
 onShow(() => {
   useSmqjhCartStore().getCartList('XSB')
   useTabbar().setTabbarItem('smqjh-cart', getTotalNum.value)
+  reload()
 })
 onReachBottom(() => {
   if (!isLastPage.value) {
@@ -140,7 +142,7 @@ function handleGo() {
         <image :src="`${StaticUrl}/smqjh-fl.png`" class="h346rpx w344rpx flex-shrink-0" />
         <view class="flex flex-1 flex-col items-end justify-center">
           <image :src="`${StaticUrl}/smqjh-hot-vip.png`" class="h180rpx w344rpx" />
-          <image :src="`${StaticUrl}/smqjh-hot-vip.png`" class="mt14rpx h152rpx w344rpx" />
+          <image :src="`${StaticUrl}/smqjh-cd.png`" class="mt14rpx h152rpx w344rpx" />
         </view>
       </view>
       <view class="mt20rpx">

+ 43 - 18
src/subPack-xsb/commonTab/components/classfiy.vue

@@ -19,6 +19,7 @@ const selectGoods = ref(false)
 // 多规格商品skuid
 const selectSkuId = ref(0)
 const SelectGoodsNum = ref(1)
+const goodsInTo = ref()
 const goodsInfo = ref<Api.xsbCategoryProductList | Api.xsbProductDetail | undefined>()
 definePage({
   name: 'xsb-classfiy',
@@ -41,15 +42,10 @@ const x = computed(() => `${basllObj.value.x}px`)
 const y = computed(() => `${basllObj.value.y}px`)
 const left = computed(() => `${basllObj.value.left}px`)
 const top = computed(() => `${basllObj.value.top}px`)
-const hasCartData = computed(() => {
-  if (cartList.value.length) {
-    return '390rpx'
-  }
-  return '260rpx'
-})
+
 const productList = ref<Api.xsbCategoryProductList[]>([])
 const topScrollView = ref()
-const scrollTop = ref(0)
+const scrollTop = ref<number | undefined>(0)
 const goodsLoading = ref<LoadMoreState>()
 const navHeight = computed(() => {
   return (`${Number(MenuButtonHeight.value) + Number(statusBarHeight.value)}px`)
@@ -104,6 +100,25 @@ async function getProductList() {
     },
   })
   productList.value = res.data
+  console.log(isTopLoading.value, '=====================')
+  if (!res.data.length) {
+    scrollTop.value = undefined
+    nextTick(() => {
+      scrollTop.value = 0
+    })
+  }
+  if (!isTopLoading.value) {
+    goodsInTo.value = null
+    nextTick(() => {
+      goodsInTo.value = res.data.length ? res.data[0].prodId : null
+    })
+  }
+  else {
+    goodsInTo.value = null
+    nextTick(() => {
+      goodsInTo.value = res.data.length ? res.data[res.data.length - 4].prodId : null
+    })
+  }
   goodsLoading.value = 'finished'
   isTopLoading.value = false
   setProductNum()
@@ -111,10 +126,13 @@ async function getProductList() {
 
 function handlScrollBottom() {
   goodsLoading.value = 'loading'
+
   const index = categories?.value.findIndex(it => it.code === leftActive.value)
   console.log(index, '-================')
-  if (index + 1 === categories.value.length)
+  if (index + 1 === categories.value.length) {
+    goodsLoading.value = 'finished'
     return
+  }
   if (index !== -1) {
     handleChange({ value: categories.value[index + 1].code })
   }
@@ -419,7 +437,7 @@ function handlePay() {
           <view v-if="item.code == leftActive" class="absolute left-0 top-20rpx h60rpx w8rpx rounded-4rpx bg-[var(--them-color)]" />
         </view>
       </scroll-view>
-      <view class="content">
+      <view class="content relative">
         <view class="p20rpx">
           <image :src="`${StaticUrl}/class.png`" class="h144rpx w-full" @click="useGlobalToast().show('敬请期待 !')" />
           <view class="my20rpx flex items-center justify-end rounded-16rpx bg-#F6F6F6 px20rpx py8rpx">
@@ -432,11 +450,13 @@ function handlePay() {
         <scroll-view
           :lower-threshold="10"
           :refresher-triggered="isTopLoading" :scroll-top="scrollTop"
-          :style="{ height: `calc(100vh - ${navHeight} - 700rpx)` }" enable-passive scroll-with-animation scroll-y scroll-anchoring refresher-enabled :throttle="false"
-          @refresherrefresh="handleSrollTop" @scrolltolower="handlScrollBottom"
+          :style="{ height: `calc(100vh - ${navHeight} - 700rpx)` }" enable-passive scroll-y scroll-anchoring refresher-enabled :throttle="false"
+          :scroll-into-view="`class${goodsInTo}`"
+          @refresherrefresh="handleSrollTop"
+          @scrolltolower="handlScrollBottom"
         >
           <view v-if="productList.length" class="p20rpx">
-            <view v-for="item in productList" :key="item.id" class="relative">
+            <view v-for="item in productList" :id="`class${item.prodId}`" :key="item.id" class="relative">
               <view class="flex" @click="handleGo(item)">
                 <view class="mr20rpx h172rpx w172rpx flex-shrink-0 overflow-hidden rounded-16rpx bg-#F6F6F6">
                   <image :src="item.pic" lazy-load class="h-full w-full" />
@@ -505,15 +525,18 @@ function handlePay() {
                 </view>
               </view>
             </view>
-            <wd-loadmore :state="goodsLoading" />
+            <wd-loadmore :state="goodsLoading" :loading-props="{ color: '#9ED605', size: 20 }" />
           </view>
+
           <wd-status-tip v-else image="content" tip="暂无内容" />
-          <view v-if="goodsLoading == 'finished'" class="h-50vh" />
+          <view v-if="!productList.length" class="h-50vh" />
         </scroll-view>
+        <view v-if="goodsLoading == 'loading' || isTopLoading" class="absolute left-0 top-0 z-10 h-full w-full flex items-center justify-center bg-[rgba(255,255,255,.6)]">
+          <wd-loading color="#9ED605" :size="20" />
+        </view>
       </view>
     </view>
     <view
-      v-if="cartList.length"
       class="fixedShadow fixed bottom-60rpx left-0 z-100 box-border w-full flex items-center justify-between rounded-t-16rpx bg-white px24rpx pb60rpx pt10rpx"
     >
       <view class="ios w-full flex items-center justify-between">
@@ -601,6 +624,8 @@ function handlePay() {
             </view>
           </view>
         </view>
+        <wd-status-tip v-if="!cartList.length" image="content" tip="暂无内容" />
+
         <view class="h320rpx" />
       </view>
     </Zpopup>
@@ -637,9 +662,9 @@ function handlePay() {
 
 .wraper {
   display: flex;
-  height: calc(100vh - var(--window-top) - v-bind(navHeight) - v-bind(hasCartData) - var(--window-bottom));
-  height: calc(100vh - var(--window-top) - constant(safe-area-inset-bottom) - v-bind(navHeight) - v-bind(hasCartData) - var(--window-bottom));
-  height: calc(100vh - var(--window-top) - env(safe-area-inset-bottom) - v-bind(navHeight) - v-bind(hasCartData) - var(--window-bottom));
+  height: calc(100vh - var(--window-top) - v-bind(navHeight) - 390rpx - var(--window-bottom));
+  height: calc(100vh - var(--window-top) - constant(safe-area-inset-bottom) - v-bind(navHeight) - 390rpx - var(--window-bottom));
+  height: calc(100vh - var(--window-top) - env(safe-area-inset-bottom) - v-bind(navHeight) - 390rpx - var(--window-bottom));
 }
 
 .content {

+ 2 - 2
src/subPack-xsb/goods/index.vue

@@ -88,10 +88,10 @@ function handleGoCurren(id: number) {
 }
 
 async function getGoodsDetaile() {
-  const res = await Apis.xsb.getProductDetail({ data: { id: goodsId.value, shopId: Number(SelectShopInfo.value?.shopId), channelId: userInfo.value.channelId || 1 } })
+  const res = await Apis.xsb.getProductDetail({ data: { id: goodsId.value, shopId: Number(SelectShopInfo.value?.shopId) || 1, channelId: userInfo.value.channelId || 1 } })
   console.log(res, '请求')
   if (!res.data) {
-    useGlobalToast().show('商品异常!')
+    useGlobalToast().show('该商品没有价格权限!')
     return
   }
   goodsInfo.value = res.data