Index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <app-view class="mine">
  3. <template #header>
  4. <app-navbar 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>正常</span>
  25. <span>{{ currentAccount.accountid ?? 0 }}</span>
  26. </div>
  27. </div>
  28. <div class="bank">
  29. <ul>
  30. <li>
  31. <span>余额</span>
  32. <span>{{ currentAccount.currentbalance?.toFixed(2) }}</span>
  33. </li>
  34. <li>
  35. <span>净值</span>
  36. <span>{{ currentAccount.hazardValue?.toFixed(2) }}</span>
  37. </li>
  38. </ul>
  39. <ul>
  40. <li>
  41. <span>预扣</span>
  42. <span>{{ currentAccount.freezeMargin?.toFixed(2) }}</span>
  43. </li>
  44. <li>
  45. <span>占用</span>
  46. <span>{{ currentAccount.usedmargin?.toFixed(2) }}</span>
  47. </li>
  48. </ul>
  49. <ul>
  50. <li>
  51. <span>可用</span>
  52. <span>{{ currentAccount.avaiableBalance?.toFixed(2) }}</span>
  53. </li>
  54. <li>
  55. <span>风险率</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')">入金</Button>
  64. <Button size="small" round @click="doInOutMoney('1')">出金</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">我的持仓</Iconfont>
  72. </li>
  73. <li @click="routerTo('order-list')">
  74. <Iconfont label-direction="bottom" icon="g-icon-order--line">我的订单</Iconfont>
  75. </li>
  76. <li @click="routerTo('order-delivery')">
  77. <Iconfont label-direction="bottom" icon="g-icon-delivery--line">交货提货</Iconfont>
  78. </li>
  79. <li @click="routerTo('order-performance')">
  80. <Iconfont label-direction="bottom" icon="g-icon-performance--line">履约信息</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">资金信息</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">实名认证</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">实名认证</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">签约账户</Iconfont>
  104. </template>
  105. </Cell>
  106. <Cell is-link :to="{ name: 'mine-profile' }">
  107. <template #title>
  108. <Iconfont icon="g-icon-profile">个人信息</Iconfont>
  109. </template>
  110. </Cell>
  111. <Cell is-link :to="{ name: 'rules-zcxy' }">
  112. <template #title>
  113. <Iconfont icon="g-icon-zcxy">用户注册协议</Iconfont>
  114. </template>
  115. </Cell>
  116. <Cell is-link :to="{ name: 'rules-yszc' }">
  117. <template #title>
  118. <Iconfont icon="g-icon-yszc">关于隐私</Iconfont>
  119. </template>
  120. </Cell>
  121. <Cell is-link :to="{ name: 'rules-fwrx' }">
  122. <template #title>
  123. <Iconfont icon="g-icon-fwrx">服务热线</Iconfont>
  124. </template>
  125. </Cell>
  126. <Cell is-link :to="{ name: 'mine-setting' }">
  127. <template #title>
  128. <Iconfont icon="g-icon-setting">设置</Iconfont>
  129. </template>
  130. </Cell>
  131. <Cell is-link :to="{ name: 'rules-gywm' }">
  132. <template #title>
  133. <Iconfont icon="g-icon-gywm">关于我们</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">退出登录</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. const { router, routerTo } = useNavigation()
  155. const loginStore = useLoginStore()
  156. const userStore = useUserStore()
  157. const accountStore = useAccountStore()
  158. const { currentAccount } = accountStore.$toRefs()
  159. const headerRef = shallowRef<HTMLDivElement>()
  160. const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
  161. const onReady = (el: HTMLDivElement) => {
  162. // 设置背景图位置
  163. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  164. }
  165. /// 进行出入金操作判断
  166. const doInOutMoney = (tab: string) => {
  167. if (authStatus.value === AuthStatus.Certified) {
  168. fullloading((hideLoading) => {
  169. queryBankAccountSign().then((res) => {
  170. hideLoading()
  171. const { signstatus } = res.data[0] ?? {}
  172. /// 只有已签约的情况下才可以进行出入金
  173. if (signstatus && signstatus === 4) {
  174. router.push({ name: 'bank-wallet', query: { tab } })
  175. } else {
  176. dialog({
  177. message: '请先添加签约账户信息!',
  178. showCancelButton: true,
  179. confirmButtonText: '去签约'
  180. }).then(() => {
  181. router.push({ name: 'bank-sign' })
  182. })
  183. }
  184. }).catch(() => {
  185. hideLoading('加载失败', 'fail')
  186. })
  187. }, '正在加载...')
  188. } else {
  189. dialog({
  190. message: '请先实名认证,再进行该操作!',
  191. showCancelButton: true,
  192. confirmButtonText: '去实名'
  193. }).then(() => {
  194. router.push({ name: 'account-certification' })
  195. })
  196. }
  197. }
  198. const userLogout = () => {
  199. dialog({
  200. message: '是否退出当前账号?',
  201. showCancelButton: true
  202. }).then(() => {
  203. loginStore.clearAutoLoginData()
  204. eventBus.$emit('LogoutNotify')
  205. })
  206. }
  207. onActivated(() => {
  208. if (authStatus.value !== AuthStatus.Certified) {
  209. userStore.getUserData()
  210. }
  211. accountStore.getAccountList()
  212. })
  213. </script>
  214. <style lang="less">
  215. @import './index.less';
  216. </style>