applySignalDialog.vue 19 KB

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