<template>
    <cwg-page-wrapper class="create-page" :isHeaderFixed="true">


        <view class="container">
            <view
                class="app-page-head card-header d-flex gap-3 flex-wrap align-items-center justify-content-between border-0">
                <view class="app-page-head mb-0">
                    <h1 class="app-page-title" v-t="'Home.page_customer.item6'"></h1>
                </view>
            </view>
            <view class="table-loading-mask">
                <uni-loading v-if="pictLoading" />
            </view>
            <view class="col-xxl-12 mb-4" v-if="!pictLoading">
                <view class="row">
                    <!-- <view class="col-12 m-b30">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-4">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">
                                        <image src="/static/images/vu/promotion-1.jpg" alt=""
                                            class="img-fluid rounded" mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100 bg-dark bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <a href="#"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</a>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2"> <a href="#"
                                            class="badge badge-sm bg-secondary mb-1">28 Apr, 2026</a>
                                        <h4> <a href="#" class="text-dark">Monthly Trading Challenge</a> </h4>
                                        <view>Complete Trading Targets · Enjoy Multi-Tier Exclusive Gifts</view>
                                        <button type="submit" value="Submit"
                                            class="btn btn-danger mb-3 waves-effect waves-light">Join Now</button>
                                        <button type="submit" value="Submit"
                                            class="btn btn-outline-dark1 mb-3 waves-effect waves-light">Event
                                            Terms</button>
                                        <button type="submit" value="Submit"
                                            class="btn btn-outline-dark1 mb-3 waves-effect waves-light">Participation
                                            Method</button>
                                        <button type="submit" value="Submit"
                                            class="btn btn-outline-dark1 mb-3 waves-effect waves-light">Mission
                                            List</button>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <view class="col-12 m-b30">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-4">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">
                                        <image src="/static/images/vu/promotion.png" alt="" class="img-fluid rounded" mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100 bg-dark bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <a href="#"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</a>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2"><a href="#"
                                            class="badge badge-sm bg-secondary mb-1">28 Apr, 2026</a>
                                        <h4> <a href="#" class="text-dark">CWG Monthly Premium Bonus</a> </h4>
                                        <view>Deposit now to receive generous bonuses of up to $5000! The more you
                                            deposit,
                                            the higher the reward, making every investment more valuable!</view>
                                        <button type="submit" value="Submit"
                                            class="btn btn-danger mb-3 waves-effect waves-light">Join Now</button>
                                        <button type="submit" value="Submit"
                                            class="btn btn-outline-dark1 mb-3 waves-effect waves-light">Event
                                            Terms</button>
                                        <button type="submit" value="Submit"
                                            class="btn btn-outline-dark1 mb-3 waves-effect waves-light">Participation
                                            Method</button>
                                        <button type="submit" value="Submit"
                                            class="btn btn-outline-dark1 mb-3 waves-effect waves-light">Mission
                                            List</button>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view> -->

                    <!-- 月度活动 -->
                    <view class="col-12 m-b30" v-if="country == 'CN'">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-3">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">
                                        <image src="/static/images/yue.jpg" alt="" class="img-fluid rounded"
                                            mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100 bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <a @click="openSurplusActivityDialog1()"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</a>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2">
                                        <h4> <text class="text-dark crm-one-font"
                                                v-t="'MonthlyActivities.item1'"></text> </h4>
                                        <view class="crm-one-font"></view>
                                        <view class="d-flex flex-wrap gap-2">
                                            <view
                                                :class="['btn btn-dark waves-effect waves-light', monthlyGive ? 'btn-danger' : 'disabled']"
                                                @click="openSurplusActivityDialog1()">
                                                <text v-t="'news_add_field1.activities10_trading_aoyun.item3'"></text>
                                            </view>
                                            <cwg-link type="pdf" class="btn btn-outline-dark1 waves-effect waves-light"
                                                target="_blank" title="wallet.item15"
                                                :url="`pdf/pdf13/CWG Prime Bonus-cn.pdf`" />
                                            <cwg-link type="pdf" class="btn btn-outline-dark1 waves-effect waves-light"
                                                target="_blank" title="Transfer.item7"
                                                :url="`pdf/pdf13/CWG Markets Prime Bonus Application Process-cn.pdf`" />
                                            <view class="btn btn-outline-dark1 waves-effect waves-light"
                                                @click="goMonthlyTaskList()">
                                                <text v-t="'wallet.item14'"></text>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <!-- 赠金活动 -->
                    <view class="col-12 m-b30">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-3">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">
                                        <image src="/static/images/su.png" alt="" class="img-fluid rounded"
                                            mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100 bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <a @click="openSurplusActivityDialog()"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</a>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2">
                                        <h4> <text class="text-dark crm-one-font" v-t="'surplusList.item1'"></text>
                                        </h4>
                                        <p class="crm-one-font lh-sm" v-t="'surplusList.item2'"></p>
                                        <view class="d-flex flex-wrap gap-2">
                                            <view
                                                :class="['btn btn-dark waves-effect waves-light', surplusGive ? 'btn-danger' : 'disabled']"
                                                @click="openSurplusActivityDialog()">
                                                <text v-t="'news_add_field1.activities10_trading_aoyun.item3'"></text>
                                            </view>
                                            <cwg-link type="pdf" class="btn btn-outline-dark1 waves-effect waves-light"
                                                target="_blank" title="wallet.item15"
                                                :url="`pdf/pdf12/CWG Prime Bonus-${locale}.pdf`" />
                                            <cwg-link type="pdf"
                                                v-if="locale == 'cn' || locale == 'zhHant' || locale == 'en'"
                                                class="btn btn-outline-dark1 waves-effect waves-light" target="_blank"
                                                title="Transfer.item7"
                                                :url="`pdf/pdf12/CWG Markets Prime Bonus Application Process-${locale}.pdf`" />
                                            <cwg-link type="pdf" v-else
                                                class="btn btn-outline-dark1 waves-effect waves-light" target="_blank"
                                                title="Transfer.item7"
                                                :url="`pdf/pdf12/CWG Markets Prime Bonus Application Process-en.pdf`" />
                                            <view class="btn btn-outline-dark1 waves-effect waves-light"
                                                @click="goSurplusTaskList()">
                                                <text v-t="'wallet.item14'"></text>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>



                    <!-- 美金活动（/custom/activity/shows/info dollar） -->
                    <view class="col-12 m-b30" v-if="dollarActivity">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-3">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">

                                        <image v-if="dollarCoverSrc" :src="dollarCoverSrc" alt=""
                                            class="img-fluid rounded" mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100 bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <view @click="openDollarParticipate"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</view>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2">
                                        <h4> <text class="text-dark crm-one-font" v-if="dollarActivity.title">{{
                                            dollarActivity.title }}</text>
                                        </h4>
                                        <p class="crm-one-font lh-sm" v-if="dollarActivity.subTitle">
                                            {{ dollarActivity.subTitle }}</p>
                                        <view class="d-flex flex-wrap gap-2">
                                            <view
                                                :class="['btn btn-dark waves-effect waves-light', dollarParticipateEnabled ? 'btn-danger' : 'disabled']"
                                                @click="openDollarParticipate">
                                                <text v-t="'DollarActivity.participate'"></text>
                                            </view>
                                            <view class="btn btn-outline-dark1 waves-effect waves-light"
                                                @click="goDollarTaskList">
                                                <text v-t="'wallet.item14'"></text>
                                            </view>
                                            <view v-if="dollarActivity.content"
                                                class="btn btn-outline-dark1 waves-effect waves-light"
                                                @click="goDollarActivityDetail">
                                                <text v-t="'DollarActivity.activityDetails'"></text>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <!-- 无忧交易 -->
                    <view class="col-12 m-b30" v-if="tableDataNoWorriesFlag">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-3">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">
                                        <image src="/static/images/jihua.png" alt="" class="img-fluid rounded"
                                            mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100 bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <a @click="toSingle('NoWorries')"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</a>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2">
                                        <h4 @click="toSingle('NoWorries')"> <text class="text-dark crm-one-font"
                                                v-t="'news_add_field1.activitiesNoWorries.item1'"></text>
                                        </h4>
                                        <p class="crm-one-font lh-sm" v-t="'news_add_field1.activitiesNoWorries.item2'">
                                        </p>
                                        <view class="d-flex flex-wrap gap-2">
                                            <view v-if="typeof tableDataNoWorries == 'boolean' && tableDataNoWorries"
                                                :class="['btn btn-dark waves-effect waves-light', 'btn-danger']"
                                                @click="toApplyNoWorriesOpen()">
                                                <text v-t="'news_add_field1.activitiesNoWorries.item3'"></text>
                                            </view>
                                            <view
                                                :class="['btn btn-dark waves-effect waves-light', isRealizationNoWorries == 1 ? 'btn-danger' : 'disabled']"
                                                @click="toRealizationNoWorries()">
                                                <text v-t="'news_add_field1.activitiesNoWorries.item4'"></text>
                                            </view>
                                            <view @click="toSingle('NoWorries')"
                                                :class="['btn btn-outline-dark1 waves-effect waves-light']">
                                                <text v-t="'news_add_field1.activitiesNoWorries.item5'"></text>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <!-- 交易大赛 -->
                    <view class="col-12 m-b30" v-if="tableDataCptFlag">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-3">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">
                                        <image src="/static/images/banner.jpg" alt="" class="img-fluid rounded"
                                            mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100  bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <a @click="toApplyCptOpen()"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</a>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2">
                                        <h4> <text class="text-dark crm-one-font"
                                                v-t="'news_add_field1.activitiesJYDS2025.item1'"></text> </h4>
                                        <p class="crm-one-font" v-t="'news_add_field1.activitiesJYDS2025.item2'">
                                        </p>
                                        <view class="d-flex flex-wrap gap-2">
                                            <view class="btn btn-danger  waves-effect waves-light"
                                                v-if="tableDataCpt.signStatus == 0" @click="toApplyCptOpen()">
                                                <text v-t="'news_add_field1.activitiesJYDS.item3'"></text>
                                            </view>
                                            <view class="btn btn-dark waves-effect waves-light"
                                                v-if="tableDataCpt.signStatus == 1">
                                                <text v-t="'news_add_field1.activitiesJYDS.item3_1'"></text>
                                            </view>
                                            <view class="btn btn-outline-dark1  waves-effect waves-light"
                                                @click="toSingle('23xinjia')">
                                                <text v-t="'news_add_field1.activitiesJYDS.item4'"></text>
                                            </view>
                                            <view class="btn btn-outline-dark1  waves-effect waves-light"
                                                @click="toOpenSingle(tableDataCpt.pageAddress)">
                                                <text v-t="'news_add_field1.activitiesJYDS.item4_1'"></text>
                                            </view>
                                        </view>

                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <!-- 24精英杯活动 -->
                    <!-- 赠送活动列表2 -->
                    <view class="col-12 m-b30" v-for="(item, index) in tableDataGive" :key="index + 'give'">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-3" v-if="item.coverUrl">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">
                                        <image :src="imgUrl + item.coverUrl" alt="" class="img-fluid rounded"
                                            mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100  bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <a @click="toActivity24nianzhong()"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</a>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2">
                                        <h4> <text class="text-dark crm-one-font">{{ item.title }}</text> </h4>
                                        <p class="crm-one-font">{{ item.subTitle }}</p>
                                        <view class="d-flex flex-wrap gap-2">
                                            <view
                                                :class="['btn btn-dark waves-effect waves-light', item.valid == 1 ? 'btn-danger' : 'disabled']"
                                                @click="toActivity24nianzhong()">
                                                <text v-t="'Custom.Activity.Apply'"></text>
                                            </view>
                                            <view class="btn btn-outline-dark1  waves-effect waves-light"
                                                @click="toSingle('newList', item.id)">
                                                <text v-t="'Custom.Activity.Single'"></text>
                                            </view>
                                        </view>

                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                    <!-- 活动列表 -->
                    <view class="col-12 m-b30" v-for="(item, index) in tableData" :key="index + 'tttt'">
                        <view class="card card-action action-elevate action-border-primary">
                            <view class="row g-0">
                                <view class="col-md-3" v-if="item.coverUrl">
                                    <view class="card-header border-0 p-0 m-2 position-relative overflow-hidden">
                                        <image :src="imgUrl + item.coverUrl" alt="" class="img-fluid rounded"
                                            mode="widthFix" />
                                        <view
                                            class="position-absolute action-visible top-0 start-0 h-100 w-100  bg-opacity-50 rounded d-flex align-items-center justify-content-center">
                                            <a @click="applications(item)"
                                                class="btn btn-icon btn-lg btn-secondary rounded-circle waves-effect waves-light">
                                                →</a>
                                        </view>
                                    </view>
                                </view>
                                <view class="col-md-8 py-3 d-flex flex-column">
                                    <view class="card-body px-3 py-2">
                                        <h4> <text class="text-dark crm-one-font">{{ item.title }}</text> </h4>
                                        <p class="crm-one-font">{{ item.subTitle }}</p>
                                        <view class="d-flex flex-wrap gap-2">
                                            <view
                                                :class="['btn btn-dark waves-effect waves-light', overdue(item.startTime, item.endTime) ? 'btn-danger' : 'disabled']"
                                                @click="applications(item)">
                                                <text v-t="'Custom.Activity.Apply'"></text>
                                            </view>
                                            <view type="submit" value="Submit"
                                                class="btn btn-outline-dark1 waves-effect waves-light"
                                                @click="checkActivity(item)">
                                                <text v-t="'Custom.Activity.List'"></text>
                                            </view>
                                            <view type="submit" value="Submit"
                                                class="btn btn-outline-dark1 waves-effect waves-light"
                                                @click="toSingle(item.id)">
                                                <text v-t="'Custom.Activity.Single'"></text>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
            </view>
        </view>


        <!--弹出框-->
        <cwg-popup v-model:visible="dialogChinaUnionPay" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="des1" style="font-size: 16px; line-height: 1.6; margin: 30px 0 50px"
                    v-html="t('news_add_field1.activities.item11')"></view>
            </view>
            <template #footer>
                <button type="primary" @click="toTransformActive">{{ t('Btn.Confirm') }}</button>
                <button @click="dialogChinaUnionPay = false">{{ t('Btn.Cancel') }}</button>
            </template>
        </cwg-popup>
        <!-- 23匠鑫活动过期弹出框 -->
        <cwg-popup v-model:visible="dialogChinaUnionPayJX" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="des1" style="font-size: 16px; line-height: 1.6; margin: 30px 0 50px"
                    v-html="t('news_add_field1.activitiesJX.item24')"></view>
            </view>
            <template #footer>
                <button type="primary" @click="dialogChinaUnionPayJX = false">{{ t('Btn.Confirm') }}</button>
                <button @click="dialogChinaUnionPayJX = false">{{ t('Btn.Cancel') }}</button>
            </template>
        </cwg-popup>

        <!--弹出框-->
        <cwg-popup v-model:visible="dialogChinaUnionPay1" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="des1" style="font-size: 16px; line-height: 1.6; margin: 30px 0 50px"
                    v-html="t('news_add_field1.activities.item12')"></view>
            </view>
            <template #footer>
                <button type="primary" @click="toRealizationActive">{{ t('Btn.Confirm') }}</button>
                <button @click="dialogChinaUnionPay1 = false">{{ t('Btn.Cancel') }}</button>
            </template>
        </cwg-popup>

        <!--23活动申请弹出-->
        <cwg-popup v-model:visible="dialogDealResult" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="content" style="font-size: 14px; text-align: left">
                    <form :rules="rules" :model="dialogDealResult_form" label-position="top">
                        <view class="form-item">
                            <view class="form-label">{{ t('Label.TradingAccount') }}</view>
                            <picker mode="selector" :range="loginOptions" :range-key="'label'"
                                @change="onDialogDealResultLoginChange">
                                <view class="picker-input">
                                    {{ dialogDealResult_form.login || t('placeholder.choose') }}
                                </view>
                            </picker>
                        </view>
                    </form>

                </view>
            </view>
            <template #footer>
                <button type="primary" @click="toApply23">{{ t('Btn.Confirm') }}</button>
                <button @click="toApply23Cancel">{{ t('Btn.Cancel') }}</button>
            </template>
        </cwg-popup>

        <!--23匠鑫活动申请弹出-->
        <cwg-popup v-model:visible="dialogDealResultJx" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="content" style="font-size: 14px; text-align: left">
                    <form :rules="rules" :model="dialogDealResultJx_form" label-position="top">
                        <view class="form-item">
                            <view class="form-label">{{ t('Label.TradingAccount') }}</view>
                            <picker mode="selector" :range="loginOptions" :range-key="'label'"
                                @change="onDialogDealResultJxLoginChange">
                                <view class="picker-input">
                                    {{ dialogDealResultJx_form.login || t('placeholder.choose') }}
                                </view>
                            </picker>
                        </view>
                    </form>

                </view>
            </view>
            <template #footer>
                <button type="primary" @click="toApply23Jx">{{ t('Btn.Confirm') }}</button>
                <button @click="toApply23JxCancel">{{ t('Btn.Cancel') }}</button>
            </template>
        </cwg-popup>

        <!--23匠鑫活动申请弹出-->
        <cwg-popup v-model:visible="dialogDealResultJxVip" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="content" style="font-size: 14px; text-align: left">
                    <form :rules="rules" :model="dialogDealResultJx_formVip" label-position="top">
                        <view class="form-item">
                            <view class="form-label">{{ t('Label.TradingAccount') }}</view>
                            <picker mode="selector" :range="loginOptions" :range-key="'label'"
                                @change="onDialogDealResultJxVipLoginChange">
                                <view class="picker-input">
                                    {{ dialogDealResultJx_formVip.login || t('placeholder.choose') }}
                                </view>
                            </picker>
                        </view>
                    </form>

                </view>
            </view>
            <template #footer>
                <button type="primary" @click="toApply23JxVip">{{ t('Btn.Confirm') }}</button>
                <button @click="toApply23JxCancelVip">{{ t('Btn.Cancel') }}</button>
            </template>
        </cwg-popup>

        <!--交易大赛活动申请弹出-->
        <cwg-popup v-model:visible="dialogDealResultCpt" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="content" style="font-size: 14px; text-align: left">
                    <form :rules="rules" :model="dialogDealResultCpt_form" label-position="top">
                        <view class="form-item">
                            <view class="form-label">{{ t('Label.TradingAccount') }}</view>
                            <picker mode="selector" :range="loginOptions" :range-key="'label'"
                                @change="onDialogDealResultCptLoginChange">
                                <view class="picker-input">
                                    {{ dialogDealResultCpt_form.login || t('placeholder.choose') }}
                                </view>
                            </picker>
                        </view>
                        <view class="form-item">
                            <view class="form-label">{{ t('Documentary.console.item20') }}</view>
                            <input class="form-input" v-model="dialogDealResultCpt_form.nickname" type="text" />
                        </view>
                        <view class="form-item">
                            <view class="form-label">{{ t('news_add_field1.activitiesJYDS.item4_3') }}</view>
                            <input class="form-input" v-model="dialogDealResultCpt_form.recipient" type="text" />
                        </view>
                        <view class="form-item">
                            <view class="form-label">{{ t('news_add_field1.activitiesJYDS.item4_2') }}</view>
                            <input class="form-input" v-model="dialogDealResultCpt_form.mobile" type="text" />
                        </view>
                        <view class="form-item">
                            <view class="form-label">{{ t('Shop.Address.DetailedAddress') }}</view>
                            <input class="form-input" v-model="dialogDealResultCpt_form.address" type="text" />
                        </view>
                        <view v-html="t('news_add_field1.activitiesJYDS.item4_4')"></view>
                    </form>

                </view>
            </view>
            <template #footer>
                <button type="primary" @click="toApplyCpt">{{ t('Btn.Confirm') }}</button>
                <button @click="toApplyCptCancel">{{ t('Btn.Cancel') }}</button>
            </template>
        </cwg-popup>

        <!--任务提示弹出框-->
        <cwg-popup v-model:visible="dialogNewTask" :title="t('wallet.item16')" type="center" :mask-click="false"
            :show-footers="true">
            <view class="dia-content">
                <view class="des1" style="font-size: 14px; line-height: 1.6; margin: 30px 0 50px">
                    <text v-html="t('wallet.item17')"></text>{{ newTaskList.endTime }}
                    <text v-html="t('wallet.item18')"></text>{{ newTaskList.tradeVolume }}
                    <text v-html="t('wallet.item19')"></text>{{ newTaskList.raffleNumber }}
                    <text v-html="t('wallet.item20')"></text>
                </view>

            </view>
            <template #footer>
                <button type="primary" @click="dialogNewTask = false">{{ t('Btn.Confirm') }}</button>
                <button @click="dialogNewTask = false">{{ t('Home.msg.item3') }}</button>
            </template>
        </cwg-popup>

        <!--抽奖弹出框-->
        <cwg-popup v-model:visible="dialogNewTaskDraw" :title="t('wallet.item65')" type="center" :mask-click="false"
            :show-footers="true" width="800px">
            <view class="dia-content">
                <DrawLotteryRaffle :curLuckyDrawTimesF="LuckyDrawsNumber"></DrawLotteryRaffle>

            </view>
            <template #footer>
                <button @click="closedialogNewTaskDraw">{{ t('Home.msg.item3') }}</button>
            </template>
        </cwg-popup>

        <!--24精英杯活动申请弹出-->
        <cwg-popup v-model:visible="dialogDealResultJxJYB" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="content" style="font-size: 14px; text-align: left">
                    <form :rules="rules" :model="dialogDealResultJx_formJYB" label-position="top">
                        <view class="form-item">
                            <view class="form-label">{{ t('Label.TradingAccount') }}</view>
                            <picker mode="selector" :range="loginOptions" :range-key="'label'"
                                @change="onDialogDealResultJxJYBLoginChange">
                                <view class="picker-input">
                                    {{ dialogDealResultJx_formJYB.login || t('placeholder.choose') }}
                                </view>
                            </picker>
                        </view>
                    </form>

                </view>
            </view>
            <template #footer>
                <button type="primary" @click="toApply24JYBVip">{{ t('Btn.Confirm') }}</button>
                <button @click="toApply24JYBCancelVip">{{ t('Btn.Cancel') }}</button>
            </template>
        </cwg-popup>

        <!--24无忧交易申请弹出-->
        <cwg-popup v-model:visible="dialogDealResultNoWorries" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="content" style="font-size: 14px; text-align: left">
                    <form :rules="rules" :model="dialogDeal_formNoWorries" label-position="top">
                        <view class="form-item">
                            <view class="form-label">{{ t('Label.TradingAccount') }}</view>
                            <picker mode="selector" :range="loginOptions" :range-key="'label'"
                                @change="onDialogDeal_formNoWorriesLoginChange">
                                <view class="picker-input">
                                    {{ dialogDeal_formNoWorries.login || t('placeholder.choose') }}
                                </view>
                            </picker>
                        </view>
                    </form>

                </view>
            </view>
            <template #footer>
                <button type="primary" @click="toApplyNoWorries">{{
                    t('news_add_field1.activitiesNoWorries.item6_1') }}</button>
                <button @click="toApplyNoWorriesCancel">{{ t('news_add_field1.activitiesNoWorries.item6_2')
                }}</button>
            </template>
        </cwg-popup>

        <!--盈利转换弹出框-->
        <cwg-popup v-model:visible="dialogNoWorries" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="des1" style="font-size: 16px; line-height: 1.6; margin: 30px 0 50px"
                    v-html="t('news_add_field1.activitiesNoWorries.item7')"></view>

            </view>
            <template #footer>
                <button type="primary" @click="realizationNoWorries">{{
                    t('news_add_field1.activitiesNoWorries.item6_1') }}</button>
                <button @click="dialogNoWorries = false">{{ t('news_add_field1.activitiesNoWorries.item6_2')
                    }}</button>
            </template>
        </cwg-popup>

        <!--申请成功弹出框-->
        <cwg-popup v-model:visible="dialogNoWorriesApply" type="center" :mask-click="false" :show-footers="true">
            <view class="dia-content">
                <view class="des1" style="font-size: 16px; line-height: 1.6; margin: 30px 0 50px"
                    v-html="t('news_add_field1.activitiesNoWorries.item6')"></view>

            </view>
            <template #footer>
                <button type="primary" @click="dialogNoWorriesApply = false">{{
                    t('news_add_field1.activitiesNoWorries.item6_1') }}</button>
                <button @click="dialogNoWorriesApply = false">{{ t('news_add_field1.activitiesNoWorries.item6_2')
                }}</button>
            </template>
        </cwg-popup>

        <!--收益模拟器弹出框-->
        <cwg-popup v-model:visible="openCalculatorFlag" :title="t('news_add_field1.NewYear24.item4')" type="center"
            :mask-click="false" :show-footers="true">
            <view class="dia-content NewYear_calculator">
                <view class="content">
                    <view class="calculator-input">
                        <view class="input-prefix">{{ t('news_add_field1.NewYear24.item5') }}</view>
                        <input class="input-field" v-model="NewYear24DataBalance" type="digit" />
                    </view>
                    <view class="tip">
                        <text v-html="t('news_add_field1.NewYear24.item6')"></text>
                        <text class="red">${{ NewYear24Data.balance }}</text>
                        <text v-html="t('news_add_field1.NewYear24.item7')"></text>
                        <text class="red">${{ NewYear24Data.income }}</text>
                        <text v-html="t('news_add_field1.NewYear24.item8')"></text>
                    </view>
                </view>

            </view>
            <template #footer>
                <button type="primary" @click="calculateIncome">{{ t('news_add_field1.NewYear24.item8_1')
                    }}</button>
                <button @click="openCalculatorFlag = false">{{ t('news_add_field1.NewYear24.item8_2') }}</button>
            </template>
        </cwg-popup>

        <!-- 现在有的活动 -->
        <!-- 11111111动态活动申请 -->
        <cwg-popup v-model:visible="dialogInfoTradingAdd" :title="t('surplusList.item1')" type="center"
            :mask-click="false" :show-footers="true" width="600px">
            <view class="dia-content surplusActivityDialog">
                <view class="content" style="padding: 20px">
                    <view class="form-item">
                        <view class="form-label">{{ t('Drawer.Label.ActivityName') }}:</view>
                        <uni-easyinput :disabled="true" v-model="information.title"
                            :placeholder="t('placeholder.choose')" type="text" />
                    </view>

                    <view class="form-item">
                        <view class="form-label">{{
                            t('Drawer.Label.ActivityLogin') }}:</view>
                        <cwg-combox :clearable="false" v-model:value="information.login" :options="loginOptions"
                            :placeholder="t('placeholder.choose')" />
                    </view>
                    <view class="form-item">
                        <view class="form-label">{{
                            t('Label.Note') }}:</view>
                        <uni-easyinput v-model="information.participationNote" :placeholder="t('placeholder.choose')"
                            type="textarea" autoHeight />
                    </view>
                    <view class="form-item">
                        <checkbox-group :value="information.agree ? ['1'] : []" @change="onAgreeChange">
                            <label class="checkbox">
                                <checkbox value="1" :checked="information.agree" />
                                <view class="crm-cursor" style="display: inline-block; margin-left: 10px;">
                                    <text>
                                        <text v-if="!isZh.value" v-t="'Drawer.msg.activityAgree1'"></text>
                                        <text v-if="locale == 'en'" v-t="'Drawer.msg.activityAgree1'"></text>
                                        <text v-if="locale == 'en'" v-t="'Drawer.msg.activityAgree2'"></text>
                                        <text v-t="'Drawer.msg.activityTerms'" @click.stop="toSingle(information.id)"
                                            style="font-weight: bold; text-decoration: underline;"
                                            class="crm-cursor"></text>
                                        <text v-if="!isZh.value" v-t="'Drawer.msg.activityAgree2'"></text>
                                    </text>
                                </view>
                            </label>
                        </checkbox-group>
                    </view>
                </view>
            </view>
            <template #footer>
                <button @click="closeAdd">{{ t('Btn.Cancel') }}</button>
                <button type="primary" @click="activityApply" :disabled="!information.login || !information.agree">
                    {{ t('Btn.Confirm') }}
                </button>
            </template>
        </cwg-popup>
        <!-- 11111111动态活动账户操作 -->
        <cwg-popup v-model:visible="dialogInfoTradingAdd1" :title="t('surplusList.item1')" type="center"
            :mask-click="false" :show-footers="true" width="600px">
            <view class="dia-content surplusActivityDialog">
                <view class="content" style="padding: 20px">
                    <view class="form-item">
                        <view class="form-label">{{ t('Drawer.Label.ActivityName') }}:</view>
                        <uni-easyinput :disabled="true" v-model="information.title"
                            :placeholder="t('placeholder.choose')" type="text" />
                    </view>

                    <view class="form-item">
                        <view class="form-label">{{
                            t('Drawer.Label.ActivityList') }}:</view>
                    </view>
                    <cwg-tabel ref="tableRef" :columns="columns" :mobilePrimaryFields="mobilePrimaryFields"
                        :queryParams="search1" :api="getApplyListApi">
                        <template #status="{ row }">
                            <text v-if="row.status == 1" v-t="'State.ToBeProcessed'"></text>
                            <text v-if="row.status == 2 && row.completeStatus == 0" v-t="'State.Ongoing'"></text>
                            <text v-if="row.status == 2 && row.completeStatus == 1"
                                v-t="'State.InTheProcessing'"></text>
                            <text v-if="row.status == 2 && row.completeStatus == 2" v-t="'State.Completed'"></text>
                            <text style="display: block" v-if="row.status == 3">
                                <text style="display: block" v-t="'State.Refused'"></text>
                                <text style="display: block">(<text v-t="'State.Participate'"></text>)</text>
                            </text>
                            <text style="display: block" v-if="row.completeStatus == 3">
                                <text style="display: block" v-t="'State.Refused'"></text>
                                <text style="display: block">(<text v-t="'State.Complete'"></text>)</text>
                            </text>
                        </template>
                        <template #action="{ row }">
                            <text class="crm-cursor status-tag status-completed" v-if="
                                row.status == 2 && row.completeStatus == 0
                            " v-t="'State.Complete'" @click="handleCommand(row)">{{ row.participationNote }}</text>
                            <text v-else>{{ row.participationNote }}</text>
                        </template>
                    </cwg-tabel>
                </view>
            </view>
            <template #footer>
                <button @click="closeAdd">{{ t('Btn.Cancel') }}</button>
                <button type="primary" @click="activityApply" :disabled="!information.login">
                    {{ t('Btn.Confirm') }}
                </button>
            </template>
        </cwg-popup>
        <!-- 11111111Surplus活动弹框 -->
        <cwg-popup v-model:visible="dialogSurplusActivity" :title="t('surplusList.item1')" type="center"
            :mask-click="false" :show-footers="true" width="600px">
            <view class="dia-content surplusActivityDialog">
                <view class="content" style="padding: 20px">
                    <view class="form-item">
                        <view class="form-label">{{
                            t('Custom.Deposit.Title1') }}:</view>

                        <cwg-combox :clearable="false" v-model:value="valueInfo" :options="loginComboxOptions"
                            :placeholder="t('placeholder.choose')" @change="handleValueInfoChange" />
                    </view>
                    <view class="form-item">
                        <view class="form-label">{{
                            t('surplusList.item3') }}:</view>
                        <cwg-combox :class="{ disabled: surplusActivityLoading }" :clearable="false"
                            v-model:value="selectedSurplusActivity" :options="surplusActivityOptions"
                            :placeholder="t('placeholder.choose')" />
                    </view>
                </view>
            </view>
            <template #footer>
                <button @click="closeSurplusActivityDialog">{{ t('Btn.Cancel') }}</button>
                <button type="primary" @click="confirmSurplusActivity"
                    :disabled="!selectedSurplusActivity || !valueInfo">
                    {{ t('Btn.Confirm') }}
                </button>
            </template>
        </cwg-popup>
        <!-- 111111月赏礼遇活动弹框 -->
        <cwg-popup v-model:visible="dialogSurplusActivity1" :title="t('MonthlyActivities.item1')" type="center"
            :mask-click="false" :show-footers="true" width="600px">
            <view class="dia-content">
                <view class="content" style="padding: 20px; font-size: 16px">
                    <strong v-t="'MonthlyActivities.item8'"></strong>
                </view>
            </view>
            <template #footer>
                <button @click="closeSurplusActivityDialog1">{{ t('Btn.Cancel') }}</button>
                <button type="primary" @click="confirmSurplusActivity1">{{ t('Btn.Confirm') }}</button>
            </template>
        </cwg-popup>
        <cwg-confirm-popup v-if="showPage" />
    </cwg-page-wrapper>
</template>

<script setup lang="ts">
import { ref, reactive, computed, onMounted, onUnmounted, watch, nextTick } from 'vue'
import { onShow, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import ActivityCard from './components/ActivityCard.vue'
import ActivityDialogs from './components/ActivityDialogs.vue'
import { activityApi } from "@/service/activity"
import { customApi } from "@/service/custom"
import Config from '@/config/index'
import useUserStore from "@/stores/use-user-store";
const userStore = useUserStore();
import { isAfterJuly28 } from "@/utils/dateUtils"
import { useConfirm } from '@/hooks/useConfirm'
const confirm = useConfirm()
const { t, locale } = useI18n()
let { Code, Host05 } = Config
const showPage = ref(false)

// 国家列表
const countries = [
    "DZ", "AO", "BJ", "BW", "BF", "CM", "CG", "CD", "CI", "DJ", "EG", "ET",
    "GA", "GM", "GH", "GN", "KE", "MG", "MW", "ML", "MR", "MA", "MZ", "NA",
    "NE", "NG", "RW", "SN", "SL", "SO", "ZA", "SS", "SD", "TZ", "TG", "TN",
    "UG", "ZM", "ZW", "LS", "BH", "IR", "IQ", "IL", "JO", "KW", "LB", "OM",
    "PS", "QA", "SA", "SY", "TR", "AE", "YE", "AR", "BO", "BR", "CL", "CO",
    "EC", "GY", "PY", "PE", "SR", "UY", "VE", "BZ", "CR", "SV", "GT", "HN",
    "NI", "PA", "AU", "CA", "AL", "AD", "AM", "AT", "AZ", "BY", "BE", "BA",
    "BG", "HR", "CY", "CZ", "DK", "EE", "FI", "FR", "GE", "DE", "GR", "HU",
    "IS", "IE", "IT", "XK", "LV", "LI", "LT", "LU", "MT", "MD", "MC", "ME",
    "NL", "MK", "NO", "PL", "PT", "RO", "RU", "SM", "RS", "SK", "SI", "ES",
    "SE", "CH", "UA", "VA",
]

// ==================== 响应式数据 ====================
const monthlyGive = ref(false) // 是否可以参加CWG Markets 月赏礼遇活动
const selectedAccount = ref<any>(null)
const valueInfo = ref<any>(null)
const loginOptions1 = ref<any[]>([])
const standard = ref(true)
const limitedStatus = ref<any>(null)
const flag = ref(false)
const pictLoading = ref(false)
const openType = ref("")
const dialogInfoTradingAdd = ref(false) //新增
const dialogInfoTradingAdd1 = ref(false) //新增
const imgUrl = ref(Host05)
const show = ref(false)
const dialogTableVisible = ref(false)
const formInfo = ref({}) //传给弹窗的值
const information = reactive({
    id: "",
    title: "",
    login: "",
    participationNote: "",
})
const hot = ref("")
const singleData = ref({})
const anshiClose = ref(true)
const tableData1 = ref<any>({}) //20赠金活动
const interval = ref<any>(null) //倒计时方法
const isCountDown = ref("") //倒计时
const isCashBack = ref(false) //返现按钮
const tableData2 = ref<any>(true) //2023迎新活动
const tableData2Flag = ref(false) //2023迎新活动
const isTransform = ref<any>(null) //转换按钮
const isRealization = ref<any>(null) //变现按钮
const dialogChinaUnionPay = ref(false)
const dialogChinaUnionPay1 = ref(false)
const loginOptions = ref<any[]>([])
const dialogDealResult = ref(false)
const dialogDealResult_form = reactive({ login: "" })
const tableData3Flag = ref(false) //匠鑫学院cwg活动
const tableData3 = ref<any>(true) //匠鑫学院cwg活动
const isRealizationJx = ref<any>(null) //变现按钮
const dialogDealResultJx = ref(false)
const dialogDealResultJx_form = reactive({ login: "" })
const dialogChinaUnionPayJX = ref(false)
const tableData3FlagVip = ref(false) //匠鑫学院cwg活动
const tableData3Vip = ref<any>(true) //匠鑫学院cwg活动
const isRealizationJxVip = ref<any>(null) //变现按钮
const dialogDealResultJxVip = ref(false)
const dialogDealResultJx_formVip = reactive({ login: "" })
const dialogChinaUnionPayJXVip = ref(false)
const tableData3FlagJYB = ref(false) //24精英杯cwg活动
const tableData3JYB = ref<any>(true) //24精英杯cwg活动
const isRealizationJxJYB = ref<any>(null) //变现按钮
const dialogDealResultJxJYB = ref(false)
const dialogDealResultJx_formJYB = reactive({ login: "" })
const dialogChinaUnionPayJXJYB = ref(false)
const tableData4Flag = ref(false) //年中赠金活动
const tableData4 = ref<any>(true) //年中赠金活动
const tableData4TwoFlag = ref(false) //年中赠金活动-20
const tableData4Two = ref<any>(true) //年中赠金活动-20
const tableDataCptFlag = ref(false) //交易大赛活动
const tableDataCpt = ref<any>(true) //交易大赛活动
const dialogDealResultCpt = ref(false)
const dialogDealResultCpt_form = reactive({
    login: "",
    address: "",
    cptId: "",
    mobile: "",
    nickname: "",
    recipient: "",
})
const dialogChinaUnionPayCpt = ref(false)
const tableDataCptFlagCode = ref("")
const isZh = computed(() => ['cn', 'zh', 'zhHant'].includes(locale.value))
//CWG 现金嘉年华-抽奖
const newTask = ref(false) //新任务
const newTaskList = ref({ endTime: "", tradeVolume: "", raffleNumber: "" }) //新任务列表
const dialogNewTask = ref(false) //新任务弹窗
const dialogNewTaskDraw = ref(false) //打开抽奖弹窗
const LuckyDrawsNumber = ref("0") //抽奖次数
const choujiaClose = ref(false)

const tableDataNoWorriesFlag = ref(false) //24无忧交易
const tableDataNoWorries = ref<any>(false) //24无忧交易
const isRealizationNoWorries = ref<any>(null) //变现按钮
const dialogDealResultNoWorries = ref(false)
const dialogDeal_formNoWorries = reactive({ login: "" })
const dialogNoWorries = ref(false)
const dialogNoWorriesApply = ref(false)

const tableDataNewYear24Flag = ref(false) //24新年庆典
const tableDataNewYear24 = ref<any>(false) //24新年庆典
const openCalculatorFlag = ref(false)
const NewYear24DataBalance = ref("")
const NewYear24Data = reactive({
    balance: 0,
    income: 0,
})

const dialogSurplusActivity1 = ref(false) // CWG Markets 月赏礼遇活动弹框
const surplusActivityOptions1 = ref<any[]>([]) // CWG Markets 月赏礼遇活动下拉框选项
const selectedSurplusActivity1 = ref<any>(null) // 选中的CWG Markets 月赏礼遇活动
const surplusActivityLoading1 = ref(false) // 加载状态
const surplusGive1 = ref(false) // 是否可以参加CWG Markets 月赏礼遇活动

// Surplus活动相关
const dialogSurplusActivity = ref(false) // surplus活动弹框
const surplusActivityOptions = ref<any[]>([]) // surplus活动下拉框选项
const selectedSurplusActivity = ref<any>(null) // 选中的surplus活动
const surplusActivityLoading = ref(false) // 加载状态
const surplusGive = ref(false) // 是否可以参加surplus活动
const activityShowsInfo = ref<any>(null) // 活动显示信息

const tableData = ref<any[]>([])
const search = reactive({
    date: [] as any[],
    startDate: "",
    endDate: "",
    type: 1,
})
//分页
const pagerInfo = reactive({ row: 10, current: 1, pageTotal: 0, rowTotal: 0 })
const tableDataGive = ref<any[]>([])

// 验证规则
const rules = reactive({
    login: [
        {
            required: true,
            message: t("vaildate.select.empty"),
            trigger: "change",
        },
    ],
    address: [
        {
            required: true,
            message: t("vaildate.input.empty"),
            trigger: "blur",
        },
    ],
    mobile: [
        {
            required: true,
            message: t("vaildate.input.empty"),
            trigger: "blur",
        },
    ],
    nickname: [
        {
            required: true,
            message: t("vaildate.input.empty"),
            trigger: "blur",
        },
    ],
    recipient: [
        {
            required: true,
            message: t("vaildate.input.empty"),
            trigger: "blur",
        },
    ],
})

// ==================== 计算属性 ====================
const country = computed(() => {
    return userStore?.userInfo?.customInfo?.country
})

const myCid = computed(() => {
    return userStore?.userInfo?.customInfo?.cId
})

const isSupportedCountry = computed(() => {
    try {
        const country = userStore?.userInfo?.customInfo?.country
        return countries.includes(country)
    } catch {
        return false
    }
})

const dollarActivity = computed(() => {
    const info = activityShowsInfo.value;
    if (!info || !info.dollar) {
        return null;
    }
    const d = info.dollar;
    if (Number(d.show) !== 1) {
        return null;
    }
    return d;
})

const dollarCoverSrc = computed(() => {
    const d = dollarActivity.value;
    if (!d || !d.coverUrl) {
        return "";
    }
    const u = String(d.coverUrl);
    if (/^https?:\/\//i.test(u)) {
        return u;
    }
    return Host05 + u;
})

const dollarActivityDate = computed(() => {
    const d = dollarActivity.value;
    if (!d) {
        return "";
    }
    const raw =
        d.revokeDate ||
        d.activityEndTime ||
        d.endDate ||
        d.endTime ||
        d.activityStartTime ||
        "";
    if (!raw) {
        return "";
    }
    return String(raw).split(" ")[0];
})

const dollarParticipateEnabled = computed(() => {
    return dollarActivity.value && Number(dollarActivity.value.customApply) === 1
})


const isGuoQin = computed(() => {
    let flag = false
    let startTime1 = "2024/10/01 00:00:00"
    let endTime1 = "2024/10/07 23:59:59"
    let timezone = 8
    let offset_GMT = new Date().getTimezoneOffset()
    let nowDate = new Date().getTime()
    let now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000).getTime()
    let end = new Date(endTime1).getTime()
    let start = new Date(startTime1).getTime()
    if (now > start && now < end) {
        flag = true
    }
    return flag
})

const showMonthlyActivity2026 = computed(() => {
    let targetTime = "2026/01/01 00:00:00"
    let timezone = 8
    let offset_GMT = new Date().getTimezoneOffset()
    let nowDate = new Date().getTime()
    let now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000).getTime()
    let target = new Date(targetTime).getTime()
    return now >= target
})

// ==================== 工具方法 ====================
//时间补0
const getzero = (time: number | string) => {
    return time > "9" ? time : "0" + time
}

//时间格式转换
const timeConvert = (val: string) => {
    if (val) {
        var datetime = new Date(val.replace(/-/g, "/"))
        var year = datetime.getFullYear()
        var month = datetime.getMonth() + 1
        var date = datetime.getDate()
        if (month < 10) {
            month = "0" + month
        }
        if (date < 10) {
            date = "0" + date
        }
        var time = year + "年" + month + "月" + date + "日"
        return time
    }
    return ""
}

//判断匠鑫活动是否报名结束
const timeExpireJx = (endTime: string) => {
    let endTime1 = endTime.replace(/-/g, "/").split(" ")[0]
    let timezone = 2
    let offset_GMT = new Date().getTimezoneOffset()
    let nowDate = new Date().getTime()
    let now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000).getTime()
    let end = new Date(endTime1).getTime()
    return now < end
}

//判断活动是否结束
const overdue = (startTime: string, endTime: string) => {
    let startTime1 = startTime.replace(/-/g, "/").split(" ")[0]
    let endTime1 = endTime.replace(/-/g, "/").split(" ")[0]
    let timezone = 2
    let offset_GMT = new Date().getTimezoneOffset()
    let nowDate = new Date().getTime()
    let now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000).getTime()
    let start = new Date(startTime1).getTime()
    let end = new Date(endTime1).getTime()
    return start < now && now < end
}

const isAfterJuly21 = () => {
    const currentDate = new Date()
    const july21 = new Date(currentDate.getFullYear(), 6, 21)
    return currentDate >= july21
}

// 判断是否在9月30日晚上12点之后，用于隐藏特定活动
const isAfterSeptember30 = () => {
    return true
}

const standardTime = () => {
    standard.value = false
}

const groupCurrency = (type: string) => {
    if (type == "GBP") {
        return ": £"
    } else if (type == "USD") {
        return ": $"
    } else if (type == "EUR") {
        return ": €"
    } else if (type == "USC") {
        return ": ￠"
    } else {
        return ": $"
    }
}

const groupCurrency1 = (type: string) => {
    if (type == "GBP") {
        return "£"
    } else if (type == "USD") {
        return "$"
    } else if (type == "EUR") {
        return "€"
    } else if (type == "USC") {
        return "￠"
    } else {
        return "$"
    }
}

const groupTypeName = (type: string) => {
    if (type == "1") {
        return t("AccountType.ClassicAccount")
    } else if (type == "2") {
        return t("AccountType.SeniorAccount")
    } else if (type == "3") {
        return isAfterJuly28() ? "--" : t("AccountType.AgencyAccount")
    } else if (type == "5") {
        return t("AccountType.SpeedAccount")
    } else if (type == "6") {
        return t("AccountType.SpeedAccount")
    } else if (type == "7") {
        return t("AccountType.StandardAccount")
    } else if (type == "8") {
        return t("AccountType.CentAccount")
    }
    return ""
}

// ==================== API 请求方法 ====================
const loginComboxOptions = computed(() => {
    return loginOptions1.value.map((item) => ({
        text: item.label,
        value: item.login
    }))
})
//获取账户信息
const getDateList = async () => {
    let res = await customApi.DropdownlusActivityOptions({ platform: "" })
    if (res.code == Code.StatusOK) {
        // loginOptions1.value = res.data
        loginOptions1.value = res.data.map(item => ({
            ...item,
            label: `${item.login} - ${groupTypeName(item.type)} - ${t('Custom.Deposit.AvailableBalance')}${groupCurrency(item.currency)}${item.balance}`,
            disable: item.closeFunctions.includes('1')
        }))
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//获取list
const searchFunc = async () => {
    if (flag.value) {
        return
    } else {
        flag.value = true
    }
    pictLoading.value = true
    let res = await activityApi.ActivityExtensionIist({
        hot: hot.value,
        tag: 1,
        lang: ["cn", "zhHant"].indexOf(locale.value) !== -1 ? "cn" : "en",
        page: {
            current: pagerInfo.current,
            row: pagerInfo.row,
        },
    })
    if (res.code == Code.StatusOK) {
        tableData.value = res.data
        pagerInfo.rowTotal = res.page.rowTotal
        pagerInfo.pageTotal = res.page.pageTotal
        flag.value = false
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
        flag.value = false
    }
    pictLoading.value = false
}

//获取list-赠金活动列表
const searchFunc1 = async () => {
    pictLoading.value = true
    let res = await activityApi.ActivityExtensionGiveList({
        page: {
            current: pagerInfo.current,
            row: pagerInfo.row,
        },
    })
    if (res.code == Code.StatusOK) {
        tableDataGive.value = res.data
        pagerInfo.rowTotal = res.page.rowTotal
        pagerInfo.pageTotal = res.page.pageTotal
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    pictLoading.value = false
}

//详情
const getSingle = async (id: string) => {
    let res = await activityApi.ActivitySingle({
        id: id,
    })
    if (res.code == Code.StatusOK) {
        singleData.value = res.data
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//获取客户申请活动列表
const Api = async () => {
    let res = await activityApi.ActivityApplyList({
        page: {
            current: pagerInfo.current,
            row: pagerInfo.row,
        },
    })
    if (res.code == Code.StatusOK) {
        pagerInfo.rowTotal = res.page.rowTotal
        pagerInfo.pageTotal = res.page.pageTotal
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//20赠金活动数据
const getActivityPercentageGiveInfo = async () => {
    let res = await activityApi.ActivityPercentageGiveInfo({})
    if (res.code == Code.StatusOK) {
        tableData1.value = res.data
        if (typeof tableData1.value == "object") {
            let timezone = 2
            let offset_GMT = new Date().getTimezoneOffset()
            let nowDate = new Date().getTime()
            let nowTime = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000)
            let startTime = new Date(tableData1.value.activityStartTime.replace(/-/g, "/")).getTime()
            if (nowTime < startTime) {
                interval.value = setInterval(() => {
                    let timezone = 2
                    let offset_GMT = new Date().getTimezoneOffset()
                    let nowDate = new Date().getTime()
                    let nowTime = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000)
                    let sec = 1000,
                        min = 60 * sec,
                        hour = min * 60,
                        day = 24 * hour
                    let time = startTime - nowTime
                    let DAY = getzero(Math.floor(time / day))
                    let HOUR = getzero(Math.floor((time % day) / hour))
                    let MIN = getzero(Math.floor((time % hour) / min))
                    let SEC = getzero(Math.floor((time % min) / sec))
                    isCountDown.value = `${DAY}${t("Label.Day")}${HOUR}:${MIN}:${SEC}`
                    if (nowTime >= startTime) {
                        clearInterval(interval.value)
                        getActivityPercentageGiveInfo()
                    }
                }, 1000)
            } else if (nowTime > startTime && tableData1.value.status == 0) {
                isCashBack.value = true
            }
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//返现
const cashBack = async () => {
    let res = await activityApi.ActivityPercentageGiveApply({})
    if (res.code == Code.StatusOK) {
        uni.showToast({ title: t("Msg.Application"), icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//20赠金活动申请
const toDeposit = () => {
    uni.navigateTo({ url: "/pages/customer/deposit/index" })
}

//2023迎新活动数据
const Activity23HundredInfo = async () => {
    let res = await activityApi.Activity23HundredInfo({})
    if (res.code == Code.StatusOK) {
        tableData2.value = res.data
        if (typeof tableData2.value == "object") {
            tableData2Flag.value = true
            let timezone = 2
            let offset_GMT = new Date().getTimezoneOffset()
            let nowDate = new Date().getTime()
            let nowTime = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000)
            let startTime = new Date(tableData2.value.activityStartTime.replace(/-/g, "/")).getTime()
            let endTime = new Date(tableData2.value.activityEndTime.replace(/-/g, "/")).getTime()
            if (nowTime < endTime && nowTime > startTime) {
                if (tableData2.value.status == 2 && tableData2.value.activityStatus == 0) {
                    isTransform.value = 1
                } else if (
                    tableData2.value.status == 2 &&
                    (tableData2.value.activityStatus == 1 ||
                        (tableData2.value.balanceStatus != 2 && tableData2.value.creditStatus != 2))
                ) {
                    isTransform.value = 2
                } else if (tableData2.value.status == 2 && tableData2.value.activityStatus == 3) {
                    isTransform.value = 2
                }
            } else {
                isTransform.value = 2
            }
            if (tableData2.value.status == 2 && tableData2.value.activityStatus == 2) {
                isTransform.value = null
                if (tableData2.value.realizationStatus == 0) {
                    isRealization.value = 1
                } else if (
                    tableData2.value.realizationStatus == 1 ||
                    (tableData2.value.realizationCreditStatus != 2 && tableData2.value.realizationBalanceStatus != 2)
                ) {
                    isRealization.value = 2
                } else if (tableData2.value.realizationStatus == 3) {
                    isRealization.value = 2
                }
            } else {
                isRealization.value = null
            }
        } else {
            if (tableData2.value) {
                tableData2Flag.value = true
            }
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
        tableData2.value = true
    }
}

//获取交易账户的下拉列表
const toApply23Open = async () => {
    pictLoading.value = true
    let res = await activityApi.Activity23Login({})
    if (res.code == Code.StatusOK) {
        loginOptions.value = res.data
        dialogDealResult.value = true
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    pictLoading.value = false
}

//2023迎新活动申请
const toApply23 = async () => {
    if (flag.value) {
        return
    } else {
        flag.value = true
    }
    let res = await activityApi.Activity23HundredApply({
        login: dialogDealResult_form.login,
    })
    if (res.code == Code.StatusOK) {
        toApply23Cancel()
        Activity23HundredInfo()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

const toApply23Cancel = () => {
    dialogDealResult_form.login = ""
    dialogDealResult.value = false
}

//盈利转换
const toTransform = () => {
    dialogChinaUnionPay.value = true
}

const toTransformActive = async () => {
    let res = await activityApi.Activity23HundredTransform({})
    if (res.code == Code.StatusOK) {
        dialogChinaUnionPay.value = false
        Activity23HundredInfo()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//盈利变现
const toRealization = () => {
    dialogChinaUnionPay1.value = true
}

const toRealizationActive = async () => {
    let res = await activityApi.Activity23HundredRealization({})
    if (res.code == Code.StatusOK) {
        dialogChinaUnionPay1.value = false
        Activity23HundredInfo()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//2023匠鑫活动数据
const Activity23JiangxinInfo = async () => {
    let res = await activityApi.Activity23JiangxinInfo({})
    if (res.code == Code.StatusOK) {
        tableData3.value = res.data
        if (tableData3.value.show == 1) {
            tableData3Flag.value = true
        } else if (tableData3.value.show == 0) {
            tableData3Flag.value = false
        } else if (!tableData3.value.show) {
            tableData3Flag.value = true
            let timezone = 2
            let offset_GMT = new Date().getTimezoneOffset()
            let nowDate = new Date().getTime()
            let nowTime = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000)
            let endTime = tableData3.value.activityEndTime
                ? new Date(tableData3.value.activityEndTime.replace(/-/g, "/")).getTime()
                : null
            if (
                tableData3.value.status == 2 &&
                tableData3.value.realizationStatus == 0 &&
                endTime &&
                nowTime > endTime
            ) {
                isRealizationJx.value = 1
            } else {
                isRealizationJx.value = 2
            }
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//获取交易账户的下拉列表
const toApply23JxOpen = async () => {
    pictLoading.value = true
    let res = await activityApi.Activity23JxLogin({})
    if (res.code == Code.StatusOK) {
        loginOptions.value = res.data
        dialogDealResultJx.value = true
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    pictLoading.value = false
}

//2023迎新活动申请
const toApply23Jx = async () => {
    if (flag.value) {
        return
    } else {
        flag.value = true
    }
    let res = await activityApi.Activity23JiangxinApply({
        login: dialogDealResultJx_form.login,
    })
    if (res.code == Code.StatusOK) {
        toApply23JxCancel()
        Activity23JiangxinInfo()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

const toApply23JxCancel = () => {
    dialogDealResultJx_form.login = ""
    dialogDealResultJx.value = false
}

//盈利变现
const toRealizationJx = async () => {
    let res = await activityApi.Activity23JiangxinRealization({
        id: tableData3.value.id,
    })
    if (res.code == Code.StatusOK) {
        Activity23JiangxinInfo()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//2023匠鑫活动数据Vip
const Activity23JiangxinInfoVip = async () => {
    let res = await activityApi.Activity23JiangxinInfoVip({})
    if (res.code == Code.StatusOK) {
        tableData3Vip.value = res.data
        if (tableData3Vip.value.show == 1) {
            tableData3FlagVip.value = true
        } else if (tableData3Vip.value.show == 0) {
            tableData3FlagVip.value = false
        } else if (!tableData3Vip.value.show) {
            tableData3FlagVip.value = true
            let timezone = 2
            let offset_GMT = new Date().getTimezoneOffset()
            let nowDate = new Date().getTime()
            let nowTime = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000)
            let endTime = tableData3Vip.value.activityEndTime
                ? new Date(tableData3Vip.value.activityEndTime.replace(/-/g, "/")).getTime()
                : null
            if (
                tableData3Vip.value.status == 2 &&
                tableData3Vip.value.realizationStatus == 0 &&
                endTime &&
                nowTime > endTime
            ) {
                isRealizationJxVip.value = 1
            } else {
                isRealizationJxVip.value = 2
            }
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//获取交易账户的下拉列表Vip
const toApply23JxOpenVip = async () => {
    pictLoading.value = true
    let res = await activityApi.Activity23JxLoginVip({})
    if (res.code == Code.StatusOK) {
        loginOptions.value = res.data
        dialogDealResultJxVip.value = true
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    pictLoading.value = false
}

//2023迎新活动申请Vip
const toApply23JxVip = async () => {
    if (flag.value) {
        return
    } else {
        flag.value = true
    }
    let res = await activityApi.Activity23JiangxinApplyVip({
        login: dialogDealResultJx_formVip.login,
    })
    if (res.code == Code.StatusOK) {
        toApply23JxCancelVip()
        Activity23JiangxinInfoVip()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

const toApply23JxCancelVip = () => {
    dialogDealResultJx_formVip.login = ""
    dialogDealResultJxVip.value = false
}

//盈利变现Vip
const toRealizationJxVip = async () => {
    let res = await activityApi.Activity23JiangxinRealizationVip({
        id: tableData3Vip.value.id,
    })
    if (res.code == Code.StatusOK) {
        Activity23JiangxinInfoVip()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//2023年中赠金活动数据-10
const Activity24nianzhongInfo = async () => {
    let res = await activityApi.Activity23nianzhongInfo({})
    if (res.code == Code.StatusOK) {
        tableData4.value = res.data
        if (tableData4.value.show == 1) {
            tableData4Flag.value = true
        } else if (tableData4.value.show == 0) {
            tableData4Flag.value = false
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//2023年中赠金活动跳转
const toActivity24nianzhong = () => {
    uni.navigateTo({ url: "/pages/customer/deposit-select" })
}

//标准账户交易奖励跳转
const toActivity24Trading = () => {
    uni.navigateTo({ url: "/pages/customer/new/index" })
}

//2023年中赠金活动数据-20
const Activity24nianzhongTwoInfo = async () => {
    let res = await activityApi.Activity23nianzhongTwoInfo({})
    if (res.code == Code.StatusOK) {
        tableData4Two.value = res.data
        if (tableData4Two.value.show == 1) {
            tableData4TwoFlag.value = true
        } else if (tableData4Two.value.show == 0) {
            tableData4TwoFlag.value = false
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//交易大赛数据-参数
const GetActivityCptCode = async () => {
    let res = await activityApi.ActivityCptinfoGetCode({})
    if (res.code == Code.StatusOK) {
        tableDataCptFlagCode.value = res.data.code
        if (tableDataCptFlagCode.value) {
            ActivityCptInfo(tableDataCptFlagCode.value)
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//交易大赛数据
const ActivityCptInfo = async (code: string) => {
    let res = await activityApi.ActivityCptinfoCode({
        infoCode: code,
    })
    if (res.code == Code.StatusOK) {
        tableDataCpt.value = res.data
        if (tableDataCpt.value == null) {
            tableDataCptFlag.value = false
        } else {
            tableDataCptFlag.value = true
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//获取交易账户的下拉列表
const toApplyCptOpen = async () => {
    pictLoading.value = true
    let res = await activityApi.ActivityCptInfoLogins({
        cptId: tableDataCpt.value.id,
    })
    if (res.code == Code.StatusOK) {
        loginOptions.value = res.data
        dialogDealResultCpt.value = true
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    pictLoading.value = false
}

//交易大赛申请
const toApplyCpt = async () => {
    if (flag.value) {
        return
    } else {
        flag.value = true
    }
    let res = await activityApi.ActivityCptInfoAdd({
        cptId: tableDataCpt.value.id,
        login: dialogDealResultCpt_form.login,
        nickname: dialogDealResultCpt_form.nickname,
        mobile: dialogDealResultCpt_form.mobile,
        address: dialogDealResultCpt_form.address,
        recipient: dialogDealResultCpt_form.recipient,
    })
    if (res.code == Code.StatusOK) {
        toApplyCptCancel()
        GetActivityCptCode()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

const toApplyCptCancel = () => {
    dialogDealResultCpt_form.login = ""
    dialogDealResultCpt_form.nickname = ""
    dialogDealResultCpt_form.mobile = ""
    dialogDealResultCpt_form.address = ""
    dialogDealResultCpt_form.recipient = ""
    dialogDealResultCpt.value = false
}

const toOpenSingle = (pageAddress: string) => {
    let link = ""
    if (pageAddress.indexOf("html?") == -1) {
        link = "?code=" + tableDataCptFlagCode.value
    }
    if (pageAddress.indexOf("html?") > -1 && pageAddress.indexOf("code") == -1) {
        link = "&code=" + tableDataCptFlagCode.value
    }
    plus.runtime.openURL(imgUrl.value + pageAddress + link)
}

//CWG 现金嘉年华-新任务
const ActivitYdepositRaffleAim = async () => {
    let res = await activityApi.ActivitYdepositRaffleAim({})
    if (res.code == Code.StatusOK) {
        if (res.data == null) {
            newTask.value = false
        } else {
            newTask.value = true
            newTaskList.value = res.data
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//CWG 现金嘉年华-抽奖次数
const ActivitYdepositRaffleinfo = async () => {
    let res = await activityApi.ActivitYdepositRaffleinfo({})
    if (res.code == Code.StatusOK) {
        if (res.data == null) {
            LuckyDrawsNumber.value = "0"
        } else {
            LuckyDrawsNumber.value = res.data.raffleResidueNumber || "0"
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//现金嘉年华跳转抽奖历史
const toHistoryLuckyDraw = () => {
    uni.navigateTo({ url: "/pages/customer/history/lucky/draw/index" })
}

//现金嘉年华跳转任务列表
const toTaskList = () => {
    uni.navigateTo({ url: "/pages/customer/task/list/index" })
}

const UtoTaskList = () => {
    uni.navigateTo({ url: "/pages/customer/Utask/list/index" })
}

const goSurplusTaskList = () => {
    uni.navigateTo({ url: "/pages/activities/surplus-list" })
}

const goMonthlyTaskList = () => {
    uni.navigateTo({ url: "/pages/activities/monthly-list" })
}

const toOpenTask = () => {
    dialogNewTaskDraw.value = true
}

//新任务弹窗
const toNewTask = () => {
    dialogNewTask.value = true
}

const closedialogNewTaskDraw = () => {
    dialogNewTaskDraw.value = false
    ActivitYdepositRaffleinfo()
}

//分页返回数据
const handleCurrentChange = (val: number) => {
    pagerInfo.current = val
    searchFunc()
    searchFunc1()
}

//20赠金是否到期-4月30号23:59:59的时候关闭申请
const is20Open = () => {
    let endTime1 = "2023/04/30 23:59:59"
    let timezone = 2
    let offset_GMT = new Date().getTimezoneOffset()
    let nowDate = new Date().getTime()
    let now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000).getTime()
    let end = new Date(endTime1).getTime()
    if (now > end) {
        anshiClose.value = false
    }
}

//抽抽奖是否到期-2023-11-25 00:00:00-2023-12-31 23:59:59
const isRaffleOpen = () => {
    let endTime1 = "2025/9/30 23:59:59"
    let startTime1 = "2025/7/1 00:00:00"
    let timezone = 2
    let offset_GMT = new Date().getTimezoneOffset()
    let nowDate = new Date().getTime()
    let now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000).getTime()
    let end = new Date(endTime1).getTime()
    let start = new Date(startTime1).getTime()
    if (now < end && start < now) {
        choujiaClose.value = true
        ActivitYdepositRaffleAim()
        ActivitYdepositRaffleinfo()
    }
}

//24精英杯活动
const Activity24JYBInfoVip = async () => {
    let res = await activityApi.Activity24JYBInfoVip({})
    if (res.code == Code.StatusOK) {
        tableData3JYB.value = res.data
        if (tableData3JYB.value.show == 1) {
            tableData3FlagJYB.value = true
        } else if (tableData3JYB.value.show == 0) {
            tableData3FlagJYB.value = false
        } else if (!tableData3JYB.value.show) {
            tableData3FlagJYB.value = true
            let timezone = 2
            let offset_GMT = new Date().getTimezoneOffset()
            let nowDate = new Date().getTime()
            let nowTime = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000)
            let endTime = tableData3JYB.value.activityEndTime
                ? new Date(tableData3JYB.value.activityEndTime.replace(/-/g, "/")).getTime()
                : null
            if (
                tableData3JYB.value.status == 2 &&
                tableData3JYB.value.realizationStatus == 0 &&
                endTime &&
                nowTime > endTime
            ) {
                isRealizationJxJYB.value = 1
            } else {
                isRealizationJxJYB.value = 2
            }
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//获取交易账户的下拉列表Vip
const toApply24JYBOpenVip = async () => {
    pictLoading.value = true
    let res = await activityApi.Activity24JYBLoginVip({})
    if (res.code == Code.StatusOK) {
        loginOptions.value = res.data
        dialogDealResultJxJYB.value = true
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    pictLoading.value = false
}

//24精英杯活动申请
const toApply24JYBVip = async () => {
    //this.$refs["dialogDealResultJx_formJYB"].validate
    if (flag.value) {
        return
    } else {
        flag.value = true
    }
    let res = await activityApi.Activity24JYBApplyVip({
        login: dialogDealResultJx_formJYB.login,
    })
    if (res.code == Code.StatusOK) {
        toApply24JYBCancelVip()
        Activity24JYBInfoVip()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

const toApply24JYBCancelVip = () => {
    dialogDealResultJx_formJYB.login = ""
    dialogDealResultJxJYB.value = false
}

//24精英杯活动盈利变现
const toRealization24JYBVip = async () => {
    let res = await activityApi.Activity24JYBRealizationVip({
        id: tableData3JYB.value.id,
    })
    if (res.code == Code.StatusOK) {
        Activity24JYBInfoVip()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//24无忧交易
const ActivityNoWorriesInfo = async () => {
    let res = await activityApi.ActivityNoWorriesInfo({})
    if (res.code == Code.StatusOK) {
        tableDataNoWorries.value = res.data
        if (typeof tableDataNoWorries.value == "object") {
            tableDataNoWorriesFlag.value = true
            let timezone = 2
            let offset_GMT = new Date().getTimezoneOffset()
            let nowDate = new Date().getTime()
            let nowTime = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000)
            let startTime = new Date(tableDataNoWorries.value.compensateTime.replace(/-/g, "/")).getTime()
            let endTime = new Date(tableDataNoWorries.value.revokeTime.replace(/-/g, "/")).getTime()
            if (
                nowTime < endTime &&
                nowTime > startTime &&
                (tableDataNoWorries.value.status == 0 ||
                    tableDataNoWorries.value.status == 3) &&
                tableDataNoWorries.value.compensateStatus == 2 &&
                tableDataNoWorries.value.activityStatus == 1
            ) {
                isRealizationNoWorries.value = 1
            } else {
                isRealizationNoWorries.value = null
            }
        } else {
            if (tableDataNoWorries.value) {
                tableDataNoWorriesFlag.value = true
            }
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//获取交易账户的下拉列表
const toApplyNoWorriesOpen = async () => {
    pictLoading.value = true
    let res = await activityApi.ActivityNoWorriesLogin({})
    if (res.code == Code.StatusOK) {
        loginOptions.value = res.data
        dialogDealResultNoWorries.value = true
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    pictLoading.value = false
}

//24无忧交易申请
const toApplyNoWorries = async () => {
    if (flag.value) {
        return
    } else {
        flag.value = true
    }
    let res = await activityApi.ActivityNoWorriesApply({
        login: dialogDeal_formNoWorries.login,
    })
    if (res.code == Code.StatusOK) {
        dialogNoWorriesApply.value = true
        toApplyNoWorriesCancel()
        ActivityNoWorriesInfo()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

const toApplyNoWorriesCancel = () => {
    // this.$refs["dialogDeal_formNoWorries"] &&
    //    this.$refs["dialogDeal_formNoWorries"].resetFields();
    dialogDeal_formNoWorries.login = ""
    dialogDealResultNoWorries.value = false
}

//盈利变现
const toRealizationNoWorries = () => {
    dialogNoWorries.value = true
}

//24无忧交易盈利变现
const realizationNoWorries = async () => {
    let res = await activityApi.ActivityNoWorriesRealization({
        id: tableDataNoWorries.value.id,
    })
    if (res.code == Code.StatusOK) {
        dialogNoWorries.value = false
        ActivityNoWorriesInfo()
        uni.showToast({ title: res.msg, icon: "success" })
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

//24新年庆典
const isNewYear24Open = () => {
    let endTime1 = "2025/3/31 23:59:59"
    let startTime1 = "2025/1/1 00:00:00"
    let timezone = 2
    let offset_GMT = new Date().getTimezoneOffset()
    let nowDate = new Date().getTime()
    let now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000).getTime()
    let end = new Date(endTime1).getTime()
    let start = new Date(startTime1).getTime()
    if (now < end && start < now) {
        ActivityNewYear24()
    }
}

const ActivityNewYear24 = async () => {
    let res = await activityApi.ActivityNewYear24({})
    if (res.code == Code.StatusOK) {
        tableDataNewYear24.value = res.data
        if (typeof tableDataNewYear24.value == "object") {
            tableDataNewYear24Flag.value = true
        } else {
            if (tableDataNewYear24.value) {
                tableDataNewYear24Flag.value = true
            }
        }
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

const openCalculator = () => {
    openCalculatorFlag.value = true
}

const calculateIncome = () => {
    NewYear24Data.balance = Number(NewYear24DataBalance.value) || 0
    let rate = 0
    tableDataNewYear24.value.details.forEach((item: any) => {
        if (
            NewYear24Data.balance > item.min &&
            NewYear24Data.balance <= item.max
        ) {
            rate = item.rate
        } else if (
            NewYear24Data.balance > item.min &&
            NewYear24Data.balance >= item.max &&
            item.max == 0
        ) {
            rate = item.rate
        }
    })
    NewYear24Data.income = (
        ((NewYear24Data.balance * rate) / 100 / 365) *
        30
    ).toFixed(2)
}

//限时活动
const ActivityRequiteInfo = async () => {
    let res = await activityApi.ActivityRequiteInfo({})
    if (res.code == Code.StatusOK) {
        limitedStatus.value = res.data
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
}

// 获取活动显示信息
const getActivityShowsInfo = async () => {
    try {
        let res = await activityApi.ActivityShowsInfo()
        if (res.code == Code.StatusOK) {
            activityShowsInfo.value = res.data
            surplusGive.value = res.data.surplusGive || false
            monthlyGive.value = res.data.monthlyGive || false
        } else {
            uni.showToast({ title: res.msg, icon: "none" })
            surplusGive.value = false
            monthlyGive.value = false
        }
    } catch (error) {
        uni.showToast({ title: "获取活动信息失败", icon: "none" })
        surplusGive.value = false
        monthlyGive.value = false
    }
}

// 打开surplus活动弹框
const openSurplusActivityDialog = async () => {
    console.log(surplusGive.value)
    if (!surplusGive.value) {
        return
    }
    dialogSurplusActivity.value = true
    surplusActivityLoading.value = true
    selectedSurplusActivity.value = null
}

const openSurplusActivityDialog1 = async () => {
    if (!monthlyGive.value) {
        return
    }
    dialogSurplusActivity1.value = true
    surplusActivityLoading1.value = true
    selectedSurplusActivity1.value = null
    getMonthlyActivityOptions()
}

const getSurplusActivityOptions = async () => {
    let res = await activityApi.ActivitySurplusDepositAmount({
        login: selectedAccount.value.login,
        platform: selectedAccount.value.platform,
    })
    if (res.code == Code.StatusOK) {
        surplusActivityOptions.value = res.data.map((item: any, index: number) => ({
            id: index,
            value: item.level,
            text: `${t("AmountLabel.item1")}: ${item.amount} | ${t("AmountLabel.item2")}: ${item.needVolume}`,
            giveFlag: item.giveFlag,
        }))
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    surplusActivityLoading.value = false
}

const getMonthlyActivityOptions = async () => {
    let res = await activityApi.ActivityMonthlyDepositAmount({})
    if (res.code == Code.StatusOK) {
        surplusActivityOptions1.value = res.data.map((item: any, index: number) => ({
            id: index,
            value: item.level,
            label: `${t("入金量")}: ${item.needAmount} | ${t("入金手数")}: ${item.needVolume}`,
        }))
    } else {
        uni.showToast({ title: res.msg, icon: "none" })
    }
    surplusActivityLoading1.value = false
}

// 关闭surplus活动弹框
const closeSurplusActivityDialog = () => {
    dialogSurplusActivity.value = false
    selectedSurplusActivity.value = null
    surplusActivityOptions.value = []
    valueInfo.value = null
}

// 确认参加surplus活动
const confirmSurplusActivity = async () => {
    try {
        surplusActivityLoading.value = true
        let res = await activityApi.ActivitySurplusAdd({
            login: selectedAccount.value.login,
            platform: selectedAccount.value.platform,
            level: selectedSurplusActivity.value,
        })
        if (res.code == Code.StatusOK) {
            uni.showToast({ title: res.msg, icon: "success" })
            closeSurplusActivityDialog()
            surplusActivityLoading.value = false
            getActivityShowsInfo()
        } else {
            uni.showToast({ title: res.msg, icon: "none" })
        }
    } catch (error) {
        uni.showToast({ title: error?.msg, icon: "none" })
    }
}

// 关闭surplus活动弹框
const closeSurplusActivityDialog1 = () => {
    dialogSurplusActivity1.value = false
    selectedSurplusActivity1.value = null
    surplusActivityOptions1.value = []
    valueInfo.value = null
}

// 确认参加月度豪礼活动
const confirmSurplusActivity1 = async () => {
    try {
        surplusActivityLoading1.value = true
        let res = await activityApi.ActivityMonthlyAdd({})
        if (res.code == Code.StatusOK) {
            uni.showToast({ title: res.msg, icon: "success" })
            closeSurplusActivityDialog1()
            surplusActivityLoading1.value = false
            getActivityShowsInfo()
        } else {
            uni.showToast({ title: res.msg, icon: "none" })
        }
    } catch (error) {
        uni.showToast({ title: error?.msg, icon: "none" })
    }
}

//搜索
const handleSearch = () => {
    pagerInfo.current = 1
    searchFunc()
    searchFunc1()
}

//新增
const closeDiaAdd = () => {
    dialogInfoTradingAdd.value = false
    dialogInfoTradingAdd1.value = false
}

const closeAdd = (val: boolean) => {
    dialogInfoTradingAdd.value = false
    dialogInfoTradingAdd1.value = false
}

const confirmToReload = () => {
    dialogInfoTradingAdd.value = false
    dialogInfoTradingAdd1.value = false
    searchFunc()
}

//获取客户申请活动列表
//点击操作的回调

const tableRef = ref(null)
const handleCommand = (command) => {
    if (command.type == "check") {
        ActivityComplete(command.id);
    }
}
const ActivityComplete = async (id: number) => {
    await confirm({
        content: t("news_add_field.ApplicationDialog.ActivitiesDes"),
        title: t("Msg.SystemPrompt"),
        confirmText: t("Btn.item6"),
        cancelText: t("Btn.item7"),
    })
    if (flag.value) {
        return;
    } else {
        flag.value = true;
    }
    let res = await activityApi.ActivityComplete({ id: id });
    if (res.code == Code.StatusOK) {
        tableRef.value?.reload()
        uni.showToast({
            title: t("Msg.Success"),
            icon: "success",
        })
        flag.value = false;
    } else {
        uni.showToast({
            title: res.msg,
            icon: "none",
        })
        flag.value = false;
    }
}
// 表格列配置（支持插槽和格式化）
const columns = computed(() => [
    {
        prop: 'login',
        label: t('Drawer.Label.TradingAccount'),
        align: 'center',
        formatter: ({ row }) => row.login || '--'
    },
    {
        prop: 'addTime',
        label: t('Drawer.Label.Date'),
        align: 'center',
        formatter: ({ row }) => row.addTime || '--'
    },
    {
        prop: 'status',
        label: t('Drawer.Label.Status'),
        align: 'center',
        slot: 'status'
    },
    {
        label: t('Label.Note'),
        align: 'center',
        type: 'note'
    },
    {
        prop: 'action',
        label: t('Label.Action'),
        align: 'center',
        slot: 'action'
    }
])
//获取申请活动所需数据
const getStatus = async () => {
    let res = await activityApi.ActivityInfo({
        activityId: information.id,
    });
    if (res.code == Code.StatusOK) {
        loginOptions.value = res.data.map((item: any) => ({
            text: item.login,
            value: item.login,
            disable: item.status == 1 ||
                information.groupTypes.indexOf(item.groupType) == '-1' ||
                information.loginTypes.indexOf(item.type) == '-1'
        }))
    } else {
        uni.showToast({
            title: res.msg,
            icon: "none",
        })
    }
}
//申请活动
const activityApply = async () => {

    if (!information.agree) {
        uni.showToast({
            title: t("Msg.SystemPrompt"),
            icon: "none",
        })
        return;
    }
    if (flag.value) {
        return;
    } else {
        flag.value = true;
    }

    try {
        let res = await activityApi.ActivityApply({
            activityId: information.id,
            ...information,
        });
        if (res.code == Code.StatusOK) {
            confirmToReload();
            uni.showToast({
                title: t("Msg.Success"),
                icon: "none",
            })
            flag.value = false;
        } else {
            uni.showToast({
                title: res.msg,
                icon: "none",
            })
            flag.value = false;
        }
    } catch (error) {
        uni.showToast({
            title: error?.msg,
            icon: "none",
        })
        flag.value = false;
    }
}
const getApplyListApi = ref(null)
const search1 = reactive({
    activityId: ''
})

//申请列表弹出
const checkActivity = (val: any) => {
    information.id = val.id
    information.title = val.title
    dialogInfoTradingAdd1.value = true
    getApplyListApi.value = activityApi.ActivityApplyList
    search1.activityId = information.id
}



//回显
const onAgreeChange = (e) => {
    information.agree = e.detail.value.length > 0
}
//申请活动弹出
const applications = (val: any) => {
    information.id = val.id
    information.title = val.title
    getStatus()
    let loginType: any[] = []
    val.loginTypes.forEach((item: any) => {
        loginType.push(item.loginType)
    })
    let groupType: any[] = []
    val.groupTypes.forEach((item: any) => {
        groupType.push(item.groupType)
    })
    information.loginTypes = loginType
    information.groupTypes = groupType
    information.myType12 = 1
    console.log(information, 1212);

    dialogInfoTradingAdd.value = true
}

//详情
const toSingle = (id: string, listID?: string) => {
    if (
        id == "20zj" ||
        id == "23yx" ||
        id == "23jx" ||
        id == "23nz" ||
        id == "23nzTwo" ||
        id == "23jxVip" ||
        id == "23xinjia" ||
        id == "23jnhcj" ||
        id == "23nz_zx" ||
        id == "24JYB" ||
        id == "NoWorries" ||
        id == "NewYear24"
    ) {
        if (id == "23jx") {
            uni.navigateTo({
                url: `/pages/activities/content?id=&type=1&active=${id}&data1=${tableData3.value.show ? tableData3.value.activityStartTime : tableData3.value.showActivityStartTime}&data2=${tableData3.value.show ? tableData3.value.activityEndTime : tableData3.value.showActivityEndTime}&data3=${tableData3.value.show ? tableData3.value.applicationStartTime : tableData3.value.showApplicationStartTime}&data4=${tableData3.value.show ? tableData3.value.applicationEndTime : tableData3.value.showApplicationEndTime}`,
            })
        } else if (id == "23jxVip") {
            uni.navigateTo({
                url: `/pages/activities/content?id=&type=1&active=${id}&data1=${tableData3Vip.value.show ? tableData3Vip.value.activityStartTime : tableData3Vip.value.showActivityStartTime}&data2=${tableData3Vip.value.show ? tableData3Vip.value.activityEndTime : tableData3Vip.value.showActivityEndTime}&data3=${tableData3Vip.value.show ? tableData3Vip.value.applicationStartTime : tableData3Vip.value.showApplicationStartTime}&data4=${tableData3Vip.value.show ? tableData3Vip.value.applicationEndTime : tableData3Vip.value.showApplicationEndTime}`,
            })
        } else if (id == "24JYB") {
            uni.navigateTo({
                url: `/pages/activities/content?id=&type=1&active=${id}&data1=${tableData3JYB.value.show ? tableData3JYB.value.activityStartTime : tableData3JYB.value.showActivityStartTime}&data2=${tableData3JYB.value.show ? tableData3JYB.value.activityEndTime : tableData3JYB.value.showActivityEndTime}&data3=${tableData3JYB.value.show ? tableData3JYB.value.applicationStartTime : tableData3JYB.value.showApplicationStartTime}&data4=${tableData3JYB.value.show ? tableData3JYB.value.applicationEndTime : tableData3JYB.value.showApplicationEndTime}`,
            })
        } else if (id == "23nz") {
            uni.navigateTo({
                url: `/pages/activities/content?id=&type=1&active=${id}&data3=${tableData4.value.show ? tableData4.value.applicationStartTime : tableData4.value.showApplicationStartTime}&data4=${tableData4.value.show ? tableData4.value.applicationEndTime : tableData4.value.showApplicationEndTime}`,
            })
        } else if (id == "23nzTwo") {
            uni.navigateTo({
                url: `/pages/activities/content?id=&type=1&active=${id}&data3=${tableData4Two.value.show ? timeConvert(tableData4Two.value.applicationStartTime) : timeConvert(tableData4Two.value.showApplicationStartTime)}&data4=${tableData4Two.value.show ? timeConvert(tableData4Two.value.applicationEndTime) : timeConvert(tableData4Two.value.showApplicationEndTime)}`,
            })
        } else if (id == "NoWorries") {
            uni.navigateTo({
                url: `/pages/activities/content?id=&type=1&active=${id}`,
            })
        } else if (id == "NewYear24") {
            uni.navigateTo({
                url: `/pages/activities/content?id=&type=1&active=${id}`,
            })
        } else {
            uni.navigateTo({
                url: `/pages/activities/content?id=&type=1&active=${id}`,
            })
        }
    } else if (id == "newList") {
        uni.navigateTo({
            url: `/pages/activities/content?id=${listID}&type=1&active=newList`,
        })
    } else {
        uni.navigateTo({
            url: `/pages/activities/content?id=${id}&type=1`,
        })
    }
}
const goDollarActivityDetail = () => {
    uni.navigateTo({
        url: `/pages/activities/content?id=&type=1&active=dollar`,
    })
}
const goDollarTaskList = () => {
    uni.navigateTo({
        url: `/pages/activities/dollar-list`,
    })
}
const openDollarParticipate = async () => {

    if (!dollarParticipateEnabled.value) {
        return;
    }
    try {
        await confirm({
            content: t("DollarActivity.confirmParticipate"),
            title: t("Msg.SystemPrompt"),
            confirmText: t("Btn.Confirm"),
            cancelText: t("Btn.Cancel"),
        })
    } catch {
        return;
    }
    if (flag.value) {
        return;
    } else {
        flag.value = true;
    }

    let res = await activityApi.ActivityDollarAdd({});
    if (res.code == Code.StatusOK) {
        uni.showToast({
            title: res.msg,
            icon: "success",
        })
        getActivityShowsInfo();
        flag.value = false;
        tableRef.value?.reload()
    } else {
        uni.showToast({
            title: res.msg,
            icon: "none",
        })
        flag.value = false;
    }
}
const handleValueInfoChange = (value: any) => {
    const selectedAccountObj = loginOptions1.value.find((item) => item.login === value)
    console.log("选中的账户对象:", selectedAccountObj)
    selectedAccount.value = selectedAccountObj
    getSurplusActivityOptions()
}

// ==================== 监听器 ====================
watch(NewYear24DataBalance, (newVal) => {
    NewYear24Data.balance = Number(newVal) || 0
})
watch(dialogSurplusActivity, (newVal) => {
    if (!newVal) { closeSurplusActivityDialog() }
})
watch(dialogSurplusActivity1, (newVal) => {
    if (!newVal) { closeSurplusActivityDialog1() }
})

// ==================== 生命周期 ====================
onMounted(() => {
    getDateList()
    // 2025-07-31 00:00:00 之后关闭 standard
    const endTime = new Date("2025/07/31 00:00:00").getTime()
    const timezone = 3
    const offset_GMT = new Date().getTimezoneOffset()
    const nowDate = new Date().getTime()
    const now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000).getTime()
    if (now >= endTime) {
        standard.value = false
    }
    is20Open()
    searchFunc()
    searchFunc1()
    getActivityPercentageGiveInfo()
    Activity23HundredInfo()
    // Activity23JiangxinInfo()
    Activity23JiangxinInfoVip()
    Activity24nianzhongInfo()
    Activity24nianzhongTwoInfo()
    GetActivityCptCode()
    Activity24JYBInfoVip()
    ActivityNoWorriesInfo()
    isRaffleOpen()
    isNewYear24Open()
    ActivityRequiteInfo()
    getActivityShowsInfo()
})

onUnmounted(() => {
    if (interval.value) {
        clearInterval(interval.value)
    }
})

onShow(async (options) => {
    showPage.value = false
    await nextTick()
    setTimeout(async () => {
        showPage.value = true
        await nextTick()
    }, 100)
})
onPullDownRefresh(() => {
    // 下拉刷新
    searchFunc()
    searchFunc1()
    uni.stopPullDownRefresh()
})

onReachBottom(() => {
    // 上拉加载更多
    if (pagerInfo.current < pagerInfo.pageTotal) {
        pagerInfo.current++
        searchFunc()
    }
})

// ==================== 导出 ====================
// 由于使用 <script setup>，所有顶层绑定都会自动暴露给模板
</script>

<style scoped lang="scss">
@import "@/uni.scss";

.card {
    color: var(--cwg-gray-color);
}

// 弹窗样式优化
.dia-content {
    .content {
        padding: 0 !important;
    }

    .form-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        margin-bottom: 20px;
        gap: 16px;

        .form-label {
            width: 120px;
            font-weight: 500;
            color: var(--bs-heading-color);
            font-size: px2rpx(16);
        }

        :deep(.cwg-combox) {
            flex: 1;
            width: 100%;

            .el-input__wrapper {
                border-radius: 4px;
            }

            &.disabled {
                .el-input__wrapper {
                    background-color: #f5f5f5;
                    cursor: not-allowed;
                }
            }
        }
    }
}

.btn-outline-dark1 {
    background-color: var(--btn-color) !important;
    color: var(--bs-emphasis-color) !important;
}

.surplusActivityDialog {
    height: 300px;
}

.dollar-activity-html {
    word-break: break-word;

    :deep(p) {
        margin: 0 0 6px;
    }
}
</style>