trading-center.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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.dealLogin }}</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"></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. ]"></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">
  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 } 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', width: 100 },
  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: 1,
  414. volume: '',
  415. ratio: '',
  416. leverage: '',
  417. agree: false,
  418. })
  419. const formRef = ref<any>(null)
  420. const rules = {
  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. const followLoginOptions = computed(() => {
  441. return dialogFllowLoginData.value.map(item => ({
  442. value: item.login,
  443. text: `${item.login} - ${getAccountTypeText(item.loginType)} - ${t('Custom.Deposit.AvailableBalance')}: $${item.balance || 0}`,
  444. }))
  445. })
  446. const toSubscribe = async (row: any) => {
  447. uni.showLoading({ title: t('State.InTheProcessing') })
  448. try {
  449. let res = await documentaryApi.followDealSubscribeInfo({ dealId: row.dealId })
  450. if (res.code === 200) {
  451. dialogFllowData1.value = row
  452. dialogFllowData.value.protect = 0
  453. dialogFllowLoginData.value = res.data || []
  454. dialogFllow.value = true
  455. } else {
  456. uni.showToast({ title: res.msg, icon: 'none' })
  457. }
  458. } finally {
  459. uni.hideLoading()
  460. }
  461. }
  462. const selectLogin = (val: string) => {
  463. const target = dialogFllowLoginData.value.find(item => item.login === val)
  464. if (target) {
  465. dialogFllowData.value.leverage = `1:${target.leverage}`
  466. }
  467. }
  468. const openAgreement = () => {
  469. const lang = locale.value
  470. const url = ['cn', 'zhHant'].includes(lang) ? 'pdf/CopyTradeUserAgreementcn.pdf' : 'pdf/CopyTradeUserAgreement.pdf'
  471. // Use plus.runtime.openURL or window.open depending on platform
  472. // #ifdef H5
  473. window.open(url, '_blank')
  474. // #endif
  475. // #ifndef H5
  476. uni.showToast({ title: 'Not supported on this platform', icon: 'none' })
  477. // #endif
  478. }
  479. let submitting = false
  480. const applyFllow = async () => {
  481. if (submitting) return
  482. if (!dialogFllowData.value.agree) {
  483. uni.showToast({ title: t('vaildate.agree.empty'), icon: 'none' })
  484. return
  485. }
  486. try {
  487. await formRef.value?.validate()
  488. } catch (e) {
  489. return
  490. }
  491. submitting = true
  492. uni.showLoading({ title: t('State.InTheProcessing') })
  493. try {
  494. const payload = {
  495. dealId: dialogFllowData1.value.id,
  496. followLogin: dialogFllowData.value.followLogin,
  497. protect: dialogFllowData.value.protect,
  498. protectType: dialogFllowData.value.protect ? dialogFllowData.value.protectType : null,
  499. protectAmount: dialogFllowData.value.protect ? dialogFllowData.value.protectAmount : null,
  500. protectRatio: dialogFllowData.value.protect ? dialogFllowData.value.protectRatio : null,
  501. followType: dialogFllowData.value.followType,
  502. volume: dialogFllowData.value.followType == 1 ? Number(dialogFllowData.value.volume) * 100 : null,
  503. ratio: dialogFllowData.value.followType == 2 ? dialogFllowData.value.ratio : null,
  504. }
  505. let res = await documentaryApi.followDealSubscriSubscribe(payload)
  506. if (res.code === 200) {
  507. uni.showToast({ title: t('Msg.Success'), icon: 'success' })
  508. applyFllowCancel()
  509. } else {
  510. const msg = res.msg == 'EMPTY_POSITION_BEFORE_SUBSCRIBE' ? t('Documentary.tradingCenter.item134') : res.msg
  511. uni.showToast({ title: msg, icon: 'none' })
  512. }
  513. } finally {
  514. submitting = false
  515. uni.hideLoading()
  516. }
  517. }
  518. const applyFllowCancel = () => {
  519. dialogFllow.value = false
  520. dialogFllowData.value = {
  521. followLogin: '', protect: 0, protectType: 1, protectAmount: '', protectRatio: '',
  522. followType: 1, volume: '', ratio: '', leverage: '', agree: false,
  523. }
  524. }
  525. </script>
  526. <style scoped lang="scss">
  527. @import "@/uni.scss";
  528. .time-header {
  529. display: flex;
  530. justify-content: flex-end;
  531. font-size: 14px;
  532. margin-bottom: 10px;
  533. font-weight: 500;
  534. color: var(--bs-heading-color);
  535. .time-value {
  536. margin-left: 6px;
  537. color: var(--bs-heading-color);
  538. }
  539. }
  540. .recommend-tag {
  541. font-size: 12px;
  542. color: var(--bs-emphasis-color);
  543. padding: 2px 6px;
  544. border-radius: 4px;
  545. display: inline-block;
  546. &.top {
  547. background-color: #eb3f57;
  548. }
  549. &.green {
  550. background-color: #89be30;
  551. }
  552. }
  553. .action-icon {
  554. display: inline-flex;
  555. cursor: pointer;
  556. }
  557. .btn-primary {
  558. background-color: #4497ff;
  559. color: white;
  560. padding: 0 px2rpx(12);
  561. border: none;
  562. font-size: px2rpx(12);
  563. display: inline-flex;
  564. align-items: center;
  565. justify-content: center;
  566. gap: px2rpx(4);
  567. height: 28px;
  568. line-height: 28px;
  569. border-radius: 4px;
  570. }
  571. .dia-content {
  572. padding: 10px;
  573. .fllow-title {
  574. display: flex;
  575. justify-content: space-between;
  576. align-items: center;
  577. border-bottom: 1px solid #eee;
  578. padding-bottom: 10px;
  579. margin-bottom: 10px;
  580. .title {
  581. font-weight: bold;
  582. color: var(--bs-heading-color);
  583. padding-left: 8px;
  584. border-left: 4px solid #eb3f57;
  585. font-size: 16px;
  586. }
  587. .time {
  588. font-size: 12px;
  589. color: #888;
  590. }
  591. }
  592. .section-title {
  593. margin-top: 20px;
  594. .title {
  595. border-left-color: #4497ff;
  596. }
  597. }
  598. .fllow-info-grid {
  599. display: grid;
  600. grid-template-columns: 1fr 1fr;
  601. gap: 10px 20px;
  602. .fllow-content {
  603. display: flex;
  604. justify-content: space-between;
  605. font-size: 14px;
  606. border-bottom: 1px dashed #eee;
  607. padding-bottom: 4px;
  608. .tit {
  609. color: var(--bs-heading-color);
  610. }
  611. .con {
  612. font-weight: 500;
  613. color: var(--bs-heading-color);
  614. }
  615. }
  616. }
  617. .form-grid {
  618. display: grid;
  619. grid-template-columns: 1fr 1fr;
  620. gap: 10px 20px;
  621. margin-top: 10px;
  622. }
  623. .terms-desc {
  624. font-size: 12px;
  625. color: #888;
  626. margin: 10px 0;
  627. }
  628. .agree-label {
  629. display: flex;
  630. align-items: center;
  631. font-size: 14px;
  632. color: var(--bs-heading-color);
  633. .link {
  634. color: #4497ff;
  635. cursor: pointer;
  636. }
  637. }
  638. }
  639. .cancel-btn,
  640. .confirm-btn {
  641. flex: 1;
  642. margin: 0 10px;
  643. border-radius: 4px;
  644. }
  645. .cancel-btn {
  646. background-color: #f5f5f5;
  647. color: var(--bs-heading-color);
  648. }
  649. .confirm-btn {
  650. //background-color: #4497ff;
  651. color: #fff;
  652. }
  653. </style>