Index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <app-view class="mine">
  3. <template #header>
  4. <app-navbar :title="$t('mine.title')" :show-back-button="false" @ready="onReady" />
  5. </template>
  6. <div ref="headerRef" class="mine-header">
  7. <div class="mine-header__wrapper">
  8. <div class="profile">
  9. <div class="profile-user">
  10. <div class="profile-user__avatar" @click="routerTo('user-avatar')">
  11. <img class="g-image--avatar" :src="userStore.userAvatar" />
  12. </div>
  13. <div class="profile-user__info">
  14. <div class="top">
  15. <span>{{ userStore.customerName }}</span>
  16. <Icon name="checked" color="var(--van-tag-success-color)"
  17. v-if="authStatus === AuthStatus.Certified" />
  18. <Icon name="warning" color="var(--van-tag-warning-color)" v-else />
  19. </div>
  20. <div class="bottom">{{ loginStore.loginId }}</div>
  21. </div>
  22. </div>
  23. <div class="profile-account">
  24. <span>{{ $t('mine.normal') }}</span>
  25. <span>{{ currentAccount.accountid ?? 0 }}</span>
  26. </div>
  27. </div>
  28. <div class="bank">
  29. <ul>
  30. <li>
  31. <span>{{ $t('mine.balance') }}</span>
  32. <span>{{ currentAccount.currentbalance?.toFixed(2) }}</span>
  33. </li>
  34. <li>
  35. <span>{{ $t('mine.netWorth') }}</span>
  36. <span>{{ currentAccount.hazardValue?.toFixed(2) }}</span>
  37. </li>
  38. </ul>
  39. <ul>
  40. <li>
  41. <span>{{ $t('mine.freezeMargin') }}</span>
  42. <span>{{ currentAccount.freezeMargin?.toFixed(2) }}</span>
  43. </li>
  44. <li>
  45. <span>{{ $t('mine.usedMargin') }}</span>
  46. <span>{{ currentAccount.usedmargin?.toFixed(2) }}</span>
  47. </li>
  48. </ul>
  49. <ul>
  50. <li>
  51. <span>{{ $t('mine.availableFunds') }}</span>
  52. <span>{{ currentAccount.avaiableMoney?.toFixed(2) }}</span>
  53. </li>
  54. <li>
  55. <span>{{ $t('mine.riskRate') }}</span>
  56. <span :class="currentAccount.hazardRatioColor">
  57. {{ parsePercent(currentAccount.hazardRatio) }}
  58. </span>
  59. </li>
  60. </ul>
  61. </div>
  62. <div class="button">
  63. <Button type="danger" size="small" round @click="doInOutMoney('0')">{{ $t('mine.cashin') }}</Button>
  64. <Button size="small" round @click="doInOutMoney('1')">{{ $t('mine.cashout') }}</Button>
  65. </div>
  66. </div>
  67. </div>
  68. <app-block class="mine-iconbar">
  69. <ul>
  70. <li @click="routerTo('order-position')">
  71. <Iconfont label-direction="bottom" icon="g-icon-position--line">{{ $t('mine.myposition') }}</Iconfont>
  72. </li>
  73. <li @click="routerTo('order-list')">
  74. <Iconfont label-direction="bottom" icon="g-icon-order--line">{{ $t('mine.myorder') }}</Iconfont>
  75. </li>
  76. </ul>
  77. </app-block>
  78. <app-block class="g-navmenu">
  79. <CellGroup>
  80. <Cell is-link :to="{ name: 'bank-capital' }">
  81. <template #title>
  82. <Iconfont icon="g-icon-capital">{{ $t('mine.fundsinfo') }}</Iconfont>
  83. </template>
  84. </Cell>
  85. <Cell is-link :to="{ name: 'account-authresult' }" v-if="authStatus === AuthStatus.Submitted">
  86. <template #title>
  87. <Iconfont icon="g-icon-certification">{{ $t('mine.authentication') }}</Iconfont>
  88. </template>
  89. </Cell>
  90. <Cell is-link :to="{ name: 'account-certification' }" v-else-if="authStatus !== AuthStatus.Certified">
  91. <template #title>
  92. <Iconfont icon="g-icon-certification">{{ $t('mine.authentication') }}</Iconfont>
  93. </template>
  94. </Cell>
  95. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified && hasSignContract">
  96. <template #title>
  97. <Iconfont icon="g-icon-sign">{{ $t('mine.banksign') }}</Iconfont>
  98. </template>
  99. </Cell>
  100. <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId() } }"
  101. v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
  102. <template #title>
  103. <Iconfont icon="g-icon-order--line">{{ $t('mine.protocol') }}</Iconfont>
  104. </template>
  105. </Cell>
  106. <Cell is-link :to="{ name: 'mine-profile' }">
  107. <template #title>
  108. <Iconfont icon="g-icon-profile">{{ $t('mine.personalinformation') }}</Iconfont>
  109. </template>
  110. </Cell>
  111. <Cell is-link :to="{ name: 'rules-zcxy' }">
  112. <template #title>
  113. <Iconfont icon="g-icon-zcxy">{{ $t('rules.zcxy') }}</Iconfont>
  114. </template>
  115. </Cell>
  116. <Cell is-link :to="{ name: 'rules-yszc' }">
  117. <template #title>
  118. <Iconfont icon="g-icon-yszc">{{ $t('rules.yszc') }}</Iconfont>
  119. </template>
  120. </Cell>
  121. <Cell is-link :to="{ name: 'rules-fwrx' }">
  122. <template #title>
  123. <Iconfont icon="g-icon-fwrx">{{ $t('rules.fwrx') }}</Iconfont>
  124. </template>
  125. </Cell>
  126. <Cell is-link :to="{ name: 'mine-setting' }">
  127. <template #title>
  128. <Iconfont icon="g-icon-setting">{{ $t('mine.settings') }}</Iconfont>
  129. </template>
  130. </Cell>
  131. <Cell is-link :to="{ name: 'rules-gywm' }">
  132. <template #title>
  133. <Iconfont icon="g-icon-gywm">{{ $t('mine.aboutus') }}</Iconfont>
  134. </template>
  135. </Cell>
  136. </CellGroup>
  137. </app-block>
  138. <div class="mine-footer">
  139. <Button class="button-logout" type="danger" size="small" round @click="userLogout">{{ $t('common.logout') }}</Button>
  140. </div>
  141. </app-view>
  142. </template>
  143. <script lang="ts" setup>
  144. import { shallowRef, onActivated, computed } from 'vue'
  145. import { Cell, CellGroup, Button, Icon } from 'vant'
  146. import { fullloading, dialog } from '@/utils/vant'
  147. import { parsePercent } from '@/filters'
  148. import { useNavigation } from '@mobile/router/navigation'
  149. import { AuthStatus } from '@/constants/account'
  150. import { queryBankAccountSign } from '@/services/api/bank'
  151. import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
  152. import { getMemberUserId } from '@/services/methods/user'
  153. import { queryUsereSignRecords } from '@/services/api/account'
  154. import eventBus from '@/services/bus'
  155. import Iconfont from '@/components/base/iconfont/index.vue'
  156. const { router, routerTo } = useNavigation()
  157. const loginStore = useLoginStore()
  158. const userStore = useUserStore()
  159. const accountStore = useAccountStore()
  160. const { currentAccount } = accountStore.$toRefs()
  161. const headerRef = shallowRef<HTMLDivElement>()
  162. /// 判断是否能签约
  163. const hasSignContract = shallowRef(false)
  164. // 实名认证状态
  165. const authStatus = computed(() => userStore.userAccount.hasauth)
  166. const onReady = (el: HTMLDivElement) => {
  167. // 设置背景图位置
  168. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  169. }
  170. /// 进行出入金操作判断
  171. const doInOutMoney = (tab: string) => {
  172. if (authStatus.value === AuthStatus.Certified) {
  173. // 判断是否已签约
  174. fullloading((hideLoading) => {
  175. queryBankAccountSign().then((res) => {
  176. hideLoading()
  177. const { signstatus } = res.data[0] ?? {}
  178. /// 判断当前有签约
  179. if (signstatus && signstatus === 4) {
  180. /// 已实名未签合同
  181. if (!hasSignContract.value) {
  182. dialog({
  183. message: '根据平台规定,请先通过《入市协议》签署协议,谢谢!',
  184. showCancelButton: true,
  185. cancelButtonText: '暂不签署',
  186. confirmButtonText: '立即签署'
  187. })
  188. .then(() => {
  189. router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId()} })
  190. })
  191. .catch(() => {
  192. router.push({ name: 'bank-wallet', query: { tab } })
  193. })
  194. } else {
  195. router.push({ name: 'bank-wallet', query: { tab } })
  196. }
  197. } else {
  198. /// 未签约
  199. if (!hasSignContract.value) {
  200. dialog({
  201. message: '根据平台规定,请先通过《入市协议》签署协议,谢谢!',
  202. showCancelButton: true,
  203. cancelButtonText: '关闭',
  204. confirmButtonText: '立即签署'
  205. }).then(() => {
  206. router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId()} })
  207. })
  208. } else {
  209. dialog({
  210. message: '根据平台规定,请先通过《银行签约》签约银行,谢谢!',
  211. showCancelButton: true,
  212. cancelButtonText: '关闭',
  213. confirmButtonText: '立即签约'
  214. }).then(() => {
  215. router.push({ name: 'bank-sign' })
  216. })
  217. }
  218. }
  219. }).catch(() => {
  220. hideLoading('加载失败', 'fail')
  221. })
  222. }, '正在加载...')
  223. } else {
  224. dialog({
  225. message: '请先实名认证,再进行该操作!',
  226. showCancelButton: true,
  227. confirmButtonText: '去实名'
  228. }).then(() => {
  229. router.push({ name: 'account-certification' })
  230. })
  231. }
  232. }
  233. const userLogout = () => {
  234. dialog({
  235. message: '是否退出当前账号?',
  236. showCancelButton: true
  237. }).then(() => {
  238. loginStore.clearAutoLoginData()
  239. eventBus.$emit('LogoutNotify')
  240. })
  241. }
  242. onActivated(() => {
  243. if (authStatus.value !== AuthStatus.Certified) {
  244. userStore.getUserData()
  245. }
  246. accountStore.getAccountList()
  247. /// 机构不需要签合同
  248. if (userStore.userInfo.usertype === 2) {
  249. hasSignContract.value = true
  250. return
  251. }
  252. /// 查询数据
  253. queryUsereSignRecords({
  254. data: {
  255. userId: loginStore.userId,
  256. memberUserId: getMemberUserId(),
  257. templatetype: 2
  258. }
  259. }).then((res) => {
  260. /// 判断是否能签约
  261. hasSignContract.value = !res.data.some(e => e.recordstatus != 3)
  262. })
  263. })
  264. </script>
  265. <style lang="less">
  266. @import './index.less';
  267. </style>