Search.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. <template>
  2. <div class="search-page">
  3. <!-- 顶部标题 -->
  4. <div class="page-header">
  5. <div class="header-content">
  6. <div class="logo-wrapper">
  7. <div class="logo-container">
  8. <img src="@/assets/images/logo.png" alt="告白语音" class="logo-image" />
  9. </div>
  10. </div>
  11. </div>
  12. </div>
  13. <!-- 搜索框 -->
  14. <div class="search-container">
  15. <div class="search-input-card">
  16. <div class="search-input">
  17. <van-field
  18. v-model="searchValue"
  19. placeholder="搜索Id号码"
  20. clearable
  21. class="user-search-field"
  22. />
  23. <van-button type="primary" class="search-btn" @click="onSearch">搜索</van-button>
  24. </div>
  25. </div>
  26. </div>
  27. <!-- 充值金额选择 -->
  28. <div class="recharge-section">
  29. <h2 class="section-title">充值金额</h2>
  30. <div class="recharge-grid">
  31. <div
  32. v-for="(item, index) in coinOptions"
  33. :key="index"
  34. class="recharge-item"
  35. :class="{ active: selectedRecharge === index }"
  36. @click="selectRecharge(index)"
  37. >
  38. <div class="diamond-icon">
  39. <img src="@/assets/images/recharge_zuanshi.png" alt="钻石" class="diamond-img" />
  40. </div>
  41. <div class="recharge-amount">{{ item.amount }}</div>
  42. <div class="recharge-price">¥{{ item.price }}</div>
  43. </div>
  44. </div>
  45. </div>
  46. <!-- 支付方式 -->
  47. <div class="payment-section">
  48. <div class="payment-option">
  49. <div class="payment-icon">
  50. <img src="@/assets/images/recharge_paypal.png" alt="支付宝支付" class="alipay-icon" />
  51. </div>
  52. <div class="payment-name">支付宝支付</div>
  53. <div class="payment-selected">
  54. <img src="@/assets/images/duihao.png" alt="选中" class="check-icon" />
  55. </div>
  56. </div>
  57. </div>
  58. <!-- 温馨提示 -->
  59. <div class="tips-section">
  60. <div class="tips-title">温馨提示:</div>
  61. <div class="tips-content">
  62. <div class="tip-item">1. 充值前请确定您已满18周岁并具有完全民事行为能力。</div>
  63. <div class="tip-item">2. 安全账号转账、理赔转账、刷单、代充均为骗局,请认真核实并确认</div>
  64. <div class="tip-item">3. 大额充值,请确保支付宝账户余额充足</div>
  65. <div class="tip-item">4. 如有疑问,请联系服务号客服</div>
  66. </div>
  67. <!-- 协议勾选 -->
  68. <div class="agreement-checkbox" @click="toggleAgreement">
  69. <div class="checkbox-wrapper" :class="{ checked: agreementChecked }">
  70. <van-icon v-if="agreementChecked" name="success" size="14" color="#fff" />
  71. </div>
  72. <div class="agreement-text">
  73. 我已阅读并同意 <span class="agreement-link" @click.stop="showAgreement">《用户充值协议》</span>
  74. </div>
  75. </div>
  76. </div>
  77. <!-- 支付按钮 -->
  78. <div class="pay-button">
  79. <van-button type="primary" block round @click="confirmPay">确认支付</van-button>
  80. </div>
  81. <!-- 协议弹框 -->
  82. <van-dialog
  83. v-model="agreementVisible"
  84. title="用户充值协议"
  85. confirm-button-text="我已阅读"
  86. @confirm="agreementChecked = true"
  87. :show-cancel-button="false"
  88. >
  89. <div class="agreement-content">
  90. <iframe v-if="agreementVisible" src="https://gbyy91.com/agreement/recharge.html" frameborder="0" class="agreement-iframe"></iframe>
  91. </div>
  92. </van-dialog>
  93. </div>
  94. </template>
  95. <script>
  96. import { getProductList } from '@/api/product'
  97. import { getUserInfo } from '@/api/user'
  98. import { getPlatformType, getDevicePayWayId } from '@/utils/config'
  99. export default {
  100. name: 'SearchPage',
  101. data() {
  102. return {
  103. tianyongchao: '',
  104. copyData: '',
  105. userCode: '',
  106. searchValue: '',
  107. coinOptions: [],
  108. selectedRecharge: 0,
  109. paymentMethod: 'alipay',
  110. agreementChecked: false,
  111. agreementVisible: false
  112. }
  113. },
  114. created() {
  115. // 获取产品列表
  116. this.fetchProductList()
  117. },
  118. methods: {
  119. // 获取产品列表
  120. async fetchProductList() {
  121. try {
  122. const payWayId = getDevicePayWayId()
  123. const res = await getProductList(payWayId)
  124. this.coinOptions = res.data || []
  125. } catch (error) {
  126. console.error('获取产品列表失败:', error)
  127. // 设置默认数据,以防接口调用失败
  128. this.coinOptions = [
  129. { amount: 60, price: 6 },
  130. { amount: 120, price: 6 },
  131. { amount: 300, price: 6 },
  132. { amount: 600, price: 6 },
  133. { amount: 1000, price: 6 },
  134. { amount: 2000, price: 6 },
  135. { amount: 3800, price: 6 },
  136. { amount: 5000, price: 6 },
  137. { amount: 10000, price: 6 }
  138. ]
  139. }
  140. },
  141. async onSearch() {
  142. if (!this.searchValue) {
  143. this.$toast('请输入用户ID')
  144. return
  145. }
  146. try {
  147. // 显示加载提示
  148. this.$toast.loading({
  149. message: '搜索中...',
  150. forbidClick: true,
  151. duration: 0
  152. })
  153. // 从接口获取用户信息
  154. const res = await getUserInfo(this.searchValue)
  155. this.$toast.clear()
  156. if (res.data && res.data.userId) {
  157. // 跳转到充值页面,并传递用户信息
  158. this.$router.push({
  159. path: '/recharge',
  160. query: {
  161. id: res.data.userId,
  162. nickname: res.data.userName,
  163. avatar: res.data.avatar
  164. }
  165. })
  166. } else {
  167. this.$toast('未找到该用户')
  168. }
  169. } catch (error) {
  170. this.$toast.clear()
  171. console.error('获取用户信息失败:', error)
  172. this.$toast('搜索用户失败,请重试')
  173. }
  174. },
  175. selectRecharge(index) {
  176. this.selectedRecharge = index
  177. },
  178. // 切换协议勾选状态
  179. toggleAgreement() {
  180. this.agreementChecked = !this.agreementChecked
  181. },
  182. // 显示协议弹框
  183. showAgreement() {
  184. this.agreementVisible = true
  185. },
  186. confirmPay() {
  187. if (!this.searchValue) {
  188. this.$toast('请先搜索用户')
  189. return
  190. }
  191. // 检查协议是否勾选
  192. if (!this.agreementChecked) {
  193. this.$toast('请阅读并同意充值协议')
  194. return
  195. }
  196. // 使用二次确认弹窗
  197. this.$dialog.confirm({
  198. title: '支付确认',
  199. message: `
  200. <div class="confirm-dialog-content">
  201. <div class="confirm-price">¥${this.coinOptions[this.selectedRecharge]?.price || 0}</div>
  202. <div class="confirm-tip">请核实并确认ID是否正确,请提防:</div>
  203. <div class="warning-list">
  204. <div class="warning-item">刷单赚取佣金</div>
  205. <div class="warning-item">公检法要求转账到安全账户</div>
  206. <div class="warning-item">购物退款、理赔需要转账</div>
  207. <div class="warning-item">代充值</div>
  208. <div class="warning-item">支付返利活动</div>
  209. </div>
  210. </div>
  211. `,
  212. confirmButtonText: '确认支付',
  213. cancelButtonText: '取消',
  214. showCancelButton: true,
  215. showConfirmButton: true,
  216. className: 'custom-dialog',
  217. allowHtml: true
  218. }).then(() => {
  219. // 继续搜索并支付流程
  220. this.onSearch()
  221. }).catch(() => {
  222. // 取消支付
  223. })
  224. }
  225. }
  226. }
  227. </script>
  228. <style scoped>
  229. .search-page {
  230. min-height: 100vh;
  231. display: flex;
  232. flex-direction: column;
  233. background-color: #F5F7FA;
  234. padding-bottom: 10px;
  235. position: relative;
  236. overflow: hidden;
  237. }
  238. /* 顶部标题样式 */
  239. .page-header {
  240. padding: 5px 16px 0;
  241. display: flex;
  242. align-items: center;
  243. margin-bottom: 0;
  244. }
  245. .header-content {
  246. display: flex;
  247. align-items: center;
  248. width: 100%;
  249. }
  250. .logo-wrapper {
  251. display: flex;
  252. align-items: center;
  253. justify-content: flex-start;
  254. width: 100%;
  255. }
  256. .logo-container {
  257. display: flex;
  258. align-items: center;
  259. justify-content: flex-start;
  260. }
  261. .logo-image {
  262. width: 60px;
  263. height: 60px;
  264. object-fit: contain;
  265. }
  266. /* 页面标题样式 */
  267. .page-title {
  268. text-align: center;
  269. margin-bottom: 5px;
  270. }
  271. .page-title h1 {
  272. font-size: 18px;
  273. font-weight: 600;
  274. color: #333;
  275. margin: 0;
  276. }
  277. /* 搜索框样式 */
  278. .search-container {
  279. padding: 0 8px;
  280. margin-top: 0;
  281. margin-bottom: 5px;
  282. }
  283. .search-input-card {
  284. background-color: #fff;
  285. border-radius: 12px;
  286. padding: 8px;
  287. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  288. }
  289. .search-input {
  290. display: flex;
  291. align-items: center;
  292. margin-top: 0;
  293. background-color: transparent;
  294. border-radius: 0;
  295. padding: 0;
  296. box-shadow: none;
  297. }
  298. .user-search-field {
  299. flex: 1;
  300. background-color: #F5F5F5;
  301. border-radius: 30px;
  302. margin-right: 10px;
  303. height: 38px;
  304. display: flex;
  305. align-items: center;
  306. }
  307. .user-search-field :deep(.van-field__control) {
  308. height: 38px;
  309. min-height: 38px;
  310. text-align: left;
  311. padding-left: 15px;
  312. padding-right: 0;
  313. font-size: 14px;
  314. color: #999;
  315. line-height: 38px;
  316. }
  317. .user-search-field :deep(.van-field__placeholder) {
  318. text-align: left;
  319. width: 100%;
  320. padding-left: 15px;
  321. color: #999;
  322. line-height: 38px;
  323. }
  324. .search-btn {
  325. height: 38px;
  326. line-height: 38px;
  327. border-radius: 20px;
  328. background-color: #B66FFF;
  329. border: none;
  330. padding: 0 15px;
  331. font-size: 14px;
  332. box-shadow: 0 2px 6px rgba(182, 111, 255, 0.3);
  333. }
  334. /* 充值金额样式 */
  335. .recharge-section {
  336. padding: 0 8px;
  337. margin-bottom: 5px;
  338. }
  339. .section-title {
  340. font-size: 14px;
  341. font-weight: bold;
  342. margin-bottom: 5px;
  343. color: #333;
  344. }
  345. .recharge-grid {
  346. display: grid;
  347. grid-template-columns: repeat(3, 1fr);
  348. gap: 10px;
  349. padding: 0 2px;
  350. }
  351. .recharge-item {
  352. background-color: #F0F0F0;
  353. border-radius: 8px;
  354. padding: 8px 8px;
  355. display: flex;
  356. flex-direction: column;
  357. align-items: center;
  358. cursor: pointer;
  359. transition: all 0.2s ease;
  360. border: 1px solid #DDDDDD;
  361. position: relative;
  362. overflow: hidden;
  363. }
  364. .recharge-item.active {
  365. background-color: #F5EEFF;
  366. border: 1px solid #B66FFF;
  367. transform: scale(1.02);
  368. box-shadow: 0 2px 8px rgba(182, 111, 255, 0.2);
  369. }
  370. .recharge-item.active:before {
  371. content: "";
  372. position: absolute;
  373. top: 0;
  374. right: 0;
  375. width: 0;
  376. height: 0;
  377. border-style: solid;
  378. border-width: 0 20px 20px 0;
  379. border-color: transparent #B66FFF transparent transparent;
  380. }
  381. .recharge-item.active:after {
  382. content: "✓";
  383. position: absolute;
  384. top: 0;
  385. right: 3px;
  386. color: white;
  387. font-size: 10px;
  388. font-weight: bold;
  389. }
  390. .diamond-icon {
  391. margin-bottom: 3px;
  392. }
  393. .diamond-img {
  394. width: 20px;
  395. height: 20px;
  396. object-fit: contain;
  397. }
  398. .recharge-amount {
  399. font-size: 14px;
  400. font-weight: bold;
  401. margin-bottom: 1px;
  402. }
  403. .recharge-price {
  404. font-size: 12px;
  405. color: #666;
  406. }
  407. /* 支付方式样式 */
  408. .payment-section {
  409. padding: 0 8px;
  410. margin-bottom: 5px;
  411. background-color: #fff;
  412. border-radius: 12px;
  413. margin-left: 8px;
  414. margin-right: 8px;
  415. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  416. }
  417. .payment-option {
  418. display: flex;
  419. align-items: center;
  420. padding: 8px;
  421. border-bottom: 1px solid #EAEAEA;
  422. }
  423. .payment-icon {
  424. margin-right: 12px;
  425. }
  426. .alipay-icon {
  427. width: 28px;
  428. height: 28px;
  429. object-fit: contain;
  430. }
  431. .payment-name {
  432. flex: 1;
  433. font-size: 14px;
  434. font-weight: 500;
  435. color: #333;
  436. }
  437. .payment-selected {
  438. display: flex;
  439. align-items: center;
  440. justify-content: center;
  441. }
  442. .check-icon {
  443. width: 20px;
  444. height: 20px;
  445. object-fit: contain;
  446. }
  447. /* 温馨提示样式 */
  448. .tips-section {
  449. padding: 8px 12px;
  450. margin: 0 8px 5px;
  451. background-color: #f8f8f8;
  452. border-radius: 12px;
  453. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  454. }
  455. .tips-title {
  456. font-size: 14px;
  457. font-weight: 600;
  458. color: #333;
  459. margin-bottom: 5px;
  460. }
  461. .tips-content {
  462. margin-bottom: 4px;
  463. }
  464. .tip-item {
  465. font-size: 12px;
  466. color: #666;
  467. margin-bottom: 6px;
  468. line-height: 1.5;
  469. }
  470. .tip-item:last-child {
  471. margin-bottom: 0;
  472. }
  473. .agreement-checkbox {
  474. display: flex;
  475. align-items: center;
  476. margin-top: 5px;
  477. cursor: pointer;
  478. }
  479. .checkbox-wrapper {
  480. width: 16px;
  481. height: 16px;
  482. border: 1px solid #ddd;
  483. border-radius: 3px;
  484. margin-right: 6px;
  485. display: flex;
  486. align-items: center;
  487. justify-content: center;
  488. }
  489. .checkbox-wrapper.checked {
  490. background-color: #B66FFF;
  491. border-color: #B66FFF;
  492. }
  493. .agreement-text {
  494. font-size: 12px;
  495. color: #666;
  496. }
  497. .agreement-link {
  498. color: #B66FFF;
  499. text-decoration: none;
  500. }
  501. /* 协议弹框样式 */
  502. .agreement-content {
  503. padding: 10px;
  504. height: 60vh;
  505. overflow: hidden;
  506. }
  507. .agreement-iframe {
  508. width: 100%;
  509. height: 100%;
  510. border: none;
  511. }
  512. /* 支付按钮样式 */
  513. .pay-button {
  514. padding: 0 8px;
  515. margin-top: auto;
  516. margin-bottom: 5px;
  517. }
  518. .pay-button .van-button {
  519. background-color: #B66FFF;
  520. border: none;
  521. height: 38px;
  522. font-size: 15px;
  523. font-weight: 500;
  524. box-shadow: 0 4px 12px rgba(182, 111, 255, 0.3);
  525. }
  526. /* 二次确认弹窗样式 */
  527. :deep(.custom-dialog) {
  528. width: 90%;
  529. max-width: 300px;
  530. border-radius: 12px;
  531. overflow: hidden;
  532. }
  533. :deep(.custom-dialog .van-dialog__header) {
  534. padding: 15px 0;
  535. font-weight: 600;
  536. font-size: 16px;
  537. color: #333;
  538. }
  539. :deep(.custom-dialog .van-dialog__content) {
  540. padding: 10px 20px 20px;
  541. }
  542. :deep(.confirm-dialog-content) {
  543. display: flex;
  544. flex-direction: column;
  545. align-items: center;
  546. text-align: center;
  547. }
  548. :deep(.confirm-price) {
  549. font-size: 24px;
  550. font-weight: bold;
  551. color: #333;
  552. margin-bottom: 10px;
  553. }
  554. :deep(.confirm-tip) {
  555. font-size: 14px;
  556. color: #333;
  557. font-weight: 500;
  558. margin-bottom: 3px;
  559. text-align: left;
  560. align-self: flex-start;
  561. }
  562. :deep(.warning-list) {
  563. width: 100%;
  564. text-align: left;
  565. margin-top: 0;
  566. }
  567. :deep(.warning-item) {
  568. font-size: 13px;
  569. color: #666;
  570. margin-bottom: 5px;
  571. position: relative;
  572. padding-left: 12px;
  573. }
  574. :deep(.warning-item:before) {
  575. content: "•";
  576. position: absolute;
  577. left: 0;
  578. color: #666;
  579. }
  580. :deep(.custom-dialog .van-dialog__footer) {
  581. display: flex;
  582. border-top: 1px solid #eee;
  583. }
  584. :deep(.custom-dialog .van-button) {
  585. flex: 1;
  586. height: 44px;
  587. font-size: 16px;
  588. border: none;
  589. border-radius: 0;
  590. margin: 0;
  591. }
  592. :deep(.custom-dialog .van-dialog__cancel) {
  593. color: #333;
  594. }
  595. :deep(.custom-dialog .van-dialog__confirm) {
  596. color: #f44336;
  597. font-weight: normal;
  598. }
  599. </style>