index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <app-view class="home-mine">
  3. <template #header>
  4. <app-navbar title="我的" :show-back-button="false" @ready="onReady" />
  5. </template>
  6. <div ref="headerRef" class="home-mine__header">
  7. <div class="home-mine__header-wrapper">
  8. <div class="profile">
  9. <div class="profile-user">
  10. <div class="profile-user__avatar">
  11. <img class="g-image--avatar" src="" />
  12. </div>
  13. <div class="profile-user__info">
  14. <div>
  15. <Tag :type="authStatus ? 'success' : 'primary'">{{ getAuthStatusName(authStatus) }}</Tag>
  16. </div>
  17. <span>{{ getLoginId() }}</span>
  18. </div>
  19. </div>
  20. <div class="profile-account">
  21. <span>正常</span>
  22. <span>{{ getFirstAccountId() }}</span>
  23. </div>
  24. </div>
  25. <div class="bank" v-if="accountInfo">
  26. <div class="bank-item">
  27. <span>余额</span>
  28. <span>{{ accountInfo.currentbalance.toFixed(2) }}</span>
  29. </div>
  30. <div class="bank-item">
  31. <span>冻结</span>
  32. <span>{{ freezeMargin.toFixed(2) }}</span>
  33. </div>
  34. <div class="bank-item">
  35. <span>可用</span>
  36. <span>{{ avaiableMoney.toFixed(2) }}</span>
  37. </div>
  38. <div class="bank-item">
  39. <span>
  40. <a @click="routerTo('bank-statement')">资金流水</a>
  41. </span>
  42. <span></span>
  43. </div>
  44. </div>
  45. <div class="button">
  46. <Button size="small" @click="doInOutMoney('1')" round>提现</Button>
  47. <Button type="primary" size="small" color="#00577C" @click="doInOutMoney('0')" round>充值</Button>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="home-mine__iconbar">
  52. <ul>
  53. <li @click="routerTo('mine-generalize')">
  54. <app-iconfont icon="icon-wodetuiguang" label-direction="bottom">我的推广</app-iconfont>
  55. </li>
  56. <li @click="routerTo('my-order')" style="align-items:flex-start">
  57. <app-iconfont icon="icon-wodedingdan" label-direction="bottom">我的订单</app-iconfont>
  58. </li>
  59. <!-- <li>
  60. <app-iconfont icon="icon-wodecangdan" label-direction="bottom">我的仓单</app-iconfont>
  61. </li>
  62. <li>
  63. <app-iconfont icon="icon-fapiaoxinxi" label-direction="bottom">发票信息</app-iconfont>
  64. </li>
  65. <li @click="routerTo('mine-address')">
  66. <app-iconfont icon="icon-shouhuodizhi" label-direction="bottom">收货地址</app-iconfont>
  67. </li> -->
  68. </ul>
  69. </div>
  70. <div class="g-navmenu">
  71. <CellGroup>
  72. <Cell is-link :to="{ name: 'account-certification' }"
  73. v-if="[AuthStatus.Uncertified, AuthStatus.Rejected].includes(authStatus)">
  74. <template #title>
  75. <app-iconfont icon="icon-shimingrenzheng">实名认证</app-iconfont>
  76. </template>
  77. </Cell>
  78. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified">
  79. <template #title>
  80. <app-iconfont icon="icon-qianyuezhanghu">签约账户</app-iconfont>
  81. </template>
  82. </Cell>
  83. <Cell is-link :to="{ name: 'rules-zcxy' }">
  84. <template #title>
  85. <app-iconfont icon="icon-yonghuzhucexieyi">用户注册协议</app-iconfont>
  86. </template>
  87. </Cell>
  88. <Cell is-link :to="{ name: 'rules-yszc' }">
  89. <template #title>
  90. <app-iconfont icon="icon-guanyuzhengce">关于隐私</app-iconfont>
  91. </template>
  92. </Cell>
  93. <Cell is-link :to="{ name: 'mine-service' }">
  94. <template #title>
  95. <app-iconfont icon="icon-kefurexian">客服热线</app-iconfont>
  96. </template>
  97. </Cell>
  98. <Cell is-link :to="{ name: 'setting' }">
  99. <template #title>
  100. <app-iconfont icon="icon-shezhi">设置</app-iconfont>
  101. </template>
  102. </Cell>
  103. <Cell is-link :to="{ name: 'rules-gywm' }">
  104. <template #title>
  105. <app-iconfont icon="icon-guanyuwomen">关于我们</app-iconfont>
  106. </template>
  107. </Cell>
  108. <Cell is-link :to="{ name: 'logoff' }">
  109. <template #title>
  110. <app-iconfont icon="icon-zhuxiaofuwu">注销服务</app-iconfont>
  111. </template>
  112. </Cell>
  113. </CellGroup>
  114. </div>
  115. <div class="home-mine__footer">
  116. <Button class="button-logout" @click="userLogout">退出登录</Button>
  117. </div>
  118. </app-view>
  119. </template>
  120. <script lang="ts" setup>
  121. import { shallowRef, onActivated } from 'vue'
  122. import { Cell, CellGroup, Button, Tag, Toast } from 'vant'
  123. import { fullloading, dialog } from '@/utils/vant'
  124. import { useNavigation } from '@/hooks/navigation'
  125. import { useLoginStore, useAccountStore, } from '@/stores'
  126. import { useAuth } from '@/business/auth'
  127. import AppIconfont from '@mobile/components/base/iconfont/index.vue'
  128. import { useBankAccountSign } from '@/business/bank'
  129. import { queryUserAccount } from '@/services/api/account'
  130. import { AuthStatus, getAuthStatusName } from '@/constants/account';
  131. const { router, routerTo } = useNavigation()
  132. const { getUserId, getLoginId, getFirstAccountId } = useLoginStore()
  133. const { getBankAccountList, bankInfo } = useBankAccountSign()
  134. const { logout } = useAuth()
  135. const { accountInfo, freezeMargin, avaiableMoney } = useAccountStore()
  136. const authStatus = shallowRef(AuthStatus.Uncertified) // 实名认证状态
  137. const headerRef = shallowRef<HTMLDivElement>()
  138. const onReady = (el: HTMLDivElement) => {
  139. // 设置背景图位置
  140. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  141. }
  142. /// 进行出入金操作判断
  143. const doInOutMoney = (tab: string) => {
  144. if (authStatus.value === AuthStatus.Certified) {
  145. fullloading((hideLoading) => {
  146. getBankAccountList().then(() => {
  147. hideLoading()
  148. const { signstatus } = bankInfo.value ?? {}
  149. /// 只有已签约的情况下才可以进行出入金
  150. if (signstatus && signstatus === 4) {
  151. router.push({ name: 'bank-wallet', query: { tab } })
  152. } else {
  153. dialog('请先添加签约账户信息!', {
  154. showCancelButton: true,
  155. confirmButtonText: '去签约'
  156. }).then(() => {
  157. router.push({ name: 'bank-sign' })
  158. })
  159. }
  160. }).catch(() => {
  161. Toast.fail('加载失败')
  162. })
  163. }, '正在加载...')
  164. } else {
  165. dialog('请先实名认证,再进行该操作!', {
  166. showCancelButton: true,
  167. confirmButtonText: '去实名'
  168. }).then(() => {
  169. router.push({ name: 'account-certification' })
  170. })
  171. }
  172. }
  173. const userLogout = () => {
  174. dialog('是否退出当前账号?', {
  175. showCancelButton: true
  176. }).then(() => {
  177. logout()
  178. })
  179. }
  180. onActivated(() => {
  181. if (authStatus.value !== AuthStatus.Certified) {
  182. // 获取用户账号信息
  183. queryUserAccount({
  184. data: {
  185. userID: getUserId()
  186. },
  187. success: (res) => {
  188. authStatus.value = res.data.hasauth
  189. }
  190. })
  191. }
  192. })
  193. </script>
  194. <style lang="less">
  195. @import './index.less';
  196. </style>