index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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-authresult' }" v-if="authStatus === AuthStatus.Submitted">
  109. <template #title>
  110. <Iconfont icon="g-icon-certification">实名认证</Iconfont>
  111. </template>
  112. </Cell>
  113. <Cell is-link :to="{ name: 'account-certification' }" v-else-if="authStatus !== AuthStatus.Certified">
  114. <template #title>
  115. <Iconfont icon="g-icon-certification">实名认证</Iconfont>
  116. </template>
  117. </Cell>
  118. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified && canBankSign">
  119. <template #title>
  120. <Iconfont icon="g-icon-sign">签约账户</Iconfont>
  121. </template>
  122. </Cell>
  123. <Cell is-link :to="{ name: 'account-protocol', query: { memberUserId: getMemberUserId() } }"
  124. v-if="userStore.userType != 2 && authStatus === AuthStatus.Certified">
  125. <template #title>
  126. <Iconfont icon="g-icon-order--line">合同签署</Iconfont>
  127. </template>
  128. </Cell>
  129. <Cell is-link :to="{ name: 'mine-profile' }">
  130. <template #title>
  131. <Iconfont icon="g-icon-profile">个人信息</Iconfont>
  132. </template>
  133. </Cell>
  134. <Cell is-link :to="{ name: 'rules-zcxy' }">
  135. <template #title>
  136. <Iconfont icon="g-icon-zcxy">用户注册协议</Iconfont>
  137. </template>
  138. </Cell>
  139. <Cell is-link :to="{ name: 'rules-yszc' }">
  140. <template #title>
  141. <Iconfont icon="g-icon-yszc">关于隐私</Iconfont>
  142. </template>
  143. </Cell>
  144. <Cell is-link :to="{ name: 'rules-fwrx' }">
  145. <template #title>
  146. <Iconfont icon="g-icon-fwrx">服务热线</Iconfont>
  147. </template>
  148. </Cell>
  149. <Cell is-link :to="{ name: 'mine-setting' }">
  150. <template #title>
  151. <Iconfont icon="g-icon-setting">设置</Iconfont>
  152. </template>
  153. </Cell>
  154. <Cell is-link :to="{ name: 'rules-gywm' }">
  155. <template #title>
  156. <Iconfont icon="g-icon-gywm">关于我们</Iconfont>
  157. </template>
  158. </Cell>
  159. </CellGroup>
  160. </app-block>
  161. <div class="mine-footer">
  162. <Button class="button-logout" type="primary" size="small" round @click="userLogout">退出登录</Button>
  163. </div>
  164. </app-view>
  165. </template>
  166. <script lang="ts" setup>
  167. import { shallowRef, onActivated, computed } from 'vue'
  168. import { Cell, CellGroup, Button, Icon } from 'vant'
  169. import { fullloading, dialog } from '@/utils/vant'
  170. import { handlePriceColor } from '@/filters'
  171. import { useNavigation } from '@mobile/router/navigation'
  172. import { AuthStatus } from '@/constants/account'
  173. import { queryBankAccountSign } from '@/services/api/bank'
  174. import { useLoginStore, useAccountStore, useUserStore, useSBYJOrderStore } from '@/stores'
  175. import eventBus from '@/services/bus'
  176. import Iconfont from '@/components/base/iconfont/index.vue'
  177. import { getMemberUserId, getUserId } from '@/services/methods/user'
  178. import { queryTencentUsereSignRecords } from '@/services/api/account'
  179. const { router, routerTo } = useNavigation()
  180. const loginStore = useLoginStore()
  181. const userStore = useUserStore()
  182. const sbyjOrderStore = useSBYJOrderStore()
  183. const accountStore = useAccountStore()
  184. const { currentAccount } = accountStore.$toRefs()
  185. /// 判断是否能签约
  186. const canBankSign = shallowRef(false)
  187. const headerRef = shallowRef<HTMLDivElement>()
  188. const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
  189. // 浮动盈亏
  190. const profitLoss = computed(() => {
  191. // 水贝亿爵订单列表
  192. const orderList = sbyjOrderStore.orderComputedList.filter((e) => e.tHDetailEx.accountID === currentAccount.value.accountid)
  193. // 计算浮动盈亏
  194. return orderList.reduce((pre, cur) => pre += cur.tHDetailEx.floatPL, 0)
  195. })
  196. const onReady = (el: HTMLDivElement) => {
  197. // 设置背景图位置
  198. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  199. }
  200. /// 进行出入金操作判断
  201. const doInOutMoney = (tab: string) => {
  202. if (authStatus.value === AuthStatus.Certified) {
  203. /// 当前未签署合同
  204. if (!canBankSign.value) {
  205. dialog({
  206. message: '请先去签署合同条例!',
  207. showCancelButton: true,
  208. confirmButtonText: '去签署合同'
  209. }).then(() => {
  210. router.push({ name: 'account-protocol', query: { memberUserId: getMemberUserId() } })
  211. })
  212. return
  213. }
  214. // 判断是否已签约
  215. fullloading((hideLoading) => {
  216. queryBankAccountSign().then((res) => {
  217. hideLoading()
  218. const { signstatus } = res.data[0] ?? {}
  219. /// 只有已签约的情况下才可以进行出入金
  220. if (signstatus && signstatus === 4) {
  221. router.push({ name: 'bank-wallet', query: { tab } })
  222. } else {
  223. dialog({
  224. message: '请先添加签约账户信息!',
  225. showCancelButton: true,
  226. confirmButtonText: '去签约'
  227. }).then(() => {
  228. router.push({ name: 'bank-sign' })
  229. })
  230. }
  231. }).catch(() => {
  232. hideLoading('加载失败', 'fail')
  233. })
  234. }, '正在加载...')
  235. } else {
  236. dialog({
  237. message: '请先实名认证,再进行该操作!',
  238. showCancelButton: true,
  239. confirmButtonText: '去实名'
  240. }).then(() => {
  241. router.push({ name: 'account-certification' })
  242. })
  243. }
  244. }
  245. const userLogout = () => {
  246. dialog({
  247. message: '是否退出当前账号?',
  248. showCancelButton: true
  249. }).then(() => {
  250. loginStore.clearAutoLoginData()
  251. eventBus.$emit('LogoutNotify')
  252. })
  253. }
  254. onActivated(() => {
  255. if (authStatus.value !== AuthStatus.Certified) {
  256. userStore.getUserData()
  257. }
  258. accountStore.getAccountList()
  259. /// 机构不需要签合同
  260. if (userStore.userInfo.usertype === 2) {
  261. canBankSign.value = true
  262. return
  263. }
  264. /// 查询数据
  265. queryTencentUsereSignRecords({
  266. data: {
  267. userId: getUserId(),
  268. memberUserId: getMemberUserId()
  269. }
  270. }).then((res) => {
  271. /// 判断是否能签约
  272. canBankSign.value = res.data.length === 0 || res.data.some(e => e.recordstatus === 3)
  273. })
  274. })
  275. </script>
  276. <style lang="less">
  277. @import './index.less';
  278. </style>