1***@qq.com
1***@qq.com
  • 发布:2025-09-14 00:19
  • 更新:2025-09-14 02:54
  • 阅读:71

uniappX hbuilderX最新版本编译后我的scrollTop不生效,每次走完请求都是0

分类:uni-app x

<template name="custom-scroll-view">
<!-- 1.ref绑定数据,可以操作this.$refs操作dom,实例的方法等
2.refresher-enabled用来开启下拉刷新
3.style用来定义样式
4.refresher-threshold用来定义下拉阈值
5.refresher-triggered设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
6.refresher-default-style自定义下拉刷新
7.refresherBackground下拉框背景颜色
8.bounces控制下拉是否回弹
9.show-scrollbar控制是否显示滚动条
10.@refresherpulling下拉刷新控件被下拉-->

<list-view v-if="listIs === 'list-view'" ref="csmList" :id="listId" refresher-enabled="true" :style="[pagingStyle]"  
    refresher-threshold="10" :refresher-triggered="refresherTriggered" refresher-default-style="none"  
    :refresherBackground="refresherBackground" bounces="false" show-scrollbar="false" @refresherpulling="_onRefresherpulling"  
    @refresherrefresh="_onRefresherrefresh" @refresherrestore="_onRefresherrestore" :scroll-top="scrollTop"  
    @scrolltolower="_onScrolltolower" @scroll="_onScroll">  
    <list-item slot="refresher">  
        <view ref="customRefresher" class="zpx-list-refresher" >  
            <custom-refresher ref="commonRefresher" :default-text="$t('refresh.pullDown')"  
                :pulling-text="$t('refresh.refresh')" :refreshing-text="$t('refresh.loading')"  
                :status="refresherStatus" :refreshDateText="$t('refresh.refreshTimeText')" />  
        </view>  

    </list-item>  

    <slot name="slot1"></slot>  
    <slot name="slot2"></slot>  
    <slot name="slot3"></slot>  
    <slot name="slot4"></slot>  
    <slot name="slot5"></slot>  
    <slot name="slot6"></slot>  
    <slot name="slot7"></slot>  
    <slot name="slot8"></slot>  
    <slot name="slot9"></slot>  
    <slot name="slot10"></slot>  
    <slot name="dataList"></slot>  
    <list-item>  
        <template v-if="showLoadMore">  
            <custom-load-more :status="loadMoreStatus" :default-text="loadMoreDefaultText"  
                :loading-text="$t('loadMore.loadingText')" :no-more-text="$t('loadMore.noMoreText')"  
                :fail-text="loadMoreFailText" />  
        </template>  
    </list-item>  
</list-view>  

<scroll-view v-else ref="csmList" :id="listId" refresher-enabled="true" :style="[pagingStyle]"  
    refresher-threshold="60" :refresher-triggered="refresherTriggered" refresher-default-style="none"  
    refresherBackground="#fff" bounces="false" show-scrollbar="false" @refresherpulling="_onRefresherpulling"  
    @refresherrefresh="_onRefresherrefresh" @refresherrestore="_onRefresherrestore" :scroll-top="scrollTop"  
    @scrolltolower="_onScrolltolower" @scroll="_onScroll">  

    <view slot="refresher">  
        <view ref="zpxListRefresher" class="zpx-list-refresher" >  
            <custom-refresher ref="commonRefresher" :default-text="$t('refresh.pullDown')"  
                :pulling-text="$t('refresh.refresh')" :refreshing-text="$t('refresh.loading')"  
                :status="refresherStatus" :refreshDateText="$t('refresh.refreshTimeText')" />  
        </view>  

    </view>  

    <slot name="slot1"></slot>  
    <slot name="slot2"></slot>  
    <slot name="slot3"></slot>  
    <slot name="slot4"></slot>  
    <slot name="slot5"></slot>  
    <slot name="slot6"></slot>  
    <slot name="slot7"></slot>  
    <slot name="slot8"></slot>  
    <slot name="slot9"></slot>  
    <slot name="slot10"></slot>  
    <slot name="dataList"></slot>  
    <view>  
        <template v-if="showLoadMore">  
            <custom-load-more :status="loadMoreStatus" :default-text="loadMoreDefaultText"  
                :loading-text="$t('loadMore.loadingText')" :no-more-text="$t('loadMore.noMoreText')"  
                :fail-text="loadMoreFailText" />  
        </template>  
    </view>  

</scroll-view>  

</template>
<script lang="uts">
import { gc } from './config/index.uts'
import Enum from './enums/index.uts'
import customRefresher from './components/custom-refresher.uvue'
import customLoadMore from './components/custom-load-more.uvue'
import { getTime } from './utils/index.uts'
export default {
components: { customRefresher, customLoadMore },
data() {
return {
// 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
refresherTriggered: false,
// refresher节点高度
refresherNodeHeight: 0 as number,
// z-paging-x中list-view或scroll-view的节点
$csmList: null as null | UniElement,
// 当前页
pageNo: 1,
// 竖向滚动条位置
scrollTop: 0,
oldScrollTop: 0,
// 下拉刷新状态
refresherStatus: Enum.Refresher.Default,
// 下拉刷新最后更新时间更新的时间戳
refresherTimeTextTimestamp: 0,
// 是否是加载中状态
isLoading: true,
isFlag: true,
// 底部加载更多状态
loadMoreStatus: Enum.More.Default,
customNoMore: -1,
//第一个插槽数据
slot1: [] as any[],
//第二个插槽数据
slot2: [] as any[],
//第三个插槽数据
slot3: [] as any[],
slot4: [] as any[],
slot5: [] as any[],
slot6: [] as any[],
slot7: [] as any[],
slot8: [] as any[],
slot9: [] as any[],
slot10: [] as any[],
dataList: [] as any[],
// 上次下拉刷新时间戳(用于防抖)
lastRefreshTime: 0 as number
}
},
props: {
// 自定义初始的pageNo,默认为1
defaultPageNo: {
type: Number,
default: gc<number>('default-page-no', 1)
},
// 自定义pageSize,默认为10
defaultPageSize: {
type: Number,
default: gc<number>('default-page-size', 10)
},
// 设置组件的style
pagingStyle: {
type: Object,
default: gc<object>('paging-style', {})
},

        // list的类型:list-view或scroll-view,默认为list-view  
        listIs: {  
            type: String,  
            default: gc<string>('list-is', 'list-view'),  
        },  
        // 下拉刷新区域背景颜色  
        refresherBackground: {  
            type: String,  
            default: gc<string>('refresher-background', '#FFF')  
        },  
        // 列表刷新时自动显示下拉刷新view,默认为否  
        showRefresherWhenReload: {  
            type: Boolean,  
            default: gc<boolean>('show-refresher-when-reload', false)  
        },  
        // 是否显示最后更新时间,默认为否  
        showRefresherUpdateTime: {  
            type: Boolean,  
            default: gc<boolean>('show-refresher-update-time', false)  
        },  
        // 如果需要区别不同页面的最后更新时间,请为不同页面的z-paging-x的`refresher-update-time-key`设置不同的字符串  
        refresherUpdateTimeKey: {  
            type: String,  
            default: gc<string>('refresher-update-time-key', 'default')  
        },  
        // 是否启用加载更多数据(含滑动到底部加载更多数据和点击加载更多数据),默认为是  
        loadMoreEnabled: {  
            type: Boolean,  
            default: gc<boolean>('load-more-enabled', true)  
        },  
        // 滑动到底部"默认"文字,默认:点击加载更多  
        loadMoreDefaultText: {  
            type: String,  
            default: gc<string>('load-more-default-text', '点击加载更多')  
        },  
        // 滑动到底部"加载中"文字,默认:正在加载...  
        loadMoreLoadingText: {  
            type: String,  
            default: gc<string>('load-more-loading-text', '正在加载...')  
        },  
        // 滑动到底部"没有更多"文字,默认:没有更多了  
        loadMoreNoMoreText: {  
            type: String,  
            default: gc<string>('load-more-no-more-text', '没有更多了')  
        },  
        // 滑动到底部"加载失败"文字,默认:加载失败,点击重新加载  
        loadMoreFailText: {  
            type: String,  
            default: gc<string>('load-more-fail-text', '加载失败,点击重新加载')  
        },  
        // mounted后自动调用reload方法(mounted后自动调用接口),默认为是  
        auto: {  
            type: Boolean,  
            default: gc<boolean>('auto', true)  
        },  
        // reload时自动滚动到顶部,默认为是  
        scrollToTopWhenReload: {  
            type: Boolean,  
            default: gc<boolean>('scrollToTopWhenReload', true)  
        },  
        // reload时立即自动清空原list,默认为是,若立即自动清空,则在reload之后、请求回调之前页面是空白的  
        cleanListWhenReload: {  
            type: Boolean,  
            default: gc<boolean>('cleanListWhenReload', true)  
        },  
        // 空数据描述文字  
        emptyText: {  
            type: String,  
            default: gc<string>('empty-text', '没有数据哦~')  
        },  
        // 空数据加载失败文字  
        emptyErrorText: {  
            type: String,  
            default: gc<string>('empty-error-text', '很抱歉,加载失败')  
        },  
        // 空数据图片  
        emptyImg: {  
            type: String,  
            default: gc<string>('empty-img', '')  
        },  
        // 空数据加载失败图片  
        emptyErrorImg: {  
            type: String,  
            default: gc<string>('empty-error-img', '')  
        },  
        //自动显示点击返回顶部按钮,默认为否  
        showBackToTop: {  
            type: Boolean,  
            default: gc<boolean>('show-back-to-top', false)  
        },  
        //点击返回顶部按钮显示/隐藏的阈值(滚动距离),单位为px,默认为300px  
        backToTopThreshold: {  
            type: Number,  
            default: gc<number>('back-to-top-threshold', 300)  
        },  
        //点击返回顶部按钮的自定义图片地址,默认使用z-paging内置的图片  
        backToTopImg: {  
            type: String,  
            default: gc<string>('back-to-top-img', '')  
        },  
        // 点击返回顶部按钮的style  
        backToTopStyle: {  
            type: Object,  
            default: gc<object>('back-to-top-style', {}),  
        },  

        // list的类型:list-view或scroll-view,默认为list-view  
        listIs: {  
            type: String,  
            default: gc<string>('list-is', 'list-view'),  
        },  
        // list的id  
        listId: {  
            type: String,  
            default: gc<string>('list-id', ''),  
        },  
        // 下拉刷新默认文字  
        refresherDefaultText: {  
            type: String,  
            default: gc<string>('refresher-default-text', '下拉刷新')  
        },  
        // 下拉刷新下拉中文字  
        refresherPullingText: {  
            type: String,  
            default: gc<string>('refresher-pulling-text', '松开立即刷新')  
        },  
        // 下拉刷新刷新中文字  
        refresherRefreshingText: {  
            type: String,  
            default: gc<string>('refresher-refreshing-text', '正在刷新...')  
        },  
        data2: {  // 自定义属性名(如 `data`)  
            type: Object,  
            default: () => ({})  
        },  
        // 是否启用滚动到底部加载更多,默认为true  
        enableScrollToLower: {  
            type: Boolean,  
            default: gc<boolean>('enable-scroll-to-lower', true)  
        },  
    },  
    mounted() {  
        //this.$csmList = this.$refs['csmList'] as UniElement;  
        this.pageNo = this.defaultPageNo;  
        if (this.auto) {  
            this.reload();  
        }  
        this.$nextTick(() => {  
            const refresherEle = this.$refs["zpxListRefresher"] as UniElement | null;  
            if (refresherEle !== null) {  
                refresherEle.getBoundingClientRectAsync()!.then((rect : DOMRect) => {  
                    this.refresherNodeHeight = rect.height;  
                })  
            }  

        })  

    },  
    //计算属性  
    computed: {  
        isFirstPage() : boolean {  
            return this.pageNo === this.defaultPageNo;  
        },  
        showLoadMore() : boolean {  
            // console.log("testetete");  
            // console.log(this.loadMoreEnabled);  
            // console.log(!this.isLoading);  
            // console.log(this.dataList.length);  
            // console.log(this.loadMoreEnabled && (!this.isLoading || this.dataList.length > 0));  
            return this.loadMoreEnabled && (!this.isLoading || this.dataList.length > 0);  
        },  

    },  
    //监听数据变化  
    watch: {  
        slot1(newVal : any[]) {  
            this.$emit('update:data1', newVal);  
        },  
        slot2(newVal : any[]) {  
            this.$emit('update:data2', newVal);  
        },  
        slot3(newVal : any[]) {  
            this.$emit('update:data3', newVal);  
        },  
        slot4(newVal : any[]) {  
            this.$emit('update:data4', newVal);  
        },  
        slot5(newVal : any[]) {  
            this.$emit('update:data5', newVal);  
        },  
        slot6(newVal : any[]) {  
            this.$emit('update:data6', newVal);  
        },  
        slot7(newVal : any[]) {  
            this.$emit('update:data7', newVal);  
        },  
        slot8(newVal : any[]) {  
            this.$emit('update:data8', newVal);  
        },  
        slot9(newVal : any[]) {  
            this.$emit('update:data9', newVal);  
        },  
        slot10(newVal : any[]) {  
            this.$emit('update:data10', newVal);  
        },  
        dataList(newVal : any[]) {  
            this.$emit('update:dataList', newVal);  
        },  
        refresherStatus(newVal : number) {  
            this.$emit('refresherStatusChange', newVal);  
        },  
        loadMoreStatus(newVal : number) {  
            this.$emit('loadMoreStatusChange', newVal);  
        },  
    },  
    methods: {  
        // 下拉刷新控件被下拉事件  
        _onRefresherpulling(e : RefresherEvent) {  
            this.refresherStatus = e.detail.dy < 60 ? Enum.Refresher.Default : Enum.Refresher.ReleaseToRefresh;  
        },  
        // 下拉刷新被触发事件  
        _onRefresherrefresh(e : RefresherEvent) {  
            this._handleRefresh();  
        },  
        // 处理用户下拉刷新  
        _handleRefresh() {  

            this.refresherStatus = Enum.Refresher.Loading;  
            this.refresherTriggered = true;  
            this.pageNo = this.defaultPageNo;  
            this.isFlag = true;  
            this.loadMoreStatus = Enum.More.Default;  

            this._emitQuery(this.pageNo, this.defaultPageSize);  
        },  
        // emit query事件  
        _emitQuery(pageNo : number, pageSize : number) {  
            this.isLoading = true;  
            const now = Date.now();  
            //防抖10s最多刷新一次  
            if (now - this.lastRefreshTime < 200) {  
                // 10秒内不允许再次刷新  

                setTimeout(() => {  
                    this.endRefresh()  
                }, 100)  

                return;  
            }  
            this.lastRefreshTime = now;  
            this.$emit('query', pageNo, pageSize, this.isFlag);  
            //console.log("调用");  
            setTimeout(() => {  
                this.endRefresh()  
            }, 1000)  
        },  
        // 下拉刷新被复位事件  
        _onRefresherrestore(e : RefresherEvent) {  
            //console.log("下拉事件被结束")  
        },  
        // 处理加载更多数据  
        _handleLoadMore() {  

            if (!this.loadMoreEnabled || this.isLoading || this.loadMoreStatus === Enum.More.NoMore) {  

                return;  
            }  

            this.loadMoreStatus = Enum.More.Loading;  
            this.isFlag = false;  
            this.pageNo++;  
            this._emitQuery(this.pageNo, this.defaultPageSize);  
        },  
        // 直接结束下拉刷新状态  
        endRefresh() {  
            // 设置下拉刷新状态为结束  
            this.refresherTriggered = false;  
            this.refresherStatus = Enum.Refresher.Default;  
            this.isLoading = false;  
        },  
        // 滚动到底部事件  
        _onScrolltolower(e : ScrollToLowerEvent) {  

            if (!this.enableScrollToLower) return;  
            this._handleLoadMore();  
        },  
        // 监听滚动事件  
        _onScroll(e: ScrollEvent) {  
            this.oldScrollTop = e.detail.scrollTop;  
        },  
        // 请求结束(成功)调用此方法,将请求的结果数组传递给z-paging-x处理  
        complete(data: null | any[], type: string | null) {  
            if (type == null) {  
                const finalData: any[] = data === null ? [] : data;  
                this.endRefresh();  
                const currentData: any[] = [...finalData];  

                // customNoMore:-1代表交由z-paging-x自行判断;1代表没有更多了;0代表还有更多数据  
                if (this.customNoMore != -1) {  
                    if (this.customNoMore == 1 || (this.customNoMore != 0 && finalData.length == 0)) {  
                        this.loadMoreStatus = Enum.More.NoMore;  
                    }  
                } else {  
                    if (finalData.length == 0 || (finalData.length > 0 && finalData.length < this.defaultPageSize)) {  
                        this.loadMoreStatus = Enum.More.NoMore;  
                    } else {  
                        this.loadMoreStatus = Enum.More.Default;  
                    }  
                }  

                // 如果是第一页,则覆盖当前数据;如果是加载更多,则拼接数据  
                if (this.isFirstPage) {  
                    // 使用临时变量保存旧数据  

                    // 先设置新数据  
                    this.dataList = currentData;  
                    // 在下一个tick恢复滚动位置  
                    this.$nextTick(() => {  
                        this.scrollToY(0);  
                    });  
                } else {  
                    // 加载更多时直接拼接数据  
                    this.dataList = this.dataList.concat(currentData);  
                }  
            } else {  
                this.swichSlot(type, data)  
            }  
        },  
        //【通过total判断是否有更多数据】请求成功调用此方法,将请求的结果传递给z-paging-x处理,第一个参数为请求结果数组,第二个参数为total(列表总数)  
        completeByTotal(data : null | any[], total : number) {  

            const finalData : any[] = data === null ? [] : data;  
            this.$nextTick(() => {  
                // console.log("total=" + finalData.length);  
                // console.log("total=" + this.isFirstPage);  
                // console.log("total="+this.dataList.length);  
                let nomore = false;  
                const realTotalDataCount = this.isFirstPage ? 0 : this.dataList.length;  
                const dataLength = finalData.length;  
                let exceedCount = realTotalDataCount + dataLength - total;  

                if (exceedCount >= 0) {  
                    nomore = true;  
                    // 仅截取total内部分的数据  
                    exceedCount = this.defaultPageSize - exceedCount;  
                    if (exceedCount > 0 && exceedCount < finalData.length) {  
                        data = finalData.splice(0, exceedCount);  
                    }  
                }  
                this.completeByNoMore(data, nomore);  
            })  
        },  
        scrollToY(y: number) {  

            // 强制重置scrollTop  
            this.scrollTop = -1;  
            // 使用nextTick确保DOM更新后再设置新的scrollTop  
            this.$nextTick(() => {  
                this.scrollTop = y;  
            });  
        },  
        //【自行判断是否有更多数据】请求成功调用此方法,将请求的结果传递给z-paging-x处理,第一个参数为请求结果数组,第二个参数为是否没有更多数据  
        completeByNoMore(data : null | any[], nomore : boolean) {  
            this.customNoMore = nomore == true ? 1 : 0;  
            this.complete(data, null);  
        },  
        // 刷新列表数据  
        reload() {  
            // 重置页码  
            this.pageNo = this.defaultPageNo;  
            // 重置加载更多状态  
            this.loadMoreStatus = Enum.More.Loading  
            // 先滚动到顶部  
            this.scrollToY(0);  
            // 发起查询  
            this.$nextTick(() => {  
                this._emitQuery(this.pageNo, this.defaultPageSize);  
            });  
        },  
        swichSlot(type : string, newValue : any[] | null) {  
            if (newValue == null) return;  

            switch (type) {  
                case 'slot1':  
                    this.slot1 = newValue as any[];  
                    break;  
                case 'slot2':  
                    this.slot2 = newValue as any[];  
                    break;  
                case 'slot3':  
                    this.slot3 = newValue as any[];  
                    break;  
                case 'slot4':  
                    this.slot4 = newValue as any[];  
                    break;  
                case 'slot5':  
                    this.slot5 = newValue as any[];  
                    break;  
                case 'slot6':  
                    this.slot6 = newValue as any[];  
                    break;  
                case 'slot7':  
                    this.slot7 = newValue as any[];  
                    break;  
                case 'slot8':  
                    this.slot8 = newValue as any[];  
                    break;  
                case 'slot9':  
                    this.slot9 = newValue as any[];  
                    break;  
                case 'slot10':  
                    this.slot10 = newValue as any[];  
                    break;  
                case 'dataList':  
                    this.dataList = newValue as any[];  
                    break;  
            }  
        },  
    }  
}  

</script>
<style lang="scss">
@import "./css/z-paging-main.css";
</style>

2025-09-14 00:19 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com (作者)

我已经试过了,HbuilderX 4.6.4版本没问题,4.7.6就回出问题

1***@qq.com

1***@qq.com (作者)

官方赶紧解决或者给解决方案啊

1***@qq.com

1***@qq.com (作者)

/**

  • 商品分类页面
  • 功能:
    1. 展示商品分类(一级分类和二级分类)
    1. 商品列表展示
    1. 商品数量管理
    1. 分类筛选和搜索
      */
      <template>
      <!-- #ifdef APP -->
      <!-- APP端使用scroll-view包裹整个页面,确保滚动正常 -->
      <scroll-view style="flex:1;">
      <!-- #endif -->

      <view class="container" :style="{ paddingTop: statusBarHeight.toString() + 'px' }">
      <!-- 搜索栏:用于搜索商品 -->
      <view class="search-bar">
      <input type="text" class="search-input" :placeholder="$t('search.input')" @click="onClick()" />
      </view>

      <!-- 主体内容区:包含一级分类和商品列表 -->  
      <view class="main-content">  
          <!-- 左侧一级分类侧边栏 -->  
          <scroll-view class="sidebar" direction="vertical" :show-scrollbar="false" :bounces="false">  
              <view v-for="(item, index) in firstLevelCategories" :key="index" class="sidebar-item"  
                  :class="{ active: currentFirstLevel === item.id }" @click="selectFirstLevelCategory(item)">  
                  <text class="sidebar-text">{{ getCurrentLangText(item) }}</text>  
              </view>  
          </scroll-view>  
      
          <!-- 右侧内容区域 -->  
          <view class="product-content">  
              <!-- 二级分类区域 -->  
              <view class="second-level-wrapper">  
                  <!-- 二级分类横向滚动区域 -->  
                  <scroll-view class="scroll-view_H" direction="horizontal" :show-scrollbar="false"  
                      :scroll-into-view="'second-' + currentSecondLevel" :scroll-with-animation="true">  
                      <view v-for="(item, index) in secondLevelCategories" :key="index"  
                          :id="'second-' + item.id" class="second-level-item_H"  
                          :class="{ active: currentSecondLevel === item.id }"  
                          @click="selectSecondLevelCategory(item)">  
                          <text class="second-level-text">{{ getCurrentLangText2(item) }}</text>  
                      </view>  
                  </scroll-view>  
      
                  <!-- 二级分类弹出框 -->  
                  <!-- <view v-if="showSecondLevelPopup" class="second-level-popup">  
                      <view class="popup-content">  
                          <view v-for="(item, index) in secondLevelCategories" :key="index" class="popup-item"  
                              :class="{ active: currentSecondLevel === index }">  
                              <text class="popup-item-text">{{ getCurrentLangText2(item) }}</text>  
                          </view>  
                      </view>  
                  </view> -->  
              </view>  
      
              <!-- 商品列表 -->  
              <custom-scroll-view ref="fc1" class="product-list" v-model:dataList="dataList" style="flex:1"  
                  :auto="true" @query="queryList">  
                  <template #dataList>  
                      <list-item>  
                          <!-- 商品项 -->  
                          <view v-for="(item, index) in dataList" :key="index" class="product-item"  
                              :class="{ 'sold-out': item.stock === 0 }">  
                              <image class="product-image" :src="item.image" mode="aspectFill"  
                                  @click="onDetail(item)" />  
                              <view class="product-info">  
                                  <text class="product-name">{{ getLanguage(item,'name') }}</text>  
                                  <view class="price-container">  
                                      <view class="price-row">  
                                          <text  
                                              :style="item.size[0].disPrice!=null ? priceStyle2 : priceStyle1">¥{{ item.size[0].price }}</text>  
                                          <text class="discount-price"  
                                              v-if="item.size[0].disPrice!=null">¥{{ item.size[0].disPrice}}</text>  
                                      </view>  
                                      <view class="member-price-row" v-if="item.size[0].vipPrice!=null">  
                                          <text class="member-tag">{{ $t('home.vipPrice') }}</text>  
                                          <text class="member-price">¥{{ item.size[0].vipPrice }}</text>  
                                      </view>  
                                  </view>  
                                  <view class="product-actions">  
                                      <view v-if="(item.stock ?? 0) > 0" class="quantity-control">  
                                          <view class="quantity-btn minus" @click="decreaseQuantity(item)">  
                                              <text class="quantity-btn-text">-</text>  
                                          </view>  
                                          <text class="quantity-text">{{ getProductQuantity(item.id) }}</text>  
                                          <view class="quantity-btn plus" @click="increaseQuantity(item)">  
                                              <text class="quantity-btn-text">+</text>  
                                          </view>  
                                      </view>  
                                      <view v-else class="sold-out-tag">  
                                          <text class="sold-out-text">售罄</text>  
                                      </view>  
                                  </view>  
                              </view>  
                          </view>  
                      </list-item>  
                  </template>  
              </custom-scroll-view>  
          </view>  
      </view>  

      </view>

    <!-- #ifdef APP -->
    </scroll-view>
    <!-- #endif -->
    <product-box v-model="show" :product="currentProduct" />
    <!-- 自定义底部导航栏 -->

</template>

<script lang="uts">
import { state, getLangue } from '@/store/index.uts'
import { FirstLevel, SecondLevel } from '@/types/categories.uts'
import { product, size, cart, cartData } from '@/types/index.uts'
import { getFirstLevel } from '@/mock/categoriesPagination.uts'
import { loadMoreData } from '@/mock/homePagination.uts'
import { getLanguageProduct } from '@/utils/index.uts'
import { redirectSearch, redirectProductDetail } from '@/utils/redirect.uts'

// 定义事件名称常量  
const CART_ITEM_UPDATED = 'cart_item_updated'  // 购物车商品更新事件  
const CART_ITEM_DELETED = 'cart_item_deleted'  // 购物车商品删除事件  
const CART_STORAGE_KEY = 'cart_data'  

/**  
 * 购物车商品数据模型  
 */  
type CartItemData = {  
    id : number  
    name : string  
    price : number  
    image : string  
    quantity : number  
    stock : number  
    selected : boolean  
    sizeIndex : number  
}  

export default {  

    data() {  
        return {  
            show: false,  
            firstLevelCategories: [] as FirstLevel[],    // 一级分类列表  
            secondLevelCategories: [] as SecondLevel[],   // 二级分类列表  
            dataList: [] as product[],                 // 商品列表  
            currentFirstLevel: 0,                      // 当前选中的一级分类ID  
            currentSecondLevel: 0,                     // 当前选中的二级分类ID  
            currentFilter: 0,                          // 当前选中的筛选条件索引  
            searchKeyword: '',                         // 搜索关键词  
            isExpanded: false,                         // 是否展开分类弹出框  
            isLoading: false,                          // 是否正在加载数据  
            cartQuantities: new Map<number, number>(), // 存储商品数量的Map  
            statusBarHeight: state.statusBarHeight,      // 状态栏高度  
            showSecondLevelPopup: false,  // 控制二级分类弹出框显示  
            productQuantities: new Map<number, number>(), // 存储商品数量的Map  
            priceStyle1: new Map<string, string>([  
                ['font-size', '32rpx'],  
                ['font-weight', 'bold']  
            ]),  
            priceStyle2: new Map<string, string>([  
                ['font-size', '24rpx'],  
                ['margin-right', '12rpx'],  
                ['text-decoration', 'line-through'],  
                ['text-decoration-line', 'line-through']  
            ]),  
            currentProduct: {  
                id: 0,  
                zhName: '',  
                enName: '',  
                zhHantName: '',  
                image: '',  
                stock: 0,  
                size: [{  
                    id: 1,  
                    zhSize: '',  
                    enSize: '',  
                    zhHantSize: '',  
                    price: 0,  
                    disPrice: null,  
                    vipPrice: null,  
                    orderStock: 1,  
                    coupon: null,  
                    beginTime: null,  
                    endTime: null  
                }]  
            } as product, // 添加当前选中的商品  
            currentSpecIndex: 0, // 当前选中的规格索引  
            specNormalStyle: new Map<string, string>([  
                ['font-size', '26rpx'],  
                ['color', '#666666']  
            ]),  
            specActiveStyle: new Map<string, string>([  
                ['font-size', '26rpx'],  
                ['color', '#ffffff']  
            ]),  
        }  
    },  

    computed: {  

    },  

    // 使用 onLoad 替代 onMounted  
    mounted() {  
        this.loadCategories()  
        // 订阅购物车事件  
        uni.$on(CART_ITEM_UPDATED, this.handleCartItemUpdated)  
        uni.$on(CART_ITEM_DELETED, this.handleCartItemDeleted)  
        // 订阅规格卡片事件  
        uni.$on("cart", this.loadCartData)  
        uni.$on("clear_cart", this.clearCart)  
        // 加载本地购物车数据  
        this.loadCartData()  
    },  

    // 使用 onShow 替代 onMounted 用于事件订阅  
    onShow() : void {  

    },  

    // 使用 onHide 替代 onMounted 用于事件取消订阅  
    onHide() : void {  

    },  

    // 使用 onUnload 用于页面卸载时的清理  
    onUnload() {  
        uni.$off("cart", this.loadCartData)  
        uni.$off("clear_cart", this.clearCart)  
        // 取消订阅事件  
        uni.$off(CART_ITEM_UPDATED, this.handleCartItemUpdated)  
        uni.$off(CART_ITEM_DELETED, this.handleCartItemDeleted)  
    },  

    methods: {  
        onDetail(item : product) {  
            redirectProductDetail(item)  
        },  
        onClick() {  
            redirectSearch('8')  
        },  
        //获取一二级分类国际化  
        getCurrentLangText(item : FirstLevel) : string {  
            const currentLang = getLangue()  
            // 将对象转换为 UTSJSONObject  
            let result : string = ''  

            switch (currentLang) {  
                case 'en-US':  
                    result = item.enName  
                    break  
                case 'zh-HK':  
                    result = item.zhHantName  
                    break  
                case 'zh-CN':  
                    result = item.zhName  
                    break  

            }  

            return result  
        },  
        //获取一二级分类国际化  
        getCurrentLangText2(item : SecondLevel) : string {  
            const currentLang = getLangue()  
            // 将对象转换为 UTSJSONObject  
            let result : string = ''  

            switch (currentLang) {  
                case 'en-US':  
                    result = item.enName  
                    break  
                case 'zh-HK':  
                    result = item.zhHantName  
                    break  
                case 'zh-CN':  
                    result = item.zhName  
                    break  

            }  

            return result  
        },  
        /**  
         * 加载分类数据  
         * 初始化一级分类和二级分类数据  
         */  
        loadCategories() : void {  
            this.firstLevelCategories = (getFirstLevel().data.list as FirstLevel[]);  
            //初始化选择第一个分类  
            this.selectfirstLevelCategories()  
            // 初始化显示第一个分类的子分类  
            this.updateSecondLevelCategories(0)  
            this.queryList(1, 10, false)  

        },  
        /**  
         * 初始化选中一级分类  
         */  
        selectfirstLevelCategories() {  
            this.currentFirstLevel = this.firstLevelCategories[0].id  
        },  
        /**  
         * 初始化选中二级分类  
         */  
        updateSecondLevelCategories(index : number) : void {  
            const selectedCategory = this.firstLevelCategories[0]  
            this.secondLevelCategories = selectedCategory.children as SecondLevel[];  
            this.currentSecondLevel = this.secondLevelCategories[0].id  

        },  

        /**  
         * 选择一级分类  
         * @param category 选中的分类对象  
         */  
        selectFirstLevelCategory(category : FirstLevel) : void {  
            this.currentFirstLevel = category.id;  
            this.secondLevelCategories = category.children ?? [] as SecondLevel[]  
            // 确保有二级分类时,选中第一个分类  
            if (this.secondLevelCategories.length > 0) {  
                this.currentSecondLevel = this.secondLevelCategories[0].id;  
            } else {  
                this.currentSecondLevel = 0;  
            }  
            // 重置页码并滚动到顶部  
            const scrollRef = this.$refs['fc1'] as CustomScrollViewComponentPublicInstance;  
            this.dataList = []  
            scrollRef.reload();  // 这会重置页码并触发新的查询  

        },  
        /**  
         * 选择二级分类  
         * @param category 选中的二级分类索引  
         */  
        selectSecondLevelCategory(category : SecondLevel) : void {  
            this.currentSecondLevel = category.id;  
            // 重置页码并滚动到顶部  
            this.dataList = []  
            const scrollRef = this.$refs['fc1'] as CustomScrollViewComponentPublicInstance;  

            scrollRef.reload();  // 这会重置页码并触发新的查询  

        },  
        //获取商品国际化  
        getLanguage(item : product, type : string) {  
            return getLanguageProduct(item, type)  
        },  
        /**  
         * 根据分类加载商品  
         * @param firstLevelId 一级分类ID  
         * @param secondLevelId 二级分类ID  
         */  
        queryList(pageNo : number, pageSize : number, isFlag : boolean) {  
            loadMoreData(pageNo,  
                pageSize  
            ).then((res) => {  
                if (this.$refs['fc1'] != null) {  
                    (this.$refs['fc1'] as CustomScrollViewComponentPublicInstance).completeByTotal(res.data.list as any[], res.data.total);  
                }  
            })  

        },  

        /**  
         * 加载本地购物车数据  
         */  
        loadCartData() : void {  
            console.log("zhixing");  
            try {  
                let res:string = uni.getStorageSync('cart') as string  
                let parsedData : cart[] | null = []  
                if (res != '') {  
                    parsedData = JSON.parse<cart[]>(res)  
                }  
                if (parsedData != null) {  
                    console.log(parsedData)  
                    // 直接使用JSON.parse解析数组  
                    if (Array.isArray(parsedData)) {  
                        this.productQuantities.clear()  
                        for (var index = 0; index < parsedData.length; index++) {  
                            let ele = parsedData[index];  
                            let element = parsedData[index].size;  
                            let quantity = 0;  
                            element.forEach(res => {  
                                quantity += res.quantity  
                            })  
                            this.productQuantities.set(ele.id, quantity)  
                        }  

                    } else {  
                        this.productQuantities.clear()  
                    }  
                }  

            } catch (e) {  

            }  
        },  

        /**  
         * 处理购物车商品更新事件  
         */  
        handleCartItemUpdated(data : UTSJSONObject) : void {  
            const productId = parseInt(data.get('productId').toString())  
            const quantity = parseInt(data.get('quantity').toString())  
            this.productQuantities.set(productId, quantity)  
        },  

        /**  
         * 处理购物车商品删除事件  
         */  
        handleCartItemDeleted(data : UTSJSONObject) : void {  
            try {  
                // 尝试获取type属性,如果存在且为clear则是清空事件  
                const type = data.get('type').toString()  
                if (type === 'clear') {  
                    // 如果是清空事件,清空所有商品数量  
                    this.productQuantities.clear()  
                    return  
                }  
            } catch (e) {  
                // 如果获取type属性失败,说明是普通删除事件  
            }  

            // 处理单个商品删除  
            const productId = parseInt(data.get('productId').toString())  
            this.productQuantities.delete(productId)  
        },  

        /**  
         * 获取商品数量  
         */  
        getProductQuantity(productId : number) : number {  
            // 如果商品数量Map中没有该商品,返回0  
            if (!this.productQuantities.has(productId)) {  
                return 0  
            }  
            const quantity = this.productQuantities.get(productId)  
            return quantity === null ? 0 : quantity  
        },  

        /**  
         * 计算总价  
         */  
        calculateTotalPrice() : number {  
            const quantity = this.getProductQuantity(this.currentProduct!.id)  
            const price = this.currentProduct!.size[this.currentSpecIndex].disPrice != null  
                ? this.currentProduct!.size[this.currentSpecIndex].disPrice!  
                : this.currentProduct!.size[this.currentSpecIndex].price  
            return quantity * price  
        },  

        /**  
         * 获取规格的国际化文本  
         */  
        getCurrentLangSpec(item : size) : string {  
            const currentLang = getLangue()  
            let result : string = ''  

            switch (currentLang) {  
                case 'en-US':  
                    result = item.enSize  
                    break  
                case 'zh-HK':  
                    result = item.zhHantSize  
                    break  
                case 'zh-CN':  
                    result = item.zhSize  
                    break  
            }  

            return result  
        },  
        clearCart() {  
            this.productQuantities.clear()  
        },  
        /**  
         * 更新购物车  
         */  
        updateCart(item : product, quantity : number) : void {  
            // 获取当前选中的规格  
            const currentSize = item.size[0]  

            let cartItem = {  
                id: item.id,  
                zhName: item.zhName,  
                enName: item.enName,  
                zhHantName: item.zhHantName,  
                image: item.image,  
                stock: item.stock,  
                zhSize: currentSize.zhSize,  
                enSize: currentSize.enSize,  
                zhHantSize: currentSize.zhHantSize,  

                size: [{  
                    id: currentSize.id,  
                    zhSize: currentSize.zhSize,  
                    enSize: currentSize.enSize,  
                    zhHantSize: currentSize.zhHantSize,  
                    price: currentSize.price,  
                    disPrice: currentSize.disPrice,  
                    vipPrice: currentSize.vipPrice,  
                    orderStock: currentSize.orderStock,  
                    orderBoolean: currentSize.orderBoolean,  
                    quantity: 1,  
                    selected: true  
                }]  
            } as cart  
            let res = uni.getStorageSync('cart') as string  
            let parsedData : cart[] | null = []  
            if (res != '') {  
                parsedData = JSON.parse<cart[]>(res)  
            }  
            if (parsedData != null) {  
                // 查找商品是否已在购物车中  
                const index = parsedData.findIndex((res : cart) =>  
                    res.id === item.id,  
                )  
                if (index !== -1) {  
                    if (quantity === 0) {  
                        //查询缓存里的内容的规格是否为1如果为1则删除整个商品  
                        console.log("删除商品");  
                        parsedData.splice(0, 1)  
                    } else {  
                        parsedData[index].size[0].quantity = quantity  
                    }  

                    // 更新已存在的商品  
                } else {  
                    // 添加新商品  
                    parsedData.push(cartItem)  
                }  
                console.log(parsedData);  
                uni.setStorageSync('cart', JSON.stringify(parsedData) )  
            } else {  
                // 如果解析失败,创建新数组  
                let newArray = [cartItem]  
                uni.setStorageSync('cart', newArray)  
            }  
            uni.$emit('cart')  
        },  

        /**  
         * 增加商品数量  
         */  
        increaseQuantity(item : product) : void {  
            let quantity = this.productQuantities.get(item.id) ?? 0;  

            if (item.size.length > 1) {  
                this.show = true  
                this.currentProduct = item  
            } else {  
                if (typeof item.size[0].orderBoolean === "boolean" && item.size[0].orderBoolean == true) {  
                    if (quantity < item.size[0].orderStock) {  
                        quantity += 1  
                        this.productQuantities.set(item.id, quantity)  
                        //this.localQuantity = quantity // 更新本地状态  
                    } else {  
                        uni.showToast({  
                            title: '库存不足',  
                            icon: 'none'  
                        })  
                        return  
                    }  
                } else {  
                    let sum = 0;  
                    let elm = this.productQuantities.get(item.id) ?? 0;  
                    sum += elm * item.size[0].orderStock  

                    if (sum + item.size[0].orderStock <= item.stock) {  
                        quantity += 1  
                        this.productQuantities.set(item.id, quantity)  
                        //this.localQuantity = quantity // 更新本地状态  
                    } else {  
                        uni.showToast({  
                            title: '库存不足',  
                            icon: 'none'  
                        })  
                        return  
                    }  
                }  
                this.updateCart(item, quantity)  
            }  

        },  

        /**  
         * 减少商品数量  
         */  
        decreaseQuantity(item : product) : void {  
            if (item.size.length > 1) {  
                this.show = true  
                this.currentProduct = item  
            } else {  
                let quantity = this.productQuantities.get(item.id) ?? 0;  
                if (quantity > 0) {  
                    quantity -= 1  
                    this.productQuantities.set(item.id, quantity)  

                    this.updateCart(item, quantity)  
                }  
            }  

        },  

    }  
}  

</script>

<style lang="scss">
/ 容器样式 /
.container {
flex: 1;
background-color: #fff;
}

/* 搜索栏样式 */  
.search-bar {  
    padding: 24rpx 30rpx;  
    background-color: #ffffff;  
    height: 120rpx;  
    /* 增加搜索栏高度 */  
    border-bottom-width: 1rpx;  
    border-bottom-color: #f0f0f0;  

    .search-input {  
        height: 88rpx;  
        /* 增加输入框高度 */  
        background-color: #f5f5f5;  
        border-radius: 44rpx;  
        /* 调整圆角以匹配新高度 */  
        padding: 0 40rpx;  
        /* 增加左右内边距 */  
        font-size: 30rpx;  
        /* 稍微增大字体 */  
        color: #333333;  
    }  
}  

/* 主体内容区样式 */  
.main-content {  
    flex: 1;  
    flex-direction: row;  
    margin-top: 20rpx;  
}  

/* 侧边栏样式 */  
.sidebar {  
    width: 180rpx;  
    height: 100%;  
    background-color: #f8f8f8;  

    &-item {  
        height: 100rpx;  
        flex-direction: row;  
        align-items: center;  
        justify-content: flex-start;  
        border-left-width: 6rpx;  
        border-left-color: transparent;  
        padding: 0 10rpx;  

        &.active {  
            background-color: #e8e8e8;  
        }  
    }  

    &-text {  
        font-size: 28rpx;  
        color: #333333;  
    }  
}  

/* 商品内容区样式 */  
.product-content {  
    flex: 1;  
    background-color: #ffffff;  
    margin-left: 20rpx;  
}  

/* 二级分类区域 */  
.second-level-wrapper {  
    flex-direction: row;  
    align-items: center;  
    height: 80rpx;  
    margin-top: 16rpx;  
    padding: 8rpx 0;  
    background-color: #ffffff;  
    border-bottom-width: 1rpx;  
    border-bottom-color: #eeeeee;  
}  

/* 滚动区域样式 */  
.scroll-view_H {  
    flex: 1;  
    height: 64rpx;  
    flex-direction: row;  
}  

.second-level-item_H {  
    width: 200rpx;  
    height: 64rpx;  
    flex-direction: row;  
    align-items: center;  
    justify-content: center;  
    margin-right: 16rpx;  
    border-radius: 32rpx;  
    background-color: #f8f8f8;  
    border-width: 1rpx;  
    border-color: #eeeeee;  

    &.active {  
        background-color: #e8e8e8;  
        border-color: #e8e8e8;  
        box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);  
    }  

    .second-level-text {  
        font-size: 24rpx;  
        color: #333333;  
        font-weight: normal;  
        white-space: nowrap;  
        text-align: center;  
    }  

    &:last-child {  
        margin-right: 20rpx;  
    }  
}  

/* 筛选栏样式 */  
.filter-bar {  
    flex-direction: row;  
    height: 80rpx;  
    border-bottom-width: 1rpx;  
    border-bottom-color: #eeeeee;  
    background-color: #ffffff;  

    &-item {  
        flex: 1;  
        flex-direction: row;  
        align-items: center;  
        justify-content: center;  
        height: 80rpx;  

        &.active {  
            .filter-text {  
                font-weight: bold;  
            }  
        }  
    }  

    &-text {  
        font-size: 28rpx;  
        color: #666666;  
        font-weight: normal;  

        &.active {  
            color: #ff5500;  
        }  
    }  

    &-arrow {  
        font-size: 32rpx;  
        color: #ff5500;  
        margin-left: 4rpx;  
    }  
}  

/* 商品列表样式 */  
.product-list {  
    flex: 1;  
}  

/* 商品项样式 */  
.product-item {  
    flex-direction: row;  
    padding: 20rpx;  
    border-bottom-width: 1rpx;  
    border-bottom-color: #eeeeee;  
    margin-bottom: 20rpx;  

    &:last-child {  
        border-bottom-width: 0;  
        margin-bottom: 0;  
    }  

    &.sold-out {  
        opacity: 0.6;  

        .product-image {  
            //filter: grayscale(100%);  
        }  
    }  

    .product-image {  
        width: 200rpx;  
        height: 200rpx;  
        border-radius: 8rpx;  
    }  

    .product-info {  
        flex: 1;  
        margin-left: 20rpx;  
        flex-direction: column;  
    }  

    .product-name {  
        font-size: 28rpx;  
        color: #333333;  
        margin-bottom: 10rpx;  
    }  

    .price-container {  
        flex-direction: column;  
        margin-bottom: 20rpx;  
    }  

    .price-row {  
        flex-direction: row;  
        align-items: center;  
        margin-bottom: 8rpx;  
    }  

    .original-price {  
        font-size: 24rpx;  
        color: #999999;  
        //text-decoration: line-through;  
        //text-decoration-color: #999999;  
        //text-decoration-style: solid;  
        text-decoration-thickness: 1rpx;  
        margin-right: 12rpx;  
    }  

    .discount-price {  
        font-size: 32rpx;  
        color: #ff5500;  
        font-weight: bold;  
    }  

    .member-price-row {  
        flex-direction: row;  
        align-items: center;  
        margin-top: 4rpx;  
    }  

    .member-tag {  
        font-size: 20rpx;  
        color: #ffffff;  
        background-color: #008000;  
        padding: 2rpx 8rpx;  
        border-radius: 4rpx;  
        margin-right: 8rpx;  
    }  

    .member-price {  
        font-size: 28rpx;  
        color: #008000;  
        font-weight: bold;  
    }  

    .product-actions {  
        margin-top: auto;  
        flex-direction: row;  
        justify-content: flex-end;  
    }  

    .quantity-control {  
        flex-direction: row;  
        align-items: center;  
        background-color: #f5f5f5;  
        border-radius: 30rpx;  
        padding: 4rpx;  
        height: 60rpx;  

        .quantity-btn {  
            width: 52rpx;  
            height: 52rpx;  
            border-radius: 26rpx;  
            background-color: #ffffff;  
            flex-direction: row;  
            align-items: center;  
            justify-content: center;  
        }  

        .quantity-text {  
            width: 60rpx;  
            text-align: center;  
            font-size: 28rpx;  
            color: #333333;  
        }  
    }  

    .sold-out-tag {  
        background-color: #999999;  
        border-radius: 30rpx;  
        padding: 8rpx 24rpx;  
        margin-top: auto;  

        .sold-out-text {  
            color: #ffffff;  
            font-size: 24rpx;  
        }  
    }  
}  

/* 平台适配样式 */  
@media screen and (platform: ios) {  
    .search-input {  
        height: 80rpx;  
    }  

    .sidebar {  
        width: 200rpx;  
    }  
}  

@media screen and (platform: android) {  
    .search-input {  
        height: 72rpx;  
    }  

    .sidebar {  
        width: 180rpx;  
    }  
}  

/* 添加滚动容器样式 */  
.scroll-container {  
    width: 100%;  
    overflow: hidden; // 防止出现双滚动条  
}  

/* 下拉箭头样式 */  
.dropdown-arrow {  
    width: 60rpx;  
    height: 64rpx;  
    flex-direction: row;  
    align-items: center;  
    justify-content: center;  
    background-color: #f8f8f8;  
    border-radius: 32rpx;  
    margin: 0 20rpx;  
    border-width: 1rpx;  
    border-color: #eeeeee;  

    .arrow-icon {  
        font-size: 32rpx;  
        color: #666666;  
    }  
}  

/* 二级分类弹出框样式 */  
.second-level-popup {  
    position: absolute;  
    top: 80rpx; // 调整位置到二级分类区域下方  
    left: 0;  
    right: 0;  
    z-index: 100;  
    background-color: #ffffff;  
    border-bottom-width: 1rpx;  
    border-bottom-color: #eeeeee;  
    box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);  
}  

.popup-content {  
    padding: 20rpx;  
    flex-direction: row;  
    flex-wrap: wrap;  
}  

.popup-item {  
    width: 200rpx;  
    height: 64rpx;  
    flex-direction: row;  
    align-items: center;  
    justify-content: center;  
    margin: 10rpx;  
    border-radius: 32rpx;  
    background-color: #f8f8f8;  
    border-width: 1rpx;  
    border-color: #eeeeee;  

    &.active {  
        background-color: #e8e8e8;  
        border-color: #e8e8e8;  
        box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);  
    }  

    .popup-item-text {  
        font-size: 24rpx;  
        color: #333333;  
        font-weight: normal;  
        white-space: nowrap;  
        text-align: center;  
    }  
}  

/* 添加弹窗相关样式 */  
.popup-content {  
    background-color: #fff;  
    border-top-left-radius: 20rpx;  
    border-top-right-radius: 20rpx;  
}  

.safe-area-inset-bottom {  
    padding-bottom: env(safe-area-inset-bottom);  
}  

/* 规格和数量控制样式 */  
.spec-select,  
.quantity-section {  
    width: 100%;  
}  

.spec-container {  
    width: 100%;  
}  

.spec-item {  
    background-color: #f5f5f5;  
    border-color: #dddddd;  

    &.spec-item-active {  
        background-color: #007AFF;  
        border-color: #007AFF;  
    }  
}  

.spec-normal-style {  
    font-size: 26rpx;  
    color: #666666;  
}  

.spec-active-style {  
    font-size: 26rpx;  
    color: #ffffff;  
}  

.quantity-control-wrapper {  
    width: 100%;  
}  

.quantity-section {  
    width: 100%;  
}  

.quantity-header {  
    width: 100%;  
}  

.quantity-control {  
    background-color: #f5f5f5;  
    border-radius: 30rpx;  
}  

</style>这是外部的调用已经向官方提交bug反馈了

要回复问题请先登录注册