my.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view class="tab_page" :style="{'height':h+'px', 'padding-top':mt+'px'}">
  3. <up-navbar title=" " bgColor="transparent">
  4. <template #left></template>
  5. </up-navbar>
  6. <image src="https://oss.familydaf.cn/sxsnfile/20251218/0ac9931a34bd432a8a44ef619fa51362.png" class="top_bg_img" mode="widthFix"></image>
  7. <view class="info">
  8. <view class="info-top adfacjb">
  9. <view class="info-top-left adfac">
  10. <image class="avatar" :src="userInfo?.avatarPath||'https://oss.familydaf.cn/sxsnfile/20251218/00e0a9dd94c64503aeedfd20907461b6.png'"></image>
  11. <view class="text" @click="showLogin">
  12. <view class="text-top">{{userInfo?userInfo?.realName:'未登录'}}</view>
  13. <view class="text-bottom lv" v-if="userInfo">Lv&nbsp;&nbsp;&nbsp;{{userInfo?.userLevel||1}}&nbsp;&nbsp;></view>
  14. <view class="text-bottom" v-else>去登录注册&nbsp;>></view>
  15. </view>
  16. </view>
  17. <view class="info-top-right" @click="handleTurnPage('/pagesMy/information')">
  18. <image src="https://oss.familydaf.cn/sxsnfile/20251218/a4bdf4248ddd44909e8707c83fe33265.png"></image>
  19. </view>
  20. </view>
  21. <view class="info-tip">
  22. <view class="info-tip-pre adfacjb" @click="handleTurnPage('/pagesMy/information')">
  23. <view class="left">家庭公益名称:{{userInfo?userInfo.welfareName:'暂无'}}</view>
  24. <view class="right">
  25. <image src="https://oss.familydaf.cn/sxsnfile/20251218/938f573288ad401fbd1e57404a870059.png"></image>
  26. </view>
  27. </view>
  28. <view class="info-tip-pre adfacjb" @click="handleTurnPage('/pagesMy/information')">
  29. <view class="left">家庭公益口号:{{userInfo?userInfo.welfareSlogan:'暂无'}}</view>
  30. <view class="right">
  31. <image src="https://oss.familydaf.cn/sxsnfile/20251218/938f573288ad401fbd1e57404a870059.png"></image>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="box" style="margin-top: 40rpx;">
  37. <view class="box-title">公益记录</view>
  38. <view class="box-card adfacjb">
  39. <view class="box-card-pre adffcac red" @click="handleTurnPage('/pagesMy/heartNumber?loveValue='+numInfo?.loveValue)">
  40. <image class="top" src="https://oss.familydaf.cn/sxsnfile/20251218/046c057625704329a478d535cd1b4364.png"></image>
  41. <view class="num">{{(numInfo?.loveValue||0).toFixed(2)}}</view>
  42. <view class="text adf">
  43. <text>我的爱心值</text>
  44. <image src="https://oss.familydaf.cn/sxsnfile/20251218/2e8332c5f36a45cab3af336aa324d20c.png"></image>
  45. </view>
  46. </view>
  47. <view class="box-card-pre adffcac purple" @click="handleTurnPage('/pagesMy/archives')">
  48. <image class="top" src="https://oss.familydaf.cn/sxsnfile/20251218/ee5fffc2b10647ef9492150aed6bb29d.png"></image>
  49. <view class="num">{{(numInfo?.myArchives||0).toFixed(2)}}</view>
  50. <view class="text adf">
  51. <text>我的档案</text>
  52. <image src="https://oss.familydaf.cn/sxsnfile/20251218/6e9e879da03944a4911b48550e915641.png"></image>
  53. </view>
  54. </view>
  55. <view class="box-card-pre adffcac orange" @click="handleTurnPage('/pagesMy/volunteerHours?volunteerHours='+numInfo?.volunteerHours)">
  56. <image class="top" src="https://oss.familydaf.cn/sxsnfile/20251218/3fdb7e3c0d3c444ab03dd5f51a5e3fe0.png"></image>
  57. <view class="num">{{(numInfo?.volunteerHours||0).toFixed(2)}}</view>
  58. <view class="text adf">
  59. <text>义工时长(h)</text>
  60. <image src="https://oss.familydaf.cn/sxsnfile/20251218/625a9a7d454c4e7985bd7e12a9f1af93.png"></image>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="box" @click="handleTurnPage('/pagesMy/achievement')">
  66. <view class="box-title">我的成就</view>
  67. <view class="box-achievement adfacjb">
  68. <view class="box-achievement-left">收获<span>{{numInfo?.myMedals||0}}</span>项成就</view>
  69. <view class="box-achievement-right adfacjb">
  70. <view class="imgs"></view>
  71. <view class="jt">
  72. <image src="https://oss.familydaf.cn/sxsnfile/20251218/938f573288ad401fbd1e57404a870059.png"></image>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="box">
  78. <view class="box-title">其他功能</view>
  79. <view class="box-other adfacjb">
  80. <view class="box-other-pre adffcac" @click="handleTurnPage('/pagesMy/practice')">
  81. <image src="https://oss.familydaf.cn/sxsnfile/20251218/f6d2c342d9414909b4626e34909917c7.png"></image>
  82. <text>申领社会实践记录</text>
  83. </view>
  84. <view class="box-other-pre adffcac" @click="handleTurnPage('/pagesMy/familyMember')">
  85. <image src="https://oss.familydaf.cn/sxsnfile/20251218/248ed751f8bf4821b29cd236ec2dc78b.png"></image>
  86. <text>家庭成员</text>
  87. </view>
  88. <view class="box-other-pre adffcac" @click="handleTurnPage('/pagesMy/exclusiveScroll')">
  89. <image src="https://oss.familydaf.cn/sxsnfile/20251218/7ee3c42e8408489fb0768406d72b73b4.png"></image>
  90. <text>我的专享卷</text>
  91. </view>
  92. </view>
  93. </view>
  94. <CusTabbar :tabbarIndex="2"></CusTabbar>
  95. <login-register></login-register>
  96. </view>
  97. </template>
  98. <script setup name="">
  99. import CusTabbar from '@/components/CusTabbar/index.vue'
  100. import { ref, onMounted, watch, nextTick, getCurrentInstance } from 'vue'
  101. const { proxy } = getCurrentInstance();
  102. import { useUserStore } from '@/common/stores/user';
  103. const userStore = useUserStore();
  104. import { useGlobalShare } from '@/common/composables/useGlobalShare';
  105. const { isLogin } = useGlobalShare();
  106. const userInfo = ref(null)
  107. const numInfo = ref(null)
  108. const showLogin = () => {
  109. if(userInfo.value) return
  110. userStore.openLoginModal();
  111. }
  112. const handleTurnPage = (url) => {
  113. if(!isLogin()) return
  114. if(url == '/pagesMy/achievement'){
  115. url = `/pagesMy/achievement?numInfo=`+JSON.stringify(numInfo.value)
  116. }
  117. uni.navigateTo({ url })
  118. }
  119. const getUserInfo = () => {
  120. try{
  121. proxy.$api.get(`/wx/${JSON.parse(uni.getStorageSync('userInfo')).id}`).then(({data:res})=>{
  122. if(res.code!==0) return proxy.$showToast(res.msg)
  123. userInfo.value = res.data;
  124. })
  125. }catch(e){
  126. userInfo.value = null
  127. }
  128. }
  129. const getUserNums = () => {
  130. proxy.$api.get(`/wx/userWelfareData/${JSON.parse(uni.getStorageSync('userInfo')).id}`).then(({data:res})=>{
  131. if(res.code!==0) return proxy.$showToast(res.msg)
  132. numInfo.value = res.data;
  133. })
  134. }
  135. watch(()=>userStore.token,(newVal,oldVal)=>{
  136. if(oldVal!=newVal&&newVal){
  137. setTimeout(()=>{
  138. uni.showToast({
  139. title: '登录成功',
  140. icon: 'success'
  141. });
  142. },200)
  143. nextTick(()=>{
  144. getUserInfo()
  145. getUserNums()
  146. })
  147. }
  148. })
  149. onMounted(()=>{
  150. if(uni.getStorageSync('userInfo')){
  151. getUserInfo()
  152. getUserNums()
  153. }
  154. })
  155. </script>
  156. <style scoped lang="scss">
  157. .tab_page{
  158. .info{
  159. margin-top: 40rpx;
  160. position: relative;
  161. padding: 0 24rpx 0 16rpx;
  162. &-top{
  163. &-left{
  164. .avatar{
  165. width: 148rpx;
  166. height: 148rpx;
  167. }
  168. .text{
  169. margin-left: 24rpx;
  170. &-top{
  171. font-family: PingFang-SC, PingFang-SC;
  172. font-weight: bold;
  173. font-size: 40rpx;
  174. color: #151B29;
  175. line-height: 40rpx;
  176. }
  177. &-bottom{
  178. font-family: PingFangSC, PingFang SC;
  179. font-weight: 400;
  180. font-size: 26rpx;
  181. color: #151B29;
  182. line-height: 26rpx;
  183. margin-top: 26rpx;
  184. &.lv{
  185. width: 137rpx;
  186. height: 42rpx;
  187. background: url('https://oss.familydaf.cn/sxsnfile/20251218/b6e6f5b45ad34f91bbaf66c9890fc2cd.png') no-repeat;
  188. background-size: 100% 100%;
  189. font-family: PingFangSC, PingFang SC;
  190. font-weight: 600;
  191. font-size: 26rpx;
  192. color: #FFFFFF;
  193. line-height: 38rpx;
  194. padding-left: 16rpx;
  195. box-sizing: border-box;
  196. margin-top: 18rpx;
  197. }
  198. }
  199. }
  200. }
  201. &-right{
  202. image{
  203. width: 48rpx;
  204. height: 48rpx;
  205. }
  206. }
  207. }
  208. &-tip{
  209. margin-top: 4rpx;
  210. &-pre{
  211. margin-top: 36rpx;
  212. .left{
  213. font-family: PingFangSC, PingFang SC;
  214. font-weight: 400;
  215. font-size: 28rpx;
  216. color: #252525;
  217. line-height: 28rpx;
  218. }
  219. .right{
  220. image{
  221. width: 32rpx;
  222. height: 32rpx;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. .box{
  229. background: #FFFFFF;
  230. border-radius: 24rpx;
  231. padding: 40rpx 24rpx 36rpx;
  232. margin-top: 20rpx;
  233. position: relative;
  234. &-title{
  235. font-family: PingFang-SC, PingFang-SC;
  236. font-weight: bold;
  237. font-size: 36rpx;
  238. color: #151B29;
  239. line-height: 40rpx;
  240. }
  241. &-card{
  242. margin-top: 72rpx;
  243. &-pre{
  244. width: calc(100% / 3 - 8rpx);
  245. height: 200rpx;
  246. position: relative;
  247. background-size: 100% 100%;
  248. background-repeat: no-repeat;
  249. .top{
  250. width: 82rpx;
  251. height: 82rpx;
  252. position: absolute;
  253. left: 50%;
  254. margin-left: -41rpx;
  255. top: -32rpx;
  256. }
  257. .num{
  258. font-family: DINAlternate, DINAlternate;
  259. font-weight: bold;
  260. font-size: 40rpx;
  261. line-height: 40rpx;
  262. text-align: center;
  263. margin-top: 86rpx;
  264. }
  265. .text{
  266. margin-top: 20rpx;
  267. text{
  268. font-family: PingFangSC, PingFang SC;
  269. font-weight: 400;
  270. font-size: 24rpx;
  271. line-height: 24rpx;
  272. }
  273. image{
  274. width: 26rpx;
  275. height: 26rpx;
  276. margin-left: 6rpx;
  277. }
  278. }
  279. &.red{
  280. background-image: url('https://oss.familydaf.cn/sxsnfile/20251218/57acefa1a0084d1e980002e165668bc9.png');
  281. .num,.text text{
  282. color: #FC5768;
  283. }
  284. }
  285. &.purple{
  286. background-image: url('https://oss.familydaf.cn/sxsnfile/20251218/e0f97b6ca8864d2ca0c3dc48b07dae58.png');
  287. .num,.text text{
  288. color: #8360E8;
  289. }
  290. }
  291. &.orange{
  292. background-image: url('https://oss.familydaf.cn/sxsnfile/20251218/eabb899f7ab14010b61fb30ed24bd818.png');
  293. .num,.text text{
  294. color: #FF8200;
  295. }
  296. }
  297. }
  298. }
  299. &-achievement{
  300. margin-top: 24rpx;
  301. &-left{
  302. width: 210rpx;
  303. font-family: PingFangSC, PingFang SC;
  304. font-weight: 400;
  305. font-size: 24rpx;
  306. color: #676775;
  307. line-height: 24rpx;
  308. label{
  309. font-weight: bold;
  310. font-size: 32rpx;
  311. color: #EA3044;
  312. line-height: 32rpx;
  313. margin: 0 7rpx;
  314. }
  315. }
  316. &-right{
  317. width: calc(100% - 210rpx);
  318. .jt{
  319. image{
  320. width: 32rpx;
  321. height: 32rpx;
  322. }
  323. }
  324. }
  325. }
  326. &-other{
  327. margin-top: 39rpx;
  328. &-pre{
  329. width: calc(100% / 3);
  330. image{
  331. width: 48rpx;
  332. height: 48rpx;
  333. }
  334. text{
  335. font-family: PingFangSC, PingFang SC;
  336. font-weight: 400;
  337. font-size: 24rpx;
  338. color: #151B29;
  339. line-height: 33rpx;
  340. text-align: center;
  341. margin-top: 16rpx;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. </style>