index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <hc-sys class="hc-user-page" :tabbar="false" :isNavBar="false">
  3. <hc-nav-bar class="user-nav-bar" :style="`background: rgba(85, 77, 132, ${opacitys})`">
  4. <text class="i-ri-settings-4-fill" @click="toSkipClick('/pages/my/info')"/>
  5. </hc-nav-bar>
  6. <view class="user-nav-bg"/>
  7. <!--内容区域-->
  8. <view class="hc-user-content-box">
  9. <view class="user-nav-h"/>
  10. <!--个人信息卡片-->
  11. <view class="user-info-card animation-mode" :class="isAnimation?'is-animation':''">
  12. <view class="name-avatar-bar">
  13. <view class="name">{{userInfo.realName}}</view>
  14. <view class="avatar" @click="selectImageTap">
  15. <HcImg class="avatar-img" :src="userInfo.avatar" width="72" height="72"/>
  16. </view>
  17. </view>
  18. <view class="user-auth-bar">
  19. <view class="auth-tag visit">
  20. <text class="i-ri-vip-diamond-line"/>
  21. <text class="name">{{userInfo.roleName}}</text>
  22. </view>
  23. <view class="auth-tag approve">
  24. <text class="name">审批权限</text>
  25. <text class="i-ri-checkbox-circle-fill check-icon" v-if="userInfo.signatureUrl"/>
  26. <text class="i-ri-close-circle-fill close-icon" v-else/>
  27. </view>
  28. </view>
  29. <uni-row class="info-num-bar">
  30. <uni-col :span="8" class="col-bar">
  31. <view class="num">{{userInfo.fillNum}}</view>
  32. <view class="text">填报数量</view>
  33. </uni-col>
  34. <uni-col :span="8" class="col-bar">
  35. <view class="num">{{userInfo.appdNum}}</view>
  36. <view class="text">审批数量</view>
  37. </uni-col>
  38. <uni-col :span="8" class="col-bar">
  39. <view class="num">{{userInfo.fbNum}}</view>
  40. <view class="text">反馈问题</view>
  41. </uni-col>
  42. </uni-row>
  43. </view>
  44. <!--常用操作-->
  45. <view class="common-operation-box">
  46. <view class="title">常用操作</view>
  47. <uni-row :gutter="24" class="handle-row-bar">
  48. <uni-col :span="12">
  49. <view class="col-item-card animation-mode"
  50. :class="isAnimation?'in-left':''"
  51. @click="toSkipClick('/pages/my/project')"
  52. >
  53. <view class="content">
  54. <view class="title">项目管理</view>
  55. <view class="text">设置当前默认项目</view>
  56. </view>
  57. <view class="icon-bar">
  58. <text class="i-ri-stack-line"/>
  59. </view>
  60. </view>
  61. </uni-col>
  62. <uni-col :span="12" class="col-bar">
  63. <view class="col-item-card animation-mode"
  64. :class="isAnimation?'in-right':''"
  65. @click="toSkipClick('/pages/my/record')"
  66. >
  67. <view class="content">
  68. <view class="title">填报记录</view>
  69. <view class="text">查看历史记录</view>
  70. </view>
  71. <view class="icon-bar">
  72. <text class="i-ri-file-history-line"/>
  73. </view>
  74. </view>
  75. </uni-col>
  76. </uni-row>
  77. <uni-row :gutter="24" class="handle-row-bar">
  78. <uni-col :span="12">
  79. <view class="col-item-card animation-mode"
  80. :class="isAnimation?'in-left':''"
  81. @click="toSkipClick('/pages/my/explain')"
  82. >
  83. <view class="content">
  84. <view class="title">相关资料</view>
  85. <view class="text">查看系统相关资料</view>
  86. </view>
  87. <view class="icon-bar">
  88. <text class="i-ri-profile-line"/>
  89. </view>
  90. </view>
  91. </uni-col>
  92. <uni-col :span="12" class="col-bar">
  93. <view class="col-item-card animation-mode"
  94. :class="isAnimation?'in-right':''"
  95. @click="toSkipClick('/pages/my/customer')"
  96. >
  97. <view class="content">
  98. <view class="title">我的客服</view>
  99. <view class="text">问题反馈寻求帮助</view>
  100. </view>
  101. <view class="icon-bar">
  102. <text class="i-ri-question-answer-line"/>
  103. </view>
  104. </view>
  105. </uni-col>
  106. </uni-row>
  107. </view>
  108. <!--消息动态-->
  109. <view class="news-dynamics-box animation-mode" :class="isAnimation?'is-animation':''">
  110. <view class="title-bar">
  111. <text class="i-ri-notification-2-fill"/>
  112. <text class="name">消息动态圈</text>
  113. </view>
  114. </view>
  115. <!--退出按钮-->
  116. <view class="exit-button-bar" :class="isAnimation?'is-animation':''">
  117. <button class="exit-button animation-mode" @click="signOutClick">退出登录</button>
  118. </view>
  119. </view>
  120. </hc-sys>
  121. </template>
  122. <script setup>
  123. import {ref} from "vue";
  124. import mainApi from '~api/user/index';
  125. import {onShow, onHide, onPageScroll} from '@dcloudio/uni-app'
  126. import {errorToast, successToast} from "@/utils/tools";
  127. import {getTokenHeader} from "@/httpApi/request/header";
  128. import {getObjValue} from "js-fast-way";
  129. import {getUploadApi} from "@/httpApi/modules/upload";
  130. import {useAppStore} from "@/store";
  131. //初始变量
  132. const store = useAppStore()
  133. const userInfo = ref(store.userInfo);
  134. //获取数据
  135. const setUserData = async () => {
  136. const user_info = userInfo.value
  137. const user = await mainApi.queryCurrentUserData()
  138. const yown = await mainApi.appQuerYownData()
  139. userInfo.value = {
  140. ...user_info,
  141. ...getObjValue(user.data),
  142. ...getObjValue(yown.data),
  143. }
  144. }
  145. const isAnimation = ref(store.isAnimation)
  146. onShow(()=>{
  147. setUserData()
  148. if(store.isAnimation) {
  149. isAnimation.value = true
  150. }
  151. })
  152. onHide(() => {
  153. isAnimation.value = false
  154. })
  155. //选择头像
  156. const selectImageTap = () => {
  157. uni.chooseImage({
  158. count: 1,
  159. sizeType: ['original'],
  160. success: (res)=> {
  161. uploadAvatarFile(res.tempFilePaths[0])
  162. }
  163. });
  164. }
  165. //上传头像文件
  166. const uploadAvatarFile = async (file) => {
  167. uni.showLoading({title: '上传头像中...', mask: true});
  168. const url = await uploadFile(file)
  169. if(!url) {
  170. uni.hideLoading();
  171. return;
  172. }
  173. const {user_id} = userInfo.value
  174. const {error, code} = await mainApi.updateUserInfo({
  175. avatar: url,
  176. id: user_id
  177. })
  178. if (!error && code === 200) {
  179. userInfo.value.avatar = url
  180. store.setUserInfo(userInfo.value)
  181. uni.hideLoading();
  182. successToast('头像上传成功')
  183. } else {
  184. uni.hideLoading();
  185. errorToast('头像上传失败');
  186. }
  187. }
  188. //上传文件
  189. const uploadFile = async (file) => {
  190. return new Promise((resolve) => {
  191. uni.uploadFile({
  192. url: getUploadApi() + 'blade-resource/oss/endpoint/put-file',
  193. name: 'file',
  194. filePath: file,
  195. header: getTokenHeader(),
  196. timeout: 300000,
  197. success: (res) => {
  198. const data = JSON.parse(res.data)
  199. const {link} = getObjValue(data.data)
  200. if (!link) errorToast('文件上传异常');
  201. resolve(link ?? '');
  202. },
  203. fail: () => {
  204. errorToast('文件上传失败');
  205. resolve('');
  206. }
  207. });
  208. })
  209. }
  210. //跳转到其他页面
  211. const toSkipClick = (url) => {
  212. uni.navigateTo({url: url});
  213. }
  214. //退出登录
  215. const signOutClick = () => {
  216. uni.reLaunch({url: '/pages/login/login'});
  217. }
  218. //监听页面滚动
  219. const opacitys = ref(0)
  220. onPageScroll((event) => {
  221. const scrollTop = event.scrollTop
  222. if (scrollTop <= 1) {
  223. opacitys.value = 0
  224. } else if (scrollTop > 1 && scrollTop <= 10) {
  225. opacitys.value = 0.2
  226. } else if (scrollTop > 10 && scrollTop <= 20) {
  227. opacitys.value = 0.4
  228. } else if (scrollTop > 20 && scrollTop <= 30) {
  229. opacitys.value = 0.6
  230. } else if (scrollTop > 30 && scrollTop <= 40) {
  231. opacitys.value = 0.8
  232. } else if (scrollTop > 40) {
  233. opacitys.value = 1
  234. }
  235. })
  236. </script>
  237. <style lang="scss">
  238. @import "@/style/my/index.scss";
  239. </style>