<template>
  <view class="integral-container" :style="{ background: getColor('bgColor')[itemIndex] }">
    <!-- 轮播区域 -->
    <swiper
      class="banner-swiper"
      :indicator-dots="swiperData.length > 1"
      :autoplay="swiperData.length > 1"
      :circular="swiperData.length > 1"
      indicator-color="#dfddd9"
      indicator-active-color="#b27c1e"
      :indicator-top="596"
      v-if="swiperData?.length > 0"
    >
      <swiper-item v-for="(item, index) in swiperData" :key="index">
        <image
          class="banner-img"
          :src="$baseUrl + `integral/${tupianBanben}/${item?.bannerImg}`"
          mode="aspectFill"
          @click="bannerHandler(item, index)"
        />
      </swiper-item>
    </swiper>

    <view class="banner-swiper-space" v-else></view>

    <!-- 会员等级区域 -->
    <swiper
      class="vip-swiper"
      :circular="false"
      :indicator-dots="false"
      @change="handleScroll"
      :current="vipLevel"
    >
      <swiper-item class="vip-area" v-for="(item, index) in integralData?.vipLvInfo" :key="index">
        <view class="vip-area-container" @click="handleVipClick">
          <image
            class="vip-bg"
            :src="$baseUrl + `integral/${tupianBanben}/${item?.vipLvBg}`"
            mode="aspectFit"
          />
          <image
            class="vip-icon"
            :src="$baseUrl + `integral/${tupianBanben}/${item?.vipLvIcon}`"
            mode="aspectFit"
          />
          <image
            class="current-tag"
            v-if="islogin && memberInfo?.grade === gradeList[index]?.grade"
            :src="$baseUrl + `integral/${tupianBanben}/${item?.currentLvTip}`"
            mode="aspectFit"
          />

          <text
            class="current-xingyaodengji-tips"
            v-if="
              getHuangjinMaxVal()[index] == -1 &&
              !(memberInfo.grade == 0 && !memberInfo.orderUpgrade && points >= 1)
            "
            :style="{ color: getColor('jifen')[index]?.currentPoints }"
          >
            {{ itemIndex == 4 ? '您已经升至最高等级' : '您已超越该等级' }}</text
          >

          <button v-if="!islogin" type="primary" class="phone-button" @click="navigateToRegister" />
        </view>

        <view
          class="saoma-tips"
          @click="integralHandler"
          v-if="memberInfo.grade == 0 && !memberInfo.orderUpgrade && points >= 1"
        >
          <text class="saoma-tips-text" :style="{ color: getColor('saomaTips')[index]?.textColor }"
            >扫罐内码或下单有机会升级至<text
              class="saoma-tips-text-lv"
              :style="{ color: getColor('saomaTips')[index]?.jifenColor }"
              >{{ index == 0 ? gradeList[index + 1]?.gradeName : gradeList[index]?.gradeName }}</text
            >
          </text>
          <text class="saoma-tips-text-tips" :style="{ color: getColor('saomaTips')[index]?.jifenColor }"
            >累计积分
            <text
              class="saoma-tips-text-tips-num"
              :style="{ color: getColor('saomaTips')[index]?.jifenColor }"
              >{{ points }}</text
            >
            <text
              class="saoma-tips-text-tips-maxnum"
              :style="{ color: getColor('saomaTips')[index]?.textColor }"
              >/{{ getHuangjinMaxVal()[index] }}</text
            >
          </text>
        </view>
        <view
          class="jifen-progressbar"
          v-if="
            getHuangjinMaxVal()[index] != -1 &&
            !(memberInfo.grade == 0 && !memberInfo.orderUpgrade && points >= 1)
          "
          @click="integralHandler"
        >
          <!-- 积分标题和数值 -->
          <view class="jifen-header">
            <text class="jifen-label" :style="{ color: getColor('jifen')[index]?.currentPoints }"
              >累计积分</text
            >
            <text class="jifen-value">
              <text class="current-points" :style="{ color: getColor('jifen')[index]?.currentPoints }">{{
                islogin ? points : 0
              }}</text>
              <text class="separator" :style="{ color: getColor('jifen')[index]?.totalPoints }">/</text>
              <text class="total-points" :style="{ color: getColor('jifen')[index]?.totalPoints }">{{
                getHuangjinMaxVal()[index]
              }}</text>
            </text>
          </view>

          <!-- 进度条 -->
          <view class="progress-bar-container">
            <!-- 进度条背景图片 -->
            <image
              :src="$baseUrl + `integral/${tupianBanben}/barBgVip${index}.png`"
              class="progress-bar-bg"
              mode="aspectFit"
              @error="onProgressBarError"
            />
            <!-- 进度条填充图片 -->
            <view class="progress-bar-mask">
              <image
                :src="$baseUrl + `integral/${tupianBanben}/barVip${index}.png`"
                class="progress-bar-fill"
                mode="aspectFit"
                :style="{ transform: `translateX(${getProgress(index) - 100}%)` }"
                @error="onProgressBarError"
              />
            </view>
          </view>
        </view>

        <text
          class="chakanshengjigonglueTxt"
          :style="{ color: getColor('chakangonglue')[index] }"
          @click="gonglueHandler"
        >
          查看升级攻略
        </text>

        <!-- <view class="vip-info">
					<text class="vip-name"
						:style="{
							color: islogin ? `${item?.nickNameColor}` : '#6f6d67',
						}"
					>{{`${nickName}`}}</text>

					<view class="title-container">
						<text v-if="!islogin" class="vip-title1">{{`${item?.vipName}`}}</text>
						<image
							v-if="islogin"
							class="vip-title"
							:src="$baseUrl + `integral/${tupianBanben}/${item?.vipNameImg}`"
							mode="aspectFit"
						/>
						
						<image 
							v-if="!islogin"
							class="rule-icon"
							:src="$baseUrl + `integral/${tupianBanben}/integralArrow.png`"
							mode="aspectFit"
						/>
					</view>
					
				</view> -->
      </swiper-item>
    </swiper>
    <image
      class="vipCardArrowRight"
      v-if="itemIndex != 4"
      :src="$baseUrl + `integral/${tupianBanben}/vipCardArrowRight.png`"
      mode="aspectFit"
    ></image>
    <image
      class="vipCardArrowLeft"
      v-if="itemIndex != 0"
      :src="$baseUrl + `integral/${tupianBanben}/vipCardArrowLeft.png`"
      mode="aspectFit"
    ></image>

    <!-- 积分权益 -->
    <view class="privilege-container">
      <!-- 第一行 -->
      <view class="privilege-header">
        <text
          class="quanyi-title"
          :style="{ color: getColor('quanyiTitle')[itemIndex].titleColor }"
          @click="testGoto195"
          >LV{{ Number(itemIndex) + 1 }}专享权益</text
        >
        <text class="title-text" :style="{ color: getColor('quanyiTitle')[itemIndex].quanyiNumColor }"
          >当前可享<text
            class="highlight"
            :style="{ color: getColor('quanyiTitle')[itemIndex].quanyiNumColor }"
            >{{ quanyiBgs[itemIndex].quanyiNum }}</text
          >项权益，升级解锁更多权益～</text
        >
        <!-- <text class="title-text"  v-if="!islogin"
				 	:style="{ color: getColor('quanyiTitle')[itemIndex].quanyiNumColor }">最高可享 <text class="highlight"
					:style="{ color: getColor('quanyiTitle')[itemIndex].quanyiNumColor }">10</text> 项权益会员</text> -->

        <!-- <view class="rule-container">
					<text 
						class="rule-text"
						@click="vipRuleHandler"
					>
						会员规则
					</text>
					<image 
						class="rule-icon"
						:src="$baseUrl + `integral/${tupianBanben}/integralArrow.png`"
						mode="aspectFit"
					/>
				</view> -->
      </view>
      <!-- vipQuanyiData[Math.abs(itemIndex)].qunyiList" -->
      <!-- 第二行 -->
      <view class="privilege-grid">
        <view class="privilege-item" v-for="(item, index) in imgInfos" :key="index">
          <image
            class="itemBg"
            :src="
              $baseUrl +
              `integral/${tupianBanben}/${
                index === selectIdx
                  ? quanyiBgs[itemIndex]['selectImg']
                  : index < quanyiBgs[itemIndex].quanyiNum
                  ? quanyiBgs[itemIndex]['unlockImg']
                  : quanyiBgs[itemIndex]['lockImg']
              }`
            "
            :style="{ width: item.width, height: item.height }"
            mode="aspectFit"
          />
          <image
            class="privilege-icon"
            :src="$baseUrl + `integral/${tupianBanben}/${item?.img}`"
            :style="{ width: item.width, height: item.height }"
            mode="aspectFit"
            @click="handlePrivilegeClick(item, index)"
          />
          <!-- <image 
						v-if="vipQuanyiData[Math.abs(itemIndex)].isNewArr.includes(item) && itemIndex >= vipLevel"
						class="new-tip"
						:src="$baseUrl + `integral/${tupianBanben}/newTip.png`"
						mode="aspectFit"
					/> -->

          <text class="quanyi-text" :style="{ color: getColor('quanyiNameColor')[itemIndex] }">{{
            item.name
          }}</text>
          <image
            class="quanyi-text-img"
            v-if="index >= quanyiBgs[itemIndex].quanyiNum && index < 9"
            :src="$baseUrl + `integral/${tupianBanben}/quanyiLockIcon${itemIndex}.png`"
            mode="aspectFit"
          />

          <button
            v-if="!islogin"
            type="primary"
            class="phone-button-qyIcon"
            :style="{ width: item.width, height: item.height }"
            @click="navigateToRegister"
          />
        </view>
      </view>
    </view>
    <view class="quanyi-detail-area" v-if="isshowQuanyiDetail">
      <!-- MonthGift 组件 -->
      <MonthGift
        v-if="Number(selectIdx) === 0"
        :current-level="itemIndex"
        :userLevel="memberInfo?.grade"
        ref="monthGiftRef"
      />

      <!-- YearGift 组件 -->
      <YearGift
        v-if="Number(selectIdx) === 5"
        :current-level="itemIndex"
        :userLevel="memberInfo?.grade"
        ref="yearGiftRef"
      />

      <!-- BabyClass 组件 -->
      <BabyClass
        v-if="Number(selectIdx) === 1"
        :current-level="itemIndex"
        :userLevel="memberInfo?.grade"
        ref="babyClassRef"
      />

      <!-- <xinrenli 
				:index="itemIndex"
				@go-to-shop="handleGoToShop"
				v-if="Number(selectIdx) === 2"
			/> -->

      <mianfeiwenzhen
        :index="itemIndex"
        v-if="Number(selectIdx) === 2"
        @use-now="handleGoToShop_mainfeiwenzhen"
      />

      <aibenxinrenli
        :index="itemIndex"
        :isshowLock="memberInfo?.grade < 1"
        v-if="Number(selectIdx) === 3"
        @upgrade="handleGoToShop_aibenxinrenli"
      />

      <zhuanduanli
        :index="itemIndex"
        :isshowLock="memberInfo?.grade < 1"
        v-if="Number(selectIdx) === 4"
        @upgrade="handleGoToShop_zhuanduanli"
      />

      <jinjili
        :index="itemIndex"
        :isshowLock="memberInfo?.grade < 2"
        v-if="Number(selectIdx) === 7"
        @upgrade="handleGoToShop_jinjili"
      />
      <shengrili
        :index="itemIndex"
        :isshowLock="memberInfo?.grade < 2"
        v-if="Number(selectIdx) === 6"
        @upgrade="handleGoToShop_shengrili"
      />
      <suyuanyou
        :index="itemIndex"
        :isshowLock="memberInfo?.grade < 3"
        v-if="Number(selectIdx) === 8"
        @upgrade="handleGoToShop_suyuanyou"
      />

      <!-- <xinrenliPopup 
				:index="itemIndex"
				@coupon-click="handleCouponClick"
				@go-to-shop="handleGoToShop"
			/> -->
    </view>
    <view class="zhankai-quanyi" @click="handleZhankaiClick" v-if="selectIdx != -1">
      <image
        v-if="isshowShouqi"
        class="shouqi-quanyi-img"
        :src="$baseUrl + `integral/${tupianBanben}/shouqiBtn${itemIndex}.png`"
        mode="aspectFit"
      />
      <image
        v-if="!isshowShouqi"
        class="zhankai-quanyi-img"
        :src="$baseUrl + `integral/${tupianBanben}/zhankaiBtn${itemIndex}.png`"
        mode="aspectFit"
      />
    </view>

    <!-- 7天连续签到奖励容器 -->
    <view
      class="signin_reward_container"
      :class="`item-${itemIndex}`"
      v-if="integralStore?.signinAndTaskInfo?.data"
    >
      <!-- 标题区域 -->
      <view class="signin_title_area" :class="`item-${itemIndex}`">
        <text class="signin_main_title">连签7天，奖励翻5倍</text>
        <view class="help_icon" @click="handleHelpClick">
          <text class="help_text">?</text>
        </view>
        <!-- <text class="signin_sub_title">再连续签{{ 7 - signedCount }}天,获得5倍积分</text> -->
      </view>

      <!-- 奖励展示区域 -->
      <view class="reward_display_area">
        <!-- 第1-7天奖励 -->
        <view class="daily_reward_item" v-for="day in 7" :key="day">
          <!-- 奖励内容容器 -->
          <view
            class="reward_content_container"
            :class="[
              `item-${itemIndex}`,
              {
                signed: signinStatus[day - 1],
                disabled: day < todaynum && !signinStatus[day - 1],
              },
            ]"
          >
            <text class="reward_points" :class="`item-${itemIndex}`">+{{ rewardPoints[day - 1] }}</text>
            <!-- 奖励标签，通过变量控制显示 -->
            <view class="bonus_tag" v-if="bonusTagStatus[day - 1] && day === 7">
              <text class="bonus_text">{{ bonusTagText[day - 1] }}</text>
            </view>
            <!-- 已签到状态：显示白色圆圈内的对勾 -->
            <view class="reward_status signed" v-if="signinStatus[day - 1]">
              <view class="check_circle">
                <image
                  class="check_mark"
                  :src="$baseUrl + `integral/1023/sign_duihao.png`"
                  mode="aspectFit"
                />
              </view>
            </view>
            <!-- 未签到状态：显示金币图标 -->
            <image
              class="reward_coin"
              v-else
              :src="$baseUrl + `integral/1023/signIcon.png`"
              mode="aspectFit"
            />
          </view>
          <text class="day_label" :class="`item-${itemIndex}`">{{
            day < todaynum && !signinStatus[day - 1] ? '未签到' : getWeekdayLabel(day)
          }}</text>
        </view>
      </view>

      <!-- 签到按钮 -->
      <view v-if="!todaySigned" class="signin_button" :class="`item-${itemIndex}`" @click="handleSigninClick">
        <text class="signin_button_text">立即签到</text>
      </view>
      <!-- 已签到状态 -->
      <view
        v-else
        class="task_button"
        :class="`item-${itemIndex}`"
        :style="getTaskButtonBgStyle"
        @click="handleTaskButtonClick"
      >
        <text class="task_button_text" :class="`item-${itemIndex}`" :style="{ color: getTaskButtonTextColor }"
          >赚更多积分</text
        >
      </view>
    </view>
    <!-- 积分限时购 -->
    <SeckillSection :isdebug="isdebug" :itemIndex="itemIndex" @credits-sale-click="handleCreditsSaleClick" />
    <!-- 邀请得好礼组件 -->
    <InviteGift
      v-if="integralStore.originInviteHome?.data"
      :title="integralStore.originInviteHome?.data?.title"
      class="invite_container"
      :subTitle="integralStore.originInviteHome?.data?.subTitle"
      :itemIndex="itemIndex"
      :islogin="islogin"
      @invite="handleInviteClick"
      @record="handleRecordClick"
    />
    <!-- 会员活动 -->
    <view class="vip-active-area" v-if="vipActive?.length > 0">
      <text class="vip-title" :style="{ color: itemIndex === 4 ? '#fff0df' : '#1d1e25' }">会员活动</text>
      <swiper
        class="vip-active-swiper"
        :indicator-dots="vipActive?.length > 1"
        :autoplay="true"
        :circular="true"
        indicator-color="#dfddd9"
        indicator-active-color="#b27c1e"
        :indicator-top="32"
        @change="handleVipActiveSwipe"
      >
        <swiper-item v-for="(item, index) in vipActive" :key="index">
          <image
            class="vip-active-img"
            :src="item?.img.indexOf('http') !== -1 ? item?.img : $baseUrl + `${item?.img}`"
            mode="aspectFit"
            @click="handleVipActiveClick(index, item)"
          />
        </swiper-item>
      </swiper>
    </view>

    <!-- 异业券权益区域 -->
    <view class="yiyequan_area" v-if="benefitList?.length > 0">
      <!-- 主标题 -->
      <!-- <text class="yiyequan_title" :class="`item-${itemIndex}`">异业券权益</text> -->

      <!-- 权益卡片 -->
      <view class="yiyequan_card" :class="`item-${itemIndex}`">
        <!-- 卡片头部 -->
        <view class="yiyequan_card_header">
          <text class="card_title" :class="`item-${itemIndex}`">积分权益兑换</text>
          <text class="card_count" :class="`item-${itemIndex}`">您有{{ availableBenefits }}个权益可兑换</text>
        </view>

        <!-- 权益列表 -->
        <scroll-view class="benefits_list" scroll-x="true" show-scrollbar="false">
          <view
            class="benefits_container"
            :class="{ 'few-items': benefitList.length <= 2, 'single-item': benefitList.length === 1 }"
          >
            <view
              class="benefit_item"
              v-for="(benefit, index) in benefitList"
              :key="index"
              :data-comlog="{
                xcxComponentClick: 'true',
                xcxComponentExposure: 'true',
                pageName: '积分服务页',
                componentName: '异业券权益',
                componentContent: `${benefit?.goodsName}`,
              }"
              @click="handleExchangeClick(benefit, index, $event)"
            >
              <!-- 权益图片 -->
              <view class="benefit_image">
                <image class="benefit_img" :src="benefit.goodsLogo" mode="aspectFill" />
              </view>

              <!-- 单个商品时的内容区域 -->
              <view class="benefit_content" v-if="benefitList.length === 1">
                <!-- 权益名称 -->
                <text class="benefit_name" :class="`item-${itemIndex}`">{{ benefit.goodsName }}</text>

                <!-- 积分价格容器 -->
                <view class="benefit_points_container">
                  <text class="benefit_points" :class="`item-${itemIndex}`">{{ benefit.credits }}积分</text>
                </view>

                <!-- 兑换按钮 -->
                <view class="exchange_button" :class="`item-${itemIndex}`">
                  <text class="exchange_text">兑换</text>
                </view>
              </view>

              <!-- 多个商品时的内容区域 -->
              <template v-else>
                <!-- 权益名称 -->
                <text class="benefit_name" :class="`item-${itemIndex}`">{{ benefit.goodsName }}</text>

                <!-- 积分价格 -->
                <text class="benefit_points" :class="`item-${itemIndex}`">{{ benefit.credits }}积分</text>

                <!-- 兑换按钮 -->
                <view class="exchange_button" :class="`item-${itemIndex}`">
                  <text class="exchange_text">兑换</text>
                </view>
              </template>
            </view>
          </view>
        </scroll-view>
      </view>
    </view>

    <!-- 商品展示容器 -->
    <view class="goods-container" v-if="goodsDataArr?.length > 0">
      <!-- 积分兑换标题 -->
      <text class="exchange-title" :style="{ color: itemIndex === 4 ? '#FFF0DF' : '#000000' }">积分兑换</text>

      <!-- <view class="goods-container"> -->
      <!-- 页签栏 -->
      <view
        class="custom-tabs"
        :class="{
          'tabs-two': goodsDataArr?.length === 2,
          'tabs-three': goodsDataArr?.length === 3,
          'tabs-many': goodsDataArr?.length >= 4,
        }"
        v-if="goodsDataArr?.length > 1"
      >
        <!-- <view v-for="(tab, index) in tabInfo.tabTexts" :key="index" class="tab-item" :class="{ -->
        <view
          v-for="(tab, index) in goodsDataArr"
          :key="index"
          class="tab-item"
          :class="{
            active: activeIndex === index && itemIndex !== 4,
            active1: activeIndex === index && itemIndex === 4,
          }"
          @click="tabItemClick(index, tab)"
        >
          <text class="tab-line1">{{ tab?.resourcePositionName }}</text>
          <!-- <text class="tab-line1">{{ tab?.line1 }}</text> -->
          <!-- <text class="tab-line2">{{ tab?.line2 }}</text> -->
          <view class="select-line" v-if="activeIndex === index"></view>
        </view>
      </view>

      <view
        class="goods-content"
        v-for="(goodItemList, index) in goodsDataArr"
        :key="index"
        v-if="goodsDataArr?.length > 0"
      >
        <view class="goods-list" v-if="activeIndex === index">
          <!-- <view class="goods-item" v-for="(goodItem, i) in goodItemList?.resourcePositionGoods" :key="i"
						:style="{
							background: `url(${$baseUrl}integral/1022/listItemImgBg${itemIndex}.png) no-repeat center/contain`
						}"> -->
          <view class="goods-item" v-for="(goodItem, i) in goodItemList?.resourcePositionGoods" :key="i">
            <view
              class="goods-item-container"
              :data-comlog="{
                xcxComponentClick: 'true',
                xcxComponentExposure: 'true',
                pageName: '积分服务页',
                componentName: '积分商品',
                componentContent: `${goodItemList?.resourcePositionName}-${goodItem?.goodsName}`,
              }"
              @click="handleGoodsItemClick(goodItem, i, $event)"
            >
              <image
                class="goods-img"
                :src="
                  goodItem?.goodsIcon.indexOf('http') !== -1
                    ? goodItem?.goodsIcon
                    : $baseUrl + `${goodItem?.goodsIcon}`
                "
                mode="scaleToFill"
              />
              <image
                class="jifenshangpinmask"
                :src="$baseUrl + `integral/1023/jifenshangpinmask${itemIndex}.png`"
                mode="scaleToFill"
              />
              <view class="title-container1">
                <text class="title-text1">{{ goodItem?.goodsName }}</text>
              </view>

              <text v-if="Number(goodItem?.urlType) !== 2" class="price-text"
                ><text class="num">{{ goodItem?.credits }}</text
                >积分</text
              >

              <template v-else>
                <text v-if="Number(goodItem?.priceMarket) && Number(goodItem?.credits)" class="num0"
                  >低至{{ goodItem?.credits }}<text class="price-text0">积分</text
                  ><text class="price-text1">+</text><text class="price-text0">￥</text
                  >{{ goodItem?.priceMarket / 100 }}</text
                >
                <text v-else-if="Number(goodItem?.priceMarket)" class="price-text"
                  ><text class="num">￥{{ goodItem?.priceMarket / 100 }}</text></text
                >
                <text v-else-if="Number(goodItem?.credits)" class="price-text"
                  ><text class="num">{{ goodItem?.credits }}</text
                  >积分</text
                >
              </template>
            </view>
          </view>
        </view>
      </view>

      <!-- 商品内容 -->
      <!-- <view class="goods-content">
				<view class="goods-list" v-if="activeIndex === 0">
					<view class="goods-item" v-for="i in goodsData[0]?.titles?.length" :key="i" :style="{
						background: `url(${$baseUrl}integral/1022/listItemImgBg${itemIndex}.png) no-repeat center/contain`
					}">
						<view class="goods-item-container" @click="handleGoodsItemClick('xingpin', i)">
							<image class="goods-img"
								:src="$baseUrl + `integral/${tupianBanben}/${goodsData[0]?.goodsImgs[i - 1]}`"
								mode="aspectFit" />
							<view class="title-container1">
								<text class="title-text1">{{ goodsData[0]?.titles[i - 1] }}</text>
							</view>
							<text class="num0">{{ goodsData[0]?.prices[i - 1].split("积分+￥")[0] }}<text
									class="price-text0">积分</text><text class="price-text1">+</text><text
									class="price-text0">￥</text>{{ goodsData[0]?.prices[i - 1].split("积分+￥")[1]
									}}</text>
						</view>

					</view>
				</view>

				<view class="goods-list" v-if="activeIndex === 1">
					<view class="goods-item" v-for="i in goodsData[1]?.titles?.length" :key="i" :style="{
						background: `url(${$baseUrl}integral/1022/listItemImgBg${itemIndex}.png) no-repeat center/contain`
					}">
						<view class="goods-item-container" @click="handleGoodsItemClick('lingyuan', i)">

							<image class="goods-img"
								:src="$baseUrl + `integral/${tupianBanben}/${goodsData[1]?.goodsImgs[i - 1]}`"
								mode="aspectFit" />
							<view class="title-container1">
								<text class="title-text1">{{ goodsData[1]?.titles[i - 1] }}</text>
							</view>
							<text class="price-text"><text class="num">{{ goodsData[1]?.prices[i - 1] }}</text>积分</text>
						</view>
					</view>
				</view>

				<view class="goods-list" v-if="activeIndex === 2">
					<view class="goods-item" v-for="i in goodsData[2]?.titles?.length" :key="i" :style="{
						background: `url(${$baseUrl}integral/1022/listItemImgBg${itemIndex}.png) no-repeat center/contain`
					}">
						<view class="goods-item-container" @click="handleGoodsItemClick('beiwei', i)">
							<image class="goods-img"
								:src="$baseUrl + `integral/${tupianBanben}/${goodsData[2]?.goodsImgs[i - 1]}`"
								mode="aspectFit" />
							<view class="title-container1">
								<text class="title-text1">{{ goodsData[2]?.titles[i - 1] }}</text>
							</view>
							<text class="price-text"><text class="num">{{ goodsData[2]?.prices[i - 1] }}</text>积分</text>
							
						</view>
						
					</view>
				</view>
			</view> -->
    </view>

    <!-- 查看更多容器 -->
    <!-- <view class="more-container" v-if="goodsDataArr?.length > 0" @click="handleMoreClick">
			<text class="more-text">点击查看更多</text>
			<image class="more-arrow" :src="$baseUrl + `integral/${tupianBanben}/integralArrow.png`" mode="aspectFit" />
		</view> -->

    <!-- 测试注册层按钮（开发调试用） -->
    <!-- <view class="test-register-btn" @click="showRegisterDialog" v-if="!islogin">
			<text class="test-btn-text">测试注册层</text>
		</view> -->

    <!-- 调试信息（开发调试用） -->
    <!-- <view class="debug-info" v-if="!islogin">
			<text class="debug-text">登录状态: {{ islogin ? '已登录' : '未登录' }}</text>
			<text class="debug-text">注册层状态: {{ showRegisterLayer ? '显示' : '隐藏' }}</text>
			<text class="debug-text">用户昵称: {{ nickName }}</text>
		</view> -->

    <!-- 积分底部填充位置 -->
    <view class="content"> </view>

    <RegisterLayer
      v-model="showRegisterLayer"
      @confirm="handleRegisterConfirm"
      @cancel="handleRegisterCancel"
    />

    <popupShengri :type="Number(itemIndex) + 1" v-if="showPopupShengri" @close="showPopupShengri = false" />
    <ShengriliTipPanel
      :bgIndex="itemIndex"
      v-if="showShengriliTipPanel"
      @close="showShengriliTipPanel = false"
      @add="gotoAddBaby"
    />

    <!-- 签到提示弹窗 -->
    <SignedTips :visible="showSignedTips" :points="earnedPoints" @close="handleCloseSignedTips" />

    <!-- 签到规则说明弹窗 -->
    <SignRuleDes :visible="showSignRuleDes" :ruleText="ruleTextVal" @close="handleCloseSignRuleDes" />

    <!-- 分享登录弹窗 -->
    <!-- <sharepoplogin :visible="showSharePopLogin" @close="handleCloseSharePopLogin"
			@viewBenefits="handleViewBenefits" /> -->

    <!-- 分享未登录弹窗 -->
    <sharenpopnologin
      :visible="showShareNPopNoLogin"
      @close="handleCloseShareNPopNoLogin"
      @viewBenefits="handleViewBenefits"
    />

    <!-- 公众号弹窗 -->
    <!-- <GongzhonghaoPop :visible="showGongzhonghaoPop" :title="gongzhonghaoTitle"
		:description="gongzhonghaoDescription" :qrCodeUrl="gongzhonghaoQrCodeUrl"
		@close="handleCloseGongzhonghaoPop" @download="handleDownloadQrCode" /> -->
  </view>
</template>
<!-- showShengriliTipPanel -->
<script setup>
// 轮播图数据可在此定义（当前使用静态路径）
// "rgba(255,255,255,0.5)"
import { ref, onMounted, onBeforeMount, onBeforeUnmount, computed, watch } from 'vue';
import { onShareAppMessage } from '@dcloudio/uni-app';
import { jump, JumpType } from '@/utils/index.js';
import { useUserStore } from '@/stores/user';
import { fetchIntegralJSON, fetchBatchReceiveJSON, taskCompleteJSON } from '../api/integral';
import RegisterLayer from '../components/RegisterLayer.vue';

import { showLoading, hideLoading, throttleTap } from '../utils';
import xinrenli from '../components/quanyi/xinrenli.vue';
import md from '../md';
import mianfeiwenzhen from '../components/quanyi/mianfeiwenzhen.vue';
import aibenxinrenli from '../components/quanyi/aibenxinrenli.vue';
import zhuanduanli from '../components/quanyi/zhuanduanli.vue';
import BabyClass from '../components/pointRightsCom/babyClass.vue';
import monthGift from '../components/pointRightsCom/monthGift.vue';
import yearGift from '../components/pointRightsCom/yearGift.vue';
import jinjili from '../components/quanyi/jinjili.vue';
import shengrili from '../components/quanyi/shengrili.vue';
import suyuanyou from '../components/quanyi/suyuanyou.vue';
import popupShengri from '../components/popup-shengri/popup-shengri.vue';

import { getHealthField } from '@/api/common';
import MonthGift from '../components/pointRightsCom/monthGift.vue';
import YearGift from '../components/pointRightsCom/yearGift.vue';
import ShengriliTipPanel from '../components/quanyi/shengriliTipPanel.vue';
import SignedTips from '../components/qiandao/SignedTips.vue';
import SignRuleDes from '../components/qiandao/SignRuleDes.vue';
import GongzhonghaoPop from '../components/renwu/GongzhonghaoPop.vue';
import sharepoplogin from '../components/integralArea/sharepoplogin.vue';
import sharenpopnologin from '../components/integralArea/sharenpopnologin.vue';
import bannerDataIntegral from '../mock/bannerDataIntegral.json';
import jifenGoodsData from '../mock/jifenGoodsData.json';
import { onShow } from '@dcloudio/uni-app';
import { useIntegralStore } from '../stores/integral';
import { useGlobalStore } from '../stores/global';
import SeckillSection from '../components/SeckillSection.vue';
import InviteGift from '../components/integralArea/InviteGift.vue';

const isdebug = ref(false);

// 处理积分抢购点击事件
const handleCreditsSaleClick = (params) => {
  const { good, activityId, sessionKey } = params;
  console.log('点击抢购商品:', good, '活动ID:', activityId, '场次Key:', sessionKey);

  // 检查库存
  // if (good.stock <= 0) {
  // 	uni.showToast({
  // 		title: '商品已售罄',
  // 		icon: 'none'
  // 	});
  // 	return;
  // }

  // 检查用户是否登录
  // if (!islogin.value) {
  // 	uni.showToast({
  // 		title: '请先登录',
  // 		icon: 'none'
  // 	});
  // 	return;
  // }

  // 这里可以添加跳转到商品详情页或购买页面的逻辑
  // uni.showToast({
  // 	title: '抢购商品：' + good.name,
  // 	icon: 'none'
  // });

  // 构建跳转URL，添加activityId和sessionKey参数
  const url = `/v3/goodDetail/goodDetail?gid=${good.id}&activityId=${activityId}&sessionKey=${sessionKey}`;
  jump({
    type: JumpType.INNER,
    url: url,
  });
};

// 积分限时购相关函数已移至模板内联实现

// 进度条图片加载错误处理
const onProgressBarError = (e) => {
  console.error('进度条图片加载失败:', e);
  // 可以设置默认样式或显示错误提示
};

function testGoto195() {
  return;
  jump({
    type: JumpType.MINI,
    url: '/pages/my/my',
    extra: {
      appId: 'wxab14ac8f684ad962',
    },
  });
}

const orderUpgrade = ref(false);
// const maxVal = ref([]);
const integralData = ref({
  clickMore: {
    extra: {
      envVersion: 'release',
      appId: 'wx4205ec55b793245e',
    },
    type: 2,
    url: 'subPackages/xmhMainProcess/member/index?entrySource=xmh_wechatmp_points_recgoodsbot',
  },
  tupianBanben: '1022',
  swiper: [],
  goodsListData: {
    listCommon: {
      listItemImgBg: 'integral/1022/listItemImgBg.png',
    },
    tabInfo: {
      tabBg: 'tapSelectBg.png',
      tabTexts: [
        {
          line2: '',
          line1: '星品榜单',
        },
        {
          line2: '',
          line1: '0元爆款',
        },
        {
          line2: '',
          line1: '北纬专场',
        },
      ],
    },
    goodsData: [
      {
        titles: [
          '星飞帆4段儿童成长配...',
          '星飞帆卓睿4段儿童配...',
          '飞鹤臻贵儿童成长配方...',
          '茁然 茁护儿童配方奶...',
          '经典爱本乳铁蛋白配方...',
          '飞鹤茁然高钙奶酪泡芙...',
          '金装1962-中老年高钙...',
          '经典爱本膳骨配方奶粉...',
          '经典爱本清澄配方奶粉...',
          '金装1962-高钙高蛋白...',
          '德佑纯水湿巾80抽/包',
          '婴儿专护除菌除螨洗衣...',
          'DHA深海鳕鱼肠80g*4袋',
          '云朵软软绵柔巾洗脸巾...',
        ],
        prices: [
          '低至730积分+￥115',
          '低至865积分+￥195',
          '低至1000积分+￥228',
          '低至715积分+￥125',
          '低至3160积分+￥126.4',
          '低至1400积分+￥55.8',
          '低至1780积分+￥71.2',
          '低至3160积分+￥126.4',
          '低至3960积分+￥158.4',
          '低至1780积分+￥71.2',
          '低至65积分+￥36.5',
          '低至440积分+￥17.5',
          '低至520积分+￥20.8',
          '低至460积分+￥18.3',
        ],
        goodsImgs: [
          'listItemImgJx0.png',
          'listItemImgJx1.png',
          'listItemImgJx2.png',
          'listItemImgJx3.png',
          'listItemImgJx4.png',
          'listItemImgJx5.png',
          'listItemImgJx6.png',
          'listItemImgJx7.png',
          'listItemImgJx8.png',
          'listItemImgJx9.png',
          'listItemImgJx10.png',
          'listItemImgJx11.png',
          'listItemImgJx13.png',
          'listItemImgJx14.png',
        ],
      },
      {
        titles: [
          '星飞帆4段儿童成长配...',
          '飞鹤茁然儿童配方奶升...',
          '茁然 茁护儿童配方奶...',
          '宝宝钙维生素D软胶囊...',
          '公牛 新国标插座/插线...',
          '九阳煮蛋器多功能智能...',
          '荣事达电煮锅家用多功...',
          'babygo进口户外防水...',
          '苏泊尔（SUPOR）真...',
          '超级飞侠儿童绘画笔套...',
        ],
        prices: [11500, 8900, 12000, 5450, 5980, 5900, 5900, 3800, 9900, 7900],
        goodsImgs: [
          'listItemImgXL0.png',
          'listItemImgXL1.png',
          'listItemImgXL2.png',
          'listItemImgXL3.png',
          'listItemImgXL5.png',
          'listItemImgXL7.png',
          'listItemImgXL9.png',
          'listItemImgXL11.png',
          'listItemImgXL12.png',
          'listItemImgXL13.png',
        ],
      },
      {
        titles: [
          '北纬47度水果玉米',
          '北纬47度黄糯鲜玉米',
          '北纬47度白甜糯玉米',
          '北纬47度东北烧烤...',
          '北纬47度花甜糯玉米',
          '北纬47度黑珍珠玉米',
          'N47°植物酵素乳245...',
          'N47°水果玉米汁245...',
        ],
        prices: [4740, 3900, 4600, 5990, 4600, 5200, 9990, 7990],
        goodsImgs: [
          'listItemImgPzh0.png',
          'listItemImgPzh1.png',
          'listItemImgPzh2.png',
          'listItemImgPzh3.png',
          'listItemImgPzh4.png',
          'listItemImgPzh5.png',
          'listItemImgPzh6.png',
          'listItemImgPzh7.png',
        ],
      },
    ],
    productIdUrl: {
      lingyuan: [
        {
          productId: '643301938280182989',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '643301938280182990',
        },
        {
          productId: '570770855028876907',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '570770855028876908',
        },
        {
          productId: '643302772176787321',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '643302772176787322',
        },
        {
          productId: '650261586675438161',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '650261761758111604',
        },
        {
          productId: '637462885116453461',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '637462885116453462',
        },
        {
          productId: '664995106239801237',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '664995106239801238',
        },
        {
          productId: '664992929630904330',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '702706680618457075',
        },
        {
          productId: '477231839213998660',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '477231839213998661',
        },
        {
          productId: '710238004623156187',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '710238148411278894',
        },
        {
          productId: '637105594356118250',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '637105594356118251',
        },
      ],
      xingpin: [
        {
          productId: '632366292935447153',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '632366292935447154',
        },
        {
          productId: '434526218612696157',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '434526218612696158',
        },
        {
          productId: '779457178234291713',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '779457178234291714',
        },
        {
          productId: '632368902459430553',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '632368902459430554',
        },
        {
          productId: '748373470406312440',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '748373470406312441',
        },
        {
          productId: '700209063828145600',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '700209063828145601',
        },
        {
          productId: '444612538255511698',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '444612538255511699',
        },
        {
          productId: '748374838109458955',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '748374838109458956',
        },
        {
          productId: '748376191670080756',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '748376191670080757',
        },
        {
          productId: '444614841574228087',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '444614841574228088',
        },
        {
          productId: '642944987112793104',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '642944987112793105',
        },
        {
          productId: '660577242594873852',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '660577242594873853',
        },
        {
          productId: '670068445908034706',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '670072178498381183',
        },
        {
          productId: '660575857729992191',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_star',
          skuId: '660575857729992192',
        },
      ],
      beiwei: [
        {
          productId: '694019044167238066',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_north',
          skuId: '694019044167238067',
        },
        {
          productId: '548984197069284758',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_north',
          skuId: '548984197069284759',
        },
        {
          productId: '548991402553569325',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_north',
          skuId: '548991402553569326',
        },
        {
          productId: '757045038059549612',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_north',
          skuId: '757045038059549613',
        },
        {
          productId: '555507401709887582',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_north',
          skuId: '555507401709887583',
        },
        {
          productId: '555151404052796950',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_north',
          skuId: '555151404052796951',
        },
        {
          productId: '704050114989893289',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_north',
          skuId: '704050114989893290',
        },
        {
          productId: '710290587034550507',
          extra: {
            envVersion: 'release',
            appId: 'wx4205ec55b793245e',
          },
          type: 2,
          url: 'subPackages/shopMainProcess/product/index?productId={productId}&skuId={skuId}&entrySource=xmh_wechatmp_points_north',
          skuId: '710290587034550508',
        },
      ],
    },
  },
  quanyitiaozhuanInfo: {
    shengrili: {
      qushiyong: {
        extra: {
          envVersion: 'release',
          appId: 'wx4205ec55b793245e',
        },
        type: 2,
        url: 'subPackages/shopMainProcess/coupons/couponList',
      },
    },
    suyuanyou: {
      qubaoming: {
        type: 3,
        url: 'https://member.feihe.com/memberH5/#/SyySignupInfo?activityCode=syy20250806&sceneCode=WXG01',
      },
    },
  },
  vipIntegral: {
    gonglue: {
      img: 'strategyBtn.png',
      type: 3,
      url: 'https://mom.feihe.com/member/mine/pointStrategy',
    },
    jifenmingxi: {
      type: 3,
      url: 'https://mom.feihe.com/member/mine/newPointDetail?crmId={crmid}&appCode=XMH',
    },
    progressBar: {
      barBgImg: 'progressBarBgIntegral.png',
      barImg: 'progressBarIntegral.png',
    },
    vipCardInfo: {
      extra: {
        envVersion: 'release',
        appId: 'wx4205ec55b793245e',
      },
      type: 2,
      url: 'subPackages/xmhMainProcess/member/index?entrySource=xmh_wechatmp_points_recgoodsbot',
    },
    excharge: {
      img: 'integralExchargeBtn.png',
      extra: {
        envVersion: 'release',
        appId: 'wx4205ec55b793245e',
      },
      type: 2,
      url: 'subPackages/shopMainList/topicNew/index?id=1000187',
    },
  },
  viplv: {
    imgs: [
      'imgPlatinum0.png',
      'imgPlatinum1.png',
      'imgPlatinum2.png',
      'imgPlatinum3.png',
      'imgPlatinum4.png',
    ],
    upLvTxts: [
      '扫罐内码或下单有机会提升至/V2铂金会员',
      '扫罐内码或下单有机会提升至/V3钻石会员',
      '扫罐内码或下单有机会提升至/V4星光会员',
      '扫罐内码或下单有机会提升至/V5星耀会员',
      '已提升至最高等级/V5星耀会员',
    ],
    vipLvIcon: [
      'imgPlatinumIcon0.png',
      'imgPlatinumIcon1.png',
      'imgPlatinumIcon2.png',
      'imgPlatinumIcon3.png',
      'imgPlatinumIcon4.png',
    ],
    nickNameColors: ['#1d1e25', '#1d1e25', '#ffffff'],
    imgBgs: [
      'imgPlatinumBg0.png',
      'imgPlatinumBg1.png',
      'imgPlatinumBg2.png',
      'imgPlatinumBg3.png',
      'imgPlatinumBg4.png',
    ],
    dangqianColors: ['#b27c1e', '#447ab0', '#332288', '#674513', '#674513'],
    vipNameImgs: [
      'imgPlatinumName0.png',
      'imgPlatinumName1.png',
      'imgPlatinumName2.png',
      'imgPlatinumName3.png',
      'imgPlatinumName4.png',
    ],
  },
  vipActive: [
    {
      img: 'vipAct251009001.jpg',
      extra: {
        envVersion: 'release',
        appId: 'wx4205ec55b793245e',
      },
      type: 2,
      title: '兑换礼品',
      url: '/subPackages/shopMainList/topicNew/index?id=1001165',
    },
    {
      img: 'vipAct2.png',
      extra: {
        envVersion: 'release',
        appId: 'wx4205ec55b793245e',
      },
      type: 2,
      url: '/subPackages/shopMainProcess/lottery/index?utm_campaign=%E6%BA%AF%E6%BA%90%E6%8A%BD%E5%A5%96&_channel_track_key=ngSppZAj',
    },
  ],
  vipLvInfo: [
    {
      vipLvIcon: 'vipLvIcon0.png',
      vipLvBg: 'vipLvBg0.png',
      currentLvTip: 'currentLvTip0.png',
      barVip: 'barVip0.png',
      barBgVip: 'barBgVip0.png',
    },
    {
      vipLvIcon: 'vipLvIcon1.png',
      vipLvBg: 'vipLvBg1.png',
      currentLvTip: 'currentLvTip1.png',
      barVip: 'barVip1.png',
      barBgVip: 'barBgVip1.png',
    },
    {
      vipLvIcon: 'vipLvIcon2.png',
      vipLvBg: 'vipLvBg2.png',
      currentLvTip: 'currentLvTip2.png',
      barVip: 'barVip2.png',
      barBgVip: 'barBgVip2.png',
    },
    {
      vipLvIcon: 'vipLvIcon3.png',
      vipLvBg: 'vipLvBg3.png',
      currentLvTip: 'currentLvTip3.png',
      barVip: 'barVip3.png',
      barBgVip: 'barBgVip3.png',
    },
    {
      vipLvIcon: 'vipLvIcon4.png',
      vipLvBg: 'vipLvBg4.png',
      currentLvTip: 'currentLvTip4.png',
      barVip: 'barVip4.png',
      barBgVip: 'barBgVip4.png',
    },
  ],
  qunyiInfo: {
    vipRule: {
      type: 3,
      url: 'https://mom.feihe.com/member/mine/pointStrategy',
    },
    quanyiBgs: [
      {
        selectImg: 'quanyiSelectBg0.png',
        lockImg: 'quanyiLockBg0.png',
        unlockImg: 'quanyiunLockBg0.png',
        quanyiNum: 3,
      },
      {
        selectImg: 'quanyiSelectBg1.png',
        lockImg: 'quanyiLockBg1.png',
        unlockImg: 'quanyiunLockBg1.png',
        quanyiNum: 5,
      },
      {
        selectImg: 'quanyiSelectBg2.png',
        lockImg: 'quanyiLockBg2.png',
        unlockImg: 'quanyiunLockBg2.png',
        quanyiNum: 8,
      },
      {
        selectImg: 'quanyiSelectBg3.png',
        lockImg: 'quanyiLockBg3.png',
        unlockImg: 'quanyiunLockBg3.png',
        quanyiNum: 9,
      },
      {
        selectImg: 'quanyiSelectBg4.png',
        lockImg: 'quanyiLockBg4.png',
        unlockImg: 'quanyiunLockBg4.png',
        quanyiNum: 9,
      },
    ],
    rule: {
      type: 3,
      url: 'https://mom.feihe.com/member/mine/pointStrategy',
    },
    imgInfos: [
      {
        img: 'yueyueliIcon0.png',
        name: '月月礼',
        width: '99rpx',
        height: '99rpx',
      },
      {
        img: 'yuerIcon0.png',
        name: '育儿课程',
        width: '99rpx',
        height: '99rpx',
      },
      {
        img: 'mainfeiIcon0.png',
        name: '免费问诊',
        width: '99rpx',
        height: '99rpx',
      },
      {
        img: 'aibenxinrenliIcon0.png',
        name: '爱本新人礼',
        width: '99rpx',
        height: '99rpx',
      },
      {
        img: 'zhuanduanliIcon0.png',
        name: '转段礼',
        width: '99rpx',
        height: '99rpx',
      },
      {
        img: 'zhousuiliIcon0.png',
        name: '周岁礼',
        width: '99rpx',
        height: '99rpx',
      },
      {
        img: 'shengriliIcon0.png',
        name: '生日礼',
        width: '99rpx',
        height: '99rpx',
      },
      {
        img: 'jinjiliIcon0.png',
        name: '晋级礼',
        width: '99rpx',
        height: '99rpx',
      },
      {
        img: 'suyuanyouIcon0.png',
        name: '溯源游',
        width: '99rpx',
        height: '99rpx',
      },
    ],
    vipQuanyiUrl: {
      extra: {
        envVersion: 'release',
        appId: 'wx4205ec55b793245e',
      },
      type: 2,
      url: 'subPackages/xmhMainProcess/member/index?entrySource=xmh_wechatmp_points_recgoodsbot',
    },
    vipLvsQuanyi: [
      {
        isNewArr: [],
        qunyiList: [0, 2, 5],
      },
      {
        isNewArr: [6, 7],
        qunyiList: [6, 7, 0, 2, 5],
      },
      {
        isNewArr: [8, 1],
        qunyiList: [8, 1, 6, 7, 0, 2, 5],
      },
      {
        isNewArr: [9],
        qunyiList: [9, 8, 1, 6, 7, 0, 2, 5],
      },
      {
        isNewArr: [9],
        qunyiList: [9, 8, 1, 6, 7, 0, 2, 5],
      },
    ],
  },
});

const goodsDataArr = ref([]); //商品数据,包括tab内容
// const integralData = ref({});
const showShengriliTipPanel = ref(false);
const quanyitiaozhuanInfo = ref({});
const selectIdx = ref(-1); //权益选中id
const isshowShouqi = ref(false); //是否收起权益
const isshowQuanyiDetail = ref(false); //是否显示权益详情
const swiperData = ref(integralData.value?.swiper); //banner图片地方
const vipLvIcons = ref(integralData.value?.viplv?.imgs); //会员等级图标
const vipLvNameImgs = ref(integralData.value?.viplv?.vipNameImgs); //会员等级名称图片
const vipLvIconBgs = ref(integralData.value?.viplv?.imgBgs); //会员等级图标背景
const nickNameColors = ref(integralData.value?.viplv?.nickNameColors); //会员等级昵称颜色
const dangqianColors = ref(integralData.value?.viplv?.dangqianColors); //当前等级颜色
const upLvTxts = ref(integralData.value?.viplv?.upLvTxts); //会员等级提升文字
const vipIntegral = ref(integralData.value?.vipIntegral); //积分明细\
const clickMore = ref(integralData.value?.clickMore); //点击更多
const vipActive = ref({}); //会员活动
const tabInfo = ref(integralData.value?.goodsListData?.tabInfo); //tabbar信息
const listCommon = ref(integralData.value?.goodsListData?.listCommon); //商品列表通用信息
const goodsData = ref(integralData.value?.goodsListData?.goodsData); //商品数据
const productIdUrl = ref(integralData.value?.goodsListData?.productIdUrl); //商品跳转链接
const imgInfos = ref(integralData.value?.qunyiInfo?.imgInfos); //权益信息
const vipRule = ref(integralData.value?.qunyiInfo?.vipRule); //会员规则跳转
const vipLvsQuanyi = ref([]); //会员不同等级权益
const points = ref(0); //积分
const gradeList = ref([]);
const vipQuanyiUrl = ref(integralData.value?.qunyiInfo?.vipQuanyiUrl); //会员权益图标点击跳转

const activeIndex = ref(0); //tabbar选中项

const showRegisterLayer = ref(false);
const tupianBanben = ref(integralData.value?.tupianBanben); //图片版本号

const vipLevel = ref(0);
// const vipNameArr = ref(['V1 黄金会员', 'V2 铂金会员', 'V3 钻石会员', 'V4 星光会员', 'V5 星耀会员']);
const systemInfo = uni.getWindowInfo();
const rpxRatio = 750 / systemInfo.windowWidth; // 如果需要rpx换算（1px = 2rpx）
const itemIndex = ref(0);
const itemWidth = (686 + 64) / rpxRatio;

const lastScrollLeft = ref(0);

const vipQuanyiData = ref(integralData.value?.qunyiInfo?.vipLvsQuanyi);
const quanyiBgs = ref(integralData.value?.qunyiInfo?.quanyiBgs);

const recentAnnualPointsTotal = ref(0);
const nextGradeScoreRuleMin = ref(0);
const upLevelExp = ref([1000, 2000, 3000, 4000, 5000]);
const quanyiListIcon = ref([
  'yueyueliBtn.png',
  'shengriBtn.png',
  'yuerBtn.png',
  'heliBtn.png',
  'xinrenliBtn.png',
  'mianfeiBtn.png',
  'zhuanduanli.png',
  'changxianBtn.png',
  'jinjiBtn.png',
  'suyuanBtn.png',
]);
const vipBgArr = ref([]);

const privilegeSizes = ref([
  { width: '68rpx', height: '87rpx', name: '月月礼' },
  { width: '70rpx', height: '91rpx', name: '生日礼' },
  { width: '94rpx', height: '87rpx', name: '育儿课程' },
  { width: '48rpx', height: '87rpx', name: '鹤礼' },
  { width: '71rpx', height: '88rpx', name: '新人礼' },
  { width: '95rpx', height: '87rpx', name: '免费问诊' },
  { width: '70rpx', height: '86rpx', name: '转段礼' },
  { width: '94rpx', height: '87rpx', name: '尝鲜有礼' },
  { width: '70rpx', height: '89rpx', name: '晋级礼' },
  { width: '71rpx', height: '90rpx', name: '溯源游' },
]);

const userStore = useUserStore();
const integralStore = useIntegralStore();
const globalStore = useGlobalStore();

const memberInfo = ref({
  recentAnnualPointsTotal: 0,
  willExpiredPoints: 0,
  nextGradeScoreRuleMin: 0,
  grade: 0,
  points: 0,
});

const needReinit = ref(false);

const willExpiredPoints = ref(0); //即将过期积分

const islogin = ref(true); //是否登录
const vipLvDatas = ref([]);
const nickName = ref('');

const mdMap = ref([]);

const showPopupShengri = ref(false);

const signinInfo = ref({});
// 签到状态数组，控制每天是否已签到
const signinStatus = ref([true, false, false, false, false, false, false]); // 示例：第1天已签到，其他未签到

// 奖励标签显示状态数组，控制每天是否显示奖励标签
const bonusTagStatus = ref([false, false, false, false, false, false, true]); // 示例：只有第7天显示标签

// 奖励标签文本数组，控制每天标签的文本内容
const bonusTagText = ref(['', '', '', '', '', '', '5倍']); // 示例：第7天显示"5倍"

// 奖励积分数组，控制每天获得的积分
const rewardPoints = ref([0, 0, 0, 0, 0, 0, 0]); // 默认积分值

// 签到提示弹窗相关
const showSignedTips = ref(false);
const earnedPoints = ref(0);

// 签到规则说明弹窗相关
const showSignRuleDes = ref(false);

// 公众号弹窗相关
const showGongzhonghaoPop = ref(false);

// 公众号弹窗参数
const gongzhonghaoTitle = ref('公众号');
const gongzhonghaoDescription = ref('长按关注星妈会公众号,了解更多专业育儿资讯');
const gongzhonghaoQrCodeUrl = ref('https://course.feihe.com/momclub-picture/homepage/qrcode_gzh.png');

// 分享弹窗相关
const showSharePopLogin = ref(false); // 分享登录弹窗状态
const showShareNPopNoLogin = ref(false); // 分享未登录弹窗状态

const ruleTextVal = ref('');

// 异业券权益相关数据
const availableBenefits = ref(0); // 可兑换权益数量
const benefitList = ref([]);

//今天已经签到过
const todaySigned = ref(false);
//已经连续签到天数
const signedCount = ref(0);

//是否是今天
const isToday = ref(false);

//今天是第几天
const todaynum = ref(0);

// Props 定义
const props = defineProps({
  scrollTop: {
    type: Number,
    default: 0,
  },
});

//babyStage 宝宝阶段  0备用 1孕中 2出生 ,null无数据
const gotoAddBaby = () => {
  if (userStore.babyInfo?.allBabyBaseInfo?.some((baby) => baby.babyStage == 2)) {
  } else {
    if (userStore.babyInfo?.allBabyBaseInfo?.length == 3) {
      if (userStore.babyInfo?.allBabyBaseInfo?.some((baby) => baby.babyStage == 1)) {
        // const baby = userStore.babyInfo?.allBabyBaseInfo?.find(baby => baby.babyStage == 1);
        const baby = userStore.babyInfo?.allBabyBaseInfo.find((item) => item.selected);
        // debugger;
        if (baby) {
          navigateTo(`/pages/person/person?type=edit&id=${baby.id}`);
        }
      } else {
        if (userStore.babyInfo?.allBabyBaseInfo?.some((baby) => baby.babyStage == 0)) {
          //跳转2状态的编辑页
          //    const baby = userStore.babyInfo?.allBabyBaseInfo?.find(baby => baby.babyStage == 0);
          const baby = userStore.babyInfo?.allBabyBaseInfo.find((item) => item.selected);
          //    debugger;
          if (baby) {
            navigateTo(`/pages/person/person?type=edit&id=${baby.id}`);
          }
        }
      }
    } else {
      navigateTo('/pages/person/person?type=add');
    }
  }
};

//isshowShouqi 为true 时，展示收起按详情，为false 时，展示查看详情
const handleZhankaiClick = () => {
  isshowShouqi.value = !isshowShouqi.value;
  isshowQuanyiDetail.value = !isshowQuanyiDetail.value;

  // if(!isshowShouqi.value){
  // 	selectIdx.value = -1;
  // }
};
//原始数值：(points.value/maxVal.value[memberInfo.value.grade])*100;
const getProgress = (index) => {
  let progress = 0;
  const val = getHuangjinMaxVal()[index];
  progress = (points.value / val) * 100;
  if (progress > 100) {
    progress = 100;
  }
  if (progress < 0) {
    progress = 0;
  }
  return progress;
};

// 将天数转换为星期标签
const getWeekdayLabel = (day) => {
  const weekdays = ['', '周一', '周二', '周三', '周四', '周五', '周六', '周日'];
  return weekdays[day] || `第${day}天`;
};
// 获取任务按钮背景渐变样式
const getTaskButtonBgStyle = computed(() => {
  const gradients = {
    0: { from: '#D1AF82', to: '#E6C7A3' },
    1: { from: '#8DBAE6', to: '#A0C9F1' },
    2: { from: '#9980C2', to: '#BEA8E2' },
    3: { from: '#CDA36B', to: '#E0B97D' },
    4: { from: '#E7CA9F', to: '#EBD9C9' },
  };
  const gradient = gradients[itemIndex.value] || gradients[0];
  return {
    background: `linear-gradient(to right, ${gradient.from}, ${gradient.to})`,
  };
});

// 获取任务按钮文字颜色
const getTaskButtonTextColor = computed(() => {
  return itemIndex.value === 4 ? '#030200' : '#ffffff';
});

const getColor = (type) => {
  let colors = '';
  switch (type) {
    case 'chakangonglue':
      colors = ['#794c1f', '#5588ba', '#443799', '#4d2f11', '#f6cc9d'];
      break;
    case 'jifen':
      colors = [
        {
          currentPoints: '#5f3c27',
          totalPoints: '#d7aa72',
        },
        {
          currentPoints: '#385e85',
          totalPoints: '#6c9bc9',
        },
        {
          currentPoints: '#403294',
          totalPoints: '#756ae0',
        },
        {
          currentPoints: '#5f3c27',
          totalPoints: '#d4a468',
        },
        {
          currentPoints: '#f6c79c',
          totalPoints: '#d4a468',
        },
      ];
      break;
    case 'saomaTips':
      colors = [
        {
          textColor: '#d4a468',
          jifenColor: '#5f3c27',
        },
        {
          textColor: '#5588ba',
          jifenColor: '#385e85',
        },
        {
          textColor: '#756ae0',
          jifenColor: '#403294',
        },
        {
          textColor: '#d4a468',
          jifenColor: '#5f3c27',
        },
        {
          textColor: '#f6c79c',
          jifenColor: '#ffedc1',
        },
      ];
      break;
    case 'quanyiNameColor':
      colors = ['#503404', '#284a6c', '#322d6f', '#503404', '#fff0df'];
      break;

    case 'bgColor':
      colors = ['#e9e2cc', '#cee3f5', '#eae5f0', '#eee3b9', '#352f2a'];
      break;

    case 'quanyiTitle':
      colors = [
        {
          titleColor: '#503404',
          quanyiNumColor: '#9a8c74',
        },
        {
          titleColor: '#284a6c',
          quanyiNumColor: '#7b8b9a',
        },
        {
          titleColor: '#322d6f',
          quanyiNumColor: '#9c8aba',
        },
        {
          titleColor: '#503404',
          quanyiNumColor: '#9d8d6c',
        },
        {
          titleColor: '#fff0df',
          quanyiNumColor: '#c2a98d',
        },
      ];
      break;
  }

  return colors;
};

// 监听 scrollTop 变化
watch(
  () => props.scrollTop,
  (newVal) => {
    // console.log('scrollTop 变化:', newVal)
    // 执行相关逻辑，如曝光检测

    if (newVal > 650 && newVal < 1200) {
      // if(mdMap.value.indexOf('异业券权益') == -1) {
      // 	mdMap.value.push('异业券权益');
      // 	if(benefitList.value.length > 0) {
      // 		md.sensorComponentLogTake({
      // 			xcxComponentExposure: "true",
      // 			pageName: "积分服务页",
      // 			componentName: "异业券权益",
      // 			componentContent: "异业券权益"
      // 		});
      // 	}
      // }

      if (mdMap.value.indexOf('邀请记录曝光') == -1) {
        mdMap.value.push('邀请记录曝光');
        if (integralStore.originInviteHome?.data) {
          md.sensorComponentLogTake({
            xcxComponentExposure: 'true',
            pageName: '积分服务页',
            componentName: '邀请组件',
            componentContent: '去邀请',
          });

          md.sensorComponentLogTake({
            xcxComponentExposure: 'true',
            pageName: '积分服务页',
            componentName: '邀请组件',
            componentContent: '邀请记录',
          });
        }
      }

      if (mdMap.value.indexOf('积分服务页-二屏') == -1) {
        md.sensorLogTake({
          xcxPage: '积分服务页-二屏页面浏览',
          pageName: '积分服务页-二屏',
        });

        mdMap.value.push('积分服务页-二屏');
      }

      const item = vipActive.value[0];
      if (mdMap.value.indexOf(item.title) == -1) {
        md.sensorComponentLogTake({
          xcxComponentExposure: 'true',
          pageName: '积分服务页',
          componentName: '会员活动',
          componentContent: item.title,
        });
        mdMap.value.push(item.title);
      }
    }

    if (newVal > 1200 && newVal < 2058) {
      if (mdMap.value.indexOf('积分服务页-三屏') == -1) {
        md.sensorLogTake({
          xcxPage: '积分服务页-三屏页面浏览',
          pageName: '积分服务页-三屏',
        });

        mdMap.value.push('积分服务页-三屏');
      }

      const item1 = goodsDataArr.value[0];
      if (mdMap.value.indexOf(item1.resourcePositionName) == -1) {
        md.sensorComponentLogTake({
          xcxComponentExposure: 'true',
          pageName: '积分服务页',
          componentName: '积分商品tab选择',
          componentContent: item1.resourcePositionName,
        });
        mdMap.value.push(item1.resourcePositionName);
      }
    }

    if (newVal > 2058 && newVal < 2788) {
      if (mdMap.value.indexOf('积分服务页-四屏') == -1) {
        md.sensorLogTake({
          xcxPage: '积分服务页-四屏页面浏览',
          pageName: '积分服务页-四屏',
        });

        mdMap.value.push('积分服务页-四屏');
      }
    }
  }
);

const getHuangjinMaxVal = () => {
  let maxVal = [];

  if (!islogin.value) {
    return [1, 1, 1000, 5000, 10000];
  }

  switch (Number(memberInfo.value.grade)) {
    case 0:
      maxVal = [
        gradeList?.value[0]?.gradeScoreRuleMax,
        gradeList?.value[1]?.gradeScoreRuleMin,
        gradeList?.value[2]?.gradeScoreRuleMin,
        gradeList?.value[3]?.gradeScoreRuleMin,
        gradeList?.value[4]?.gradeScoreRuleMin,
      ];
      break;
    case 1:
      maxVal = [
        -1,
        gradeList?.value[1]?.gradeScoreRuleMax,
        gradeList?.value[2]?.gradeScoreRuleMin,
        gradeList?.value[3]?.gradeScoreRuleMin,
        gradeList?.value[4]?.gradeScoreRuleMin,
      ];
      break;
    case 2:
      maxVal = [
        -1,
        -1,
        gradeList?.value[2]?.gradeScoreRuleMax,
        gradeList?.value[3]?.gradeScoreRuleMin,
        gradeList?.value[4]?.gradeScoreRuleMin,
      ];
      break;
    case 3:
      maxVal = [-1, -1, -1, gradeList?.value[3]?.gradeScoreRuleMax, gradeList?.value[4]?.gradeScoreRuleMin];
      break;
    case 4:
      maxVal = [-1, -1, -1, -1, -1];
      break;
  }

  return maxVal;
};
onBeforeMount(async () => {
  console.log('onBeforeMount');
});

onShow(async () => {
  console.log('onShow111111111111');
  if (needReinit.value) {
    needReinit.value = false;
    initNetData();
  }
});

// 使用 watch 监听控制积分页面显示/隐藏的状态
// 这样可以更精确地知道页面何时显示和隐藏
watch(
  () => globalStore.curTabIndex === 2 && !globalStore.isWxFriendCircle,
  (isVisible) => {
    if (isVisible) {
    }

    console.log('isVisible:', isVisible);
  },
  { immediate: true }
);

onMounted(async () => {
  // showSignedTips.value = true;
  showLoading();

  // maxVal.value = getHuangjinMaxVal();

  mdMap.value = [];

  if (mdMap.value.indexOf('积分服务页-首屏') == -1) {
    md.sensorLogTake({
      xcxPage: '积分服务页-首屏页面浏览',
      pageName: '积分服务页-首屏',
    });

    mdMap.value.push('积分服务页-首屏');
  }

  md.sensorComponentLogTake({
    xcxComponentExposure: 'true',
    pageName: '积分服务页',
    componentName: '等级卡牌',
    componentContent: '查看升级攻略',
  });

  const { data } = await fetchIntegralJSON(globalStore.getPreviewScene('integral'));
  integralData.value = { ...data };

  let bannerData = integralData?.value?.banner;
  vipActive.value = [];

  bannerData?.forEach((item) => {
    vipActive.value.push({
      img: item.url,
      url: item.link.url,
      type: item.link.type,
      extra: item.link.extra,
      title: item.title,
    });
  });

  goodsDataArr.value = integralData?.value?.goodsList;

  swiperData.value = integralData.value?.swiper;
  vipLvIcons.value = integralData.value?.viplv?.imgs;
  vipLvIconBgs.value = integralData.value?.viplv?.imgBgs;
  vipLvNameImgs.value = integralData.value?.viplv?.vipNameImgs;
  vipIntegral.value = integralData.value?.vipIntegral;
  clickMore.value = integralData.value?.clickMore;
  // vipActive.value = integralData.value?.vipActive;
  tabInfo.value = integralData.value?.goodsListData?.tabInfo;
  listCommon.value = integralData.value?.goodsListData?.listCommon;
  goodsData.value = integralData.value?.goodsListData?.goodsData;
  productIdUrl.value = integralData.value?.goodsListData?.productIdUrl;
  vipRule.value = integralData.value?.qunyiInfo?.vipRule;
  imgInfos.value = integralData.value?.qunyiInfo?.imgInfos;
  vipQuanyiUrl.value = integralData.value?.qunyiInfo?.vipQuanyiUrl;
  // vipQuanyiData.value = [];////??????
  vipQuanyiData.value = integralData.value?.qunyiInfo?.vipLvsQuanyi;
  tupianBanben.value = integralData.value?.tupianBanben;
  quanyiBgs.value = integralData.value?.qunyiInfo?.quanyiBgs;
  quanyitiaozhuanInfo.value = integralData.value?.quanyitiaozhuanInfo;

  quanyiListIcon.value = [];
  imgInfos.value?.forEach((element, index) => {
    quanyiListIcon.value.push(element.img);
    privilegeSizes.value.push({ width: element.width, height: element.height, name: element.name });
  });

  await userStore.loadMemberInfo();
  await integralStore.getSigninAndTaskInfo();

  await integralStore.getPointsBenefitCoupon(globalStore.getPreviewScene('integral'));

  ruleTextVal.value = integralStore.signinAndTaskInfo?.data?.checkInTodo?.checkInExtra?.rule;

  if (integralStore?.signinAndTaskInfo?.data?.checkInTodo?.checkInExtra?.rule) {
    md.sensorComponentLogTake({
      xcxComponentExposure: 'true',
      pageName: '积分服务页',
      componentName: '签到组件',
      componentContent: '立即签到',
    });
  }

  //初始化签掉数据
  initSignin();

  //初始化积分权益券数据
  initPointsBenefitCoupon();

  //初始化ui
  initNetData();

  if (islogin.value) {
    itemIndex.value = vipLevel.value;
  } else {
    itemIndex.value = 0;
  }

  // 根据邀请用户类型显示对应的分享弹窗
  // if (globalStore.invateUseType === 'new') {
  // 	showShareNPopNoLogin.value = true;
  // } else if (globalStore.invateUseType === 'old') {
  // 	showSharePopLogin.value = true;
  // }

  if (globalStore.invateUseType === 'new') {
    showShareNPopNoLogin.value = true;
  }

  hideLoading();
  initExposure();

  //曝光埋点累计积分
  if (memberInfo.value.grade == 0 && !memberInfo.value.orderUpgrade && points.value >= 1) {
    md.sensorComponentLogTake({
      xcxComponentExposure: 'true',
      pageName: '积分服务页',
      componentName: '等级卡牌',
      componentContent: '累计积分',
    });
  }

  if (
    getHuangjinMaxVal()[memberInfo.value.grade] != -1 &&
    !(memberInfo.value.grade == 0 && !memberInfo.value.orderUpgrade && points.value >= 1)
  ) {
    md.sensorComponentLogTake({
      xcxComponentExposure: 'true',
      pageName: '积分服务页',
      componentName: '等级卡牌',
      componentContent: '累计积分',
    });
  }
});

const initExposure = () => {
  imgInfos.value?.forEach((item, index) => {
    md.sensorComponentLogTake({
      xcxComponentExposure: 'true',
      pageName: '积分服务页',
      componentName: '会员权益',
      componentContent: '会员权益-' + item.name,
    });
  });
};

const initSignin = () => {
  if (!integralStore?.signinAndTaskInfo?.success) {
    uni.showToast({
      title: '获取签到信息失败，请稍后重试',
      icon: 'none',
    });
    return;
  }

  signinInfo.value = integralStore?.signinAndTaskInfo?.data?.checkInTodo;
  console.log('signinInfo111111111=', signinInfo.value);

  signinInfo.value?.checkInExtra?.joinRecord?.forEach((element, index) => {
    signinStatus.value[index] = element.joined;
    if (element.coefficient && Number(element.coefficient) > 1) {
      bonusTagStatus.value[index] = true;
      bonusTagText.value[index] = element.coefficient + '倍';
    } else {
      bonusTagStatus.value[index] = false;
      bonusTagText.value[index] = '';
    }
    rewardPoints.value[index] = element.credits; // 使用接口返回的credits

    if (element.today) {
      todaySigned.value = element.joined;
      isToday.value = element.today;
      todaynum.value = index + 1;
      if (element.joined) {
        signedCount.value = index + 1;
      } else {
        signedCount.value = index;
      }
    }
  });
};

const initPointsBenefitCoupon = () => {
  if (!integralStore?.pointsBenefitCoupon?.success) {
    console.log('获取积分权益券信息失败');
    return;
  }

  const couponData = integralStore?.pointsBenefitCoupon?.data || [];
  benefitList.value = couponData;

  // benefitList.value = couponData.map((item, index) => ({
  // 	id: item.itemId || index + 1,
  // 	name: item.goodsName || '权益名称文案占位...',
  // 	points: item.credits || 100,
  // 	originalPoints: item.priceMarket || 500,
  // 	image: item.goodsIcon || '',
  // 	price: item.price || '25',
  // 	priceSale: item.priceSale || '',
  // 	url: item.url || '',
  // 	urlType: item.urlType || 0,
  // 	wxAppId: item.wxAppId || '',
  // 	envVersion: item.envVersion || 'release'
  // }));

  availableBenefits.value = benefitList.value.length;
  console.log('积分权益券数据初始化完成:', benefitList.value);
};

const initNetData = () => {
  console.log('initNetData');

  memberInfo.value = userStore.memberInfo;

  recentAnnualPointsTotal.value = memberInfo.value.recentAnnualPointsTotal;
  willExpiredPoints.value = memberInfo.value.willExpiredPoints;
  nextGradeScoreRuleMin.value = memberInfo.value.nextGradeScoreRuleMin;
  vipLevel.value = memberInfo.value.grade;
  // points.value = memberInfo.value.points;

  points.value = memberInfo.value.recentAnnualPointsTotal;
  gradeList.value = memberInfo.value.gradeList;

  if (memberInfo.value.memberId == 'not_login') {
    islogin.value = false;
  } else {
    islogin.value = true;
  }

  if (islogin.value) {
    vipCardMd(vipLevel.value);
    nickName.value = memberInfo.value.memberName;
    // 清空之前的数据
    // vipLvDatas.value = [];//??????????
    // vipLvDatas.value = integralData.value.vipLvInfo;

    // memberInfo.value?.gradeList.forEach((element, index) => {
    // 	vipLvDatas.value.push({
    // 		"vipName" : element.gradeName,
    // 	});

    // 	vipLvDatas.value[index].vipIcon = vipLvIcons.value[index];
    // 	vipLvDatas.value[index].vipIconBg = vipLvIconBgs.value[index];
    // 	vipLvDatas.value[index].vipNameImg = vipLvNameImgs.value[index];
    // 	vipLvDatas.value[index].nickNameColor = nickNameColors.value[index];
    // 	vipLvDatas.value[index].dangqianColor = dangqianColors.value[index];
    // });
  } else {
    nickName.value = '未登录';
    vipLvDatas.value = [
      {
        vipName: '登录查看会员等级',
        vipIcon: 'imgPlatinum-1.png',
        vipIconBg: 'imgPlatinumBg-1.png',
        nickNameColor: '#1d1e25',
        dangqianColor: '#b27c1e',
      },
    ];
  }
};

const vipCardMd = (vipLevel, isExposure = true) => {
  if (isExposure) {
    md.sensorComponentLogTake({
      xcxComponentExposure: 'true',
      pageName: '积分服务页',
      componentName: '等级卡牌',
      componentContent: '等级卡牌点击' + lvNameMd(vipLevel),
    });
  } else {
    md.sensorComponentLogTake({
      xcxComponentClick: 'true',
      pageName: '积分服务页',
      componentName: '等级卡牌',
      componentContent: '等级卡牌点击' + lvNameMd(vipLevel),
    });
  }
};

const lvNameMd = (lv) => {
  switch (Number(lv)) {
    case 0:
      return 'V1黄金会员';
      break;
    case 1:
      return 'V2铂金会员';
      break;
    case 2:
      return 'V3钻石会员';
      break;
    case 3:
      return 'V4星光会员';
      break;
    case 4:
      return 'V5星耀会员';
      break;
  }
};
//banner点击事件
const bannerHandler = (item, index) => {
  let buttonName = '';
  switch (index) {
    case 0:
      buttonName = '第一张焦点图';
      break;
    case 1:
      buttonName = '第二张焦点图';
      break;
    case 2:
      buttonName = '第三张焦点图';
      break;
    case 3:
      buttonName = '第四张焦点图';
      break;
  }

  md.sensorLogTake({
    xcxClick: '积分服务页-首屏页面点击',
    pageName: '积分服务页-首屏',
    buttonName: buttonName,
  });

  if (item?.url != '') {
    jump({
      type: item.type,
      url: item.url,
      extra: item.extra,
    });
  }
};

//攻略点击事件
const gonglueHandler = () => {
  md.sensorLogTake({
    xcxClick: '积分服务页-首屏页面点击',
    pageName: '积分服务页-首屏',
    buttonName: '攻略',
  });

  md.sensorComponentLogTake({
    xcxComponentClick: 'true',
    pageName: '积分服务页',
    componentName: '等级卡牌',
    componentContent: '查看升级攻略',
  });

  gotoGonglue();
  // const url = vipIntegral.value.gonglue.url;
  // const type = vipIntegral.value.gonglue.type;
  // jump({
  // 	type: type,
  // 	url: url
  // })
  console.log('gonglueHandler');
};

const gotoGonglue = async () => {
  console.log('gotoGonglue1111111111');
  const url = vipIntegral.value.gonglue.url;
  const type = vipIntegral.value.gonglue.type;
  jump({
    type: type,
    url: url,
  });
};

//积分详情点击事件---积分进度条容器
const integralHandler = () => {
  integralDetailHandler();
};

//会员规则
const vipRuleHandler = () => {
  md.sensorLogTake({
    xcxClick: '积分服务页-首屏页面点击',
    pageName: '积分服务页-首屏',
    buttonName: '会员规则入口',
  });

  const url = vipRule.value.url;
  const type = vipRule.value.type;
  jump({
    type: type,
    url: url,
  });
  console.log('vipRuleHandler');
};

//积分明细点击事件
const integralDetailHandler = () => {
  md.sensorLogTake({
    xcxClick: '积分服务页-首屏页面点击',
    pageName: '积分服务页-首屏',
    buttonName: '积分明细',
  });

  md.sensorComponentLogTake({
    xcxComponentClick: 'true',
    pageName: '积分服务页',
    componentName: '等级卡牌',
    componentContent: '累计积分',
  });
  const url = vipIntegral.value.jifenmingxi.url.replace('{crmid}', memberInfo.value.memberId);
  const type = vipIntegral.value.jifenmingxi.type;
  console.log('积分明细链接：==', url);

  jump({
    type: type,
    url: url,
  });
};

//会员活动swiper切换事件
const handleVipActiveSwipe = (e) => {
  const index = e.detail.current;
  const item = vipActive.value[index];
  console.log('vip-active-swiper切换:', { item, index });

  md.sensorComponentLogTake({
    xcxComponentExposure: 'true',
    pageName: '积分服务页',
    componentName: '会员活动',
    componentContent: item.title,
  });
};

//会员活动点击事件
const handleVipActiveClick = (index, item) => {
  console.log('handleVipActiveClick==：', item);
  let buttonName = '';
  buttonName = item?.title;
  // switch (index) {
  // 		case 0:
  // 			buttonName = '第一张焦点图';
  // 			break;
  // 		case 1:
  // 			buttonName = '第二张焦点图';
  // 			break;
  // 		case 2:
  // 			buttonName = '第三张焦点图';
  // 			break;
  // 	case 3:
  // 		buttonName = '第四张焦点图';
  // 		break;
  // 	case 4:
  // 		buttonName = '第五张焦点图';
  // 		break;
  // 	case 5:
  // 		buttonName = '第六张焦点图';
  // 		break;
  // 	case 6:
  // 		buttonName = '第七张焦点图';
  // 			break;
  // 	}

  md.sensorLogTake({
    xcxClick: '积分服务页',
    pageName: '会员活动',
    buttonName: buttonName,
  });

  const url = item?.url;
  const type = item?.type;
  const extra = item?.extra;

  jump({ type, url, extra });
};

//转换跳转类型
const convertType = (type, url, extra = {}) => {
  switch (type) {
    case 'MINI_APP_THIRD':
      return {
        type: JumpType.MINI,
        url: url,
        extra: extra,
      };
    case 'MINI_APP':
      return {
        type: JumpType.INNER,
        url: url,
      };
    case 'LINK':
      return {
        type: JumpType.H5,
        url: url,
      };
  }
};

//商品点击
const handleGoodsItemClick = throttleTap((goodsItem, googidx, event) => {
  console.log('handleGoodsItemClick：', goodsItem, googidx);

  if (event) {
    if (event.currentTarget.dataset.comlog) {
      md.sensorComponentLog(event);
    }
  }

  // const tabname = goodsDataArr[activeIndex.value].resourcePositionName;
  // const buttonName = goodsItem.goodsName;

  // md.sensorComponentLogTake({
  // 	xcxComponentClick: "true",
  // 	pageName: "积分服务页",
  // 	componentName: "积分商品",
  // 	componentContent: tabname + '-' + buttonName
  // });

  // let buttonName0 = '';
  // let buttonName1 = '';
  // switch (activeIndex.value) {
  // 	case 0:
  // 		buttonName0 = '品牌活动版分类1';
  // 		break;
  // 	case 1:
  // 		buttonName0 = '品牌活动版分类2';
  // 		break;
  // 	case 2:
  // 		buttonName0 = '品牌活动版分类3';
  // 		break;
  // }

  // buttonName1 = `-商品${googidx}`;
  // md.sensorLogTake({
  // 	xcxClick: "积分服务页-二屏页面点击",
  // 	pageName: "积分服务页-二三四屏",
  // 	buttonName: buttonName0 + buttonName1,
  // });

  //原逻辑
  // let item = productIdUrl.value[goodsItem][googidx - 1];
  // const url = item.url.replace('{productId}', item.productId).replace('{skuId}', item.skuId);
  // 	const type = item.type;
  // 	const extra = item.extra;

  //该B端配置后
  const url = goodsItem.url;
  const type = goodsItem.urlType;
  const extra = {
    appId: goodsItem.wxAppId,
    envVersion: goodsItem.envVersion,
  };

  console.log('goodsItem.url:', url);

  extra.embedded = true; //半屏拉起小程序

  jump({
    type: Number(type),
    url: url,
    extra: extra,
  });
}, 1000);

const handleScroll = (e) => {
  const currentIndex = e.detail.current;
  // console.log('当前swiper-item索引:', currentIndex);
  itemIndex.value = currentIndex;
  md.sensorComponentLogTake({
    xcxComponentClick: 'true',
    pageName: '积分服务页',
    componentName: '等级卡牌',
    componentContent: '等级卡牌切换',
  });

  vipCardMd(currentIndex);

  // 获取当前滚动位置
  // const scrollLeft = e.detail.scrollLeft;
  // const directionVal = ref(0.3);
  // if ((scrollLeft - lastScrollLeft.value) > 0) {
  // 	directionVal.value = 0.3;
  // }else{
  // 	directionVal.value = -0.3;
  // }
  // lastScrollLeft.value = scrollLeft;

  // itemIndex.value = Math.round(scrollLeft / itemWidth + directionVal.value);
};

//滚动结束时更新数据
const scrollToIndex = (index) => {};

const tabItemClick = (index, item) => {
  activeIndex.value = index;

  let buttonName = '';
  buttonName = item.resourcePositionName;
  // switch (index) {
  // 	case 0:
  // 		buttonName = '品牌活动版块部分-分类1';
  // 		break;
  // 	case 1:
  // 		buttonName = '品牌活动版块部分-分类2';
  // 		break;
  // 	case 2:
  // 		buttonName = '品牌活动版块部分-分类3';
  // 		break;
  // }

  // console.log('buttonName=', buttonName);

  md.sensorComponentLogTake({
    xcxComponentClick: 'true',
    pageName: '积分服务页',
    componentName: '积分商品tab选择',
    componentContent: buttonName,
  });

  md.sensorComponentLogTake({
    xcxComponentExposure: 'true',
    pageName: '积分服务页',
    componentName: '积分商品tab选择',
    componentContent: buttonName,
  });
  // md.sensorLogTake({
  // 	xcxClick: "积分服务页-二屏页面点击",
  // 	pageName: "积分服务页-二屏",
  // 	buttonName: buttonName,
  // });
};

// 处理查看更多点击
const handleMoreClick = () => {
  const url = clickMore.value.url;
  const type = clickMore.value.type;
  const extra = clickMore.value.extra;

  jump({
    type: type,
    url: url,
    extra: extra,
  });
};

//积分兑换按钮点击事件
const handleExchargeClick = () => {
  md.sensorLogTake({
    xcxClick: '积分服务页-首屏页面点击',
    pageName: '积分服务页-首屏',
    buttonName: '积分兑换',
  });

  const url = vipIntegral.value.excharge.url;
  const type = vipIntegral.value.excharge.type;
  const extra = vipIntegral.value.excharge.extra;

  jump({
    type: type,
    url: url,
    extra: extra,
  });
};

//会员权益点击跳转
const handlePrivilegeClick = (item, index) => {
  if (!islogin.value) {
    needReinit.value = true;
    jump({
      type: JumpType.INNER,
      url: '/pages/activity/register',
    });
    return;
  }

  // jump({
  // 	type: JumpType.H5,
  // 	url: "https://fh0926-activity.dexfu.cn/customShare/share?id=Did1NjI1NTE"
  // })
  // return;

  selectIdx.value = index;
  if (!isshowShouqi.value) {
    isshowShouqi.value = true;
  }

  if (!isshowQuanyiDetail.value) {
    isshowQuanyiDetail.value = true;
  }

  md.sensorLogTake({
    xcxClick: '积分服务页-首屏页面点击',
    pageName: '积分服务页-首屏',
    buttonName: `${item.name}`,
  });
  md.sensorComponentLogTake({
    xcxComponentClick: 'true',
    pageName: '积分服务页',
    componentName: '会员权益',
    componentContent: '会员权益-' + item.name,
  });
  console.log('selectIdx.value=', selectIdx.value);

  // const url = vipQuanyiUrl.value.url;
  // const type = vipQuanyiUrl.value.type;
  // const extra = vipQuanyiUrl.value.extra;

  // jump({
  // 	type: type,
  // 	url: url,
  // 	extra:extra
  // })
};

const navigateToRegister = async (e) => {
  console.log('获取手机号码', e);

  jump({
    type: JumpType.INNER,
    url: '/pages/activity/register',
  });
};

// 处理注册确认
const handleRegisterConfirm = async (babyInfo) => {
  console.log('注册确认，宝宝信息:', babyInfo);
  await userStore.loadMemberInfo();
  showRegisterLayer.value = false;
  initNetData();
};

// 处理注册取消
const handleRegisterCancel = () => {
  showRegisterLayer.value = false;
  console.log('注册取消');
};

// 优惠券点击事件处理
const handleCouponClick = (data) => {
  console.log('优惠券点击:', data.index, data.couponIndex);
  // 这里可以添加优惠券点击的具体逻辑
  // 比如跳转到对应的商品页面或显示优惠券详情
};

// 去星妈优选按钮点击事件处理
const handleGoToShop = (data) => {
  console.log('去星妈优选:', data.index);
  // 这里可以添加跳转到星妈优选的逻辑
  // 比如跳转到商城页面或相关活动页面
};

const handleGoToShop_mainfeiwenzhen = async (data) => {
  console.log('免费问诊:', data.index);
  const res = await getHealthField();

  if (!res.success) {
    uni.showToast({
      title: '获取健康字段失败',
      icon: 'none',
    });
    return;
  }

  const { sign, timestamp, appId, partnerUserId, env } = res.data;

  jump({
    type: JumpType.MINI,
    url: '/pages/partner/redirect',
    extra: {
      appId: 'wx81ecfb5aa3fb512f',
      envVersion: env,
      extraData: {
        sign, // 参考 4.请求参数
        timestamp, // 参考 4.请求参数
        appId, // 参考 4.请求参数
        partnerUserId, // 参考 4.请求参数
        targetApp: '/h5/partner/shining-like-a-start/landing-free-consult?sysType=CRF',
      },
    },
  });
};

const handleGoToShop_aibenxinrenli = (data) => {
  if (Number(data.index) === 0) {
    gotoGonglue();
  }
};

const handleGoToShop_zhuanduanli = (data) => {
  console.log('转段礼', data.index);
  if (Number(data.index) === 0) {
    gotoGonglue();
  }
};

const handleGoToShop_jinjili = (data) => {
  console.log('晋级礼', data.index);
  if (Number(data.index) === 0 || Number(data.index) === 1) {
    gotoGonglue();
  }
};

// 页面跳转-添加宝宝
const navigateTo = (url) => {
  uni.navigateTo({
    url,
    animationDuration: 0,
    fail: (err) => {
      console.error('页面跳转失败:', err);
      uni.showToast({
        title: '页面跳转失败',
        icon: 'none',
      });
    },
  });
};

const handleGoToShop_shengrili = async (data) => {
  console.log('生日礼', data.index);
  // debugger;
  const userStore = data.userStore;
  if (
    !(userStore.babyInfo?.allBabyBaseInfo && userStore.babyInfo?.allBabyBaseInfo.length > 0) &&
    islogin.value
  ) {
    //没有宝宝，跳转到添加宝宝页面
    if (itemIndex.value < 2) {
      gotoGonglue();
    } else {
      showShengriliTipPanel.value = true;
    }
    return;
  } else {
    if (userStore.babyInfo?.allBabyBaseInfo?.some((baby) => baby.babyStage == 2)) {
    } else {
      if (itemIndex.value < 2) {
        gotoGonglue();
      } else {
        showShengriliTipPanel.value = true;
      }
      return;
    }
  }

  switch (data.index) {
    case 4000:
      if (memberInfo.value?.grade < 2) {
        gotoGonglue();
      }
      break;
    case 3000:
      //去领取
      const data = await fetchBatchReceiveJSON();
      console.log('data22222==', data);
      // const data = {"code":"000000","data":{"babyInfo":[{"babyBirthday":"2025-08-01","babyName":"男宝","babyNum":1}],"clientOpenId":"string","equityCode":"string","grade":"2","memberId":"CRM000000000948094264","status":3000,"statusName":"string","subStatus":0,"subStatusName":"string","traceId":"string"},"message":"success","ok":true,"success":true}
      if (data.success) {
        showPopupShengri.value = true;
      }
      break;

    case 2000:
      //去升级
      gotoGonglue();
      break;

    case 1000:
      jump(quanyitiaozhuanInfo?.value?.shengrili?.qushiyong);
      //去使用
      break;
    default:
      //去领取
      break;
  }
};

const handleGoToShop_suyuanyou = (data) => {
  if (data.index < 3) {
    gotoGonglue();
  } else {
    jump(quanyitiaozhuanInfo?.value?.suyuanyou?.qubaoming);
  }
};

const handleVipClick = () => {
  if (!islogin.value) {
    needReinit.value = true;
    jump({
      type: JumpType.INNER,
      url: '/pages/activity/register',
    });
    return;
  }

  vipCardMd(vipLevel.value, false);
  const item = vipIntegral.value.vipCardInfo;

  console.log('item66666777777:', item);
  if (item.url == '') {
    return;
  }

  jump({
    type: item.type,
    url: item.url,
    extra: item.extra,
  });
  // if(islogin.value){
  // 	// console.log('点击了vip等级：',index);
  // }else{
  // }
};

// 帮助图标点击事件
const handleHelpClick = () => {
  console.log('帮助图标点击');
  showSignRuleDes.value = true;
};

// 签到按钮点击事件
const handleSigninClick = throttleTap(async () => {
  console.log('签到按钮点击');

  md.sensorComponentLogTake({
    xcxComponentClick: 'true',
    pageName: '积分服务页',
    componentName: '签到组件',
    componentContent: '立即签到',
  });

  if (!islogin.value) {
    needReinit.value = true;
    jump({
      type: JumpType.INNER,
      url: '/pages/activity/register',
    });
    return;
  }

  const data = await integralStore.checkIn(signinInfo.value.id);
  console.log('datacheckIn=', data);
  if (data.success) {
    showSignedTips.value = true;
    earnedPoints.value = data?.data?.credits;
    await integralStore.getSigninAndTaskInfo();
    console.log('5555555');
    initSignin();
  } else {
    uni.showToast({
      title: '签到失败，请稍后重试',
      icon: 'none',
    });
  }
}, 1000);

// 关闭签到提示弹窗
const handleCloseSignedTips = () => {
  showSignedTips.value = false;
};

// 关闭签到规则说明弹窗
const handleCloseSignRuleDes = () => {
  showSignRuleDes.value = false;
};

// 关闭分享登录弹窗
const handleCloseSharePopLogin = () => {
  showSharePopLogin.value = false;
  globalStore.invateUseType = ''; // 清除用户类型
};

// 关闭分享未登录弹窗
const handleCloseShareNPopNoLogin = () => {
  showShareNPopNoLogin.value = false;
  globalStore.invateUseType = ''; // 清除用户类型
};

// 查看权益按钮点击
const handleViewBenefits = () => {
  console.log('查看我的权益');
};

// 任务按钮点击事件
const handleTaskButtonClick = () => {
  // jump({
  // 	type: JumpType.INNER,
  // 	url: '/activities/1015/home'
  // })
  // return

  console.log('任务按钮点击');
  console.log('taskTodo数据:', integralStore?.signinAndTaskInfo?.data?.taskTodo);
  globalStore.showTaskPop(integralStore?.signinAndTaskInfo?.data?.taskTodo);
};

// 关闭公众号弹窗
const handleCloseGongzhonghaoPop = () => {
  showGongzhonghaoPop.value = false;
};

// 处理异业券兑换点击
const handleExchangeClick = throttleTap((benefit, index, event) => {
  console.log('兑换权益:', benefit);

  if (event) {
    if (event.currentTarget.dataset.comlog) {
      md.sensorComponentLog(event);
    }
  }

  // md.sensorComponentLogTake({
  // 	xcxComponentClick: "true",
  // 	pageName: "积分服务页",
  // 	componentName: "异业券权益",
  // 	componentContent: benefit.goodsName
  // });

  if (!islogin.value) {
    needReinit.value = true;
    jump({
      type: JumpType.INNER,
      url: '/pages/activity/register',
    });
    return;
  }

  jump({
    type: JumpType.INNER,
    url: `/v3/goodDetail/goodDetail?gid=${benefit.appGoodsId}&orderSubSource=resource`,
  });
  // 如果有跳转链接，则跳转
  // if (benefit.url) {
  // 	const extra = {
  // 		appId: benefit.wxAppId,
  // 		envVersion: benefit.envVersion
  // 	};

  // 	jump({
  // 		type: benefit.urlType,
  // 		url: benefit.url,
  // 		extra: extra
  // 	});
  // } else {
  // 	// 这里可以添加兑换逻辑
  // 	uni.showToast({
  // 		title: `兑换${benefit.name}成功`,
  // 		icon: 'success'
  // 	});
  // }
}, 1000);

// 处理邀请按钮点击
const handleInviteClick = () => {
  console.log('去邀请按钮点击');

  md.sensorComponentLogTake({
    xcxComponentClick: 'true',
    pageName: '积分服务页',
    componentName: '邀请组件',
    componentContent: '去邀请',
  });
  console.log('islogin.valuehandleInviteClick=', islogin.value);
  if (!islogin.value) {
    needReinit.value = true;
    jump({
      type: JumpType.INNER,
      url: '/pages/activity/register',
    });
    return;
  }

  // 主动调起微信小程序分享面板
  console.log('准备调起分享面板');

  // 方法1：使用 showShareMenu
  // uni.showShareMenu({
  // 	withShareTicket: true,
  // 	menus: ['shareAppMessage', 'shareTimeline'],
  // 	success: (res) => {
  // 		console.log('showShareMenu 成功:', res);
  // 	},
  // 	fail: (err) => {
  // 		console.error('showShareMenu 失败:', err);
  // 		// 备用方案：显示提示用户手动分享
  // 		uni.showModal({
  // 			title: '分享提示',
  // 			content: '请点击右上角菜单选择分享给好友或朋友圈',
  // 			showCancel: false,
  // 			confirmText: '知道了'
  // 		});
  // 	}
  // });

  // 展示邀请得礼弹窗
  // globalStore.isShowInvitePrizePanel = true;
};

// 处理邀请记录按钮点击
const handleRecordClick = () => {
  console.log('邀请记录按钮点击');
  md.sensorComponentLogTake({
    xcxComponentClick: 'true',
    pageName: '积分服务页',
    componentName: '邀请组件',
    componentContent: '邀请记录',
  });

  if (!islogin.value) {
    needReinit.value = true;
    jump({
      type: JumpType.INNER,
      url: '/pages/activity/register',
    });
    return;
  }

  // 埋点统计
  md.sensorLogTake({
    xcxClick: '积分服务页-邀请得好礼页面点击',
    pageName: '积分服务页-邀请得好礼',
    buttonName: '邀请记录',
  });

  //展示邀请记录页面
  jump({
    type: 1,
    url: '/pages/invate/invaterecords',
  });
};

// 手动显示注册层（用于测试）
// const showRegisterDialog = () => {
// 	console.log('手动显示注册层');
// 	showRegisterLayer.value = true;
// }

// 添加 watch 监听 showRegisterLayer 变化
// watch(showRegisterLayer, (newVal, oldVal) => {
// 	console.log('showRegisterLayer 状态变化:', {
// 		旧值: oldVal,
// 		新值: newVal,
// 		时间: new Date().toLocaleString()
// 	});
// }, { immediate: true });

// // 分享配置
// onShareAppMessage((e) => {
//   console.log('onShareAppMessage e1111:', e);

//   if (e.from === 'button') {
//     return {
//       title: integralStore.originInviteHome?.data?.invitationText,
//       path: '/pages/invate/sharepage' + '?inviteCode=' + integralStore.originInviteHome?.data?.invitationCode,
//       imageUrl:
//         integralStore.originInviteHome?.data?.invitationImageUrl ||
//         'https://course.feihe.com/momclub-picture/integral/1023/invate_star_character1023.png',
//     };
//   }

//   return {
//     title: '星妈会 | 解锁你的会员服务',
//     path: '/pages/index/index?pageType=integral',
//     imageUrl:'https://course.feihe.com/momclub-picture/common/shareImg.png',
//   };
  
// });
</script>

<style lang="less" scoped>
@import '@/common.less';
@import './Integral.less';
</style>
