Index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div id="myHome" class="app">
  3. <van-sticky :offset-top="0">
  4. <van-nav-bar title="我的" />
  5. </van-sticky>
  6. <div class="userData">
  7. <van-image
  8. class="bannerImage"
  9. round
  10. fit="cover"
  11. :src="require('../../assets/image/partySchool.jpg')"
  12. />
  13. <div class="user">
  14. <p class="userName" v-text="userInfo.userName || '游客'"></p>
  15. <p class="van-ellipsis userSubName">积分:{{ userInfo.score }}</p>
  16. </div>
  17. </div>
  18. <van-cell-group>
  19. <van-cell
  20. title="我的支部"
  21. @click="() => toUrl('myPartybranch')"
  22. clickable
  23. is-link
  24. />
  25. <!-- <van-cell title="消息" @click="() => toUrl('news')" clickable is-link /> -->
  26. <van-cell
  27. title="收藏"
  28. @click="() => toUrl('collection')"
  29. clickable
  30. is-link
  31. />
  32. <van-cell
  33. title="历史记录"
  34. @click="() => toUrl('integral')"
  35. clickable
  36. is-link
  37. />
  38. <van-cell title="分享" @click="showShare = true" clickable is-link />
  39. <van-cell title="关于" @click="() => toUrl('about')" clickable is-link />
  40. <!-- <van-cell title="设置" @click="() => toUrl('5')" clickable is-link /> -->
  41. </van-cell-group>
  42. <van-share-sheet
  43. v-model="showShare"
  44. title="立即分享给好友"
  45. :options="options"
  46. @select="onSelect"
  47. />
  48. </div>
  49. </template>
  50. <script>
  51. import { getUserInfo, setUserInfo } from "@/utils/common.js";
  52. import {
  53. NavBar as vanNavBar,
  54. Sticky as vanSticky,
  55. Image as VanImage,
  56. Cell as vanCell,
  57. CellGroup as vanCellGroup,
  58. ShareSheet as vanShareSheet
  59. } from "vant";
  60. import "vant/lib/cell-group/style";
  61. import "vant/lib/nav-bar/style";
  62. import "vant/lib/share-sheet/style";
  63. import "vant/lib/sticky/style";
  64. import "vant/lib/image/style";
  65. import "vant/lib/cell/style";
  66. import { getUser } from "@/api/user/user.js";
  67. export default {
  68. name: "app",
  69. data: function() {
  70. return {
  71. userInfo: {},
  72. showShare: false,
  73. options: [
  74. { name: "微信", icon: "wechat" },
  75. { name: "微博", icon: "weibo" },
  76. { name: "复制链接", icon: "link" }
  77. ]
  78. };
  79. },
  80. methods: {
  81. toUrl(id) {
  82. if (!isNaN(Number(id))) return;
  83. window.parent
  84. ? (window.parent.location = id + ".html")
  85. : (location = id + ".html");
  86. },
  87. onSelect() {
  88. this.showShare = false;
  89. }
  90. },
  91. mounted() {
  92. this.userInfo = getUserInfo();
  93. getUser().then(res => {
  94. this.userInfo.score = (res || {}).score;
  95. setUserInfo({
  96. userName: this.userInfo.userName,
  97. score: this.userInfo.score
  98. });
  99. });
  100. },
  101. beforeDestroy: function() {},
  102. components: {
  103. vanNavBar,
  104. vanSticky,
  105. vanCell,
  106. vanCellGroup,
  107. VanImage,
  108. vanShareSheet
  109. }
  110. };
  111. </script>
  112. <style lang="scss" scoped>
  113. #myHome {
  114. .userData {
  115. padding: 1em;
  116. .bannerImage {
  117. width: 3em;
  118. height: 3em;
  119. margin-right: 1em;
  120. vertical-align: middle;
  121. }
  122. .user {
  123. display: inline-block;
  124. vertical-align: middle;
  125. font-size: 0.2rem;
  126. .userSubName {
  127. margin-top: 0.5em;
  128. font-size: 0.12rem;
  129. color: #aab3ba;
  130. }
  131. }
  132. }
  133. }
  134. </style>