applySignalDialog.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756
  1. <template>
  2. <cwg-popup :title="t('Documentary.TundManagement.item41')" :visible="visible" @close="closeDia" @confirm="confirmDia" width="700px">
  3. <uni-forms ref="formRef" :model="formData" :rules="rules" labelWidth="200" label-position="top" class="crm-form">
  4. <view class="dia-content">
  5. <!-- 名片信息 -->
  6. <view class="fllow-title">
  7. <text class="title">{{ t('Documentary.tradingCenter.item126') }}</text>
  8. </view>
  9. <view class="form-item">
  10. <uni-forms-item :label="t('Documentary.console.item20')" name="nickname">
  11. <uni-easyinput v-model="formData.nickname" :placeholder="t('placeholder.input')" />
  12. </uni-forms-item>
  13. </view>
  14. <view class="form-row">
  15. <view class="form-col">
  16. <view class="form-item">
  17. <uni-forms-item :label="t('Documentary.console.item21')" name="personalSignature">
  18. <uni-easyinput type="textarea" v-model="formData.personalSignature" :maxlength="100"
  19. @input="val => filterChineseEnglishOnly('personalSignature', val)"
  20. :placeholder="t('placeholder.input')" maxlength="24" minlength="6" />
  21. </uni-forms-item>
  22. </view>
  23. </view>
  24. <view class="form-col">
  25. <view class="form-item">
  26. <uni-forms-item :label="t('Documentary.console.item22')" name="traderStrategy">
  27. <uni-easyinput type="textarea" v-model="formData.traderStrategy" :maxlength="150"
  28. @input="val => filterChineseEnglishOnly('traderStrategy', val)"
  29. :placeholder="t('placeholder.input')" />
  30. </uni-forms-item>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="tip-red">
  35. <text>{{ t('Documentary.console.item37') }}</text>
  36. </view>
  37. <!-- 账户信息 -->
  38. <view class="fllow-title">
  39. <text class="title">{{ t('Documentary.TundManagement.item29') }}<text
  40. style="color: #eb3f57; font-weight: 500">{{ t('Documentary.item3') }}</text></text>
  41. </view>
  42. <view class="form-row">
  43. <view class="form-col">
  44. <view class="form-item">
  45. <uni-forms-item :label="t('Label.TradingAccount')" name="dealLogin">
  46. <cwg-combox v-model:value="formData.dealLogin" :options="loginOptionsData"
  47. :placeholder="t('placeholder.choose')" @change="selectLogin" />
  48. </uni-forms-item>
  49. </view>
  50. </view>
  51. <view class="form-col">
  52. <view class="form-item">
  53. <uni-forms-item :label="t('Label.PlatformType')" name="platform">
  54. <cwg-combox v-model:value="formData.platform"
  55. :options="[{ text: 'MT4', value: 'MT4' }, { text: 'MT5', value: 'MT5' }]"
  56. :placeholder="t('placeholder.choose')" />
  57. </uni-forms-item>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="form-row">
  62. <view class="form-col">
  63. <view class="form-item">
  64. <uni-forms-item :label="t('Label.AccountType')" name="loginType">
  65. <cwg-combox disabled v-model:value="formData.loginType" :options="accountTypeOptions"
  66. :placeholder="t('placeholder.choose')" />
  67. </uni-forms-item>
  68. </view>
  69. </view>
  70. <view class="form-col">
  71. <view class="form-item">
  72. <uni-forms-item :label="t('Label.Leverage')" name="leverage">
  73. <uni-easyinput disabled v-model="formData.leverage" :placeholder="t('placeholder.input')" />
  74. </uni-forms-item>
  75. </view>
  76. </view>
  77. </view>
  78. <!-- 展示设置 -->
  79. <view class="fllow-title">
  80. <text class="title">{{ t('Documentary.TundManagement.item32') }}</text>
  81. </view>
  82. <view class="form-row">
  83. <view class="form-col">
  84. <view class="form-item">
  85. <uni-forms-item :label="t('Documentary.TundManagement.item34')" name="historyShow">
  86. <cwg-combox v-model:value="formData.historyShow"
  87. :options="[{ text: t('Btn.item6'), value: 1 }, { text: t('Btn.item7'), value: 0 }]"
  88. :placeholder="t('placeholder.choose')" />
  89. </uni-forms-item>
  90. </view>
  91. </view>
  92. <view class="form-col">
  93. <view class="form-item">
  94. <uni-forms-item :label="t('Documentary.TundManagement.item35')" name="historyTime">
  95. <uni-datetime-picker type="date" v-model="formData.historyTime"
  96. :placeholder="t('Documentary.TundManagement.item37')" />
  97. </uni-forms-item>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="form-item">
  102. <uni-forms-item :label="t('Documentary.TundManagement.item36')" name="introduceShow">
  103. <cwg-combox v-model:value="formData.introduceShow"
  104. :options="[{ text: t('Btn.item6'), value: 1 }, { text: t('Btn.item7'), value: 0 }]"
  105. :placeholder="t('placeholder.choose')" />
  106. </uni-forms-item>
  107. </view>
  108. <!-- 分润设置 -->
  109. <view class="fllow-title">
  110. <text class="title">{{ t('Documentary.TundManagement.item33') }}</text>
  111. </view>
  112. <view class="form-row">
  113. <view class="form-col">
  114. <view class="form-item">
  115. <uni-forms-item :label="t('Documentary.TundManagement.item38')" name="distributionType">
  116. <cwg-combox v-model:value="formData.distributionType"
  117. :options="[{ text: t('Documentary.TundManagement.item59'), value: 1 }]"
  118. :placeholder="t('placeholder.choose')" />
  119. </uni-forms-item>
  120. </view>
  121. </view>
  122. <view class="form-col">
  123. <view class="form-item">
  124. <uni-forms-item :label="t('Documentary.TundManagement.item39')" name="distributionRatio">
  125. <view style="display: flex; align-items: center;">
  126. <uni-easyinput v-model="formData.distributionRatio" :placeholder="t('placeholder.input')"
  127. style="flex: 1;" />
  128. <text style="margin-left: 5px;">(%)</text>
  129. </view>
  130. </uni-forms-item>
  131. </view>
  132. </view>
  133. <view class="form-col">
  134. <view class="form-item">
  135. <uni-forms-item :label="t('Documentary.tradingCenter.item32')" name="settlementCycle">
  136. <cwg-combox v-model:value="formData.settlementCycle"
  137. :options="optList1"
  138. :placeholder="t('placeholder.choose')" />
  139. </uni-forms-item>
  140. </view>
  141. </view>
  142. </view>
  143. <!-- 协议 -->
  144. <view class="form-item agree">
  145. <uni-forms-item name="agree">
  146. <checkbox-group @change="onAgreeChange">
  147. <label class="checkbox-agree">
  148. <checkbox value="1" :checked="!!formData.agree" />
  149. <text class="agree-text">
  150. {{ t('Documentary.TundManagement.item42') }}
  151. <cwg-link type="pdf" style="text-decoration: underline;" class="a" v-if="['cn', 'zhHant'].indexOf(locale) != -1"
  152. url="pdf/CopyTradeUserAgreementcn.pdf" target="_blank" title="Documentary.TundManagement.item43" />
  153. <cwg-link type="pdf" style="text-decoration: underline;" class="a" v-else url="pdf/CopyTradeUserAgreement.pdf"
  154. target="_blank" title="Documentary.TundManagement.item43" />
  155. {{ t('Documentary.TundManagement.item42_2') }}
  156. </text>
  157. </label>
  158. </checkbox-group>
  159. </uni-forms-item>
  160. </view>
  161. </view>
  162. </uni-forms>
  163. <template #footer>
  164. <button @click="closeDia">{{ t('Btn.Cancel') }}</button>
  165. <button type="primary" @click="confirmDia">{{ t('Btn.Confirm') }}</button>
  166. </template>
  167. </cwg-popup>
  168. </template>
  169. <script setup>
  170. import { ref, computed, watch } from 'vue'
  171. import { useI18n } from 'vue-i18n'
  172. import Config from '@/config/index'
  173. import { documentaryApi } from '@/service/documentary'
  174. import {useFollowEnum} from '@/pages/follow/const/enum'
  175. const props = defineProps({
  176. visible: { type: Boolean, default: false },
  177. loginOptions: { type: Array, default: () => [] }
  178. })
  179. const emit = defineEmits(['close', 'confirm'])
  180. const { t, locale } = useI18n()
  181. const { Code } = Config
  182. const {optList1} = useFollowEnum()
  183. const formRef = ref(null)
  184. const formData = ref({
  185. nickname: '',
  186. personalSignature: '',
  187. traderStrategy: '',
  188. dealLogin: '',
  189. platform: '',
  190. loginType: '',
  191. leverage: '',
  192. historyShow: '',
  193. historyTime: '',
  194. introduceShow: '',
  195. distributionType: '',
  196. distributionRatio: '',
  197. settlementCycle: '',
  198. agree: false
  199. })
  200. const isSubmitting = ref(false)
  201. const accountTypeOptions = [
  202. { text: t('AccountType.ClassicAccount'), value: 1 },
  203. { text: t('AccountType.SeniorAccount'), value: 2 },
  204. { text: t('AccountType.SpeedAccount'), value: 5 },
  205. { text: t('AccountType.SpeedAccount'), value: 6 },
  206. { text: t('AccountType.StandardAccount'), value: 7 },
  207. { text: t('AccountType.CentAccount'), value: 8 }
  208. ]
  209. const loginOptionsData = computed(() => {
  210. return props.loginOptions.map(item => ({
  211. text: `${item.login} - ${groupTypeName(item.type)} - ${t('Custom.Deposit.AvailableBalance')}${groupCurrency(item.currency)}${item.balance}`,
  212. value: item.login,
  213. disabled: item.balance < 200
  214. }))
  215. })
  216. const groupTypeName = (type) => {
  217. const option = accountTypeOptions.find(opt => opt.value == type)
  218. return option ? option.text : type
  219. }
  220. const groupCurrency = (type) => {
  221. if (type == "GBP") {
  222. return ": £";
  223. } else if (type == "USD") {
  224. return ": $";
  225. } else if (type == "EUR") {
  226. return ": €";
  227. } else if (type == "USC") {
  228. return ": ¢";
  229. } else {
  230. return ": $";
  231. }
  232. }
  233. const rules = {
  234. password: {
  235. rules: [
  236. {
  237. required: true,
  238. validateFunction: (rule, value, data, callback) => {
  239. if (Config.Pattern.Password.test(value)) {
  240. callback()
  241. } else {
  242. callback(t('vaildate.password.format'))
  243. }
  244. return true
  245. }
  246. }
  247. ]
  248. },
  249. agree: {
  250. rules: [
  251. {
  252. validateFunction: (rule, value, data, callback) => {
  253. if (value) {
  254. callback()
  255. } else {
  256. callback(t('vaildate.agree.empty'))
  257. }
  258. return true
  259. }
  260. }
  261. ]
  262. },
  263. platform: {
  264. rules: [
  265. {
  266. required: true,
  267. errorMessage: t('vaildate.select.empty')
  268. }
  269. ]
  270. },
  271. currency: {
  272. rules: [
  273. {
  274. required: true,
  275. errorMessage: t('vaildate.select.empty')
  276. }
  277. ]
  278. },
  279. leverage: {
  280. rules: [
  281. {
  282. required: true,
  283. errorMessage: t('vaildate.select.empty')
  284. }
  285. ]
  286. },
  287. loginType: {
  288. rules: [
  289. {
  290. required: true,
  291. errorMessage: t('vaildate.select.empty'),
  292. }
  293. ]
  294. },
  295. dealLogin: {
  296. rules: [
  297. {
  298. required: true,
  299. errorMessage: t('vaildate.select.empty')
  300. }
  301. ]
  302. },
  303. distributionType: {
  304. rules: [
  305. {
  306. required: true,
  307. errorMessage: t('vaildate.select.empty')
  308. }
  309. ]
  310. },
  311. distributionRatio: {
  312. rules: [
  313. {
  314. required: true,
  315. errorMessage: t('vaildate.input.empty')
  316. },
  317. {
  318. validateFunction: (rule, value, data, callback) => {
  319. if (value >= 0 && value <= 50) {
  320. callback()
  321. } else {
  322. callback('0-50')
  323. }
  324. return true
  325. }
  326. }
  327. ]
  328. },
  329. settlementCycle: {
  330. rules: [
  331. {
  332. required: true,
  333. errorMessage: t('vaildate.input.empty')
  334. }
  335. ]
  336. },
  337. historyShow: {
  338. rules: [
  339. {
  340. required: true,
  341. errorMessage: t('vaildate.select.empty')
  342. }
  343. ]
  344. },
  345. historyTime: {
  346. rules: [
  347. {
  348. required: true,
  349. errorMessage: t('vaildate.select.empty')
  350. }
  351. ]
  352. },
  353. introduceShow: {
  354. rules: [
  355. {
  356. required: true,
  357. errorMessage: t('vaildate.select.empty')
  358. }
  359. ]
  360. },
  361. protectAmount: {
  362. rules: [
  363. {
  364. required: true,
  365. errorMessage: t('vaildate.input.empty')
  366. }
  367. ]
  368. },
  369. protectRatio: {
  370. rules: [
  371. {
  372. required: true,
  373. errorMessage: t('vaildate.input.empty')
  374. }
  375. ]
  376. },
  377. nickname: {
  378. rules: [
  379. {
  380. required: true,
  381. errorMessage: t('vaildate.input.empty')
  382. },
  383. {
  384. validateFunction: (rule, value, data, callback) => {
  385. if (value && /^[0-9a-zA-Z]{6,24}$/.test(value)) {
  386. callback()
  387. } else {
  388. callback(t('Msg.nickname'))
  389. }
  390. return true
  391. }
  392. }
  393. ]
  394. },
  395. personalSignature: {
  396. rules: [
  397. {
  398. required: true,
  399. errorMessage: t('vaildate.input.empty')
  400. },
  401. {
  402. validateFunction: (rule, value, data, callback) => {
  403. if (!value || /^[\u4e00-\u9fa5a-zA-Z\s]*$/.test(value)) {
  404. callback()
  405. } else {
  406. callback(t('Documentary.console.item38'))
  407. }
  408. return true
  409. }
  410. }
  411. ]
  412. },
  413. traderStrategy: {
  414. rules: [
  415. {
  416. required: true,
  417. errorMessage: t('vaildate.input.empty')
  418. },
  419. {
  420. validateFunction: (rule, value, data, callback) => {
  421. if (!value || /^[\u4e00-\u9fa5a-zA-Z\s]*$/.test(value)) {
  422. callback()
  423. } else {
  424. callback(t('Documentary.console.item38'))
  425. }
  426. return true
  427. }
  428. }
  429. ]
  430. },
  431. followType: {
  432. rules: [
  433. {
  434. required: true,
  435. errorMessage: t('vaildate.select.empty')
  436. }
  437. ]
  438. },
  439. volume: {
  440. rules: [
  441. {
  442. required: true,
  443. errorMessage: t('vaildate.input.empty')
  444. }
  445. ]
  446. },
  447. ratio: {
  448. rules: [
  449. {
  450. required: true,
  451. errorMessage: t('vaildate.input.empty')
  452. }
  453. ]
  454. }
  455. }
  456. const filterChineseEnglishOnly = (field, value) => {
  457. if (!value) return
  458. const filtered = value.replace(/[^\u4e00-\u9fa5a-zA-Z\s]/g, '')
  459. formData.value[field] = filtered
  460. }
  461. const selectLogin = (val) => {
  462. const selected = props.loginOptions.find(item => item.login === val)
  463. if (selected) {
  464. formData.value.leverage = `1:${selected.leverage}`
  465. formData.value.loginType = selected.type
  466. formData.value.platform = selected.platform
  467. }
  468. }
  469. const onAgreeChange = (e) => {
  470. formData.value.agree = e.detail.value?.includes('1')
  471. }
  472. const closeDia = () => {
  473. emit('close')
  474. resetForm()
  475. }
  476. const confirmDia = async () => {
  477. try {
  478. await formRef.value.validate()
  479. } catch (err) {
  480. return
  481. }
  482. if (isSubmitting.value) return
  483. isSubmitting.value = true
  484. try {
  485. const res = await documentaryApi.followDealApply({
  486. ...formData.value
  487. })
  488. if (res.code === Code.StatusOK) {
  489. uni.showToast({ title: t('Msg.Success'), icon: 'none' })
  490. emit('confirm')
  491. closeDia()
  492. } else {
  493. uni.showToast({ title: res.msg, icon: 'none' })
  494. }
  495. } catch (e) {
  496. uni.showToast({ title: t('Msg.Fail'), icon: 'none' })
  497. } finally {
  498. isSubmitting.value = false
  499. }
  500. }
  501. const resetForm = () => {
  502. formRef.value?.clearValidate()
  503. formData.value = {
  504. nickname: '',
  505. personalSignature: '',
  506. traderStrategy: '',
  507. dealLogin: '',
  508. platform: '',
  509. loginType: '',
  510. leverage: '',
  511. historyShow: '',
  512. historyTime: '',
  513. introduceShow: '',
  514. distributionType: '',
  515. distributionRatio: '',
  516. settlementCycle: '',
  517. agree: false
  518. }
  519. }
  520. watch(() => props.visible, (val) => {
  521. if (val && props.loginOptions?.length) {
  522. // 自动填充默认值,与原版保持一致
  523. const defaultOption = props.loginOptions.find(item => item.balance >= 200)
  524. if (defaultOption) {
  525. formData.value.dealLogin = defaultOption.login
  526. selectLogin(defaultOption.login)
  527. }
  528. }
  529. })
  530. </script>
  531. <style lang="scss" scoped>
  532. @import "@/uni.scss";
  533. .dia-content {
  534. padding: px2rpx(20);
  535. .uni-forms-item {
  536. width: 100%;
  537. }
  538. .grid-layout {
  539. display: grid;
  540. grid-template-columns: 1fr 1fr;
  541. gap: px2rpx(20);
  542. margin: px2rpx(24) 0;
  543. padding: px2rpx(20);
  544. background-color: transparent;
  545. border-radius: px2rpx(8);
  546. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  547. }
  548. .fllow-title {
  549. margin: px2rpx(10) 0 px2rpx(16);
  550. padding-left: px2rpx(8);
  551. border-left: 4px solid #dc3545;
  552. border-bottom: none;
  553. .title {
  554. font-size: px2rpx(16);
  555. font-weight: 600;
  556. color: var(--bs-emphasis-color);
  557. }
  558. }
  559. .delete-grid {
  560. margin: px2rpx(16) 0;
  561. }
  562. .delete-row {
  563. display: flex;
  564. gap: px2rpx(12);
  565. }
  566. .delete-item {
  567. flex: 1;
  568. display: flex;
  569. justify-content: space-between;
  570. align-items: center;
  571. padding: px2rpx(12) 0;
  572. border-bottom: 1px dashed #e9ecef;
  573. &:first-child {
  574. padding-right: px2rpx(16);
  575. }
  576. &:last-child {
  577. padding-left: px2rpx(16);
  578. }
  579. }
  580. .delete-label {
  581. font-size: px2rpx(14);
  582. color: var(--bs-body-color);
  583. }
  584. .delete-value {
  585. font-size: px2rpx(14);
  586. color: var(--bs-emphasis-color);
  587. font-weight: 400;
  588. }
  589. .delete-tip {
  590. margin-top: px2rpx(16);
  591. font-size: px2rpx(14);
  592. color: var(--bs-emphasis-color);
  593. line-height: 1.5;
  594. padding-top: px2rpx(16);
  595. }
  596. .tip-star {
  597. color: #dc3545;
  598. margin-right: px2rpx(4);
  599. }
  600. .agree {
  601. margin-top: px2rpx(20);
  602. }
  603. .checkbox-agree {
  604. display: flex;
  605. align-items: flex-start;
  606. gap: px2rpx(8);
  607. .agree-text {
  608. font-size: px2rpx(14);
  609. color: var(--bs-body-color);
  610. line-height: 1.5;
  611. width: 100%;
  612. white-space: wrap;
  613. .a {
  614. color: #007bff;
  615. text-decoration: underline;
  616. margin: 0 px2rpx(4);
  617. &:hover {
  618. color: #0056b3;
  619. }
  620. }
  621. }
  622. }
  623. .fllow-content {
  624. margin-bottom: px2rpx(16);
  625. .tit {
  626. font-size: px2rpx(14);
  627. font-weight: 500;
  628. color: var(--bs-body-color);
  629. margin-bottom: px2rpx(6);
  630. text-transform: uppercase;
  631. letter-spacing: px2rpx(0.5);
  632. }
  633. .con {
  634. font-size: px2rpx(16);
  635. font-weight: 400;
  636. color: var(--bs-emphasis-color);
  637. line-height: 1.4;
  638. }
  639. }
  640. .form-row {
  641. display: grid;
  642. grid-template-columns: 1fr 1fr;
  643. gap: px2rpx(20);
  644. margin-top: px2rpx(16);
  645. @media screen and (max-width: 768px) {
  646. grid-template-columns: 1fr;
  647. }
  648. }
  649. .form-item {
  650. display: flex;
  651. flex-direction: column;
  652. align-items: flex-start;
  653. text {
  654. font-size: px2rpx(14);
  655. font-weight: 500;
  656. color: var(--bs-body-color);
  657. margin-bottom: px2rpx(8);
  658. white-space: nowrap;
  659. }
  660. input,
  661. select,
  662. textarea {
  663. width: 100%;
  664. padding: px2rpx(10);
  665. border: 1px solid #ced4da;
  666. border-radius: px2rpx(4);
  667. font-size: px2rpx(14);
  668. transition: all 0.2s ease;
  669. &:focus {
  670. outline: none;
  671. border-color: #4dabf7;
  672. box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.2);
  673. }
  674. }
  675. textarea {
  676. resize: vertical;
  677. min-height: px2rpx(100);
  678. }
  679. }
  680. .tip-red {
  681. color: #dc3545;
  682. font-size: px2rpx(14);
  683. margin: px2rpx(12) 0 px2rpx(24) 0;
  684. }
  685. .tip-text {
  686. margin-top: px2rpx(24);
  687. font-size: px2rpx(14);
  688. color: var(--bs-body-color);
  689. line-height: 1.5;
  690. padding: px2rpx(16);
  691. background-color: #e7f3ff;
  692. border-radius: px2rpx(4);
  693. border-left: 4px solid #4dabf7;
  694. }
  695. }
  696. </style>