Index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. <div class="bank-item">
  30. <span>余额</span>
  31. <span>{{ currentAccount.currentbalance?.toFixed(2) ?? '0.00' }}</span>
  32. </div>
  33. <div class="bank-item">
  34. <span>预扣</span>
  35. <span>{{ currentAccount.freezeMargin?.toFixed(2) }}</span>
  36. </div>
  37. <div class="bank-item">
  38. <span>可用</span>
  39. <span>{{ currentAccount.avaiableMoney?.toFixed(2) }}</span>
  40. </div>
  41. </div>
  42. <div class="button">
  43. <Button type="danger" size="small" round @click="doInOutMoney('0')">入金</Button>
  44. <Button size="small" round @click="doInOutMoney('1')">出金</Button>
  45. </div>
  46. </div>
  47. </div>
  48. <app-block class="mine-iconbar">
  49. <ul>
  50. <li @click="routerTo('order-position')">
  51. <Iconfont label-direction="bottom" icon="g-icon-position--line">我的持仓</Iconfont>
  52. </li>
  53. <li @click="routerTo('order-list')">
  54. <Iconfont label-direction="bottom" icon="g-icon-order--line">我的订单</Iconfont>
  55. </li>
  56. <li @click="routerTo('order-performance')">
  57. <Iconfont label-direction="bottom" icon="g-icon-performance--line">履约信息</Iconfont>
  58. </li>
  59. <li @click="routerTo('order-delivery')">
  60. <Iconfont label-direction="bottom" icon="g-icon-delivery--line">交货提货</Iconfont>
  61. </li>
  62. </ul>
  63. </app-block>
  64. <app-block class="g-navmenu">
  65. <CellGroup>
  66. <Cell is-link :to="{ name: 'bank-capital' }">
  67. <template #title>
  68. <Iconfont icon="g-icon-capital">资金信息</Iconfont>
  69. </template>
  70. </Cell>
  71. <Cell is-link :to="{ name: 'account-certification' }" v-if="authStatus !== AuthStatus.Certified">
  72. <template #title>
  73. <Iconfont icon="g-icon-certification">实名认证</Iconfont>
  74. </template>
  75. </Cell>
  76. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified && canBankSign">
  77. <template #title>
  78. <Iconfont icon="g-icon-sign">签约账户</Iconfont>
  79. </template>
  80. </Cell>
  81. <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId()} }" v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
  82. <template #title>
  83. <Iconfont icon="g-icon-order--line">合同签署</Iconfont>
  84. </template>
  85. </Cell>
  86. <Cell is-link :to="{ name: 'mine-profile' }">
  87. <template #title>
  88. <Iconfont icon="g-icon-profile">个人信息</Iconfont>
  89. </template>
  90. </Cell>
  91. <Cell is-link :to="{ name: 'rules-zcxy' }">
  92. <template #title>
  93. <Iconfont icon="g-icon-zcxy">用户注册协议</Iconfont>
  94. </template>
  95. </Cell>
  96. <Cell is-link :to="{ name: 'rules-yszc' }">
  97. <template #title>
  98. <Iconfont icon="g-icon-yszc">关于隐私</Iconfont>
  99. </template>
  100. </Cell>
  101. <Cell is-link :to="{ name: 'rules-fwrx' }">
  102. <template #title>
  103. <Iconfont icon="g-icon-fwrx">服务热线</Iconfont>
  104. </template>
  105. </Cell>
  106. <Cell is-link :to="{ name: 'mine-setting' }">
  107. <template #title>
  108. <Iconfont icon="g-icon-setting">设置</Iconfont>
  109. </template>
  110. </Cell>
  111. <Cell is-link :to="{ name: 'rules-gywm' }">
  112. <template #title>
  113. <Iconfont icon="g-icon-gywm">关于我们</Iconfont>
  114. </template>
  115. </Cell>
  116. </CellGroup>
  117. </app-block>
  118. <div class="mine-footer">
  119. <Button class="button-logout" type="danger" size="small" round @click="userLogout">退出登录</Button>
  120. </div>
  121. </app-view>
  122. </template>
  123. <script lang="ts" setup>
  124. import { shallowRef, onMounted, onActivated, computed } from 'vue'
  125. import { Cell, CellGroup, Button, Icon } from 'vant'
  126. import { fullloading, dialog } from '@/utils/vant'
  127. import { useNavigation } from '@mobile/router/navigation'
  128. import { AuthStatus } from '@/constants/account'
  129. import { queryBankAccountSign } from '@/services/api/bank'
  130. import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
  131. import eventBus from '@/services/bus'
  132. import Iconfont from '@/components/base/iconfont/index.vue'
  133. import { getMemberUserId } from '@/services/methods/user'
  134. import { queryMdUserSwapProtocol } from '@/services/api/swap'
  135. import { getUserId } from '@/services/methods/user'
  136. import { useRequest } from '@/hooks/request'
  137. const { router, routerTo } = useNavigation()
  138. const loginStore = useLoginStore()
  139. const userStore = useUserStore()
  140. const positionStore = usePositionStore()
  141. const accountStore = useAccountStore()
  142. const { currentAccount } = accountStore.$toRefs()
  143. const headerRef = shallowRef<HTMLDivElement>()
  144. const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
  145. /// 查询用户掉期协议签署表
  146. const { dataList: protocolList} = useRequest(queryMdUserSwapProtocol, {
  147. params: {
  148. userId: getUserId()
  149. }
  150. })
  151. /// 判断是否能签约
  152. const canBankSign = computed(() => {
  153. return protocolList.value.some(e => { return e.protocolstatus === 4 })
  154. })
  155. const onReady = (el: HTMLDivElement) => {
  156. // 设置背景图位置
  157. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  158. }
  159. /// 进行出入金操作判断
  160. const doInOutMoney = (tab: string) => {
  161. if (authStatus.value === AuthStatus.Certified) {
  162. /// 当前未签署合同
  163. if (!canBankSign.value) {
  164. dialog({
  165. message: '请先去签署合同条例!',
  166. showCancelButton: true,
  167. confirmButtonText: '去签署合同'
  168. }).then(() => {
  169. router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId()} })
  170. })
  171. return
  172. }
  173. fullloading((hideLoading) => {
  174. queryBankAccountSign().then((res) => {
  175. hideLoading()
  176. const { signstatus } = res.data[0] ?? {}
  177. /// 只有已签约的情况下才可以进行出入金
  178. if (signstatus && signstatus === 4) {
  179. router.push({ name: 'bank-wallet', query: { tab } })
  180. } else {
  181. dialog({
  182. message: '请先添加签约账户信息!',
  183. showCancelButton: true,
  184. confirmButtonText: '去签约'
  185. }).then(() => {
  186. router.push({ name: 'bank-sign' })
  187. })
  188. }
  189. }).catch(() => {
  190. hideLoading('加载失败', 'fail')
  191. })
  192. }, '正在加载...')
  193. } else {
  194. dialog({
  195. message: '请先实名认证,再进行该操作!',
  196. showCancelButton: true,
  197. confirmButtonText: '去实名'
  198. }).then(() => {
  199. router.push({ name: 'account-certification' })
  200. })
  201. }
  202. }
  203. const userLogout = () => {
  204. dialog({
  205. message: '是否退出当前账号?',
  206. showCancelButton: true
  207. }).then(() => {
  208. loginStore.clearAutoLoginData()
  209. eventBus.$emit('LogoutNotify')
  210. })
  211. }
  212. onActivated(() => {
  213. if (authStatus.value !== AuthStatus.Certified) {
  214. userStore.getUserData()
  215. }
  216. accountStore.getAccountList()
  217. })
  218. onMounted(() => {
  219. // 请求持仓列表,待优化---可用资金计算可能需要订阅行情
  220. positionStore.getTradePosition()
  221. })
  222. </script>
  223. <style lang="less">
  224. @import './index.less';
  225. </style>