trading-center.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('Documentary.page_doc.item2')" />
  4. <view class="info-card">
  5. <!-- <view class="time-header">-->
  6. <!-- <text>{{ t('Documentary.console.item2') }}:</text>-->
  7. <!-- <text class="time-value">{{ time }}</text>-->
  8. <!-- </view>-->
  9. <cwg-complex-search :fields="filterFields" v-model="searchParams" @search="handleSearch" @reset="handleReset" />
  10. <cwg-tabel ref="tableRef" :columns="currentColumns" :mobilePrimaryFields="mobilePrimaryFields" :immediate="true"
  11. :queryParams="queryParams" :api="listApi" :show-operation="false" @sort-change="handleSortChange">
  12. <!-- TOP/推荐 -->
  13. <template #recommend="{ row }">
  14. <view v-if="row.top == 1" class="recommend-tag top">TOP</view>
  15. <view v-else-if="row.recommend == 1" class="recommend-tag green">{{ t('Documentary.tradingCenter.item26') }}
  16. </view>
  17. </template>
  18. <!-- 账户类型 -->
  19. <template #groupType="{ row }">
  20. <text v-if="row.groupType == 1">{{ t('AccountType.ClassicAccount') }}</text>
  21. <text v-else-if="row.groupType == 2">{{ t('AccountType.SeniorAccount') }}</text>
  22. <text v-else-if="row.groupType == 5 || row.groupType == 6">{{ t('AccountType.SpeedAccount') }}</text>
  23. <text v-else-if="row.groupType == 7">{{ t('AccountType.StandardAccount') }}</text>
  24. <text v-else-if="row.groupType == 8">{{ t('AccountType.CentAccount') }}</text>
  25. <text v-else>--</text>
  26. </template>
  27. <!-- 活跃度 -->
  28. <template #activity="{ row }">
  29. <text>{{ getActivityText(row.activity) }}</text>
  30. </template>
  31. <!-- 查看图表 -->
  32. <template #view="{ row }">
  33. <view class="action-icon cursor-pointer" @click="toView(row)" :data-tooltip="t('vu.tooltip.t15')">
  34. <cwg-icon name="crm-chart-area" :size="24" color="#000" />
  35. </view>
  36. </template>
  37. <!-- 订阅 -->
  38. <template #subscribe="{ row }">
  39. <view class="btn-primary" size="mini" @click="toSubscribe(row)">
  40. <text>{{ t('Documentary.tradingCenter.item25') }}</text>
  41. </view>
  42. </template>
  43. </cwg-tabel>
  44. </view>
  45. <!-- 自动跟随设置弹窗 -->
  46. <cwg-popup v-model:visible="dialogFllow" type="center" :title="t('Documentary.tradingCenter.item27')"
  47. :showFooters="true">
  48. <scroll-view scroll-y class="dia-content" style="max-height: 60vh;">
  49. <view class="fllow-title">
  50. <text class="title">{{ t('Documentary.tradingCenter.item27') }}-{{ dialogFllowData1.nickname || '--' }}</text>
  51. <text class="time">{{ t('Documentary.tradingCenter.item45') }}: {{ time }}</text>
  52. </view>
  53. <view class="fllow-info-grid">
  54. <view class="fllow-content">
  55. <text class="tit">{{ t('Documentary.tradingCenter.item29') }}</text>
  56. <text class="con">{{ dialogFllowData1.maskLogin }}</text>
  57. </view>
  58. <view class="fllow-content">
  59. <text class="tit">{{ t('Documentary.console.item3') }}</text>
  60. <text class="con">{{ dialogFllowData1.dealPlatform || '--' }}</text>
  61. </view>
  62. <view class="fllow-content">
  63. <text class="tit">{{ t('Documentary.console.item7') }}</text>
  64. <text class="con">{{ dialogFllowData1.dealBalance || '0.00' }}</text>
  65. </view>
  66. <view class="fllow-content">
  67. <text class="tit">{{ t('Label.AccountType') }}</text>
  68. <text class="con">{{ getAccountTypeText(dialogFllowData1.dealLoginType) }}</text>
  69. </view>
  70. <view class="fllow-content">
  71. <text class="tit">{{ t('Documentary.console.item6') }}</text>
  72. <text class="con">{{ dialogFllowData1.dealEquity || '0.00' }}</text>
  73. </view>
  74. <view class="fllow-content">
  75. <text class="tit">{{ t('Documentary.tradingCenter.item30') }}</text>
  76. <text class="con">{{ dialogFllowData1.distributionType == 1 ? t('Documentary.TundManagement.item59') : '--'
  77. }}
  78. </text>
  79. </view>
  80. <view class="fllow-content">
  81. <text class="tit">{{ t('Label.Credit') }}</text>
  82. <text class="con">{{ dialogFllowData1.dealCredit || '0.00' }}</text>
  83. </view>
  84. <view class="fllow-content">
  85. <text class="tit">{{ t('Documentary.AgentBackground.item12') }}</text>
  86. <text class="con">{{ dialogFllowData1.distributionRatio || '0' }}%</text>
  87. </view>
  88. <view class="fllow-content">
  89. <text class="tit">{{ t('Label.Leverage') }}</text>
  90. <text class="con">1:{{ dialogFllowData1.dealLeverage || '--' }}</text>
  91. </view>
  92. <view class="fllow-content">
  93. <text class="tit">{{ t('Documentary.tradingCenter.item32') }}</text>
  94. <text class="con">{{ optObj[dialogFllowData1.settlementCycle] || '--' }}</text>
  95. </view>
  96. </view>
  97. <view class="fllow-title section-title">
  98. <text class="title">{{ t('Documentary.tradingCenter.item33') }}</text>
  99. </view>
  100. <uni-forms ref="formRef" :modelValue="dialogFllowData" :rules="rules" label-position="top" labelWidth="80">
  101. <view class="form-grid">
  102. <uni-forms-item :label="t('Documentary.console.item4')" name="followLogin">
  103. <uni-data-select v-model="dialogFllowData.followLogin" :localdata="followLoginOptions"
  104. @change="selectLogin" :placeholder="t('common.choose')"
  105. :emptyTips="t('common.noMore')"></uni-data-select>
  106. </uni-forms-item>
  107. <uni-forms-item :label="t('Documentary.tradingCenter.item34')" name="leverage">
  108. <uni-easyinput v-model="dialogFllowData.leverage" disabled />
  109. </uni-forms-item>
  110. <uni-forms-item :label="t('Documentary.tradingCenter.item35')" name="followType">
  111. <uni-data-select v-model="dialogFllowData.followType" :localdata="[
  112. { value: 3, text: t('Documentary.tradingCenter.item118') },
  113. { value: 2, text: t('Documentary.tradingCenter.item117') },
  114. { value: 1, text: t('Documentary.tradingCenter.item116') }
  115. ]" :placeholder="t('common.choose')" :emptyTips="t('common.noMore')"></uni-data-select>
  116. </uni-forms-item>
  117. <uni-forms-item v-if="dialogFllowData.followType == 1" :label="t('Documentary.tradingCenter.item119')"
  118. name="volume">
  119. <uni-easyinput v-model="dialogFllowData.volume" />
  120. </uni-forms-item>
  121. <uni-forms-item v-if="dialogFllowData.followType == 2"
  122. :label="t('Documentary.tradingCenter.item122') + ' (%)'" name="ratio">
  123. <uni-easyinput v-model="dialogFllowData.ratio" />
  124. </uni-forms-item>
  125. </view>
  126. <view class="fllow-title section-title">
  127. <text class="title">{{ t('Documentary.tradingCenter.item37') }}</text>
  128. <switch :checked="dialogFllowData.protect === 1"
  129. @change="e => dialogFllowData.protect = e.detail.value ? 1 : 0" color="#368FEC"
  130. style="transform: scale(0.7)" />
  131. </view>
  132. <view class="form-grid" v-if="dialogFllowData.protect === 1">
  133. <uni-forms-item :label="t('Documentary.tradingCenter.item38')" name="protectType">
  134. <uni-data-select v-model="dialogFllowData.protectType" :localdata="[
  135. { value: 1, text: t('Documentary.tradingCenter.item120') }
  136. ]"></uni-data-select>
  137. </uni-forms-item>
  138. <uni-forms-item v-if="dialogFllowData.protectType == 1"
  139. :label="t('Documentary.tradingCenter.item39') + '($)'" name="protectAmount">
  140. <uni-easyinput v-model="dialogFllowData.protectAmount" />
  141. </uni-forms-item>
  142. <uni-forms-item v-if="dialogFllowData.protectType == 2"
  143. :label="t('Documentary.tradingCenter.item122') + '(%)'" name="protectRatio">
  144. <uni-easyinput v-model="dialogFllowData.protectRatio" />
  145. </uni-forms-item>
  146. </view>
  147. <view class="terms-desc">
  148. <text>{{ t('Documentary.tradingCenter.item130') }}</text>
  149. </view>
  150. <uni-forms-item name="agree">
  151. <label class="agree-label mt-2">
  152. <checkbox :checked="dialogFllowData.agree" @click="dialogFllowData.agree = !dialogFllowData.agree"
  153. style="transform:scale(0.7)" />
  154. <text>{{ t('Documentary.tradingCenter.item40') }} -</text>
  155. <cwg-link type="pdf" title="Documentary.tradingCenter.item41"
  156. v-if="['cn', 'zhHant'].indexOf(locale) != -1" style="color: #4497ff"
  157. url="pdf/CopyTradeUserAgreementcn.pdf" target="_blank" />
  158. <cwg-link type="pdf" style="color: #4497ff" title="Documentary.tradingCenter.item41"
  159. url="pdf/CopyTradeUserAgreement.pdf" target="_blank" v-else />
  160. </label>
  161. </uni-forms-item>
  162. </uni-forms>
  163. </scroll-view>
  164. <template #footer>
  165. <button hover-class="" class="cancel-btn" @click="applyFllowCancel">{{ t('Btn.Cancel') }}</button>
  166. <button hover-class="" class="confirm-btn" type="primary" @click="applyFllow">{{ t('Btn.Confirm') }}</button>
  167. </template>
  168. </cwg-popup>
  169. </cwg-page-wrapper>
  170. </template>
  171. <script setup lang="ts">
  172. import { computed, ref, nextTick, onMounted, onUnmounted, watch } from 'vue'
  173. import { useI18n } from 'vue-i18n'
  174. import { documentaryApi } from '@/service/documentary'
  175. import useUserStore from '@/stores/use-user-store'
  176. import { useFollowEnum } from '@/pages/follow/const/enum'
  177. import { useFilters } from '@/composables/useFilters'
  178. const { numberDecimal } = useFilters()
  179. const { t, locale } = useI18n()
  180. const userStore = useUserStore()
  181. const userInfo = computed(() => userStore.userInfo)
  182. const { optObj } = useFollowEnum()
  183. // --- Time fetching ---
  184. const time = ref('')
  185. let timer: any = null
  186. const getLocalTime = () => {
  187. let timezone = 2
  188. let offset_GMT = new Date().getTimezoneOffset()
  189. let nowDate = new Date().getTime()
  190. let now = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000)
  191. let year = now.getFullYear()
  192. let month = String(now.getMonth() + 1).padStart(2, '0')
  193. let day = String(now.getDate()).padStart(2, '0')
  194. let hh = String(now.getHours()).padStart(2, '0')
  195. let mm = String(now.getMinutes()).padStart(2, '0')
  196. time.value = `${year}/${month}/${day} ${hh}:${mm}`
  197. }
  198. const getDate = async () => {
  199. try {
  200. let res = await documentaryApi.followDealSignalRefreshDate()
  201. if (res.code === 200 && res.data) {
  202. time.value = res.data
  203. } else {
  204. getLocalTime()
  205. }
  206. } catch (error) {
  207. getLocalTime()
  208. }
  209. }
  210. onMounted(() => {
  211. getDate()
  212. })
  213. onUnmounted(() => {
  214. })
  215. // --- Table Config ---
  216. const searchParams = ref({
  217. nickname: '',
  218. plStart: '', plEnd: '',
  219. plRateStart: '', plRateEnd: '',
  220. volumeStart: '', volumeEnd: '',
  221. winRateStart: '', winRateEnd: '',
  222. maxDdRateStart: '', maxDdRateEnd: '',
  223. activityRange: '',
  224. followsStart: '', followsEnd: '',
  225. })
  226. const filterFields = computed(() => [
  227. { key: 'nickname', type: 'input', label: t('TradingCenter.item13'), placeholder: t('TradingCenter.item13') },
  228. {
  229. key: 'plStart',
  230. type: 'number',
  231. label: t('TradingCenter.item3') + ' (' + t('TradingCenter.item1') + ')',
  232. placeholder: t('TradingCenter.item3') + ' (' + t('TradingCenter.item1') + ')',
  233. },
  234. {
  235. key: 'plEnd',
  236. type: 'number',
  237. label: t('TradingCenter.item3') + ' (' + t('TradingCenter.item2') + ')',
  238. placeholder: t('TradingCenter.item3') + ' (' + t('TradingCenter.item2') + ')',
  239. },
  240. {
  241. key: 'plRateStart',
  242. type: 'number',
  243. label: t('TradingCenter.item4') + ' (' + t('TradingCenter.item1') + ')',
  244. placeholder: t('TradingCenter.item4') + ' (' + t('TradingCenter.item1') + ')',
  245. },
  246. {
  247. key: 'plRateEnd',
  248. type: 'number',
  249. label: t('TradingCenter.item4') + ' (' + t('TradingCenter.item2') + ')',
  250. placeholder: t('TradingCenter.item4') + ' (' + t('TradingCenter.item2') + ')',
  251. },
  252. {
  253. key: 'volumeStart',
  254. type: 'number',
  255. label: t('TradingCenter.item5') + ' (' + t('TradingCenter.item1') + ')',
  256. placeholder: t('TradingCenter.item5') + ' (' + t('TradingCenter.item1') + ')',
  257. },
  258. {
  259. key: 'volumeEnd',
  260. type: 'number',
  261. label: t('TradingCenter.item5') + ' (' + t('TradingCenter.item2') + ')',
  262. placeholder: t('TradingCenter.item5') + ' (' + t('TradingCenter.item2') + ')',
  263. },
  264. {
  265. key: 'winRateStart',
  266. type: 'number',
  267. label: t('TradingCenter.item6') + ' (' + t('TradingCenter.item1') + ')',
  268. placeholder: t('TradingCenter.item6') + ' (' + t('TradingCenter.item1') + ')',
  269. },
  270. {
  271. key: 'winRateEnd',
  272. type: 'number',
  273. label: t('TradingCenter.item6') + ' (' + t('TradingCenter.item2') + ')',
  274. placeholder: t('TradingCenter.item6') + ' (' + t('TradingCenter.item2') + ')',
  275. },
  276. {
  277. key: 'maxDdRateStart',
  278. type: 'number',
  279. label: t('TradingCenter.item7') + ' (' + t('TradingCenter.item1') + ')',
  280. placeholder: t('TradingCenter.item7') + ' (' + t('TradingCenter.item1') + ')',
  281. },
  282. {
  283. key: 'maxDdRateEnd',
  284. type: 'number',
  285. label: t('TradingCenter.item7') + ' (' + t('TradingCenter.item2') + ')',
  286. placeholder: t('TradingCenter.item7') + ' (' + t('TradingCenter.item2') + ')',
  287. },
  288. {
  289. key: 'activityRange',
  290. type: 'select',
  291. label: t('TradingCenter.item8'),
  292. placeholder: t('TradingCenter.item8'),
  293. options: [
  294. { value: 'inactive', text: t('activeState.item1') },
  295. { value: 'active', text: t('activeState.item2') },
  296. { value: 'very_active', text: t('activeState.item3') },
  297. ],
  298. },
  299. {
  300. key: 'followsStart',
  301. type: 'number',
  302. label: t('TradingCenter.item9') + ' (' + t('TradingCenter.item1') + ')',
  303. placeholder: t('TradingCenter.item9') + ' (' + t('TradingCenter.item1') + ')',
  304. },
  305. {
  306. key: 'followsEnd',
  307. type: 'number',
  308. label: t('TradingCenter.item9') + ' (' + t('TradingCenter.item2') + ')',
  309. placeholder: t('TradingCenter.item9') + ' (' + t('TradingCenter.item2') + ')',
  310. },
  311. ])
  312. const sortState = ref({
  313. orderColumn: 1, // 1:plRate, 2:pl, 3:volume, 4:winRate, 5:maxDdRate, 6:activity, 7:follows
  314. orderType: 1, // 1:asc, 2:desc
  315. })
  316. const queryParams = computed(() => {
  317. const act = searchParams.value.activityRange
  318. return {
  319. ...searchParams.value,
  320. activityStart: act === 'inactive' ? 0 : act === 'active' ? 0.33 : act === 'very_active' ? 0.66 : null,
  321. activityEnd: act === 'inactive' ? 0.33 : act === 'active' ? 0.66 : act === 'very_active' ? 1 : null,
  322. orderColumn: sortState.value.orderColumn,
  323. orderType: sortState.value.orderType,
  324. }
  325. })
  326. const tableRef = ref(null)
  327. const listApi = ref(documentaryApi.followDealSearchList)
  328. const handleSearch = (params: any) => {
  329. searchParams.value = params
  330. nextTick(() => {
  331. tableRef.value?.refreshTable()
  332. })
  333. }
  334. const handleReset = (params: any) => {
  335. searchParams.value = params
  336. nextTick(() => {
  337. tableRef.value?.refreshTable()
  338. })
  339. }
  340. const handleSortChange = ({ prop, order }: any) => {
  341. const propToColumn: Record<string, number> = {
  342. 'plRate': 1, 'pl': 2, 'volume': 3, 'winRate': 4, 'maxDdRate': 5, 'activity': 6, 'follows': 7,
  343. }
  344. sortState.value.orderColumn = propToColumn[prop] || 1
  345. sortState.value.orderType = order === 'desc' ? 2 : 1
  346. nextTick(() => {
  347. tableRef.value?.refreshTable()
  348. })
  349. }
  350. const currentColumns = computed(() => [
  351. // { prop: 'recommend', label: '', slot: 'recommend', align: 'center', width: 60 },
  352. { prop: 'nickname', label: t('Documentary.tradingCenter.item1'), align: 'left' },
  353. { prop: 'maskLogin', label: t('newLoop.item11'), align: 'center' },
  354. { prop: 'pl', label: t('TradingCenter.item3'), align: 'center', sortable: true },
  355. { prop: 'volume', label: t('TradingCenter.item5'), align: 'center', sortable: true },
  356. { prop: 'follows', label: t('TradingCenter.item9'), align: 'center', sortable: true },
  357. { prop: 'groupType', label: t('Label.AccountType'), slot: 'groupType', align: 'center' },
  358. { prop: 'plRate', label: t('TradingCenter.item4'), align: 'center', sortable: true },
  359. { prop: 'winRate', label: t('TradingCenter.item6'), align: 'center', sortable: true },
  360. { prop: 'maxDdRate', label: t('TradingCenter.item7'), align: 'center', sortable: true },
  361. { prop: 'activity', label: t('TradingCenter.item8'), slot: 'activity', align: 'center', sortable: true },
  362. { prop: 'view', label: t('Documentary.tradingCenter.item23'), slot: 'view', align: 'center' },
  363. // { prop: 'recommendReason', label: t('Documentary.tradingCenter.item142'), align: 'center', width: 100 },
  364. { prop: 'subscribe', label: t('Documentary.tradingCenter.item24'), slot: 'subscribe', align: 'center' },
  365. ])
  366. const mobilePrimaryFields = computed(() => [
  367. { prop: 'nickname', label: t('Documentary.tradingCenter.item1'), align: 'center' },
  368. { prop: 'maskLogin', label: t('newLoop.item11'), align: 'center' },
  369. { prop: 'groupType', label: t('Label.AccountType'), slot: 'groupType', align: 'center' },
  370. {
  371. prop: 'more',
  372. type: 'more',
  373. width: 20,
  374. align: 'right',
  375. },
  376. ])
  377. const getAccountTypeText = (type: number) => {
  378. const accountTypeMap: Record<number, string> = {
  379. 1: 'AccountType.ClassicAccount',
  380. 2: 'AccountType.SeniorAccount',
  381. 3: 'AccountType.AgencyAccount',
  382. 5: 'AccountType.SpeedAccount',
  383. 6: 'AccountType.SpeedAccount',
  384. 7: 'AccountType.StandardAccount',
  385. 8: 'AccountType.CentAccount',
  386. }
  387. return type && accountTypeMap[type] ? t(accountTypeMap[type]) : '--'
  388. }
  389. const getActivityText = (activity: number) => {
  390. if (!activity) return '--'
  391. switch (activity) {
  392. case 1:
  393. return t('activeState.item1')
  394. case 2:
  395. return t('activeState.item2')
  396. case 3:
  397. return t('activeState.item3')
  398. default:
  399. return activity
  400. }
  401. }
  402. const toView = (row: any) => {
  403. uni.navigateTo({
  404. url: `/pages/follow/trading-center-single?dealLogin=${row.dealLogin}&id=${row.id}&login=${row.login}`,
  405. })
  406. }
  407. // --- Follow Subscription ---
  408. const dialogFllow = ref(false)
  409. const dialogFllowData1 = ref<any>({})
  410. const dialogFllowLoginData = ref<any[]>([])
  411. const dialogFllowData = ref({
  412. followLogin: '',
  413. protect: 0,
  414. protectType: 1,
  415. protectAmount: '',
  416. protectRatio: '',
  417. followType: undefined,
  418. volume: '',
  419. ratio: '',
  420. leverage: '',
  421. agree: false,
  422. })
  423. const formRef = ref<any>(null)
  424. const rules = computed(() => ({
  425. protectAmount: { rules: [{ required: true, errorMessage: t('vaildate.input.empty') }] },
  426. protectRatio: { rules: [{ required: true, errorMessage: t('vaildate.input.empty') }] },
  427. volume: {
  428. rules: [{ required: true, errorMessage: t('vaildate.input.empty') }, {
  429. validateFunction: (rule, value, data, callback) => {
  430. if (value) {
  431. const num = Number(value)
  432. if (isNaN(num) || num <= 0) {
  433. callback(t('vu.follow.v1'))
  434. } else {
  435. callback()
  436. }
  437. }
  438. }
  439. }]
  440. },
  441. ratio: { rules: [{ required: true, errorMessage: t('vaildate.input.empty') }] },
  442. followLogin: { rules: [{ required: true, errorMessage: t('vaildate.select.empty') }] },
  443. followType: { rules: [{ required: true, errorMessage: t('vaildate.select.empty') }] },
  444. agree: { rules: [{ required: true, errorMessage: t('vaildate.agree.empty') }] },
  445. }));
  446. watch(locale, () => {
  447. formRef.value?.clearValidate()
  448. })
  449. const followLoginOptions = computed(() => {
  450. return dialogFllowLoginData.value.map(item => ({
  451. value: item.login,
  452. text: `${item.login} - ${getAccountTypeText(item.loginType)} - ${t('Custom.Deposit.AvailableBalance')}: $${numberDecimal(item.balance || 0)}`,
  453. }))
  454. })
  455. const toSubscribe = async (row: any) => {
  456. uni.showLoading({ title: t('State.InTheProcessing') })
  457. try {
  458. let res = await documentaryApi.followDealSubscribeInfo({ dealId: row.dealId })
  459. if (res.code === 200) {
  460. dialogFllowData1.value = row
  461. dialogFllowData.value.protect = 0
  462. dialogFllowLoginData.value = res.data || []
  463. dialogFllow.value = true
  464. } else {
  465. uni.showToast({ title: res.msg, icon: 'none' })
  466. }
  467. } finally {
  468. uni.hideLoading()
  469. }
  470. }
  471. const selectLogin = (val: string) => {
  472. const target = dialogFllowLoginData.value.find(item => item.login === val)
  473. if (target) {
  474. dialogFllowData.value.leverage = `1:${target.leverage}`
  475. }
  476. }
  477. const openAgreement = () => {
  478. const lang = locale.value
  479. const url = ['cn', 'zhHant'].includes(lang) ? 'pdf/CopyTradeUserAgreementcn.pdf' : 'pdf/CopyTradeUserAgreement.pdf'
  480. // Use plus.runtime.openURL or window.open depending on platform
  481. // #ifdef H5
  482. window.open(url, '_blank')
  483. // #endif
  484. // #ifndef H5
  485. uni.showToast({ title: 'Not supported on this platform', icon: 'none' })
  486. // #endif
  487. }
  488. let submitting = false
  489. const applyFllow = async () => {
  490. if (submitting) return
  491. if (!dialogFllowData.value.agree) {
  492. uni.showToast({ title: t('vaildate.agree.empty'), icon: 'none' })
  493. return
  494. }
  495. try {
  496. await formRef.value?.validate()
  497. } catch (e) {
  498. return
  499. }
  500. submitting = true
  501. uni.showLoading({ title: t('State.InTheProcessing') })
  502. try {
  503. const payload = {
  504. dealId: dialogFllowData1.value.id,
  505. followLogin: dialogFllowData.value.followLogin,
  506. protect: dialogFllowData.value.protect,
  507. protectType: dialogFllowData.value.protect ? dialogFllowData.value.protectType : null,
  508. protectAmount: dialogFllowData.value.protect ? dialogFllowData.value.protectAmount : null,
  509. protectRatio: dialogFllowData.value.protect ? dialogFllowData.value.protectRatio : null,
  510. followType: dialogFllowData.value.followType,
  511. volume: dialogFllowData.value.followType == 1 ? Number(dialogFllowData.value.volume) * 100 : null,
  512. ratio: dialogFllowData.value.followType == 2 ? dialogFllowData.value.ratio : null,
  513. }
  514. let res = await documentaryApi.followDealSubscriSubscribe(payload)
  515. if (res.code === 200) {
  516. uni.showToast({ title: t('Msg.Success'), icon: 'success' })
  517. applyFllowCancel()
  518. } else {
  519. const msg = res.msg == 'EMPTY_POSITION_BEFORE_SUBSCRIBE' ? t('Documentary.tradingCenter.item134') : res.msg
  520. uni.showToast({ title: msg, icon: 'none' })
  521. }
  522. } finally {
  523. submitting = false
  524. uni.hideLoading()
  525. }
  526. }
  527. const applyFllowCancel = () => {
  528. dialogFllow.value = false
  529. dialogFllowData.value = {
  530. followLogin: '', protect: 0, protectType: 1, protectAmount: '', protectRatio: '',
  531. followType: 1, volume: '', ratio: '', leverage: '', agree: false,
  532. }
  533. }
  534. </script>
  535. <style scoped lang="scss">
  536. @import "@/uni.scss";
  537. .time-header {
  538. display: flex;
  539. justify-content: flex-end;
  540. font-size: 14px;
  541. margin-bottom: 10px;
  542. font-weight: 500;
  543. color: var(--bs-heading-color);
  544. .time-value {
  545. margin-left: 6px;
  546. color: var(--bs-heading-color);
  547. }
  548. }
  549. .recommend-tag {
  550. font-size: 12px;
  551. color: var(--bs-emphasis-color);
  552. padding: 2px 6px;
  553. border-radius: 4px;
  554. display: inline-block;
  555. &.top {
  556. background-color: #eb3f57;
  557. }
  558. &.green {
  559. background-color: #89be30;
  560. }
  561. }
  562. .action-icon {
  563. display: inline-flex;
  564. cursor: pointer;
  565. }
  566. .btn-primary {
  567. min-width: px2rpx(70);
  568. background-color: #4497ff;
  569. color: white;
  570. padding: 0 px2rpx(12);
  571. border: none;
  572. font-size: px2rpx(12);
  573. display: block;
  574. height: 28px;
  575. line-height: 28px;
  576. border-radius: 4px;
  577. cursor: pointer;
  578. }
  579. .dia-content {
  580. padding: 10px;
  581. .fllow-title {
  582. display: flex;
  583. justify-content: space-between;
  584. align-items: center;
  585. border-bottom: 1px solid #eee;
  586. padding-bottom: 10px;
  587. margin-bottom: 10px;
  588. .title {
  589. font-weight: bold;
  590. color: var(--bs-heading-color);
  591. padding-left: 8px;
  592. border-left: 4px solid #eb3f57;
  593. font-size: 16px;
  594. }
  595. .time {
  596. font-size: 12px;
  597. color: #888;
  598. }
  599. }
  600. .section-title {
  601. margin-top: 20px;
  602. .title {
  603. border-left-color: #4497ff;
  604. }
  605. }
  606. .fllow-info-grid {
  607. display: grid;
  608. grid-template-columns: 1fr 1fr;
  609. gap: 10px 20px;
  610. @media screen and (max-width: 750px) {
  611. grid-template-columns: none;
  612. }
  613. .fllow-content {
  614. display: flex;
  615. justify-content: space-between;
  616. font-size: 14px;
  617. border-bottom: 1px dashed #eee;
  618. padding-bottom: 4px;
  619. .tit {
  620. color: var(--bs-heading-color);
  621. }
  622. .con {
  623. font-weight: 500;
  624. color: var(--bs-heading-color);
  625. }
  626. }
  627. }
  628. .form-grid {
  629. display: grid;
  630. grid-template-columns: 1fr 1fr;
  631. gap: 10px 20px;
  632. margin-top: 10px;
  633. @media screen and (max-width: 750px) {
  634. grid-template-columns: none;
  635. }
  636. }
  637. .terms-desc {
  638. font-size: 12px;
  639. color: #888;
  640. margin: 10px 0;
  641. }
  642. .agree-label {
  643. display: flex;
  644. align-items: center;
  645. font-size: px2rpx(14);
  646. color: var(--bs-heading-color);
  647. .link {
  648. color: #4497ff;
  649. cursor: pointer;
  650. }
  651. }
  652. }
  653. .cancel-btn,
  654. .confirm-btn {
  655. margin: 0 10px;
  656. border-radius: 4px;
  657. }
  658. .cancel-btn {
  659. background-color: #f5f5f5;
  660. color: var(--bs-heading-color);
  661. }
  662. .confirm-btn {
  663. //background-color: #4497ff;
  664. color: #fff;
  665. }
  666. </style>