Index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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.accountName }}</span>
  16. <Icon name="checked" color="var(--van-tag-success-color)" v-if="authStatus" />
  17. <Icon name="warning" color="var(--van-tag-warning-color)" v-else />
  18. </div>
  19. <div class="bottom">{{ loginStore.loginId }}</div>
  20. </div>
  21. </div>
  22. <div class="profile-account">
  23. <span>正常</span>
  24. <span>{{ currentAccount.accountid ?? 0 }}</span>
  25. </div>
  26. </div>
  27. <div class="bank">
  28. <div class="bank-item">
  29. <span>余额</span>
  30. <span>{{ currentAccount.currentbalance?.toFixed(2) ?? '0.00' }}</span>
  31. </div>
  32. <div class="bank-item">
  33. <span>冻结</span>
  34. <span>{{ currentAccount.freezeMargin?.toFixed(2) }}</span>
  35. </div>
  36. <div class="bank-item">
  37. <span>可用</span>
  38. <span>{{ currentAccount.avaiableMoney?.toFixed(2) }}</span>
  39. </div>
  40. <div class="bank-item">
  41. <span>
  42. <a @click="routerTo('bank-statement')">资金流水</a>
  43. </span>
  44. <span></span>
  45. </div>
  46. </div>
  47. <div class="button">
  48. <Button size="small" round @click="doInOutMoney('1')">提现</Button>
  49. <Button type="danger" size="small" round @click="doInOutMoney('0')">充值</Button>
  50. </div>
  51. </div>
  52. </div>
  53. <app-block class="mine-iconbar">
  54. <ul>
  55. <li @click="routerTo('order-position')">
  56. <Iconfont label-direction="bottom" icon="icon-a-zu746">我的持仓</Iconfont>
  57. </li>
  58. <li @click="routerTo('order-list')">
  59. <Iconfont label-direction="bottom" icon="icon-a-zu771defuben">我的订单</Iconfont>
  60. </li>
  61. <li @click="routerTo('order-delivery')">
  62. <Iconfont label-direction="bottom" icon="icon-a-zu803">交货提货</Iconfont>
  63. </li>
  64. <li @click="routerTo('order-performance')">
  65. <Iconfont label-direction="bottom" icon="icon-a-zu802">履约信息</Iconfont>
  66. </li>
  67. </ul>
  68. </app-block>
  69. <app-block class="g-navmenu">
  70. <CellGroup>
  71. <Cell is-link :to="{ name: 'account-certification' }"
  72. v-if="[AuthStatus.Uncertified, AuthStatus.Rejected].includes(authStatus)">
  73. <template #title>
  74. <Iconfont icon="icon-shimingrenzheng">实名认证</Iconfont>
  75. </template>
  76. </Cell>
  77. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified">
  78. <template #title>
  79. <Iconfont icon="icon-qianyuezhanghu">签约账户</Iconfont>
  80. </template>
  81. </Cell>
  82. <Cell is-link :to="{ name: 'mine-profile' }">
  83. <template #title>
  84. <Iconfont icon="icon-fapiaoshuoming">个人信息</Iconfont>
  85. </template>
  86. </Cell>
  87. <Cell is-link :to="{ name: 'rules-zcxy' }">
  88. <template #title>
  89. <Iconfont icon="icon-yonghuzhucexieyi">用户注册协议</Iconfont>
  90. </template>
  91. </Cell>
  92. <Cell is-link :to="{ name: 'rules-yszc' }">
  93. <template #title>
  94. <Iconfont icon="icon-guanyuzhengce">关于隐私</Iconfont>
  95. </template>
  96. </Cell>
  97. <Cell is-link :to="{ name: 'rules-fwrx' }">
  98. <template #title>
  99. <Iconfont icon="icon-kefurexian">服务热线</Iconfont>
  100. </template>
  101. </Cell>
  102. <Cell is-link :to="{ name: 'mine-setting' }">
  103. <template #title>
  104. <Iconfont icon="icon-shezhi">设置</Iconfont>
  105. </template>
  106. </Cell>
  107. <Cell is-link :to="{ name: 'rules-gywm' }">
  108. <template #title>
  109. <Iconfont icon="icon-guanyuwomen">关于我们</Iconfont>
  110. </template>
  111. </Cell>
  112. </CellGroup>
  113. </app-block>
  114. <div class="mine-footer">
  115. <Button class="button-logout" type="danger" size="small" round @click="userLogout">退出登录</Button>
  116. </div>
  117. </app-view>
  118. </template>
  119. <script lang="ts" setup>
  120. import { shallowRef, onActivated } from 'vue'
  121. import { Cell, CellGroup, Button, Icon } from 'vant'
  122. import { fullloading, dialog } from '@/utils/vant'
  123. import { useNavigation } from '../../router/navigation'
  124. import { AuthStatus } from '@/constants/account'
  125. import { queryBankAccountSign } from '@/services/api/bank'
  126. import { queryUserAccount } from '@/services/api/account'
  127. import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
  128. import eventBus from '@/services/bus'
  129. import Iconfont from '../../components/base/iconfont/index.vue'
  130. const { router, routerTo } = useNavigation()
  131. const loginStore = useLoginStore()
  132. const userStore = useUserStore()
  133. const accountStore = useAccountStore()
  134. const { currentAccount } = accountStore.$toRefs()
  135. const headerRef = shallowRef<HTMLDivElement>()
  136. const authStatus = shallowRef(AuthStatus.Uncertified) // 实名认证状态
  137. const onReady = (el: HTMLDivElement) => {
  138. // 设置背景图位置
  139. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  140. }
  141. /// 进行出入金操作判断
  142. const doInOutMoney = (tab: string) => {
  143. if (authStatus.value === AuthStatus.Certified) {
  144. fullloading((hideLoading) => {
  145. queryBankAccountSign().then((res) => {
  146. hideLoading()
  147. const { signstatus } = res.data[0] ?? {}
  148. /// 只有已签约的情况下才可以进行出入金
  149. if (signstatus && signstatus === 4) {
  150. router.push({ name: 'bank-wallet', query: { tab } })
  151. } else {
  152. dialog({
  153. message: '请先添加签约账户信息!',
  154. showCancelButton: true,
  155. confirmButtonText: '去签约'
  156. }).then(() => {
  157. router.push({ name: 'bank-sign' })
  158. })
  159. }
  160. }).catch(() => {
  161. hideLoading('加载失败', 'fail')
  162. })
  163. }, '正在加载...')
  164. } else {
  165. dialog({
  166. message: '请先实名认证,再进行该操作!',
  167. showCancelButton: true,
  168. confirmButtonText: '去实名'
  169. }).then(() => {
  170. router.push({ name: 'account-certification' })
  171. })
  172. }
  173. }
  174. const userLogout = () => {
  175. dialog({
  176. message: '是否退出当前账号?',
  177. showCancelButton: true
  178. }).then(() => {
  179. loginStore.clearAutoLoginData()
  180. eventBus.$emit('LogoutNotify')
  181. })
  182. }
  183. onActivated(() => {
  184. console.log(authStatus.value)
  185. if (authStatus.value !== AuthStatus.Certified) {
  186. // 获取用户账号信息
  187. queryUserAccount().then((res) => {
  188. authStatus.value = res.data.hasauth
  189. })
  190. }
  191. })
  192. </script>
  193. <style lang="less">
  194. @import './index.less';
  195. </style>