account-select.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('Custom.Withdraw.Title1')" />
  4. <view class="account-selector">
  5. <template v-if="loading">
  6. </template>
  7. <template v-else-if="standardAccounts.length > 0">
  8. <!-- PC 端表格视图 -->
  9. <view class="account-table pc-view">
  10. <!-- 表头:账户类型 -->
  11. <view class="table-header">
  12. <view class="header-cell type-cell">标准型账户</view>
  13. <view class="header-cell" v-t="'vu.item9'"></view>
  14. <view class="header-cell" v-t="'vu.item10'"></view>
  15. <view class="header-cell" v-t="'vu.item11'"></view>
  16. <!-- <view class="header-cell" v-t="'vu.item12'"></view> -->
  17. </view>
  18. <!-- 标准账户行 -->
  19. <template v-for="account in standardAccounts" :key="account.id">
  20. <view class="account-row" v-if="account.showCondition()" @click="onAccountSelect(account.id)"
  21. :class="{ 'active': account.id == selectedAccountId }">
  22. <view class="row-cell type-cell">
  23. <radio-group @change="(e) => onAccountSelect(account.id)" class="radio-group">
  24. <label class="radio-label">
  25. <radio :value="account.id" :checked="selectedAccountId === account.id"
  26. color="#1e2a3a" />
  27. <image class="account-icon" :src="account.icon" mode="aspectFit" />
  28. <view class="account-info">
  29. <text class="account-name" v-t="account.name" />
  30. <text class="account-desc" v-t="account.description" />
  31. </view>
  32. </label>
  33. </radio-group>
  34. </view>
  35. <view class="row-cell">{{ account.minDeposit }}</view>
  36. <view class="row-cell">{{ account.minSpread }}</view>
  37. <view class="row-cell">{{ account.maxLeverage }}</view>
  38. <!-- <view class="row-cell">{{ account.minSpread }}</view> -->
  39. </view>
  40. </template>
  41. </view>
  42. <!-- 移动端轮播视图 -->
  43. <view class="mobile-view">
  44. <swiper class="account-swiper" :current="currentSwiperIndex" circular indicator-dots
  45. indicator-active-color="#1e2a3a" @change="onSwiperChange">
  46. <swiper-item v-for="account in filteredAccounts" :key="account.id">
  47. <view class="account-card" @click="onAccountSelect(account.id)"
  48. :class="{ 'active': account.id == selectedAccountId }">
  49. <image class="card-img" :src="account.icon" mode="aspectFit" />
  50. <view class="card-title" v-t="account.name"></view>
  51. <view class="card-tag">
  52. <text class="tag-label">{{ account.typeLabel }}</text>
  53. </view>
  54. <p class="card-desc" v-t="account.description"></p>
  55. <view class="card-info-stack">
  56. <cwg-label-line-value :label="t('vu.item9')" :value="account.minDeposit" />
  57. <cwg-label-line-value :label="t('vu.item10')" :value="account.minSpread" />
  58. <cwg-label-line-value :label="t('vu.item11')" :value="account.maxLeverage" />
  59. <!-- <cwg-label-line-value :label="t('vu.item12')" :value="account.minSpread" /> -->
  60. </view>
  61. </view>
  62. </swiper-item>
  63. </swiper>
  64. </view>
  65. <!-- 继续按钮 -->
  66. <view class="action-button">
  67. <view class="btn" @click="handleContinue">
  68. <text class="button-text" v-t="'forget.forget'" />
  69. </view>
  70. </view>
  71. </template>
  72. </view>
  73. <!-- 条款说明 -->
  74. <view class="terms-section">
  75. <text v-t="'news_add_field.OpenAccount.Des1'"></text>
  76. <text class="pdfLink">
  77. <cwg-link type="pdf" title="news_add_field.OpenAccount.Des2" url="pdf/PrivacyPolicy2019_01.pdf"
  78. target="_blank" />
  79. </text>
  80. </view>
  81. </cwg-page-wrapper>
  82. </template>
  83. <script setup>
  84. import { ref, computed, onMounted, } from 'vue';
  85. import { onLoad } from '@dcloudio/uni-app';
  86. import { customApi } from "@/service/custom";
  87. import useRouter from "@/hooks/useRouter";
  88. import { useI18n } from "vue-i18n";
  89. const router = useRouter();
  90. const { t } = useI18n();
  91. const server = ref('')
  92. const showLogin = ref(null)
  93. const isTimeShow = ref(true)
  94. const loading = ref(true)
  95. onLoad((e) => {
  96. server.value = e.server
  97. })
  98. const typeList = computed(() => [
  99. {
  100. id: 7,
  101. type: 'StandardAccount',
  102. name: 'AccountType.StandardAccount',
  103. showCondition: () => showLogin.value && showLogin.value.indexOf('7') == -1,
  104. description: 'Custom.NewAccount.DesLogin5',
  105. minDeposit: '200 USD',
  106. minSpread: '0.01',
  107. maxLeverage: '1:1000',
  108. icon: '/static/images/info/bank-information-1.webp',
  109. },
  110. {
  111. id: 2,
  112. type: 'SeniorAccount',
  113. name: 'AccountType.SeniorAccount',
  114. showCondition: () => showLogin.value && showLogin.value.indexOf('2') == -1,
  115. description: 'Custom.NewAccount.DesLogin3',
  116. minDeposit: '200 USD',
  117. minSpread: '0.01',
  118. maxLeverage: '1:1000',
  119. icon: '/static/images/info/bank-information-2.webp',
  120. },
  121. {
  122. id: 8,
  123. type: 'CentAccount',
  124. name: 'AccountType.CentAccount',
  125. showCondition: () => showLogin.value && showLogin.value.indexOf('8') == -1 && isTimeShow.value,
  126. description: 'Custom.NewAccount.DesLogin8',
  127. minDeposit: '200 USD',
  128. minSpread: '0.01',
  129. maxLeverage: '1:500',
  130. icon: '/static/images/info/bank-information-3.webp',
  131. }
  132. ])
  133. // 定义账户数据类型
  134. const standardAccounts = computed(() => typeList.value.filter(account => account.showCondition()))
  135. const getExcludeShowLogin = async () => {
  136. try {
  137. let res = await customApi.excludeShowLogin({});
  138. if (res.code == 200) {
  139. if (res.data == null) {
  140. showLogin.value = [];
  141. } else {
  142. showLogin.value = res.data.excludeShowLoginTypes;
  143. }
  144. } else {
  145. console.error('获取账户显示权限失败:', res.msg);
  146. showLogin.value = [];
  147. }
  148. } catch (error) {
  149. console.error('获取账户显示权限出错:', error);
  150. showLogin.value = [];
  151. } finally {
  152. loading.value = false;
  153. }
  154. }
  155. // 过滤后的账户列表
  156. const filteredAccounts = computed(() => {
  157. return standardAccounts.value.filter(account => account.showCondition())
  158. })
  159. // 当前选中的账户 ID
  160. const selectedAccountId = ref(7)
  161. // 轮播图当前索引
  162. const currentSwiperIndex = computed(() => {
  163. const index = filteredAccounts.value.findIndex(a => a.id === selectedAccountId.value)
  164. return index > -1 ? index : 0
  165. })
  166. // 账户选择事件
  167. const onAccountSelect = (id) => {
  168. selectedAccountId.value = id
  169. }
  170. // 轮播图切换事件
  171. const onSwiperChange = (e) => {
  172. const index = e.detail.current
  173. const account = filteredAccounts.value[index]
  174. if (account) {
  175. selectedAccountId.value = account.id
  176. }
  177. }
  178. // 继续按钮点击事件,向上传递选中的账户信息
  179. const handleContinue = () => {
  180. router.push({
  181. path: "/pages/customer/create-account",
  182. query: { id: selectedAccountId.value, server: server.value },
  183. });
  184. }
  185. //获取显示权限
  186. onMounted(() => {
  187. getExcludeShowLogin()
  188. })
  189. </script>
  190. <style lang="scss" scoped>
  191. @import "@/uni.scss";
  192. .account-selector {
  193. background-color: #fff;
  194. overflow: hidden;
  195. min-height: 400px;
  196. }
  197. .loading-container {
  198. display: flex;
  199. flex-direction: column;
  200. align-items: center;
  201. justify-content: center;
  202. height: 400px;
  203. .loading-spinner {
  204. width: 40px;
  205. height: 40px;
  206. border: 3px solid #f3f3f3;
  207. border-top: 3px solid #1e2a3a;
  208. border-radius: 50%;
  209. animation: spin 1s linear infinite;
  210. margin-bottom: 16px;
  211. }
  212. .loading-text {
  213. font-size: 14px;
  214. color: #606266;
  215. }
  216. }
  217. @keyframes spin {
  218. 0% {
  219. transform: rotate(0deg);
  220. }
  221. 100% {
  222. transform: rotate(360deg);
  223. }
  224. }
  225. .table-wrapper {
  226. width: 100%;
  227. overflow-x: auto;
  228. white-space: nowrap;
  229. }
  230. .account-table {
  231. min-width: px2rpx(350);
  232. margin-bottom: px2rpx(10);
  233. /* 保证在小屏上可滚动 */
  234. display: flex;
  235. flex-direction: column;
  236. font-size: px2rpx(14);
  237. color: #333;
  238. }
  239. .table-header {
  240. display: flex;
  241. padding: px2rpx(10) 0;
  242. font-weight: 500;
  243. color: #666;
  244. .header-cell {
  245. flex: 1;
  246. text-align: center;
  247. padding: 0 px2rpx(8);
  248. white-space: normal;
  249. word-break: break-word;
  250. }
  251. .type-cell {
  252. flex: 2;
  253. text-align: left;
  254. padding-left: px2rpx(12);
  255. }
  256. }
  257. .professional-header {
  258. margin-top: px2rpx(8);
  259. }
  260. .account-row {
  261. display: flex;
  262. align-items: center;
  263. padding: px2rpx(12) 0;
  264. margin: px2rpx(12) 0;
  265. border: 1px solid rgba(108, 133, 149, 0.2);
  266. border-radius: px2rpx(8);
  267. &:hover {
  268. box-shadow: 0 10px 15px -3px rgba(7, 10, 12, 0.08), 0 4px 6px -4px rgba(7, 10, 12, 0.08), 0 0 4px 0 rgba(7, 10, 12, 0.08);
  269. }
  270. &.active {
  271. background-color: rgba(108, 133, 149, 0.07843);
  272. }
  273. .row-cell {
  274. flex: 1;
  275. text-align: center;
  276. padding: 0 px2rpx(8);
  277. font-size: px2rpx(12);
  278. color: #1e2a3a;
  279. white-space: normal;
  280. word-break: break-word;
  281. }
  282. .type-cell {
  283. flex: 2;
  284. text-align: left;
  285. padding-left: px2rpx(12);
  286. }
  287. }
  288. .radio-group {
  289. display: flex;
  290. align-items: center;
  291. width: 100%;
  292. }
  293. .radio-label {
  294. display: flex;
  295. align-items: center;
  296. gap: px2rpx(6);
  297. width: 100%;
  298. }
  299. radio {
  300. transform: scale(0.8);
  301. margin-right: px2rpx(4);
  302. }
  303. .account-icon {
  304. width: px2rpx(48);
  305. height: px2rpx(48);
  306. margin-right: px2rpx(24);
  307. flex-shrink: 0;
  308. }
  309. .account-info {
  310. flex: 1;
  311. display: flex;
  312. flex-direction: column;
  313. text-align: left;
  314. .account-name {
  315. font-size: px2rpx(14);
  316. font-weight: 500;
  317. color: #1e2a3a;
  318. margin-bottom: px2rpx(4);
  319. }
  320. .account-desc {
  321. font-size: px2rpx(12);
  322. color: #7f8c8d;
  323. line-height: 1.4;
  324. }
  325. }
  326. .mobile-view {
  327. display: none;
  328. }
  329. @media screen and (max-width: 600px) {
  330. .pc-view {
  331. display: none;
  332. }
  333. .mobile-view {
  334. display: block;
  335. padding: px2rpx(20) 0;
  336. }
  337. .account-swiper {
  338. height: px2rpx(520);
  339. width: 100%;
  340. }
  341. .account-card {
  342. background: #fff;
  343. border-radius: px2rpx(8);
  344. margin: px2rpx(2) px2rpx(2);
  345. padding: px2rpx(16);
  346. display: flex;
  347. flex-direction: column;
  348. align-items: center;
  349. text-align: center;
  350. border: 2px solid transparent;
  351. transition: all 0.3s;
  352. height: px2rpx(400);
  353. color: rgb(20, 29, 34);
  354. box-shadow:
  355. rgba(54, 61, 66, 0.15) 0px 0px 1px 0px,
  356. rgba(54, 61, 66, 0.04) 0px 2px 2px 0px,
  357. rgba(54, 61, 66, 0.12) 0px 2px 8px 0px,
  358. rgba(54, 61, 66, 0.08) 0px -2px 4px 0px;
  359. transition: box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1);
  360. overflow: hidden;
  361. &.active {
  362. transform: translateY(px2rpx(-5));
  363. }
  364. .card-img {
  365. width: px2rpx(120);
  366. height: px2rpx(120);
  367. margin-bottom: px2rpx(20);
  368. }
  369. .card-title {
  370. font-size: px2rpx(24);
  371. font-weight: 700;
  372. color: #1e2a3a;
  373. margin-bottom: px2rpx(8);
  374. }
  375. .card-tag {
  376. background: #f0f2f5;
  377. padding: px2rpx(4) px2rpx(12);
  378. border-radius: px2rpx(20);
  379. margin-bottom: px2rpx(16);
  380. .tag-label {
  381. font-size: px2rpx(12);
  382. color: #666;
  383. }
  384. }
  385. .card-desc {
  386. font-size: px2rpx(14);
  387. color: #7f8c8d;
  388. line-height: 1.6;
  389. margin-bottom: px2rpx(24);
  390. height: px2rpx(44);
  391. overflow: hidden;
  392. }
  393. .card-info-stack {
  394. width: 100%;
  395. display: flex;
  396. flex-direction: column;
  397. gap: px2rpx(12);
  398. .info-row {
  399. display: flex;
  400. justify-content: space-between;
  401. align-items: baseline;
  402. position: relative;
  403. font-size: px2rpx(14);
  404. &::after {
  405. content: "";
  406. flex: 1;
  407. margin: 0 px2rpx(10);
  408. border-bottom: 1px dotted #ddd;
  409. height: 1px;
  410. }
  411. .label {
  412. color: #666;
  413. order: 1;
  414. }
  415. .value {
  416. color: #1e2a3a;
  417. font-weight: 500;
  418. order: 3;
  419. }
  420. }
  421. }
  422. }
  423. .action-button {
  424. justify-content: center !important;
  425. // padding: 0 px2rpx(20);
  426. .btn {
  427. width: 100%;
  428. min-width: unset !important;
  429. }
  430. }
  431. .terms-section {
  432. text-align: center;
  433. padding: 0 px2rpx(20);
  434. }
  435. }
  436. .action-button {
  437. width: 100%;
  438. display: flex;
  439. justify-content: flex-end;
  440. margin-top: px2rpx(40);
  441. .btn {
  442. width: px2rpx(320);
  443. background-color: #cf1322;
  444. padding: px2rpx(12) px2rpx(20);
  445. border-radius: px2rpx(8);
  446. text-align: center;
  447. cursor: pointer;
  448. box-sizing: border-box;
  449. transition: all 0.2s;
  450. &:active {
  451. opacity: 0.9;
  452. transform: scale(0.98);
  453. }
  454. .button-text {
  455. color: #fff;
  456. font-size: px2rpx(16);
  457. font-weight: 600;
  458. }
  459. }
  460. }
  461. .terms-section {
  462. margin: px2rpx(30) 0;
  463. font-size: px2rpx(14);
  464. line-height: 1.7;
  465. color: #666;
  466. text-align: center;
  467. .pdfLink {
  468. margin-left: px2rpx(4);
  469. a {
  470. color: var(--color-primary);
  471. text-decoration: none;
  472. &:hover {
  473. text-decoration: underline;
  474. }
  475. }
  476. }
  477. }
  478. </style>