index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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('UserAvatar')">
  11. <img class="g-image--avatar" :src="userAvatar" />
  12. </div>
  13. <div class="profile-user__info">
  14. <div>
  15. <Tag :type="authStatus ? 'success' : 'primary'">{{ getAuthStatusName(authStatus) }}</Tag>
  16. </div>
  17. <span>{{ loginId }}</span>
  18. </div>
  19. </div>
  20. <div class="profile-account">
  21. <span>正常</span>
  22. <span>{{ firstAccountId }}</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" @click="doInOutMoney('0')" round>充值</Button>
  48. </div>
  49. </div>
  50. </div>
  51. <app-block class="mine-iconbar">
  52. <ul>
  53. <li @click="showQRCode = true">
  54. <img src="@mobile/assets/icons/generalize.svg" />
  55. <span>注册编码</span>
  56. </li>
  57. <li @click="routerTo('my-order')">
  58. <img src="@mobile/assets/icons/order.svg" />
  59. <span>我的订单</span>
  60. </li>
  61. <li @click="routerTo('Pricing')">
  62. <img src="@mobile/assets/icons/wddj.svg" />
  63. <span>我的点价</span>
  64. </li>
  65. <li @click="routerTo('my-wareorder')">
  66. <img src="@mobile/assets/icons/wareorder.svg" />
  67. <span>我的仓单</span>
  68. </li>
  69. </ul>
  70. </app-block>
  71. <app-block class="g-navmenu">
  72. <CellGroup>
  73. <Cell is-link :to="{ name: 'account-certification' }"
  74. v-if="[AuthStatus.Uncertified, AuthStatus.Rejected].includes(authStatus)">
  75. <template #title>
  76. <app-iconfont icon="icon-shimingrenzheng">实名认证</app-iconfont>
  77. </template>
  78. </Cell>
  79. <Cell is-link :to="{ name: 'bank-sign' }" v-if="authStatus === AuthStatus.Certified">
  80. <template #title>
  81. <app-iconfont icon="icon-qianyuezhanghu">签约账户</app-iconfont>
  82. </template>
  83. </Cell>
  84. <Cell is-link :to="{ name: 'rules-zcxy' }">
  85. <template #title>
  86. <app-iconfont icon="icon-yonghuzhucexieyi">用户注册协议</app-iconfont>
  87. </template>
  88. </Cell>
  89. <Cell is-link :to="{ name: 'rules-yszc' }">
  90. <template #title>
  91. <app-iconfont icon="icon-guanyuzhengce">关于隐私</app-iconfont>
  92. </template>
  93. </Cell>
  94. <Cell is-link :to="{ name: 'NavigationInvoice' }">
  95. <template #title>
  96. <app-iconfont icon="icon-fapiaoshuoming">关于发票</app-iconfont>
  97. </template>
  98. </Cell>
  99. <Cell is-link :to="{ name: 'rules-fwrx' }">
  100. <template #title>
  101. <app-iconfont icon="icon-kefurexian">服务热线</app-iconfont>
  102. </template>
  103. </Cell>
  104. <Cell is-link :to="{ name: 'NavigationSetting' }">
  105. <template #title>
  106. <app-iconfont icon="icon-shezhi">设置</app-iconfont>
  107. </template>
  108. </Cell>
  109. <Cell is-link :to="{ name: 'rules-gywm' }">
  110. <template #title>
  111. <app-iconfont icon="icon-guanyuwomen">关于我们</app-iconfont>
  112. </template>
  113. </Cell>
  114. </CellGroup>
  115. </app-block>
  116. <div class="mine-footer">
  117. <Button class="button-logout" type="primary" size="small" round @click="userLogout">退出登录</Button>
  118. </div>
  119. <app-register-code v-model:show="showQRCode" :text="registerCode" />
  120. </app-view>
  121. </template>
  122. <script lang="ts" setup>
  123. import { shallowRef, onActivated, computed } from 'vue'
  124. import { Cell, CellGroup, Button, Tag, showFailToast } from 'vant'
  125. import { fullloading, dialog } from '@/utils/vant'
  126. import { getFileUrl } from '@/filters'
  127. import { useNavigation } from '@/hooks/navigation'
  128. import { loginStore, accountStore, userStore } from '@/stores'
  129. import { localData } from '@/stores/storage'
  130. import AppIconfont from '@mobile/components/base/iconfont/index.vue'
  131. import { queryBankAccountSign } from '@/services/api/bank'
  132. import { queryUserAccount } from '@/services/api/account'
  133. import { AuthStatus, getAuthStatusName } from '@/constants/account'
  134. import eventBus from '@/services/bus'
  135. import AppRegisterCode from '@mobile/components/modules/register-code/index.vue'
  136. const { router, routerTo } = useNavigation()
  137. const { userId, loginId, firstAccountId } = loginStore.$mapGetters()
  138. const { userInfo } = userStore.$mapGetters()
  139. const { accountInfo, freezeMargin, avaiableMoney } = accountStore.$mapGetters()
  140. const authStatus = shallowRef(AuthStatus.Uncertified) // 实名认证状态
  141. const registerCode = shallowRef('') // 注册编码
  142. const headerRef = shallowRef<HTMLDivElement>()
  143. const showQRCode = shallowRef(false)
  144. // 用户头像
  145. const userAvatar = computed(() => {
  146. const file = userInfo.value?.headurl
  147. return file ? getFileUrl(file) : ''
  148. })
  149. const onReady = (el: HTMLDivElement) => {
  150. // 设置背景图位置
  151. headerRef.value?.style.setProperty('background-position', `0 -${el.clientHeight}px`)
  152. }
  153. /// 进行出入金操作判断
  154. const doInOutMoney = (tab: string) => {
  155. if (authStatus.value === AuthStatus.Certified) {
  156. fullloading((hideLoading) => {
  157. queryBankAccountSign().then((res) => {
  158. hideLoading()
  159. const { signstatus } = res.data[0] ?? {}
  160. /// 只有已签约的情况下才可以进行出入金
  161. if (signstatus && signstatus === 4) {
  162. router.push({ name: 'bank-wallet', query: { tab } })
  163. } else {
  164. dialog({
  165. message: '请先添加签约账户信息!',
  166. showCancelButton: true,
  167. confirmButtonText: '去签约'
  168. }).then(() => {
  169. router.push({ name: 'bank-sign' })
  170. })
  171. }
  172. }).catch(() => {
  173. showFailToast('加载失败')
  174. })
  175. }, '正在加载...')
  176. } else {
  177. dialog({
  178. message: '请先实名认证,再进行该操作!',
  179. showCancelButton: true,
  180. confirmButtonText: '去实名'
  181. }).then(() => {
  182. router.push({ name: 'account-certification' })
  183. })
  184. }
  185. }
  186. const userLogout = () => {
  187. dialog({
  188. message: '是否退出当前账号?',
  189. showCancelButton: true
  190. }).then(() => {
  191. localData.reset('autoLoginEncryptedData') // 清除自动登录数据
  192. eventBus.$emit('LogoutNotify')
  193. })
  194. }
  195. onActivated(() => {
  196. if (authStatus.value !== AuthStatus.Certified) {
  197. // 获取用户账号信息
  198. queryUserAccount({
  199. userID: userId.value
  200. }).then((res) => {
  201. authStatus.value = res.data.hasauth
  202. registerCode.value = res.data.refernum
  203. })
  204. }
  205. })
  206. </script>
  207. <style lang="less">
  208. @import './index.less';
  209. </style>