Index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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.avaiableMoney?.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-inout')">
  74. <Iconfont label-direction="bottom" icon="g-icon-inout--line">持仓过户</Iconfont>
  75. </li>
  76. <li @click="routerTo('order-list')">
  77. <Iconfont label-direction="bottom" icon="g-icon-order--line">我的订单</Iconfont>
  78. </li>
  79. <li @click="routerTo('order-delivery')">
  80. <Iconfont label-direction="bottom" icon="g-icon-delivery--line">交货提货</Iconfont>
  81. </li>
  82. <li @click="routerTo('order-performance')">
  83. <Iconfont label-direction="bottom" icon="g-icon-performance--line">履约信息</Iconfont>
  84. </li>
  85. </ul>
  86. </app-block>
  87. <app-block class="g-navmenu">
  88. <CellGroup>
  89. <Cell is-link :to="{ name: 'bank-capital' }">
  90. <template #title>
  91. <Iconfont icon="g-icon-capital">资金信息</Iconfont>
  92. </template>
  93. </Cell>
  94. <Cell is-link :to="{ name: 'account-certification' }" v-if="authStatus !== AuthStatus.Certified">
  95. <template #title>
  96. <Iconfont icon="g-icon-certification">实名认证</Iconfont>
  97. </template>
  98. </Cell>
  99. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified && canBankSign">
  100. <template #title>
  101. <Iconfont icon="g-icon-sign">签约账户</Iconfont>
  102. </template>
  103. </Cell>
  104. <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId()} }" v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
  105. <template #title>
  106. <Iconfont icon="g-icon-order--line">合同签署</Iconfont>
  107. </template>
  108. </Cell>
  109. <Cell is-link :to="{ name: 'mine-profile' }">
  110. <template #title>
  111. <Iconfont icon="g-icon-profile">个人信息</Iconfont>
  112. </template>
  113. </Cell>
  114. <Cell is-link :to="{ name: 'rules-zcxy' }">
  115. <template #title>
  116. <Iconfont icon="g-icon-zcxy">用户注册协议</Iconfont>
  117. </template>
  118. </Cell>
  119. <Cell is-link :to="{ name: 'rules-yszc' }">
  120. <template #title>
  121. <Iconfont icon="g-icon-yszc">关于隐私</Iconfont>
  122. </template>
  123. </Cell>
  124. <Cell is-link :to="{ name: 'rules-fwrx' }">
  125. <template #title>
  126. <Iconfont icon="g-icon-fwrx">服务热线</Iconfont>
  127. </template>
  128. </Cell>
  129. <Cell is-link :to="{ name: 'mine-setting' }">
  130. <template #title>
  131. <Iconfont icon="g-icon-setting">设置</Iconfont>
  132. </template>
  133. </Cell>
  134. <Cell is-link :to="{ name: 'rules-gywm' }">
  135. <template #title>
  136. <Iconfont icon="g-icon-gywm">关于我们</Iconfont>
  137. </template>
  138. </Cell>
  139. </CellGroup>
  140. </app-block>
  141. <div class="mine-footer">
  142. <Button class="button-logout" type="danger" size="small" round @click="userLogout">退出登录</Button>
  143. </div>
  144. </app-view>
  145. </template>
  146. <script lang="ts" setup>
  147. import { shallowRef, onMounted, onActivated, computed } from 'vue'
  148. import { Cell, CellGroup, Button, Icon } from 'vant'
  149. import { parsePercent } from '@/filters'
  150. import { fullloading, dialog } from '@/utils/vant'
  151. import { useNavigation } from '@mobile/router/navigation'
  152. import { AuthStatus } from '@/constants/account'
  153. import { queryBankAccountSign } from '@/services/api/bank'
  154. import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
  155. import eventBus from '@/services/bus'
  156. import Iconfont from '@/components/base/iconfont/index.vue'
  157. import { getMemberUserId } from '@/services/methods/user'
  158. import { queryUsereSignRecords } from '@/services/api/account'
  159. const { router, routerTo } = useNavigation()
  160. const loginStore = useLoginStore()
  161. const userStore = useUserStore()
  162. const positionStore = usePositionStore()
  163. const accountStore = useAccountStore()
  164. const { currentAccount } = accountStore.$toRefs()
  165. /// 判断是否能签约
  166. const canBankSign = shallowRef(false)
  167. const headerRef = shallowRef<HTMLDivElement>()
  168. const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
  169. const onReady = (el: HTMLDivElement) => {
  170. // 设置背景图位置
  171. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  172. }
  173. /// 进行出入金操作判断
  174. const doInOutMoney = (tab: string) => {
  175. if (authStatus.value === AuthStatus.Certified) {
  176. // /// 当前未签署合同
  177. // if (!canBankSign.value) {
  178. // dialog({
  179. // message: '请先去签署合同条例!',
  180. // showCancelButton: true,
  181. // confirmButtonText: '去签署合同'
  182. // }).then(() => {
  183. // router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId()} })
  184. // })
  185. // return
  186. // }
  187. // 判断是否已签约
  188. fullloading((hideLoading) => {
  189. queryBankAccountSign().then((res) => {
  190. hideLoading()
  191. const { signstatus } = res.data[0] ?? {}
  192. /// 只有已签约的情况下才可以进行出入金
  193. if (signstatus && signstatus === 4) {
  194. router.push({ name: 'bank-wallet', query: { tab } })
  195. } else {
  196. dialog({
  197. message: '请先添加签约账户信息!',
  198. showCancelButton: true,
  199. confirmButtonText: '去签约'
  200. }).then(() => {
  201. router.push({ name: 'bank-sign' })
  202. })
  203. }
  204. }).catch(() => {
  205. hideLoading('加载失败', 'fail')
  206. })
  207. }, '正在加载...')
  208. } else {
  209. dialog({
  210. message: '请先实名认证,再进行该操作!',
  211. showCancelButton: true,
  212. confirmButtonText: '去实名'
  213. }).then(() => {
  214. router.push({ name: 'account-certification' })
  215. })
  216. }
  217. }
  218. const userLogout = () => {
  219. dialog({
  220. message: '是否退出当前账号?',
  221. showCancelButton: true
  222. }).then(() => {
  223. loginStore.clearAutoLoginData()
  224. eventBus.$emit('LogoutNotify')
  225. })
  226. }
  227. onActivated(() => {
  228. if (authStatus.value !== AuthStatus.Certified) {
  229. userStore.getUserData()
  230. }
  231. accountStore.getAccountList()
  232. /// 机构不需要签合同
  233. if (userStore.userInfo.usertype === 2) {
  234. canBankSign.value = true
  235. return
  236. }
  237. /// 查询数据
  238. queryUsereSignRecords({
  239. data: {
  240. userId: loginStore.userId
  241. }
  242. }).then((res) => {
  243. /// 判断是否能签约
  244. canBankSign.value = res.data.some(e => e.recordstatus === 3 )
  245. })
  246. })
  247. onMounted(() => {
  248. // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
  249. positionStore.getTradePosition()
  250. })
  251. </script>
  252. <style lang="less">
  253. @import './index.less';
  254. </style>