applySignalDialog.vue 19 KB

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