| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739 |
- <template>
- <view class="page-container">
- <!-- 顶部标题卡片 -->
- <view class="page-title-card">
- <text class="page-title-text">量化选股大师</text>
- </view>
- <scroll-view class="scroll-view" scroll-y>
- <view class="content-wrapper">
- <!-- 性能指标卡片 -->
- <view class="card performance-card">
- <view class="performance-item">
- <text class="performance-label">历史成功率</text>
- <text class="performance-value success">75%</text>
- </view>
- <view class="performance-item">
- <text class="performance-label">平均收益率</text>
- <text class="performance-value profit">+3.2%</text>
- </view>
- <view class="performance-item">
- <text class="performance-label">总交易次数</text>
- <text class="performance-value">120</text>
- </view>
- </view>
- <!-- 超短精选池区域 -->
- <view class="card pool-card">
- <view class="pool-header">
- <text class="pool-icon">⚡</text>
- <text class="pool-title">超短精选池</text>
- </view>
- <text class="pool-desc">今日更新,高频捕捉短期爆发机会</text>
-
- <!-- 未购买时显示锁定状态 -->
- <view v-if="!isPurchased" class="locked-content">
- <view class="lock-icon-wrapper">
- <text class="lock-icon">🔒</text>
- </view>
- <text class="lock-text">权限锁定: 查看 超短精选池 需付费</text>
- <text class="lock-desc">超短池为每日实时更新,捕捉短期爆发机会。</text>
- <view class="unlock-button" @click="showPurchaseModal">
- <text class="unlock-button-text">立即解锁 日 精选 (¥18/日)</text>
- </view>
- </view>
- <!-- 已购买时显示内容 -->
- <view v-else class="unlocked-content">
- <text class="unlocked-tip">您已解锁,可以查看超短精选池内容</text>
- <!-- 这里可以显示实际的股票池内容 -->
- <view class="stock-list-placeholder">
- <text class="placeholder-text">股票池内容将在此显示</text>
- </view>
- </view>
- </view>
- <!-- 历史股票池回顾 -->
- <view class="card history-card">
- <view class="history-header">
- <text class="history-icon">📅</text>
- <text class="history-title">历史股票池回顾</text>
- </view>
- <view class="history-search-row">
- <input
- class="history-date-input"
- type="text"
- placeholder="2025年11月20日"
- v-model="selectedDate"
- disabled
- />
- <view class="history-search-button" @click="onHistorySearch">
- <text class="search-icon">🔍</text>
- </view>
- </view>
- <text class="history-tip">请选择一个历史日期,查询当日入池股及次日表现。</text>
- </view>
- <!-- 预留底部空间 -->
- <view class="bottom-safe-area"></view>
- </view>
- </scroll-view>
- <!-- 手机号授权弹窗 -->
- <view v-if="showPhoneAuth" class="phone-auth-mask" @click="closePhoneAuth">
- <view class="phone-auth-prompt" @click.stop>
- <view class="auth-icon">📱</view>
- <text class="auth-title">授权手机号</text>
- <text class="auth-desc">为了完成登录,需要获取您的手机号</text>
-
- <button
- class="auth-button"
- open-type="getPhoneNumber"
- @getphonenumber="onGetPhoneNumber"
- >
- 授权手机号
- </button>
- </view>
- </view>
- <!-- 购买弹窗 -->
- <view v-if="showModal" class="modal-overlay" @click="closePurchaseModal">
- <view class="modal-content" @click.stop>
- <view class="modal-header">
- <text class="modal-title">超短池(日/周)订阅服务</text>
- <text class="modal-close" @click="closePurchaseModal">×</text>
- </view>
-
- <view class="subscription-options">
- <view
- class="subscription-option"
- :class="{ active: selectedPlan === 'daily' }"
- @click="selectedPlan = 'daily'"
- >
- <view class="option-info">
- <text class="option-title">日订阅</text>
- <text class="option-desc">当日有效</text>
- </view>
- <text class="option-price">¥18</text>
- </view>
-
- <view
- class="subscription-option"
- :class="{ active: selectedPlan === 'weekly' }"
- @click="selectedPlan = 'weekly'"
- >
- <view class="option-info">
- <text class="option-title">周套餐</text>
- <text class="option-desc">7天连续查看</text>
- </view>
- <text class="option-price">¥98</text>
- </view>
- </view>
- <view class="modal-footer">
- <view class="pay-button" @click="handlePurchase">
- <text class="pay-button-text">确认支付并解锁</text>
- </view>
- <text class="agreement-text">点击即表示同意《用户订阅协议》</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import { ref } from 'vue'
- import { onLoad, onShow } from '@dcloudio/uni-app'
- import { isLoggedIn as checkLoginStatus, wxAuthLogin } from '../../utils/auth.js'
- const isPurchased = ref(false)
- const showModal = ref(false)
- const showPhoneAuth = ref(false) // 是否显示手机号授权按钮
- const selectedPlan = ref('daily')
- const selectedDate = ref('2025年11月20日')
- const isLoggedIn = ref(false)
- // 检查登录状态
- const checkLogin = () => {
- isLoggedIn.value = checkLoginStatus()
- console.log('[超短池] 登录状态:', isLoggedIn.value)
- return isLoggedIn.value
- }
- // 检查购买状态
- const checkPurchaseStatus = () => {
- try {
- const purchaseInfo = uni.getStorageSync('pool_purchase')
- if (purchaseInfo) {
- const now = Date.now()
- const expireTime = purchaseInfo.expireTime
- if (now < expireTime) {
- isPurchased.value = true
- } else {
- // 已过期,清除购买信息
- uni.removeStorageSync('pool_purchase')
- isPurchased.value = false
- }
- } else {
- isPurchased.value = false
- }
- } catch (e) {
- console.error('检查购买状态失败:', e)
- isPurchased.value = false
- }
- }
- // 显示购买弹窗(需要登录)
- const showPurchaseModal = () => {
- console.log('点击立即解锁')
-
- // 检查登录状态
- if (!checkLogin()) {
- console.log('未登录,显示手机号授权弹窗')
- showPhoneAuth.value = true
- return
- }
-
- console.log('已登录,显示购买弹窗')
- showModal.value = true
- }
- // 处理手机号授权并完成登录
- const onGetPhoneNumber = async (e) => {
- console.log('[超短池] 获取手机号回调:', e.detail)
-
- if (e.detail.errMsg === 'getPhoneNumber:ok') {
- const phoneCode = e.detail.code
- console.log('[超短池] phoneCode:', phoneCode)
-
- uni.showLoading({
- title: '登录中...',
- mask: true
- })
-
- try {
- const loginRes = await uni.login()
- console.log('[超短池] uni.login完整响应:', loginRes)
- console.log('[超短池] 微信登录code:', loginRes.code)
-
- if (!loginRes.code) {
- throw new Error('获取微信登录code失败')
- }
-
- const result = await wxAuthLogin(loginRes.code, phoneCode)
-
- uni.hideLoading()
-
- if (result) {
- showPhoneAuth.value = false
- checkLogin()
- // 登录成功后显示购买弹窗
- showModal.value = true
- }
- } catch (error) {
- uni.hideLoading()
- console.error('[超短池] 登录失败:', error)
- }
- } else {
- showPhoneAuth.value = false
- uni.showToast({
- title: '需要授权手机号才能完成登录',
- icon: 'none',
- duration: 2000
- })
- }
- }
- // 关闭手机号授权弹窗
- const closePhoneAuth = () => {
- showPhoneAuth.value = false
- }
- // 关闭购买弹窗
- const closePurchaseModal = () => {
- showModal.value = false
- }
- // 处理购买
- const handlePurchase = () => {
- if (!selectedPlan.value) {
- uni.showToast({
- title: '请选择订阅方案',
- icon: 'none'
- })
- return
- }
- // 计算过期时间
- const now = Date.now()
- let expireTime = now
-
- if (selectedPlan.value === 'daily') {
- // 日订阅:当天23:59:59过期
- const today = new Date()
- today.setHours(23, 59, 59, 999)
- expireTime = today.getTime()
- } else if (selectedPlan.value === 'weekly') {
- // 周套餐:7天后过期
- expireTime = now + 7 * 24 * 60 * 60 * 1000
- }
- // 保存购买信息
- const purchaseInfo = {
- plan: selectedPlan.value,
- purchaseTime: now,
- expireTime: expireTime
- }
- uni.setStorageSync('pool_purchase', purchaseInfo)
- // 更新购买状态
- isPurchased.value = true
- // 关闭弹窗
- closePurchaseModal()
- // 显示成功提示
- uni.showToast({
- title: '解锁成功',
- icon: 'success'
- })
- }
- // 历史查询
- const onHistorySearch = () => {
- uni.showToast({
- title: '历史查询功能开发中',
- icon: 'none'
- })
- }
- // 使用uni-app生命周期钩子
- onLoad(() => {
- checkLogin()
- checkPurchaseStatus()
- })
- onShow(() => {
- // 每次页面显示时都检查登录状态和购买状态
- checkLogin()
- checkPurchaseStatus()
- })
- </script>
- <style>
- .page-container {
- height: 100vh;
- display: flex;
- flex-direction: column;
- background: #f5f6fb;
- }
- .scroll-view {
- flex: 1;
- height: 0;
- }
- .content-wrapper {
- padding: 32rpx;
- background: #f5f6fb;
- min-height: 100%;
- }
- .page-title-card {
- background: #ffffff;
- padding: 30rpx 0;
- text-align: center;
- box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
- border-radius: 0;
- }
- .page-title-text {
- font-size: 36rpx;
- font-weight: 800;
- color: #3F51F7;
- letter-spacing: 2rpx;
- }
- .card {
- background: #ffffff;
- border-radius: 24rpx;
- padding: 32rpx;
- box-shadow: 0 16rpx 40rpx rgba(37, 52, 94, 0.08);
- margin-bottom: 32rpx;
- }
- /* 性能指标卡片 */
- .performance-card {
- display: flex;
- justify-content: space-around;
- align-items: center;
- background: #f7f8fc;
- padding: 32rpx 24rpx;
- }
- .performance-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .performance-label {
- font-size: 24rpx;
- color: #666a7f;
- margin-bottom: 12rpx;
- }
- .performance-value {
- font-size: 32rpx;
- font-weight: 700;
- color: #222222;
- }
- .performance-value.success {
- color: #3abf81;
- }
- .performance-value.profit {
- color: #f16565;
- }
- /* 超短精选池卡片 */
- .pool-card {
- padding: 40rpx 32rpx;
- }
- .pool-header {
- display: flex;
- align-items: center;
- margin-bottom: 16rpx;
- }
- .pool-icon {
- font-size: 32rpx;
- margin-right: 12rpx;
- }
- .pool-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #222222;
- }
- .pool-desc {
- font-size: 26rpx;
- color: #666a7f;
- margin-bottom: 32rpx;
- }
- /* 锁定内容 */
- .locked-content {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 60rpx 0 40rpx;
- }
- .lock-icon-wrapper {
- margin-bottom: 32rpx;
- }
- .lock-icon {
- font-size: 80rpx;
- }
- .lock-text {
- font-size: 28rpx;
- color: #222222;
- margin-bottom: 16rpx;
- text-align: center;
- }
- .lock-desc {
- font-size: 24rpx;
- color: #9ca2b5;
- margin-bottom: 48rpx;
- text-align: center;
- line-height: 1.6;
- }
- .unlock-button {
- width: 100%;
- background: linear-gradient(135deg, #5d55e8, #7568ff);
- border-radius: 16rpx;
- padding: 28rpx 0;
- text-align: center;
- box-shadow: 0 12rpx 24rpx rgba(93, 85, 232, 0.4);
- }
- .unlock-button-text {
- font-size: 30rpx;
- font-weight: 600;
- color: #ffffff;
- }
- /* 已解锁内容 */
- .unlocked-content {
- margin-top: 32rpx;
- }
- .unlocked-tip {
- font-size: 26rpx;
- color: #3abf81;
- margin-bottom: 24rpx;
- display: block;
- }
- .stock-list-placeholder {
- padding: 60rpx 0;
- text-align: center;
- background: #f7f8fc;
- border-radius: 16rpx;
- }
- .placeholder-text {
- font-size: 26rpx;
- color: #9ca2b5;
- }
- /* 历史股票池回顾 */
- .history-card {
- padding: 32rpx;
- }
- .history-header {
- display: flex;
- align-items: center;
- margin-bottom: 24rpx;
- }
- .history-icon {
- font-size: 28rpx;
- margin-right: 12rpx;
- }
- .history-title {
- font-size: 30rpx;
- font-weight: 600;
- color: #222222;
- }
- .history-search-row {
- display: flex;
- align-items: center;
- margin-bottom: 16rpx;
- }
- .history-date-input {
- flex: 1;
- background: #f7f8fc;
- border-radius: 12rpx;
- padding: 24rpx 24rpx;
- font-size: 26rpx;
- color: #222222;
- }
- .history-search-button {
- width: 80rpx;
- height: 80rpx;
- background: #5d55e8;
- border-radius: 12rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-left: 16rpx;
- }
- .search-icon {
- font-size: 32rpx;
- color: #ffffff;
- }
- .history-tip {
- font-size: 24rpx;
- color: #9ca2b5;
- line-height: 1.6;
- }
- /* 购买弹窗 */
- .modal-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 1000;
- }
- .modal-content {
- width: 640rpx;
- background: #ffffff;
- border-radius: 24rpx;
- padding: 40rpx 32rpx 32rpx;
- box-sizing: border-box;
- }
- .modal-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 32rpx;
- }
- .modal-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #222222;
- }
- .modal-close {
- font-size: 48rpx;
- color: #9ca2b5;
- line-height: 1;
- width: 48rpx;
- height: 48rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .subscription-options {
- margin-bottom: 32rpx;
- }
- .subscription-option {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 32rpx 24rpx;
- border: 2rpx solid #e5e7eb;
- border-radius: 16rpx;
- margin-bottom: 20rpx;
- transition: all 0.3s;
- }
- .subscription-option.active {
- border-color: #5d55e8;
- background: #f7f8fc;
- }
- .option-info {
- display: flex;
- flex-direction: column;
- }
- .option-title {
- font-size: 28rpx;
- font-weight: 600;
- color: #222222;
- margin-bottom: 8rpx;
- }
- .option-desc {
- font-size: 24rpx;
- color: #9ca2b5;
- }
- .option-price {
- font-size: 36rpx;
- font-weight: 700;
- color: #f16565;
- }
- .modal-footer {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .pay-button {
- width: 100%;
- background: #f16565;
- border-radius: 16rpx;
- padding: 28rpx 0;
- text-align: center;
- margin-bottom: 24rpx;
- }
- .pay-button-text {
- font-size: 30rpx;
- font-weight: 600;
- color: #ffffff;
- }
- .agreement-text {
- font-size: 22rpx;
- color: #9ca2b5;
- }
- .bottom-safe-area {
- height: 80rpx;
- }
- /* 手机号授权弹窗 */
- .phone-auth-mask {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: rgba(0, 0, 0, 0.6);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 9999;
- }
- .phone-auth-prompt {
- width: 560rpx;
- background: #ffffff;
- border-radius: 24rpx;
- padding: 50rpx 40rpx;
- text-align: center;
- box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
- }
- .auth-icon {
- font-size: 72rpx;
- margin-bottom: 20rpx;
- }
- .auth-title {
- display: block;
- font-size: 32rpx;
- font-weight: 600;
- color: #222222;
- margin-bottom: 12rpx;
- }
- .auth-desc {
- display: block;
- font-size: 24rpx;
- color: #999999;
- line-height: 1.5;
- margin-bottom: 32rpx;
- }
- .auth-button {
- width: 100%;
- height: 80rpx;
- background: linear-gradient(135deg, #FF9800, #FFA726);
- color: #ffffff;
- border-radius: 40rpx;
- font-size: 30rpx;
- font-weight: 600;
- box-shadow: 0 8rpx 24rpx rgba(255, 152, 0, 0.4);
- display: flex;
- align-items: center;
- justify-content: center;
- border: none;
- padding: 0;
- line-height: 80rpx;
- }
- .auth-button::after {
- border: none;
- }
- </style>
|