index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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>
  24. <div class="bank">
  25. <ul>
  26. <li>
  27. <span>余额</span>
  28. <span>{{ currentAccount.currentbalance?.toFixed(2) }}</span>
  29. </li>
  30. <li>
  31. <span>占用定金</span>
  32. <span>{{ currentAccount.usedmargin?.toFixed(2) }}</span>
  33. </li>
  34. </ul>
  35. <ul>
  36. <li>
  37. <span>可用权益</span>
  38. <span>{{ currentAccount.avaiableMoney?.toFixed(2) }}</span>
  39. </li>
  40. <li>
  41. <span>浮动权益</span>
  42. <span :class="handlePriceColor(profitLoss)">
  43. {{ profitLoss.toFixed(2) }}
  44. </span>
  45. </li>
  46. </ul>
  47. <ul v-if="globalStore.getSystemInfo('riskType') === 2">
  48. <li>
  49. <span>净值</span>
  50. <span>{{ currentAccount.hazardValue?.toFixed(2) }}</span>
  51. </li>
  52. <li>
  53. <span>风险率</span>
  54. <span :class="currentAccount.hazardRatioColor">
  55. {{ parsePercent(currentAccount.hazardRatio) }}
  56. </span>
  57. </li>
  58. </ul>
  59. </div>
  60. <div class="button">
  61. <Button type="danger" size="small" round @click="doInOutMoney('0')">{{ $t('mine.cashin') }}</Button>
  62. <Button size="small" round @click="doInOutMoney('1')">{{ $t('mine.cashout') }}</Button>
  63. </div>
  64. </div>
  65. </div>
  66. <app-block class="mine-iconbar">
  67. <ul>
  68. <li @click="routerTo('order-list')">
  69. <Iconfont label-direction="bottom" icon="g-icon-order--line">持有订单</Iconfont>
  70. </li>
  71. <li @click="routerTo('close-list')">
  72. <Iconfont label-direction="bottom" icon="g-icon-order-close--line">终止订单</Iconfont>
  73. </li>
  74. <li @click="routerTo('delivery-list')">
  75. <Iconfont label-direction="bottom" icon="g-icon-delivery--line">{{ $t('enum.BuyOrSell.Sell') }}订单</Iconfont>
  76. </li>
  77. <li @click="routerTo('pickup-list')">
  78. <Iconfont label-direction="bottom" icon="g-icon-pickup--line">{{ $t('enum.BuyOrSell.Buy') }}订单</Iconfont>
  79. </li>
  80. <li @click="routerTo('inventory-list')" v-if="oem === 'sjgj'">
  81. <Iconfont label-direction="bottom" icon="g-icon-inventory">我的库存</Iconfont>
  82. </li>
  83. </ul>
  84. </app-block>
  85. <app-block class="g-navmenu">
  86. <CellGroup>
  87. <Cell is-link :to="{ name: 'account-authresult' }" v-if="authStatus === AuthStatus.Submitted">
  88. <template #title>
  89. <Iconfont icon="g-icon-certification">实名认证</Iconfont>
  90. </template>
  91. </Cell>
  92. <Cell is-link :to="{ name: 'account-certification' }" v-else-if="authStatus !== AuthStatus.Certified">
  93. <template #title>
  94. <Iconfont icon="g-icon-certification">实名认证</Iconfont>
  95. </template>
  96. </Cell>
  97. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified && canBankSign">
  98. <template #title>
  99. <Iconfont icon="g-icon-sign">签约账户</Iconfont>
  100. </template>
  101. </Cell>
  102. <Cell is-link :to="{ name: 'account-protocol' }"
  103. v-if="signRecords.length && userStore.userType != 2 && authStatus === AuthStatus.Certified">
  104. <template #title>
  105. <Iconfont icon="g-icon-order--line">合同签署</Iconfont>
  106. </template>
  107. </Cell>
  108. <Cell is-link :to="{ name: 'mine-profile' }">
  109. <template #title>
  110. <Iconfont icon="g-icon-profile">个人信息</Iconfont>
  111. </template>
  112. </Cell>
  113. <Cell is-link :to="{ name: 'rules-zcxy' }">
  114. <template #title>
  115. <Iconfont icon="g-icon-zcxy">用户注册协议</Iconfont>
  116. </template>
  117. </Cell>
  118. <Cell is-link :to="{ name: 'rules-yszc' }">
  119. <template #title>
  120. <Iconfont icon="g-icon-yszc">关于隐私</Iconfont>
  121. </template>
  122. </Cell>
  123. <!-- <Cell is-link :to="{ name: 'rules-fwrx' }">
  124. <template #title>
  125. <Iconfont icon="g-icon-fwrx">服务热线</Iconfont>
  126. </template>
  127. </Cell> -->
  128. <Cell is-link :to="{ name: 'notice-list' }">
  129. <template #title>
  130. <Iconfont icon="g-icon-caution">公告通知</Iconfont>
  131. <Badge :dot="noticeStore.unreadList.length > 0" />
  132. </template>
  133. </Cell>
  134. <Cell is-link :to="{ name: 'mine-setting' }">
  135. <template #title>
  136. <Iconfont icon="g-icon-setting">设置</Iconfont>
  137. </template>
  138. </Cell>
  139. <Cell is-link :to="{ name: 'rules-gywm' }">
  140. <template #title>
  141. <Iconfont icon="g-icon-gywm">关于我们</Iconfont>
  142. </template>
  143. </Cell>
  144. </CellGroup>
  145. </app-block>
  146. <div class="mine-footer">
  147. <Button class="button-logout" type="primary" size="small" round @click="userLogout">退出登录</Button>
  148. </div>
  149. </app-view>
  150. </template>
  151. <script lang="ts" setup>
  152. import { shallowRef, onActivated, computed } from 'vue'
  153. import { Cell, CellGroup, Button, Icon, Badge } from 'vant'
  154. import { fullloading, dialog } from '@/utils/vant'
  155. import { handlePriceColor, parsePercent } from '@/filters'
  156. import { useNavigation } from '@mobile/router/navigation'
  157. import { AuthStatus } from '@/constants/account'
  158. import { useRequest } from '@/hooks/request'
  159. import { queryBankAccountSign } from '@/services/api/bank'
  160. import { useGlobalStore, useNoticeStore, useLoginStore, useAccountStore, useUserStore, useSBYJOrderStore } from '@/stores'
  161. import service from '@/services'
  162. import eventBus from '@/services/bus'
  163. import Iconfont from '@/components/base/iconfont/index.vue'
  164. import { queryTencentUsereSignRecords } from '@/services/api/account'
  165. const oem = service.getConfig('oem')
  166. const { router, routerTo } = useNavigation()
  167. const globalStore = useGlobalStore()
  168. const loginStore = useLoginStore()
  169. const noticeStore = useNoticeStore()
  170. const userStore = useUserStore()
  171. const sbyjOrderStore = useSBYJOrderStore()
  172. const accountStore = useAccountStore()
  173. const { currentAccount } = accountStore.$toRefs()
  174. /// 判断是否能签约
  175. const canBankSign = shallowRef(false)
  176. const headerRef = shallowRef<HTMLDivElement>()
  177. const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
  178. // 任务 #6013
  179. const { dataList: signRecords, run: getTencentUsereSignRecords } = useRequest(queryTencentUsereSignRecords, {
  180. manual: true,
  181. onSuccess: (res) => {
  182. /// 判断是否能签约
  183. canBankSign.value = res.data.length === 0 || res.data.some(e => e.recordstatus === 3)
  184. }
  185. })
  186. // 浮动盈亏
  187. const profitLoss = computed(() => {
  188. // 水贝亿爵订单列表
  189. const orderList = sbyjOrderStore.orderComputedList.filter((e) => e.tHDetailEx.accountID === currentAccount.value.accountid)
  190. // 计算浮动盈亏
  191. return orderList.reduce((pre, cur) => pre += cur.tHDetailEx.floatPL, 0)
  192. })
  193. const onReady = (el: HTMLDivElement) => {
  194. // 设置背景图位置
  195. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  196. }
  197. /// 进行出入金操作判断
  198. const doInOutMoney = (tab: string) => {
  199. if (authStatus.value === AuthStatus.Certified) {
  200. /// 当前未签署合同
  201. if (!canBankSign.value) {
  202. dialog({
  203. message: '请先去签署合同条例!',
  204. showCancelButton: true,
  205. confirmButtonText: '去签署合同'
  206. }).then(() => {
  207. router.push({ name: 'account-protocol' })
  208. })
  209. return
  210. }
  211. // 判断是否已签约
  212. fullloading((hideLoading) => {
  213. queryBankAccountSign().then((res) => {
  214. hideLoading()
  215. const { signstatus } = res.data[0] ?? {}
  216. /// 只有已签约的情况下才可以进行出入金
  217. if (signstatus === 4) {
  218. router.push({ name: 'bank-wallet', query: { tab } })
  219. } else {
  220. dialog({
  221. message: '请先添加签约账户信息!',
  222. showCancelButton: true,
  223. confirmButtonText: '去签约'
  224. }).then(() => {
  225. router.push({ name: 'bank-sign' })
  226. })
  227. }
  228. }).catch(() => {
  229. hideLoading('加载失败', 'fail')
  230. })
  231. }, '正在加载...')
  232. } else {
  233. dialog({
  234. message: '请先实名认证,再进行该操作!',
  235. showCancelButton: true,
  236. confirmButtonText: '去实名'
  237. }).then(() => {
  238. router.push({ name: 'account-certification' })
  239. })
  240. }
  241. }
  242. const userLogout = () => {
  243. dialog({
  244. message: '是否退出当前账号?',
  245. showCancelButton: true
  246. }).then(() => {
  247. loginStore.clearAutoLoginData()
  248. eventBus.$emit('LogoutNotify')
  249. })
  250. }
  251. onActivated(() => {
  252. if (authStatus.value !== AuthStatus.Certified) {
  253. userStore.getUserData()
  254. }
  255. accountStore.getAccountList()
  256. /// 机构不需要签合同
  257. if (userStore.userInfo.usertype === 2) {
  258. canBankSign.value = true
  259. return
  260. }
  261. getTencentUsereSignRecords()
  262. })
  263. </script>
  264. <style lang="less">
  265. @import './index.less';
  266. </style>