applySignalDialog.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <template>
  2. <cwg-popup :title="t('Documentary.TundManagement.item41')" :visible="visible" @close="closeDia" @confirm="confirmDia">
  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')" />
  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 disabled 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="[{ text: '7', value: '7' }, { text: '15', value: '15' }, { text: '30', value: '30' }]"
  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 style="text-decoration: underline;" class="a" v-if="['cn', 'zhHant'].indexOf(local) != -1"
  152. url="pdf/CopyTradeUserAgreementcn.pdf" target="_blank" title="Documentary.TundManagement.item43" />
  153. <cwg-link 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. const props = defineProps({
  175. visible: { type: Boolean, default: false },
  176. loginOptions: { type: Array, default: () => [] }
  177. })
  178. const emit = defineEmits(['close', 'confirm'])
  179. const { t, locale } = useI18n()
  180. const { Code } = Config
  181. const local = locale.value
  182. const formRef = ref(null)
  183. const formData = ref({
  184. nickname: '',
  185. personalSignature: '',
  186. traderStrategy: '',
  187. dealLogin: '',
  188. platform: '',
  189. loginType: '',
  190. leverage: '',
  191. historyShow: '',
  192. historyTime: '',
  193. introduceShow: '',
  194. distributionType: '',
  195. distributionRatio: '',
  196. settlementCycle: '',
  197. agree: false
  198. })
  199. const isSubmitting = ref(false)
  200. const accountTypeOptions = [
  201. { text: t('AccountType.ClassicAccount'), value: 1 },
  202. { text: t('AccountType.SeniorAccount'), value: 2 },
  203. { text: t('AccountType.SpeedAccount'), value: 5 },
  204. { text: t('AccountType.SpeedAccount'), value: 6 },
  205. { text: t('AccountType.StandardAccount'), value: 7 },
  206. { text: t('AccountType.CentAccount'), value: 8 }
  207. ]
  208. const loginOptionsData = computed(() => {
  209. return props.loginOptions.map(item => ({
  210. text: `${item.login} - ${groupTypeName(item.type)} - ${t('Custom.Deposit.AvailableBalance')}${groupCurrency(item.currency)}${item.balance}`,
  211. value: item.login,
  212. disabled: item.balance < 200
  213. }))
  214. })
  215. const groupTypeName = (type) => {
  216. const option = accountTypeOptions.find(opt => opt.value == type)
  217. return option ? option.text : type
  218. }
  219. const groupCurrency = (type) => {
  220. if (type == "GBP") {
  221. return ": £";
  222. } else if (type == "USD") {
  223. return ": $";
  224. } else if (type == "EUR") {
  225. return ": €";
  226. } else if (type == "USC") {
  227. return ": ¢";
  228. } else {
  229. return ": $";
  230. }
  231. }
  232. const rules = {
  233. password: {
  234. rules: [
  235. {
  236. required: true,
  237. validateFunction: (rule, value, data, callback) => {
  238. if (Config.Pattern.Password.test(value)) {
  239. callback()
  240. } else {
  241. callback(t('vaildate.password.format'))
  242. }
  243. return true
  244. }
  245. }
  246. ]
  247. },
  248. agree: {
  249. rules: [
  250. {
  251. validateFunction: (rule, value, data, callback) => {
  252. if (value) {
  253. callback()
  254. } else {
  255. callback(t('vaildate.agree.empty'))
  256. }
  257. return true
  258. }
  259. }
  260. ]
  261. },
  262. platform: {
  263. rules: [
  264. {
  265. required: true,
  266. errorMessage: t('vaildate.select.empty')
  267. }
  268. ]
  269. },
  270. currency: {
  271. rules: [
  272. {
  273. required: true,
  274. errorMessage: t('vaildate.select.empty')
  275. }
  276. ]
  277. },
  278. leverage: {
  279. rules: [
  280. {
  281. required: true,
  282. errorMessage: t('vaildate.select.empty')
  283. }
  284. ]
  285. },
  286. loginType: {
  287. rules: [
  288. {
  289. required: true,
  290. errorMessage: t('vaildate.select.empty'),
  291. }
  292. ]
  293. },
  294. dealLogin: {
  295. rules: [
  296. {
  297. required: true,
  298. errorMessage: t('vaildate.select.empty')
  299. }
  300. ]
  301. },
  302. distributionType: {
  303. rules: [
  304. {
  305. required: true,
  306. errorMessage: t('vaildate.select.empty')
  307. }
  308. ]
  309. },
  310. distributionRatio: {
  311. rules: [
  312. {
  313. required: true,
  314. errorMessage: t('vaildate.input.empty')
  315. },
  316. {
  317. validateFunction: (rule, value, data, callback) => {
  318. if (value >= 0 && value <= 50) {
  319. callback()
  320. } else {
  321. callback('0-50')
  322. }
  323. return true
  324. }
  325. }
  326. ]
  327. },
  328. settlementCycle: {
  329. rules: [
  330. {
  331. required: true,
  332. errorMessage: t('vaildate.input.empty')
  333. }
  334. ]
  335. },
  336. historyShow: {
  337. rules: [
  338. {
  339. required: true,
  340. errorMessage: t('vaildate.select.empty')
  341. }
  342. ]
  343. },
  344. historyTime: {
  345. rules: [
  346. {
  347. required: true,
  348. errorMessage: t('vaildate.select.empty')
  349. }
  350. ]
  351. },
  352. introduceShow: {
  353. rules: [
  354. {
  355. required: true,
  356. errorMessage: t('vaildate.select.empty')
  357. }
  358. ]
  359. },
  360. protectAmount: {
  361. rules: [
  362. {
  363. required: true,
  364. errorMessage: t('vaildate.input.empty')
  365. }
  366. ]
  367. },
  368. protectRatio: {
  369. rules: [
  370. {
  371. required: true,
  372. errorMessage: t('vaildate.input.empty')
  373. }
  374. ]
  375. },
  376. nickname: {
  377. rules: [
  378. {
  379. required: true,
  380. errorMessage: t('vaildate.input.empty')
  381. },
  382. {
  383. validateFunction: (rule, value, data, callback) => {
  384. if (value && /^[0-9a-zA-Z]{1,24}$/.test(value)) {
  385. callback()
  386. } else {
  387. callback(t('Msg.nickname'))
  388. }
  389. return true
  390. }
  391. }
  392. ]
  393. },
  394. personalSignature: {
  395. rules: [
  396. {
  397. required: true,
  398. errorMessage: t('vaildate.input.empty')
  399. },
  400. {
  401. validateFunction: (rule, value, data, callback) => {
  402. if (!value || /^[\u4e00-\u9fa5a-zA-Z\s]*$/.test(value)) {
  403. callback()
  404. } else {
  405. callback(t('Documentary.console.item38'))
  406. }
  407. return true
  408. }
  409. }
  410. ]
  411. },
  412. traderStrategy: {
  413. rules: [
  414. {
  415. required: true,
  416. errorMessage: t('vaildate.input.empty')
  417. },
  418. {
  419. validateFunction: (rule, value, data, callback) => {
  420. if (!value || /^[\u4e00-\u9fa5a-zA-Z\s]*$/.test(value)) {
  421. callback()
  422. } else {
  423. callback(t('Documentary.console.item38'))
  424. }
  425. return true
  426. }
  427. }
  428. ]
  429. },
  430. followType: {
  431. rules: [
  432. {
  433. required: true,
  434. errorMessage: t('vaildate.select.empty')
  435. }
  436. ]
  437. },
  438. volume: {
  439. rules: [
  440. {
  441. required: true,
  442. errorMessage: t('vaildate.input.empty')
  443. }
  444. ]
  445. },
  446. ratio: {
  447. rules: [
  448. {
  449. required: true,
  450. errorMessage: t('vaildate.input.empty')
  451. }
  452. ]
  453. }
  454. }
  455. const filterChineseEnglishOnly = (field, value) => {
  456. if (!value) return
  457. const filtered = value.replace(/[^\u4e00-\u9fa5a-zA-Z\s]/g, '')
  458. formData.value[field] = filtered
  459. }
  460. const selectLogin = (val) => {
  461. const selected = props.loginOptions.find(item => item.login === val)
  462. if (selected) {
  463. formData.value.leverage = `1:${selected.leverage}`
  464. formData.value.loginType = selected.type
  465. formData.value.platform = selected.platform
  466. }
  467. }
  468. const onAgreeChange = (e) => {
  469. formData.value.agree = e.detail.value?.includes('1')
  470. }
  471. const closeDia = () => {
  472. emit('close')
  473. resetForm()
  474. }
  475. const confirmDia = async () => {
  476. try {
  477. await formRef.value.validate()
  478. } catch (err) {
  479. return
  480. }
  481. if (isSubmitting.value) return
  482. isSubmitting.value = true
  483. try {
  484. const res = await documentaryApi.followDealApply({
  485. ...formData.value
  486. })
  487. if (res.code === Code.StatusOK) {
  488. uni.showToast({ title: t('Msg.Success'), icon: 'none' })
  489. emit('confirm')
  490. closeDia()
  491. } else {
  492. uni.showToast({ title: res.msg, icon: 'none' })
  493. }
  494. } catch (e) {
  495. uni.showToast({ title: t('Msg.Fail'), icon: 'none' })
  496. } finally {
  497. isSubmitting.value = false
  498. }
  499. }
  500. const resetForm = () => {
  501. formRef.value?.clearValidate()
  502. formData.value = {
  503. nickname: '',
  504. personalSignature: '',
  505. traderStrategy: '',
  506. dealLogin: '',
  507. platform: '',
  508. loginType: '',
  509. leverage: '',
  510. historyShow: '',
  511. historyTime: '',
  512. introduceShow: '',
  513. distributionType: '',
  514. distributionRatio: '',
  515. settlementCycle: '',
  516. agree: false
  517. }
  518. }
  519. watch(() => props.visible, (val) => {
  520. if (val && props.loginOptions?.length) {
  521. // 自动填充默认值,与原版保持一致
  522. const defaultOption = props.loginOptions.find(item => item.balance >= 200)
  523. if (defaultOption) {
  524. formData.value.dealLogin = defaultOption.login
  525. selectLogin(defaultOption.login)
  526. }
  527. }
  528. })
  529. </script>
  530. <style lang="scss" scoped>
  531. @import "@/uni.scss";
  532. .dia-content {
  533. padding: px2rpx(20);
  534. .uni-forms-item {
  535. width: 100%;
  536. }
  537. .grid-layout {
  538. display: grid;
  539. grid-template-columns: 1fr 1fr;
  540. gap: px2rpx(20);
  541. margin: px2rpx(24) 0;
  542. padding: px2rpx(20);
  543. background-color: transparent;
  544. border-radius: px2rpx(8);
  545. box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  546. }
  547. .fllow-title {
  548. margin: px2rpx(10) 0 px2rpx(16);
  549. padding-left: px2rpx(8);
  550. border-left: 4px solid #dc3545;
  551. border-bottom: none;
  552. .title {
  553. font-size: px2rpx(16);
  554. font-weight: 600;
  555. color: var(--bs-emphasis-color);
  556. }
  557. }
  558. .delete-grid {
  559. margin: px2rpx(16) 0;
  560. }
  561. .delete-row {
  562. display: flex;
  563. gap: px2rpx(12);
  564. }
  565. .delete-item {
  566. flex: 1;
  567. display: flex;
  568. justify-content: space-between;
  569. align-items: center;
  570. padding: px2rpx(12) 0;
  571. border-bottom: 1px dashed #e9ecef;
  572. &:first-child {
  573. padding-right: px2rpx(16);
  574. }
  575. &:last-child {
  576. padding-left: px2rpx(16);
  577. }
  578. }
  579. .delete-label {
  580. font-size: px2rpx(14);
  581. color: var(--bs-body-color);
  582. }
  583. .delete-value {
  584. font-size: px2rpx(14);
  585. color: var(--bs-emphasis-color);
  586. font-weight: 400;
  587. }
  588. .delete-tip {
  589. margin-top: px2rpx(16);
  590. font-size: px2rpx(14);
  591. color: var(--bs-body-color);
  592. line-height: 1.5;
  593. padding-top: px2rpx(16);
  594. }
  595. .tip-star {
  596. color: #dc3545;
  597. margin-right: px2rpx(4);
  598. }
  599. .agree {
  600. margin-top: px2rpx(20);
  601. }
  602. .checkbox-agree {
  603. display: flex;
  604. align-items: flex-start;
  605. gap: px2rpx(8);
  606. .agree-text {
  607. font-size: px2rpx(14);
  608. color: var(--bs-body-color);
  609. line-height: 1.5;
  610. width: 100%;
  611. white-space: wrap;
  612. .a {
  613. color: #007bff;
  614. text-decoration: underline;
  615. margin: 0 px2rpx(4);
  616. &:hover {
  617. color: #0056b3;
  618. }
  619. }
  620. }
  621. }
  622. .fllow-content {
  623. margin-bottom: px2rpx(16);
  624. .tit {
  625. font-size: px2rpx(14);
  626. font-weight: 500;
  627. color: var(--bs-body-color);
  628. margin-bottom: px2rpx(6);
  629. text-transform: uppercase;
  630. letter-spacing: px2rpx(0.5);
  631. }
  632. .con {
  633. font-size: px2rpx(16);
  634. font-weight: 400;
  635. color: var(--bs-emphasis-color);
  636. line-height: 1.4;
  637. }
  638. }
  639. .form-row {
  640. display: grid;
  641. grid-template-columns: 1fr 1fr;
  642. gap: px2rpx(20);
  643. margin-top: px2rpx(16);
  644. @media screen and (max-width: 768px) {
  645. grid-template-columns: 1fr;
  646. }
  647. }
  648. .form-item {
  649. display: flex;
  650. flex-direction: column;
  651. align-items: flex-start;
  652. text {
  653. font-size: px2rpx(14);
  654. font-weight: 500;
  655. color: var(--bs-body-color);
  656. margin-bottom: px2rpx(8);
  657. white-space: nowrap;
  658. }
  659. input,
  660. select,
  661. textarea {
  662. width: 100%;
  663. padding: px2rpx(10);
  664. border: 1px solid #ced4da;
  665. border-radius: px2rpx(4);
  666. font-size: px2rpx(14);
  667. transition: all 0.2s ease;
  668. &:focus {
  669. outline: none;
  670. border-color: #4dabf7;
  671. box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.2);
  672. }
  673. }
  674. textarea {
  675. resize: vertical;
  676. min-height: px2rpx(100);
  677. }
  678. }
  679. .tip-red {
  680. color: #dc3545;
  681. font-size: px2rpx(14);
  682. margin: px2rpx(12) 0 px2rpx(24) 0;
  683. }
  684. .tip-text {
  685. margin-top: px2rpx(24);
  686. font-size: px2rpx(14);
  687. color: var(--bs-body-color);
  688. line-height: 1.5;
  689. padding: px2rpx(16);
  690. background-color: #e7f3ff;
  691. border-radius: px2rpx(4);
  692. border-left: 4px solid #4dabf7;
  693. }
  694. }
  695. </style>