applySignalDialog.vue 19 KB

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