index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.accountName }}</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-list')">
  51. <Iconfont label-direction="bottom" icon="g-icon-order--line">订单</Iconfont>
  52. </li>
  53. <li @click="routerTo('delivery-list')">
  54. <Iconfont label-direction="bottom" icon="g-icon-delivery--line">交收</Iconfont>
  55. </li>
  56. </ul>
  57. </app-block>
  58. <app-block class="g-navmenu">
  59. <CellGroup>
  60. <Cell is-link :to="{ name: 'bank-capital' }">
  61. <template #title>
  62. <Iconfont icon="g-icon-capital">资金信息</Iconfont>
  63. </template>
  64. </Cell>
  65. <Cell is-link :to="{ name: 'account-certification' }" v-if="authStatus !== AuthStatus.Certified">
  66. <template #title>
  67. <Iconfont icon="g-icon-certification">实名认证</Iconfont>
  68. </template>
  69. </Cell>
  70. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified">
  71. <template #title>
  72. <Iconfont icon="g-icon-sign">签约账户</Iconfont>
  73. </template>
  74. </Cell>
  75. <Cell is-link :to="{ name: 'mine-profile' }">
  76. <template #title>
  77. <Iconfont icon="g-icon-profile">个人信息</Iconfont>
  78. </template>
  79. </Cell>
  80. <Cell is-link :to="{ name: 'rules-zcxy' }">
  81. <template #title>
  82. <Iconfont icon="g-icon-zcxy">用户注册协议</Iconfont>
  83. </template>
  84. </Cell>
  85. <Cell is-link :to="{ name: 'rules-yszc' }">
  86. <template #title>
  87. <Iconfont icon="g-icon-yszc">关于隐私</Iconfont>
  88. </template>
  89. </Cell>
  90. <Cell is-link :to="{ name: 'rules-fwrx' }">
  91. <template #title>
  92. <Iconfont icon="g-icon-fwrx">服务热线</Iconfont>
  93. </template>
  94. </Cell>
  95. <Cell is-link :to="{ name: 'mine-setting' }">
  96. <template #title>
  97. <Iconfont icon="g-icon-setting">设置</Iconfont>
  98. </template>
  99. </Cell>
  100. <Cell is-link :to="{ name: 'rules-gywm' }">
  101. <template #title>
  102. <Iconfont icon="g-icon-gywm">关于我们</Iconfont>
  103. </template>
  104. </Cell>
  105. </CellGroup>
  106. </app-block>
  107. <div class="mine-footer">
  108. <Button class="button-logout" type="primary" size="small" round @click="userLogout">退出登录</Button>
  109. </div>
  110. </app-view>
  111. </template>
  112. <script lang="ts" setup>
  113. import { shallowRef, onMounted, onActivated, computed } from 'vue'
  114. import { Cell, CellGroup, Button, Icon } from 'vant'
  115. import { fullloading, dialog } from '@/utils/vant'
  116. import { useNavigation } from '@mobile/router/navigation'
  117. import { AuthStatus } from '@/constants/account'
  118. import { queryBankAccountSign } from '@/services/api/bank'
  119. import { useLoginStore, useAccountStore, useUserStore, usePositionStore } from '@/stores'
  120. import eventBus from '@/services/bus'
  121. import Iconfont from '@/components/base/iconfont/index.vue'
  122. const { router, routerTo } = useNavigation()
  123. const loginStore = useLoginStore()
  124. const userStore = useUserStore()
  125. const positionStore = usePositionStore()
  126. const accountStore = useAccountStore()
  127. const { currentAccount } = accountStore.$toRefs()
  128. const headerRef = shallowRef<HTMLDivElement>()
  129. const authStatus = computed(() => userStore.userAccount.hasauth) // 实名认证状态
  130. const onReady = (el: HTMLDivElement) => {
  131. // 设置背景图位置
  132. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  133. }
  134. /// 进行出入金操作判断
  135. const doInOutMoney = (tab: string) => {
  136. if (authStatus.value === AuthStatus.Certified) {
  137. fullloading((hideLoading) => {
  138. queryBankAccountSign().then((res) => {
  139. hideLoading()
  140. const { signstatus } = res.data[0] ?? {}
  141. /// 只有已签约的情况下才可以进行出入金
  142. if (signstatus && signstatus === 4) {
  143. router.push({ name: 'bank-wallet', query: { tab } })
  144. } else {
  145. dialog({
  146. message: '请先添加签约账户信息!',
  147. showCancelButton: true,
  148. confirmButtonText: '去签约'
  149. }).then(() => {
  150. router.push({ name: 'bank-sign' })
  151. })
  152. }
  153. }).catch(() => {
  154. hideLoading('加载失败', 'fail')
  155. })
  156. }, '正在加载...')
  157. } else {
  158. dialog({
  159. message: '请先实名认证,再进行该操作!',
  160. showCancelButton: true,
  161. confirmButtonText: '去实名'
  162. }).then(() => {
  163. router.push({ name: 'account-certification' })
  164. })
  165. }
  166. }
  167. const userLogout = () => {
  168. dialog({
  169. message: '是否退出当前账号?',
  170. showCancelButton: true
  171. }).then(() => {
  172. loginStore.clearAutoLoginData()
  173. eventBus.$emit('LogoutNotify')
  174. })
  175. }
  176. onActivated(() => {
  177. if (authStatus.value !== AuthStatus.Certified) {
  178. userStore.getUserData()
  179. }
  180. accountStore.getAccountList()
  181. })
  182. </script>
  183. <style lang="less">
  184. @import './index.less';
  185. </style>