index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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)" v-if="authStatus" />
  17. <Icon name="warning" color="var(--van-tag-warning-color)" v-else />
  18. </div>
  19. <div class="bottom">{{ loginStore.loginId }}</div>
  20. </div>
  21. </div>
  22. <div class="profile-account">
  23. <span>正常</span>
  24. <span>{{ accountInfo.accountid ?? 0 }}</span>
  25. </div>
  26. </div>
  27. <div class="bank">
  28. <div class="bank-item">
  29. <span>余额</span>
  30. <span>{{ accountInfo.currentbalance?.toFixed(2) ?? '0.00' }}</span>
  31. </div>
  32. <div class="bank-item">
  33. <span>冻结</span>
  34. <span>{{ freezeMargin.toFixed(2) }}</span>
  35. </div>
  36. <div class="bank-item">
  37. <span>可用</span>
  38. <span>{{ avaiableMoney.toFixed(2) }}</span>
  39. </div>
  40. <div class="bank-item">
  41. <span>
  42. <a @click="routerTo('bank-statement')">资金流水</a>
  43. </span>
  44. <span></span>
  45. </div>
  46. </div>
  47. <div class="button">
  48. <Button size="small" round @click="doInOutMoney('1')">提现</Button>
  49. <Button type="primary" size="small" round @click="doInOutMoney('0')">充值</Button>
  50. </div>
  51. </div>
  52. </div>
  53. <app-block class="mine-iconbar">
  54. <ul>
  55. <li @click="routerTo('order-list')">
  56. <Iconfont label-direction="bottom" icon="icon-a-zu838">订单</Iconfont>
  57. </li>
  58. <li @click="routerTo('delivery-list')">
  59. <Iconfont label-direction="bottom" icon="icon-a-zu837">交收</Iconfont>
  60. </li>
  61. </ul>
  62. </app-block>
  63. <app-block class="g-navmenu">
  64. <CellGroup>
  65. <Cell is-link :to="{ name: 'account-certification' }"
  66. v-if="[AuthStatus.Uncertified, AuthStatus.Rejected].includes(authStatus)">
  67. <template #title>
  68. <Iconfont icon="icon-shimingrenzheng">实名认证</Iconfont>
  69. </template>
  70. </Cell>
  71. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified">
  72. <template #title>
  73. <Iconfont icon="icon-qianyuezhanghu">签约账户</Iconfont>
  74. </template>
  75. </Cell>
  76. <Cell is-link :to="{ name: 'mine-profile' }">
  77. <template #title>
  78. <Iconfont icon="icon-fapiaoshuoming">个人信息</Iconfont>
  79. </template>
  80. </Cell>
  81. <Cell is-link :to="{ name: 'rules-zcxy' }">
  82. <template #title>
  83. <Iconfont icon="icon-yonghuzhucexieyi">用户注册协议</Iconfont>
  84. </template>
  85. </Cell>
  86. <Cell is-link :to="{ name: 'rules-yszc' }">
  87. <template #title>
  88. <Iconfont icon="icon-guanyuzhengce">关于隐私</Iconfont>
  89. </template>
  90. </Cell>
  91. <Cell is-link :to="{ name: 'rules-fwrx' }">
  92. <template #title>
  93. <Iconfont icon="icon-kefurexian">服务热线</Iconfont>
  94. </template>
  95. </Cell>
  96. <Cell is-link :to="{ name: 'mine-setting' }">
  97. <template #title>
  98. <Iconfont icon="icon-shezhi">设置</Iconfont>
  99. </template>
  100. </Cell>
  101. <Cell is-link :to="{ name: 'rules-gywm' }">
  102. <template #title>
  103. <Iconfont icon="icon-guanyuwomen">关于我们</Iconfont>
  104. </template>
  105. </Cell>
  106. </CellGroup>
  107. </app-block>
  108. <div class="mine-footer">
  109. <Button class="button-logout" type="primary" size="small" round @click="userLogout">退出登录</Button>
  110. </div>
  111. </app-view>
  112. </template>
  113. <script lang="ts" setup>
  114. import { shallowRef, onActivated } from 'vue'
  115. import { Cell, CellGroup, Button, Icon } from 'vant'
  116. import { fullloading, dialog } from '@/utils/vant'
  117. import { useNavigation } from '@/packages/sbyj/router/navigation'
  118. import { AuthStatus } from '@/constants/account'
  119. import { queryBankAccountSign } from '@/services/api/bank'
  120. import { queryUserAccount } from '@/services/api/account'
  121. import { useLoginStore, useAccountStore, useUserStore } from '@/stores'
  122. import eventBus from '@/services/bus'
  123. import Iconfont from '@/packages/sbyj/components/base/iconfont/index.vue'
  124. const { router, routerTo } = useNavigation()
  125. const loginStore = useLoginStore()
  126. const userStore = useUserStore()
  127. const accountStore = useAccountStore()
  128. const { accountInfo, freezeMargin, avaiableMoney } = accountStore.$toRefs()
  129. const headerRef = shallowRef<HTMLDivElement>()
  130. const authStatus = shallowRef(AuthStatus.Uncertified) // 实名认证状态
  131. const onReady = (el: HTMLDivElement) => {
  132. // 设置背景图位置
  133. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  134. }
  135. /// 进行出入金操作判断
  136. const doInOutMoney = (tab: string) => {
  137. if (authStatus.value === AuthStatus.Certified) {
  138. fullloading((hideLoading) => {
  139. queryBankAccountSign().then((res) => {
  140. hideLoading()
  141. const { signstatus } = res.data[0] ?? {}
  142. /// 只有已签约的情况下才可以进行出入金
  143. if (signstatus && signstatus === 4) {
  144. router.push({ name: 'bank-wallet', query: { tab } })
  145. } else {
  146. dialog({
  147. message: '请先添加签约账户信息!',
  148. showCancelButton: true,
  149. confirmButtonText: '去签约'
  150. }).then(() => {
  151. router.push({ name: 'bank-sign' })
  152. })
  153. }
  154. }).catch(() => {
  155. hideLoading('加载失败', 'fail')
  156. })
  157. }, '正在加载...')
  158. } else {
  159. dialog({
  160. message: '请先实名认证,再进行该操作!',
  161. showCancelButton: true,
  162. confirmButtonText: '去实名'
  163. }).then(() => {
  164. router.push({ name: 'account-certification' })
  165. })
  166. }
  167. }
  168. const userLogout = () => {
  169. dialog({
  170. message: '是否退出当前账号?',
  171. showCancelButton: true
  172. }).then(() => {
  173. loginStore.clearAutoLoginData()
  174. eventBus.$emit('LogoutNotify')
  175. })
  176. }
  177. onActivated(() => {
  178. if (authStatus.value !== AuthStatus.Certified) {
  179. // 获取用户账号信息
  180. queryUserAccount().then((res) => {
  181. authStatus.value = res.data.hasauth
  182. })
  183. }
  184. })
  185. </script>
  186. <style lang="less">
  187. @import './index.less';
  188. </style>