applySignalDialog.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <cwg-popup :title="t('Documentary.TundManagement.item41')" :visible="visible" @close="closeDia" @confirm="confirmDia">
  3. <view class="dialog-content">
  4. <uni-forms ref="formRef" :model="formData" :rules="rules" labelWidth="200" label-position="top" class="crm-form">
  5. <!-- 名片信息 -->
  6. <view class="fllow-title">
  7. <text>{{ t('Documentary.tradingCenter.item126') }}</text>
  8. </view>
  9. <uni-forms-item :label="t('Documentary.console.item20')" name="nickname">
  10. <uni-easyinput v-model="formData.nickname" :placeholder="t('placeholder.input')" />
  11. </uni-forms-item>
  12. <uni-row :gutter="20" class="responsive-row">
  13. <uni-col :xs="24" :sm="12">
  14. <uni-forms-item :label="t('Documentary.console.item21')" name="personalSignature">
  15. <uni-easyinput type="textarea" v-model="formData.personalSignature" :maxlength="100" @input="val => filterChineseEnglishOnly('personalSignature', val)" :placeholder="t('placeholder.input')" />
  16. </uni-forms-item>
  17. </uni-col>
  18. <uni-col :xs="24" :sm="12">
  19. <uni-forms-item :label="t('Documentary.console.item22')" name="traderStrategy">
  20. <uni-easyinput type="textarea" v-model="formData.traderStrategy" :maxlength="150" @input="val => filterChineseEnglishOnly('traderStrategy', val)" :placeholder="t('placeholder.input')" />
  21. </uni-forms-item>
  22. </uni-col>
  23. </uni-row>
  24. <view style="color: red; font-size: 12px; margin-bottom: 10px;">
  25. <text>{{ t('Documentary.console.item37') }}</text>
  26. </view>
  27. <!-- 账户信息 -->
  28. <view class="fllow-title">
  29. <text>{{ t('Documentary.TundManagement.item29') }}</text>
  30. <text style="color: #eb3f57; font-weight: 500">{{ t('Documentary.item3') }}</text>
  31. </view>
  32. <uni-row :gutter="20" class="responsive-row">
  33. <uni-col :xs="24" :sm="12">
  34. <uni-forms-item :label="t('Label.TradingAccount')" name="dealLogin">
  35. <cwg-combox
  36. v-model:value="formData.dealLogin"
  37. :options="loginOptionsData"
  38. :placeholder="t('placeholder.choose')"
  39. @change="selectLogin"
  40. />
  41. </uni-forms-item>
  42. </uni-col>
  43. <uni-col :xs="24" :sm="12">
  44. <uni-forms-item :label="t('Label.PlatformType')" name="platform">
  45. <cwg-combox disabled v-model:value="formData.platform" :options="[{text: 'MT4', value: 'MT4'}, {text: 'MT5', value: 'MT5'}]" :placeholder="t('placeholder.choose')" />
  46. </uni-forms-item>
  47. </uni-col>
  48. <uni-col :xs="24" :sm="12">
  49. <uni-forms-item :label="t('Label.AccountType')" name="loginType">
  50. <cwg-combox disabled v-model:value="formData.loginType" :options="accountTypeOptions" :placeholder="t('placeholder.choose')" />
  51. </uni-forms-item>
  52. </uni-col>
  53. <uni-col :xs="24" :sm="12">
  54. <uni-forms-item :label="t('Label.Leverage')" name="leverage">
  55. <uni-easyinput disabled v-model="formData.leverage" :placeholder="t('placeholder.input')" />
  56. </uni-forms-item>
  57. </uni-col>
  58. </uni-row>
  59. <!-- 展示设置 -->
  60. <view class="fllow-title">
  61. <text>{{ t('Documentary.TundManagement.item32') }}</text>
  62. </view>
  63. <uni-row :gutter="20" class="responsive-row">
  64. <uni-col :xs="24" :sm="12">
  65. <uni-forms-item :label="t('Documentary.TundManagement.item34')" name="historyShow">
  66. <cwg-combox v-model:value="formData.historyShow" :options="[{text: t('Btn.item6'), value: 1}, {text: t('Btn.item7'), value: 0}]" :placeholder="t('placeholder.choose')" />
  67. </uni-forms-item>
  68. </uni-col>
  69. <uni-col :xs="24" :sm="12">
  70. <uni-forms-item :label="t('Documentary.TundManagement.item35')" name="historyTime">
  71. <uni-datetime-picker type="date" v-model="formData.historyTime" :placeholder="t('Documentary.TundManagement.item37')" />
  72. </uni-forms-item>
  73. </uni-col>
  74. <uni-col :xs="24" :sm="12">
  75. <uni-forms-item :label="t('Documentary.TundManagement.item36')" name="introduceShow">
  76. <cwg-combox v-model:value="formData.introduceShow" :options="[{text: t('Btn.item6'), value: 1}, {text: t('Btn.item7'), value: 0}]" :placeholder="t('placeholder.choose')" />
  77. </uni-forms-item>
  78. </uni-col>
  79. </uni-row>
  80. <!-- 分润设置 -->
  81. <view class="fllow-title">
  82. <text>{{ t('Documentary.TundManagement.item33') }}</text>
  83. </view>
  84. <uni-row :gutter="20" class="responsive-row">
  85. <uni-col :xs="24" :sm="12">
  86. <uni-forms-item :label="t('Documentary.TundManagement.item38')" name="distributionType">
  87. <cwg-combox v-model:value="formData.distributionType" :options="[{text: t('Documentary.TundManagement.item59'), value: 1}]" :placeholder="t('placeholder.choose')" />
  88. </uni-forms-item>
  89. </uni-col>
  90. <uni-col :xs="24" :sm="12">
  91. <uni-forms-item :label="t('Documentary.TundManagement.item39')" name="distributionRatio">
  92. <view style="display: flex; align-items: center;">
  93. <uni-easyinput v-model="formData.distributionRatio" :placeholder="t('placeholder.input')" style="flex: 1;" />
  94. <text style="margin-left: 5px;">(%)</text>
  95. </view>
  96. </uni-forms-item>
  97. </uni-col>
  98. <uni-col :xs="24" :sm="12">
  99. <uni-forms-item :label="t('Documentary.tradingCenter.item32')" name="settlementCycle">
  100. <cwg-combox v-model:value="formData.settlementCycle" :options="[{text: '7', value: '7'}, {text: '15', value: '15'}, {text: '30', value: '30'}]" :placeholder="t('placeholder.choose')" />
  101. </uni-forms-item>
  102. </uni-col>
  103. </uni-row>
  104. <!-- 协议 -->
  105. <uni-forms-item class="agree" name="agree">
  106. <checkbox-group @change="onAgreeChange">
  107. <label class="checkbox">
  108. <checkbox value="1" :checked="!!formData.agree" />
  109. <view style="display: inline; font-size: 12px;">
  110. <text class="crm-cursor">{{ t('Documentary.TundManagement.item42') }}</text>
  111. <cwg-link type="pdf" title="Documentary.TundManagement.item43" v-if="['cn', 'zhHant'].indexOf(local) != -1" style="color: #4497ff; display: inline-block; margin: 0 4px;" url="pdf/CopyTradeUserAgreementcn.pdf" target="_blank" />
  112. <cwg-link type="pdf" style="color: #4497ff; display: inline-block; margin: 0 4px;" title="Documentary.TundManagement.item43" url="pdf/CopyTradeUserAgreement.pdf" target="_blank" v-else />
  113. <text>{{ t('Documentary.TundManagement.item42_2') }}</text>
  114. </view>
  115. </label>
  116. </checkbox-group>
  117. </uni-forms-item>
  118. </uni-forms>
  119. </view>
  120. </cwg-popup>
  121. </template>
  122. <script setup>
  123. import { ref, computed, watch } from 'vue'
  124. import { useI18n } from 'vue-i18n'
  125. import Config from '@/config/index'
  126. import { documentaryApi } from '@/service/documentary'
  127. const props = defineProps({
  128. visible: { type: Boolean, default: false },
  129. loginOptions: { type: Array, default: () => [] }
  130. })
  131. const emit = defineEmits(['close', 'confirm'])
  132. const { t, locale } = useI18n()
  133. const { Code } = Config
  134. const local = locale.value
  135. const formRef = ref(null)
  136. const formData = ref({
  137. nickname: '',
  138. personalSignature: '',
  139. traderStrategy: '',
  140. dealLogin: '',
  141. platform: '',
  142. loginType: '',
  143. leverage: '',
  144. historyShow: '',
  145. historyTime: '',
  146. introduceShow: '',
  147. distributionType: '',
  148. distributionRatio: '',
  149. settlementCycle: '',
  150. agree: false
  151. })
  152. const isSubmitting = ref(false)
  153. const accountTypeOptions = [
  154. { text: t('AccountType.ClassicAccount'), value: 1 },
  155. { text: t('AccountType.SeniorAccount'), value: 2 },
  156. { text: t('AccountType.SpeedAccount'), value: 5 },
  157. { text: t('AccountType.SpeedAccount'), value: 6 },
  158. { text: t('AccountType.StandardAccount'), value: 7 },
  159. { text: t('AccountType.CentAccount'), value: 8 }
  160. ]
  161. const loginOptionsData = computed(() => {
  162. return props.loginOptions.map(item => ({
  163. text: `${item.login} - ${groupTypeName(item.type)} - ${t('Custom.Deposit.AvailableBalance')}${groupCurrency(item.currency)}${item.balance}`,
  164. value: item.login,
  165. disabled: item.balance < 200
  166. }))
  167. })
  168. const groupTypeName = (type) => {
  169. const option = accountTypeOptions.find(opt => opt.value == type)
  170. return option ? option.text : type
  171. }
  172. const groupCurrency = (currency) => {
  173. return currency ? ` (${currency}) ` : ' '
  174. }
  175. const rules = computed(() => ({
  176. nickname: {
  177. rules: [
  178. { required: true, errorMessage: t('vaildate.input.empty') },
  179. { pattern: /^[0-9a-zA-Z]{1,24}$/, errorMessage: t('Msg.nickname') }
  180. ]
  181. },
  182. personalSignature: {
  183. rules: [
  184. { required: true, errorMessage: t('vaildate.input.empty') },
  185. { pattern: /^[\u4e00-\u9fa5a-zA-Z\s]*$/, errorMessage: t('Documentary.console.item38') }
  186. ]
  187. },
  188. traderStrategy: {
  189. rules: [
  190. { required: true, errorMessage: t('vaildate.input.empty') },
  191. { pattern: /^[\u4e00-\u9fa5a-zA-Z\s]*$/, errorMessage: t('Documentary.console.item38') }
  192. ]
  193. },
  194. dealLogin: { rules: [{ required: true, errorMessage: t('vaildate.select.empty') }] },
  195. historyShow: { rules: [{ required: true, errorMessage: t('vaildate.select.empty') }] },
  196. historyTime: { rules: [{ required: true, errorMessage: t('vaildate.select.empty') }] },
  197. introduceShow: { rules: [{ required: true, errorMessage: t('vaildate.select.empty') }] },
  198. distributionType: { rules: [{ required: true, errorMessage: t('vaildate.select.empty') }] },
  199. distributionRatio: {
  200. rules: [
  201. { required: true, errorMessage: t('vaildate.input.empty') },
  202. {
  203. validateFunction: (rule, value, data, callback) => {
  204. if (value >= 0 && value <= 50) return true
  205. callback('0-50')
  206. }
  207. }
  208. ]
  209. },
  210. settlementCycle: { rules: [{ required: true, errorMessage: t('vaildate.select.empty') }] },
  211. agree: {
  212. rules: [
  213. {
  214. validateFunction: (rule, value, data, callback) => {
  215. if (value) return true
  216. callback(t('vaildate.agree.empty'))
  217. }
  218. }
  219. ]
  220. }
  221. }))
  222. const filterChineseEnglishOnly = (field, value) => {
  223. if (!value) return
  224. const filtered = value.replace(/[^\u4e00-\u9fa5a-zA-Z\s]/g, '')
  225. formData.value[field] = filtered
  226. }
  227. const selectLogin = (val) => {
  228. const selected = props.loginOptions.find(item => item.login === val)
  229. if (selected) {
  230. formData.value.leverage = `1:${selected.leverage}`
  231. formData.value.loginType = selected.type
  232. formData.value.platform = selected.platform
  233. }
  234. }
  235. const onAgreeChange = (e) => {
  236. formData.value.agree = e.detail.value?.includes('1')
  237. }
  238. const closeDia = () => {
  239. emit('close')
  240. resetForm()
  241. }
  242. const confirmDia = async () => {
  243. try {
  244. await formRef.value.validate()
  245. } catch (err) {
  246. return
  247. }
  248. if (isSubmitting.value) return
  249. isSubmitting.value = true
  250. try {
  251. const res = await documentaryApi.followDealApply({
  252. ...formData.value
  253. })
  254. if (res.code === Code.StatusOK) {
  255. uni.showToast({ title: t('Msg.Success'), icon: 'none' })
  256. emit('confirm')
  257. closeDia()
  258. } else {
  259. uni.showToast({ title: res.msg, icon: 'none' })
  260. }
  261. } catch (e) {
  262. uni.showToast({ title: t('Msg.Fail'), icon: 'none' })
  263. } finally {
  264. isSubmitting.value = false
  265. }
  266. }
  267. const resetForm = () => {
  268. formRef.value?.clearValidate()
  269. formData.value = {
  270. nickname: '',
  271. personalSignature: '',
  272. traderStrategy: '',
  273. dealLogin: '',
  274. platform: '',
  275. loginType: '',
  276. leverage: '',
  277. historyShow: '',
  278. historyTime: '',
  279. introduceShow: '',
  280. distributionType: '',
  281. distributionRatio: '',
  282. settlementCycle: '',
  283. agree: false
  284. }
  285. }
  286. watch(() => props.visible, (val) => {
  287. if (val && props.loginOptions?.length) {
  288. // 自动填充默认值,与原版保持一致
  289. const defaultOption = props.loginOptions.find(item => item.balance >= 200)
  290. if (defaultOption) {
  291. formData.value.dealLogin = defaultOption.login
  292. selectLogin(defaultOption.login)
  293. }
  294. }
  295. })
  296. </script>
  297. <style lang="scss" scoped>
  298. @import "@/uni.scss";
  299. .crm-form {
  300. padding: 0 10px;
  301. :deep(.uni-forms-item) {
  302. margin-bottom: px2rpx(16);
  303. }
  304. :deep(.uni-easyinput__content) {
  305. border: 1px solid #dcdfe6 !important;
  306. background-color: #fff !important;
  307. }
  308. }
  309. .fllow-title {
  310. font-size: 16px;
  311. font-weight: bold;
  312. color: #333;
  313. margin-top: 15px;
  314. margin-bottom: 10px;
  315. display: flex;
  316. align-items: center;
  317. }
  318. /* 移动端排版优化 */
  319. @media screen and (max-width: 768px) {
  320. .responsive-row {
  321. display: flex;
  322. flex-direction: column;
  323. .uni-col {
  324. width: 100% !important;
  325. padding-left: 0 !important;
  326. padding-right: 0 !important;
  327. }
  328. }
  329. }
  330. .checkbox {
  331. display: flex;
  332. align-items: center;
  333. }
  334. </style>