index.vue 12 KB

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