| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- <template>
- <cwg-popup :title="t('Documentary.TundManagement.item41')" :visible="visible" @close="closeDia" @confirm="confirmDia">
- <uni-forms ref="formRef" :model="formData" :rules="rules" labelWidth="200" label-position="top" class="crm-form">
- <view class="dia-content">
- <!-- 名片信息 -->
- <view class="fllow-title">
- <text class="title">{{ t('Documentary.tradingCenter.item126') }}</text>
- </view>
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.console.item20')" name="nickname">
- <uni-easyinput v-model="formData.nickname" :placeholder="t('placeholder.input')" />
- </uni-forms-item>
- </view>
- <view class="form-row">
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.console.item21')" name="personalSignature">
- <uni-easyinput type="textarea" v-model="formData.personalSignature" :maxlength="100"
- @input="val => filterChineseEnglishOnly('personalSignature', val)"
- :placeholder="t('placeholder.input')" />
- </uni-forms-item>
- </view>
- </view>
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.console.item22')" name="traderStrategy">
- <uni-easyinput type="textarea" v-model="formData.traderStrategy" :maxlength="150"
- @input="val => filterChineseEnglishOnly('traderStrategy', val)"
- :placeholder="t('placeholder.input')" />
- </uni-forms-item>
- </view>
- </view>
- </view>
- <view class="tip-red">
- <text>{{ t('Documentary.console.item37') }}</text>
- </view>
- <!-- 账户信息 -->
- <view class="fllow-title">
- <text class="title">{{ t('Documentary.TundManagement.item29') }}<text
- style="color: #eb3f57; font-weight: 500">{{ t('Documentary.item3') }}</text></text>
- </view>
- <view class="form-row">
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Label.TradingAccount')" name="dealLogin">
- <cwg-combox v-model:value="formData.dealLogin" :options="loginOptionsData"
- :placeholder="t('placeholder.choose')" @change="selectLogin" />
- </uni-forms-item>
- </view>
- </view>
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Label.PlatformType')" name="platform">
- <cwg-combox disabled v-model:value="formData.platform"
- :options="[{ text: 'MT4', value: 'MT4' }, { text: 'MT5', value: 'MT5' }]"
- :placeholder="t('placeholder.choose')" />
- </uni-forms-item>
- </view>
- </view>
- </view>
- <view class="form-row">
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Label.AccountType')" name="loginType">
- <cwg-combox disabled v-model:value="formData.loginType" :options="accountTypeOptions"
- :placeholder="t('placeholder.choose')" />
- </uni-forms-item>
- </view>
- </view>
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Label.Leverage')" name="leverage">
- <uni-easyinput disabled v-model="formData.leverage" :placeholder="t('placeholder.input')" />
- </uni-forms-item>
- </view>
- </view>
- </view>
- <!-- 展示设置 -->
- <view class="fllow-title">
- <text class="title">{{ t('Documentary.TundManagement.item32') }}</text>
- </view>
- <view class="form-row">
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.TundManagement.item34')" name="historyShow">
- <cwg-combox v-model:value="formData.historyShow"
- :options="[{ text: t('Btn.item6'), value: 1 }, { text: t('Btn.item7'), value: 0 }]"
- :placeholder="t('placeholder.choose')" />
- </uni-forms-item>
- </view>
- </view>
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.TundManagement.item35')" name="historyTime">
- <uni-datetime-picker type="date" v-model="formData.historyTime"
- :placeholder="t('Documentary.TundManagement.item37')" />
- </uni-forms-item>
- </view>
- </view>
- </view>
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.TundManagement.item36')" name="introduceShow">
- <cwg-combox v-model:value="formData.introduceShow"
- :options="[{ text: t('Btn.item6'), value: 1 }, { text: t('Btn.item7'), value: 0 }]"
- :placeholder="t('placeholder.choose')" />
- </uni-forms-item>
- </view>
- <!-- 分润设置 -->
- <view class="fllow-title">
- <text class="title">{{ t('Documentary.TundManagement.item33') }}</text>
- </view>
- <view class="form-row">
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.TundManagement.item38')" name="distributionType">
- <cwg-combox v-model:value="formData.distributionType"
- :options="[{ text: t('Documentary.TundManagement.item59'), value: 1 }]"
- :placeholder="t('placeholder.choose')" />
- </uni-forms-item>
- </view>
- </view>
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.TundManagement.item39')" name="distributionRatio">
- <view style="display: flex; align-items: center;">
- <uni-easyinput v-model="formData.distributionRatio" :placeholder="t('placeholder.input')"
- style="flex: 1;" />
- <text style="margin-left: 5px;">(%)</text>
- </view>
- </uni-forms-item>
- </view>
- </view>
- <view class="form-col">
- <view class="form-item">
- <uni-forms-item :label="t('Documentary.tradingCenter.item32')" name="settlementCycle">
- <cwg-combox v-model:value="formData.settlementCycle"
- :options="[{ text: '7', value: '7' }, { text: '15', value: '15' }, { text: '30', value: '30' }]"
- :placeholder="t('placeholder.choose')" />
- </uni-forms-item>
- </view>
- </view>
- </view>
- <!-- 协议 -->
- <view class="form-item agree">
- <uni-forms-item name="agree">
- <checkbox-group @change="onAgreeChange">
- <label class="checkbox-agree">
- <checkbox value="1" :checked="!!formData.agree" />
- <text class="agree-text">
- {{ t('Documentary.TundManagement.item42') }}
- <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" />
- <cwg-link style="text-decoration: underline;" class="a" v-else url="pdf/CopyTradeUserAgreement.pdf"
- target="_blank" title="Documentary.TundManagement.item43" />
- {{ t('Documentary.TundManagement.item42_2') }}
- </text>
- </label>
- </checkbox-group>
- </uni-forms-item>
- </view>
- </view>
- </uni-forms>
- <template #footer>
- <button @click="closeDia">{{ t('Btn.Cancel') }}</button>
- <button type="primary" @click="confirmDia">{{ t('Btn.Confirm') }}</button>
- </template>
- </cwg-popup>
- </template>
- <script setup>
- import { ref, computed, watch } from 'vue'
- import { useI18n } from 'vue-i18n'
- import Config from '@/config/index'
- import { documentaryApi } from '@/service/documentary'
- const props = defineProps({
- visible: { type: Boolean, default: false },
- loginOptions: { type: Array, default: () => [] }
- })
- const emit = defineEmits(['close', 'confirm'])
- const { t, locale } = useI18n()
- const { Code } = Config
- const local = locale.value
- const formRef = ref(null)
- const formData = ref({
- nickname: '',
- personalSignature: '',
- traderStrategy: '',
- dealLogin: '',
- platform: '',
- loginType: '',
- leverage: '',
- historyShow: '',
- historyTime: '',
- introduceShow: '',
- distributionType: '',
- distributionRatio: '',
- settlementCycle: '',
- agree: false
- })
- const isSubmitting = ref(false)
- const accountTypeOptions = [
- { text: t('AccountType.ClassicAccount'), value: 1 },
- { text: t('AccountType.SeniorAccount'), value: 2 },
- { text: t('AccountType.SpeedAccount'), value: 5 },
- { text: t('AccountType.SpeedAccount'), value: 6 },
- { text: t('AccountType.StandardAccount'), value: 7 },
- { text: t('AccountType.CentAccount'), value: 8 }
- ]
- const loginOptionsData = computed(() => {
- return props.loginOptions.map(item => ({
- text: `${item.login} - ${groupTypeName(item.type)} - ${t('Custom.Deposit.AvailableBalance')}${groupCurrency(item.currency)}${item.balance}`,
- value: item.login,
- disabled: item.balance < 200
- }))
- })
- const groupTypeName = (type) => {
- const option = accountTypeOptions.find(opt => opt.value == type)
- return option ? option.text : type
- }
- const groupCurrency = (type) => {
- if (type == "GBP") {
- return ": £";
- } else if (type == "USD") {
- return ": $";
- } else if (type == "EUR") {
- return ": €";
- } else if (type == "USC") {
- return ": ¢";
- } else {
- return ": $";
- }
- }
- const rules = {
- password: {
- rules: [
- {
- required: true,
- validateFunction: (rule, value, data, callback) => {
- if (Config.Pattern.Password.test(value)) {
- callback()
- } else {
- callback(t('vaildate.password.format'))
- }
- return true
- }
- }
- ]
- },
- agree: {
- rules: [
- {
- validateFunction: (rule, value, data, callback) => {
- if (value) {
- callback()
- } else {
- callback(t('vaildate.agree.empty'))
- }
- return true
- }
- }
- ]
- },
- platform: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- currency: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- leverage: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- loginType: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty'),
- }
- ]
- },
- dealLogin: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- distributionType: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- distributionRatio: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- },
- {
- validateFunction: (rule, value, data, callback) => {
- if (value >= 0 && value <= 50) {
- callback()
- } else {
- callback('0-50')
- }
- return true
- }
- }
- ]
- },
- settlementCycle: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- }
- ]
- },
- historyShow: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- historyTime: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- introduceShow: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- protectAmount: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- }
- ]
- },
- protectRatio: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- }
- ]
- },
- nickname: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- },
- {
- validateFunction: (rule, value, data, callback) => {
- if (value && /^[0-9a-zA-Z]{1,24}$/.test(value)) {
- callback()
- } else {
- callback(t('Msg.nickname'))
- }
- return true
- }
- }
- ]
- },
- personalSignature: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- },
- {
- validateFunction: (rule, value, data, callback) => {
- if (!value || /^[\u4e00-\u9fa5a-zA-Z\s]*$/.test(value)) {
- callback()
- } else {
- callback(t('Documentary.console.item38'))
- }
- return true
- }
- }
- ]
- },
- traderStrategy: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- },
- {
- validateFunction: (rule, value, data, callback) => {
- if (!value || /^[\u4e00-\u9fa5a-zA-Z\s]*$/.test(value)) {
- callback()
- } else {
- callback(t('Documentary.console.item38'))
- }
- return true
- }
- }
- ]
- },
- followType: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.select.empty')
- }
- ]
- },
- volume: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- }
- ]
- },
- ratio: {
- rules: [
- {
- required: true,
- errorMessage: t('vaildate.input.empty')
- }
- ]
- }
- }
- const filterChineseEnglishOnly = (field, value) => {
- if (!value) return
- const filtered = value.replace(/[^\u4e00-\u9fa5a-zA-Z\s]/g, '')
- formData.value[field] = filtered
- }
- const selectLogin = (val) => {
- const selected = props.loginOptions.find(item => item.login === val)
- if (selected) {
- formData.value.leverage = `1:${selected.leverage}`
- formData.value.loginType = selected.type
- formData.value.platform = selected.platform
- }
- }
- const onAgreeChange = (e) => {
- formData.value.agree = e.detail.value?.includes('1')
- }
- const closeDia = () => {
- emit('close')
- resetForm()
- }
- const confirmDia = async () => {
- try {
- await formRef.value.validate()
- } catch (err) {
- return
- }
- if (isSubmitting.value) return
- isSubmitting.value = true
- try {
- const res = await documentaryApi.followDealApply({
- ...formData.value
- })
- if (res.code === Code.StatusOK) {
- uni.showToast({ title: t('Msg.Success'), icon: 'none' })
- emit('confirm')
- closeDia()
- } else {
- uni.showToast({ title: res.msg, icon: 'none' })
- }
- } catch (e) {
- uni.showToast({ title: t('Msg.Fail'), icon: 'none' })
- } finally {
- isSubmitting.value = false
- }
- }
- const resetForm = () => {
- formRef.value?.clearValidate()
- formData.value = {
- nickname: '',
- personalSignature: '',
- traderStrategy: '',
- dealLogin: '',
- platform: '',
- loginType: '',
- leverage: '',
- historyShow: '',
- historyTime: '',
- introduceShow: '',
- distributionType: '',
- distributionRatio: '',
- settlementCycle: '',
- agree: false
- }
- }
- watch(() => props.visible, (val) => {
- if (val && props.loginOptions?.length) {
- // 自动填充默认值,与原版保持一致
- const defaultOption = props.loginOptions.find(item => item.balance >= 200)
- if (defaultOption) {
- formData.value.dealLogin = defaultOption.login
- selectLogin(defaultOption.login)
- }
- }
- })
- </script>
- <style lang="scss" scoped>
- @import "@/uni.scss";
- .dia-content {
- padding: px2rpx(20);
- .uni-forms-item {
- width: 100%;
- }
- .grid-layout {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: px2rpx(20);
- margin: px2rpx(24) 0;
- padding: px2rpx(20);
- background-color: transparent;
- border-radius: px2rpx(8);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
- }
- .fllow-title {
- margin: px2rpx(10) 0 px2rpx(16);
- padding-left: px2rpx(8);
- border-left: 4px solid #dc3545;
- border-bottom: none;
- .title {
- font-size: px2rpx(16);
- font-weight: 600;
- color: var(--bs-emphasis-color);
- }
- }
- .delete-grid {
- margin: px2rpx(16) 0;
- }
- .delete-row {
- display: flex;
- gap: px2rpx(12);
- }
- .delete-item {
- flex: 1;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: px2rpx(12) 0;
- border-bottom: 1px dashed #e9ecef;
- &:first-child {
- padding-right: px2rpx(16);
- }
- &:last-child {
- padding-left: px2rpx(16);
- }
- }
- .delete-label {
- font-size: px2rpx(14);
- color: var(--bs-body-color);
- }
- .delete-value {
- font-size: px2rpx(14);
- color: var(--bs-emphasis-color);
- font-weight: 400;
- }
- .delete-tip {
- margin-top: px2rpx(16);
- font-size: px2rpx(14);
- color: var(--bs-emphasis-color);
- line-height: 1.5;
- padding-top: px2rpx(16);
- }
- .tip-star {
- color: #dc3545;
- margin-right: px2rpx(4);
- }
- .agree {
- margin-top: px2rpx(20);
- }
- .checkbox-agree {
- display: flex;
- align-items: flex-start;
- gap: px2rpx(8);
- .agree-text {
- font-size: px2rpx(14);
- color: var(--bs-body-color);
- line-height: 1.5;
- width: 100%;
- white-space: wrap;
- .a {
- color: #007bff;
- text-decoration: underline;
- margin: 0 px2rpx(4);
- &:hover {
- color: #0056b3;
- }
- }
- }
- }
- .fllow-content {
- margin-bottom: px2rpx(16);
- .tit {
- font-size: px2rpx(14);
- font-weight: 500;
- color: var(--bs-body-color);
- margin-bottom: px2rpx(6);
- text-transform: uppercase;
- letter-spacing: px2rpx(0.5);
- }
- .con {
- font-size: px2rpx(16);
- font-weight: 400;
- color: var(--bs-emphasis-color);
- line-height: 1.4;
- }
- }
- .form-row {
- display: grid;
- grid-template-columns: 1fr 1fr;
- gap: px2rpx(20);
- margin-top: px2rpx(16);
- @media screen and (max-width: 768px) {
- grid-template-columns: 1fr;
- }
- }
- .form-item {
- display: flex;
- flex-direction: column;
- align-items: flex-start;
- text {
- font-size: px2rpx(14);
- font-weight: 500;
- color: var(--bs-body-color);
- margin-bottom: px2rpx(8);
- white-space: nowrap;
- }
- input,
- select,
- textarea {
- width: 100%;
- padding: px2rpx(10);
- border: 1px solid #ced4da;
- border-radius: px2rpx(4);
- font-size: px2rpx(14);
- transition: all 0.2s ease;
- &:focus {
- outline: none;
- border-color: #4dabf7;
- box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.2);
- }
- }
- textarea {
- resize: vertical;
- min-height: px2rpx(100);
- }
- }
- .tip-red {
- color: #dc3545;
- font-size: px2rpx(14);
- margin: px2rpx(12) 0 px2rpx(24) 0;
- }
- .tip-text {
- margin-top: px2rpx(24);
- font-size: px2rpx(14);
- color: var(--bs-body-color);
- line-height: 1.5;
- padding: px2rpx(16);
- background-color: #e7f3ff;
- border-radius: px2rpx(4);
- border-left: 4px solid #4dabf7;
- }
- }
- </style>
|