Index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. <div class="profile-account-first">
  25. <span>{{ $t('account.account') }}</span>
  26. <Icon name="checked" size="14" color="#CC0000" ></Icon>
  27. </div>
  28. <span>{{ currentAccount.accountid ?? 0 }}</span>
  29. </div>
  30. </div>
  31. <div class="bank">
  32. <ul>
  33. <li>
  34. <span>{{ $t('mine.balance') }}</span>
  35. <span>{{ currentAccount.currentbalance?.toFixed(2) }}</span>
  36. </li>
  37. <li>
  38. <span>{{ $t('mine.netWorth') }}</span>
  39. <span>{{ currentAccount.hazardValue?.toFixed(2) }}</span>
  40. </li>
  41. </ul>
  42. <ul>
  43. <li>
  44. <span>{{ $t('mine.freezeMargin') }}</span>
  45. <span>{{ currentAccount.freezeMargin?.toFixed(2) }}</span>
  46. </li>
  47. <li>
  48. <span>{{ $t('mine.usedMargin') }}</span>
  49. <span>{{ currentAccount.usedmargin?.toFixed(2) }}</span>
  50. </li>
  51. </ul>
  52. <ul>
  53. <li>
  54. <span>{{ $t('mine.availableFunds') }}</span>
  55. <span>{{ currentAccount.avaiableMoney?.toFixed(2) }}</span>
  56. </li>
  57. <li>
  58. <span>{{ $t('mine.riskRate') }}</span>
  59. <span :class="currentAccount.hazardRatioColor">
  60. {{ parsePercent(currentAccount.hazardRatio) }}
  61. </span>
  62. </li>
  63. </ul>
  64. </div>
  65. <div class="button">
  66. <Button type="danger" size="small" round @click="doInOutMoney('0')">{{ $t('mine.cashin') }}</Button>
  67. <Button size="small" round @click="doInOutMoney('1')">{{ $t('mine.cashout') }}</Button>
  68. </div>
  69. </div>
  70. </div>
  71. <app-block class="mine-iconbar">
  72. <ul>
  73. <li @click="routerTo('order-position')">
  74. <Iconfont label-direction="bottom" icon="g-icon-position--line">{{ $t('mine.myposition') }}</Iconfont>
  75. </li>
  76. <li @click="routerTo('order-list')">
  77. <Iconfont label-direction="bottom" icon="g-icon-order--line">{{ $t('mine.myorder') }}</Iconfont>
  78. </li>
  79. <li @click="routerTo('order-delivery')">
  80. <Iconfont label-direction="bottom" icon="g-icon-delivery--line">{{ $t('mine.delivery') }}</Iconfont>
  81. </li>
  82. </ul>
  83. </app-block>
  84. <app-block class="g-navmenu">
  85. <CellGroup>
  86. <Cell is-link :to="{ name: 'bank-capital' }">
  87. <template #title>
  88. <Iconfont icon="g-icon-capital">{{ $t('mine.fundsinfo') }}</Iconfont>
  89. </template>
  90. </Cell>
  91. <Cell is-link :to="{ name: 'account-authresult' }" v-if="authStatus === AuthStatus.Submitted">
  92. <template #title>
  93. <Iconfont icon="g-icon-certification">{{ $t('mine.authentication') }}</Iconfont>
  94. </template>
  95. </Cell>
  96. <Cell is-link :to="{ name: 'account-certification' }" v-else-if="authStatus !== AuthStatus.Certified">
  97. <template #title>
  98. <Iconfont icon="g-icon-certification">{{ $t('mine.authentication') }}</Iconfont>
  99. </template>
  100. </Cell>
  101. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified">
  102. <template #title>
  103. <Iconfont icon="g-icon-sign">{{ $t('mine.banksign') }}</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 eventBus from '@/services/bus'
  153. import Iconfont from '@/components/base/iconfont/index.vue'
  154. import { i18n } from '@/stores'
  155. const { global: { t } } = i18n
  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. const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
  163. const onReady = (el: HTMLDivElement) => {
  164. // 设置背景图位置
  165. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  166. }
  167. /// 进行出入金操作判断
  168. const doInOutMoney = (tab: string) => {
  169. if (authStatus.value === AuthStatus.Certified) {
  170. fullloading((hideLoading) => {
  171. queryBankAccountSign().then((res) => {
  172. hideLoading()
  173. const { signstatus } = res.data[0] ?? {}
  174. /// 只有已签约的情况下才可以进行出入金
  175. if (signstatus && signstatus === 4) {
  176. router.push({ name: 'bank-wallet', query: { tab } })
  177. } else {
  178. dialog({
  179. message: t('banksign.tips1'),
  180. showCancelButton: true,
  181. cancelButtonText: t('operation.cancel'),
  182. confirmButtonText: t('banksign.tips2')
  183. }).then(() => {
  184. router.push({ name: 'bank-sign' })
  185. })
  186. }
  187. }).catch(() => {
  188. hideLoading(t('common.loadingfailed'), 'fail')
  189. })
  190. }, t('common.loading'))
  191. } else {
  192. dialog({
  193. message: t('banksign.tips3'),
  194. showCancelButton: true,
  195. cancelButtonText: t('operation.cancel'),
  196. confirmButtonText: t('banksign.tips4')
  197. }).then(() => {
  198. router.push({ name: 'account-certification' })
  199. })
  200. }
  201. }
  202. const userLogout = () => {
  203. dialog({
  204. message: t('banksign.tips5'),
  205. cancelButtonText: t('operation.cancel'),
  206. confirmButtonText: t('operation.confirm'),
  207. showCancelButton: true
  208. }).then(() => {
  209. loginStore.clearAutoLoginData()
  210. eventBus.$emit('LogoutNotify')
  211. })
  212. }
  213. onActivated(() => {
  214. if (authStatus.value !== AuthStatus.Certified) {
  215. userStore.getUserData()
  216. }
  217. accountStore.getAccountList()
  218. })
  219. </script>
  220. <style lang="less">
  221. @import './index.less';
  222. </style>