Index.vue 11 KB

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