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