pool.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. <template>
  2. <view class="page-container">
  3. <scroll-view class="scroll-view" scroll-y>
  4. <view class="content-wrapper">
  5. <!-- 超短精选池标题 -->
  6. <view class="pool-header-section">
  7. <view class="pool-header">
  8. <text class="pool-icon">⚡</text>
  9. <text class="pool-title">超短精选池</text>
  10. </view>
  11. <text class="pool-desc">今日更新,高频捕捉短期爆发机会</text>
  12. </view>
  13. <!-- 性能指标卡片 -->
  14. <view class="card performance-card">
  15. <view class="performance-item">
  16. <text class="performance-label">历史成功率</text>
  17. <text class="performance-value success">75%</text>
  18. </view>
  19. <view class="performance-item">
  20. <text class="performance-label">平均收益率</text>
  21. <text class="performance-value profit">+3.2%</text>
  22. </view>
  23. <view class="performance-item">
  24. <text class="performance-label">总交易次数</text>
  25. <text class="performance-value">120</text>
  26. </view>
  27. </view>
  28. <!-- 超短精选池区域 -->
  29. <view class="card pool-card">
  30. <!-- 未购买时显示锁定状态 -->
  31. <view v-if="!isPurchased" class="locked-content">
  32. <view class="lock-icon-wrapper">
  33. <text class="lock-icon">🔒</text>
  34. </view>
  35. <text class="lock-text">权限锁定: 查看 超短精选池 </text>
  36. <text class="lock-desc">超短池为每日实时更新,捕捉短期爆发机会。</text>
  37. <view class="unlock-button" @click="showPurchaseModal">
  38. <text class="unlock-button-text">立即打赏</text>
  39. </view>
  40. </view>
  41. <!-- 已购买时显示内容 -->
  42. <view v-else class="unlocked-content">
  43. <text class="unlocked-tip">您已解锁,可以查看超短精选池内容</text>
  44. <!-- 这里可以显示实际的股票池内容 -->
  45. <view class="stock-list-placeholder">
  46. <text class="placeholder-text">股票池内容将在此显示</text>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 历史股票池回顾 -->
  51. <view class="card history-card">
  52. <view class="history-header">
  53. <text class="history-icon">📅</text>
  54. <text class="history-title">历史股票池回顾</text>
  55. </view>
  56. <!-- 月份区间选择 -->
  57. <view class="date-range-row">
  58. <picker
  59. mode="date"
  60. fields="month"
  61. :value="startMonth"
  62. @change="onStartMonthChange"
  63. class="date-picker-half"
  64. >
  65. <view class="date-input">
  66. <text class="date-text">{{ formatMonth(startMonth) }}</text>
  67. <text class="date-icon">📅</text>
  68. </view>
  69. </picker>
  70. <text class="date-separator">至</text>
  71. <picker
  72. mode="date"
  73. fields="month"
  74. :value="endMonth"
  75. @change="onEndMonthChange"
  76. class="date-picker-half"
  77. >
  78. <view class="date-input">
  79. <text class="date-text">{{ formatMonth(endMonth) }}</text>
  80. <text class="date-icon">📅</text>
  81. </view>
  82. </picker>
  83. </view>
  84. <!-- 查询按钮 -->
  85. <view class="history-search-button-full" @click="onHistorySearch">
  86. <text class="search-button-text">🔍 查询历史数据</text>
  87. </view>
  88. <text class="history-tip">选择时间区间,查询该期间的入池股票及表现。</text>
  89. </view>
  90. <!-- 预留底部空间 -->
  91. <view class="bottom-safe-area"></view>
  92. </view>
  93. </scroll-view>
  94. <!-- 手机号授权弹窗 -->
  95. <view v-if="showPhoneAuth" class="phone-auth-mask" @click="closePhoneAuth">
  96. <view class="phone-auth-prompt" @click.stop>
  97. <text class="auth-title">授权手机号</text>
  98. <text class="auth-desc">为了完成登录,需要获取您的手机号</text>
  99. <button
  100. class="auth-button"
  101. open-type="getPhoneNumber"
  102. @getphonenumber="onGetPhoneNumber"
  103. >
  104. 授权手机号
  105. </button>
  106. </view>
  107. </view>
  108. <!-- 购买弹窗 -->
  109. <view v-if="showModal" class="modal-overlay" @click="closePurchaseModal">
  110. <view class="modal-content" @click.stop>
  111. <view class="modal-close-btn" @click="closePurchaseModal">
  112. <text class="close-icon">✕</text>
  113. </view>
  114. <view class="reward-header">
  115. <text class="reward-icon">💰</text>
  116. <text class="reward-title">打赏解锁</text>
  117. </view>
  118. <view class="reward-info">
  119. <text class="reward-desc">支持作者,解锁今日超短池内容</text>
  120. <view class="reward-amount-simple">
  121. <text class="amount-label">打赏金额:</text>
  122. <text class="amount-value">¥1</text>
  123. </view>
  124. </view>
  125. <view class="modal-footer">
  126. <view class="pay-button" @click="handlePurchase">
  127. <text class="pay-button-text">确认支付</text>
  128. </view>
  129. <text class="agreement-text">点击即表示同意《用户订阅协议》</text>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. </template>
  135. <script setup>
  136. import { ref } from 'vue'
  137. import { onLoad, onShow } from '@dcloudio/uni-app'
  138. import { isLoggedIn as checkLoginStatus } from '../../utils/auth.js'
  139. const isPurchased = ref(false)
  140. const showModal = ref(false)
  141. const showPhoneAuth = ref(false) // 是否显示手机号授权按钮
  142. const selectedPlan = ref('reward') // 固定为打赏
  143. const startMonth = ref('2025-01') // 开始月份
  144. const endMonth = ref('2025-11') // 结束月份
  145. const isLoggedIn = ref(false)
  146. // 格式化月份显示
  147. const formatMonth = (monthStr) => {
  148. if (!monthStr) return '请选择'
  149. const [year, month] = monthStr.split('-')
  150. return `${year}年${month}月`
  151. }
  152. // 检查登录状态
  153. const checkLogin = () => {
  154. isLoggedIn.value = checkLoginStatus()
  155. return isLoggedIn.value
  156. }
  157. // 检查购买状态
  158. const checkPurchaseStatus = () => {
  159. // 先检查登录状态
  160. if (!checkLogin()) {
  161. isPurchased.value = false
  162. return
  163. }
  164. try {
  165. const purchaseInfo = uni.getStorageSync('pool_purchase')
  166. if (purchaseInfo) {
  167. const now = Date.now()
  168. const expireTime = purchaseInfo.expireTime
  169. if (now < expireTime) {
  170. isPurchased.value = true
  171. } else {
  172. // 已过期,清除购买信息
  173. uni.removeStorageSync('pool_purchase')
  174. isPurchased.value = false
  175. }
  176. } else {
  177. isPurchased.value = false
  178. }
  179. } catch (e) {
  180. console.error('检查购买状态失败:', e)
  181. isPurchased.value = false
  182. }
  183. }
  184. // 显示购买弹窗(需要登录)
  185. const showPurchaseModal = () => {
  186. // 检查登录状态
  187. if (!checkLogin()) {
  188. uni.showModal({
  189. title: '登录提示',
  190. content: '此功能需要登录后使用,是否前往登录?',
  191. confirmText: '去登录',
  192. cancelText: '取消',
  193. success: (res) => {
  194. if (res.confirm) {
  195. uni.navigateTo({
  196. url: '/pages/login/login'
  197. })
  198. }
  199. }
  200. })
  201. return
  202. }
  203. showModal.value = true
  204. }
  205. // 关闭购买弹窗
  206. const closePurchaseModal = () => {
  207. showModal.value = false
  208. }
  209. // 处理购买
  210. const handlePurchase = () => {
  211. // 计算过期时间 - 当天23:59:59过期
  212. const now = Date.now()
  213. const today = new Date()
  214. today.setHours(23, 59, 59, 999)
  215. const expireTime = today.getTime()
  216. // 保存购买信息
  217. const purchaseInfo = {
  218. plan: 'reward',
  219. purchaseTime: now,
  220. expireTime: expireTime
  221. }
  222. uni.setStorageSync('pool_purchase', purchaseInfo)
  223. // 更新购买状态
  224. isPurchased.value = true
  225. // 关闭弹窗
  226. closePurchaseModal()
  227. // 显示成功提示
  228. uni.showToast({
  229. title: '解锁成功',
  230. icon: 'success'
  231. })
  232. }
  233. // 开始月份选择变化
  234. const onStartMonthChange = (e) => {
  235. startMonth.value = e.detail.value
  236. }
  237. // 结束月份选择变化
  238. const onEndMonthChange = (e) => {
  239. endMonth.value = e.detail.value
  240. }
  241. // 历史查询
  242. const onHistorySearch = () => {
  243. if (!startMonth.value || !endMonth.value) {
  244. uni.showToast({
  245. title: '请选择开始和结束月份',
  246. icon: 'none'
  247. })
  248. return
  249. }
  250. // 验证时间区间
  251. if (startMonth.value > endMonth.value) {
  252. uni.showToast({
  253. title: '开始月份不能晚于结束月份',
  254. icon: 'none'
  255. })
  256. return
  257. }
  258. uni.showToast({
  259. title: `查询${formatMonth(startMonth.value)}至${formatMonth(endMonth.value)}`,
  260. icon: 'none',
  261. duration: 2000
  262. })
  263. // TODO: 调用后端API查询历史数据
  264. // const response = await getHistoryPoolData(startMonth.value, endMonth.value)
  265. }
  266. // 使用uni-app生命周期钩子
  267. onLoad(() => {
  268. const loginStatus = checkLogin()
  269. console.log('[超短池] 登录状态:', loginStatus)
  270. checkPurchaseStatus()
  271. })
  272. onShow(() => {
  273. // 每次页面显示时都检查登录状态和购买状态
  274. const loginStatus = checkLogin()
  275. console.log('[超短池] 登录状态:', loginStatus)
  276. checkPurchaseStatus()
  277. // 设置导航栏标题
  278. uni.setNavigationBarTitle({ title: '量化交易大师' })
  279. })
  280. </script>
  281. <style>
  282. .page-container {
  283. height: 100vh;
  284. display: flex;
  285. flex-direction: column;
  286. background: #f5f6fb;
  287. }
  288. .scroll-view {
  289. flex: 1;
  290. height: 0;
  291. }
  292. .content-wrapper {
  293. padding: 32rpx;
  294. background: #f5f6fb;
  295. min-height: 100%;
  296. }
  297. .card {
  298. background: #ffffff;
  299. border-radius: 24rpx;
  300. padding: 32rpx;
  301. box-shadow: 0 16rpx 40rpx rgba(37, 52, 94, 0.08);
  302. margin-bottom: 32rpx;
  303. }
  304. /* 超短精选池标题区域 */
  305. .pool-header-section {
  306. margin-bottom: 24rpx;
  307. }
  308. .pool-header {
  309. display: flex;
  310. align-items: center;
  311. margin-bottom: 12rpx;
  312. }
  313. .pool-icon {
  314. font-size: 32rpx;
  315. margin-right: 12rpx;
  316. }
  317. .pool-title {
  318. font-size: 32rpx;
  319. font-weight: 600;
  320. color: #222222;
  321. }
  322. .pool-desc {
  323. font-size: 26rpx;
  324. color: #666a7f;
  325. }
  326. /* 性能指标卡片 */
  327. .performance-card {
  328. display: flex;
  329. justify-content: space-around;
  330. align-items: center;
  331. background: #f7f8fc;
  332. padding: 32rpx 24rpx;
  333. }
  334. .performance-item {
  335. display: flex;
  336. flex-direction: column;
  337. align-items: center;
  338. }
  339. .performance-label {
  340. font-size: 24rpx;
  341. color: #666a7f;
  342. margin-bottom: 12rpx;
  343. }
  344. .performance-value {
  345. font-size: 32rpx;
  346. font-weight: 700;
  347. color: #222222;
  348. }
  349. .performance-value.success {
  350. color: #3abf81;
  351. }
  352. .performance-value.profit {
  353. color: #f16565;
  354. }
  355. /* 超短精选池卡片 */
  356. .pool-card {
  357. padding: 32rpx;
  358. }
  359. /* 锁定内容 */
  360. .locked-content {
  361. display: flex;
  362. flex-direction: column;
  363. align-items: center;
  364. padding: 60rpx 0 40rpx;
  365. }
  366. .lock-icon-wrapper {
  367. margin-bottom: 32rpx;
  368. }
  369. .lock-icon {
  370. font-size: 80rpx;
  371. }
  372. .lock-text {
  373. font-size: 28rpx;
  374. color: #222222;
  375. margin-bottom: 16rpx;
  376. text-align: center;
  377. }
  378. .lock-desc {
  379. font-size: 24rpx;
  380. color: #9ca2b5;
  381. margin-bottom: 48rpx;
  382. text-align: center;
  383. line-height: 1.6;
  384. }
  385. .unlock-button {
  386. width: 100%;
  387. background: linear-gradient(135deg, #5d55e8, #7568ff);
  388. border-radius: 16rpx;
  389. padding: 28rpx 0;
  390. text-align: center;
  391. box-shadow: 0 12rpx 24rpx rgba(93, 85, 232, 0.4);
  392. }
  393. .unlock-button-text {
  394. font-size: 30rpx;
  395. font-weight: 600;
  396. color: #ffffff;
  397. }
  398. /* 已解锁内容 */
  399. .unlocked-content {
  400. margin-top: 32rpx;
  401. }
  402. .unlocked-tip {
  403. font-size: 26rpx;
  404. color: #3abf81;
  405. margin-bottom: 24rpx;
  406. display: block;
  407. }
  408. .stock-list-placeholder {
  409. padding: 60rpx 0;
  410. text-align: center;
  411. background: #f7f8fc;
  412. border-radius: 16rpx;
  413. }
  414. .placeholder-text {
  415. font-size: 26rpx;
  416. color: #9ca2b5;
  417. }
  418. /* 历史股票池回顾 */
  419. .history-card {
  420. padding: 32rpx;
  421. }
  422. .history-header {
  423. display: flex;
  424. align-items: center;
  425. margin-bottom: 24rpx;
  426. }
  427. .history-icon {
  428. font-size: 28rpx;
  429. margin-right: 12rpx;
  430. }
  431. .history-title {
  432. font-size: 30rpx;
  433. font-weight: 600;
  434. color: #222222;
  435. }
  436. .history-search-row {
  437. display: flex;
  438. align-items: center;
  439. }
  440. .date-range-row {
  441. display: flex;
  442. align-items: center;
  443. gap: 16rpx;
  444. margin-bottom: 24rpx;
  445. }
  446. .date-picker-half {
  447. flex: 1;
  448. }
  449. .date-separator {
  450. font-size: 26rpx;
  451. color: #666a7f;
  452. padding: 0 8rpx;
  453. }
  454. .date-input {
  455. background: #f7f8fc;
  456. border-radius: 12rpx;
  457. padding: 24rpx;
  458. font-size: 26rpx;
  459. color: #222222;
  460. display: flex;
  461. justify-content: space-between;
  462. align-items: center;
  463. }
  464. .date-text {
  465. flex: 1;
  466. }
  467. .date-icon {
  468. font-size: 28rpx;
  469. margin-left: 12rpx;
  470. }
  471. .history-search-button-full {
  472. width: 100%;
  473. background: linear-gradient(135deg, #5d55e8, #7568ff);
  474. border-radius: 16rpx;
  475. padding: 28rpx 0;
  476. text-align: center;
  477. margin-top: 12rpx;
  478. margin-bottom: 24rpx;
  479. box-shadow: 0 8rpx 20rpx rgba(93, 85, 232, 0.3);
  480. }
  481. .search-button-text {
  482. font-size: 28rpx;
  483. font-weight: 600;
  484. color: #ffffff;
  485. }
  486. .history-search-button {
  487. width: 80rpx;
  488. height: 80rpx;
  489. background: #5d55e8;
  490. border-radius: 12rpx;
  491. display: flex;
  492. align-items: center;
  493. justify-content: center;
  494. margin-left: 16rpx;
  495. }
  496. .search-icon {
  497. font-size: 32rpx;
  498. color: #ffffff;
  499. }
  500. .history-tip {
  501. font-size: 24rpx;
  502. color: #9ca2b5;
  503. line-height: 1.6;
  504. }
  505. /* 购买弹窗 */
  506. .modal-overlay {
  507. position: fixed;
  508. top: 0;
  509. left: 0;
  510. right: 0;
  511. bottom: 0;
  512. background: rgba(0, 0, 0, 0.5);
  513. display: flex;
  514. align-items: center;
  515. justify-content: center;
  516. z-index: 1000;
  517. }
  518. .modal-content {
  519. width: 640rpx;
  520. background: #ffffff;
  521. border-radius: 24rpx;
  522. padding: 48rpx 40rpx 40rpx;
  523. box-sizing: border-box;
  524. position: relative;
  525. }
  526. .modal-close-btn {
  527. position: absolute;
  528. top: 24rpx;
  529. right: 24rpx;
  530. width: 48rpx;
  531. height: 48rpx;
  532. display: flex;
  533. align-items: center;
  534. justify-content: center;
  535. z-index: 10;
  536. }
  537. .close-icon {
  538. font-size: 36rpx;
  539. color: #9ca2b5;
  540. font-weight: 300;
  541. line-height: 1;
  542. }
  543. .reward-header {
  544. display: flex;
  545. flex-direction: column;
  546. align-items: center;
  547. margin-bottom: 40rpx;
  548. }
  549. .reward-icon {
  550. font-size: 64rpx;
  551. margin-bottom: 16rpx;
  552. }
  553. .reward-title {
  554. font-size: 32rpx;
  555. font-weight: 600;
  556. color: #222222;
  557. }
  558. .reward-info {
  559. margin-bottom: 40rpx;
  560. }
  561. .reward-desc {
  562. display: block;
  563. font-size: 26rpx;
  564. color: #666a7f;
  565. text-align: center;
  566. margin-bottom: 24rpx;
  567. line-height: 1.6;
  568. }
  569. .reward-amount-simple {
  570. display: flex;
  571. justify-content: center;
  572. align-items: center;
  573. gap: 8rpx;
  574. }
  575. .amount-label {
  576. font-size: 28rpx;
  577. color: #666a7f;
  578. }
  579. .amount-value {
  580. font-size: 36rpx;
  581. font-weight: 700;
  582. color: #f16565;
  583. }
  584. .modal-footer {
  585. display: flex;
  586. flex-direction: column;
  587. align-items: center;
  588. }
  589. .pay-button {
  590. width: 100%;
  591. background: linear-gradient(135deg, #5d55e8, #7568ff);
  592. border-radius: 16rpx;
  593. padding: 28rpx 0;
  594. text-align: center;
  595. margin-bottom: 24rpx;
  596. box-shadow: 0 8rpx 20rpx rgba(93, 85, 232, 0.3);
  597. }
  598. .pay-button-text {
  599. font-size: 30rpx;
  600. font-weight: 600;
  601. color: #ffffff;
  602. }
  603. .agreement-text {
  604. font-size: 22rpx;
  605. color: #9ca2b5;
  606. }
  607. .bottom-safe-area {
  608. height: 80rpx;
  609. }
  610. /* 手机号授权弹窗 */
  611. .phone-auth-mask {
  612. position: fixed;
  613. top: 0;
  614. left: 0;
  615. right: 0;
  616. bottom: 0;
  617. background: rgba(0, 0, 0, 0.6);
  618. display: flex;
  619. align-items: center;
  620. justify-content: center;
  621. z-index: 9999;
  622. }
  623. .phone-auth-prompt {
  624. width: 560rpx;
  625. background: #ffffff;
  626. border-radius: 24rpx;
  627. padding: 50rpx 40rpx;
  628. text-align: center;
  629. box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.3);
  630. }
  631. .auth-icon {
  632. font-size: 72rpx;
  633. margin-bottom: 20rpx;
  634. }
  635. .auth-title {
  636. display: block;
  637. font-size: 32rpx;
  638. font-weight: 600;
  639. color: #222222;
  640. margin-bottom: 12rpx;
  641. }
  642. .auth-desc {
  643. display: block;
  644. font-size: 24rpx;
  645. color: #999999;
  646. line-height: 1.5;
  647. margin-bottom: 32rpx;
  648. }
  649. .auth-button {
  650. width: 100%;
  651. height: 80rpx;
  652. background: linear-gradient(135deg, #FF9800, #FFA726);
  653. color: #ffffff;
  654. border-radius: 40rpx;
  655. font-size: 30rpx;
  656. font-weight: 600;
  657. box-shadow: 0 8rpx 24rpx rgba(255, 152, 0, 0.4);
  658. display: flex;
  659. align-items: center;
  660. justify-content: center;
  661. border: none;
  662. padding: 0;
  663. line-height: 80rpx;
  664. }
  665. .auth-button::after {
  666. border: none;
  667. }
  668. </style>