trading-center.vue 25 KB

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