SiderInfo.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <div class="index-aside aside" :class="{ 'sticky top': isActive }">
  3. <div class="signin-tip sidebar-block signin">
  4. <div class="first-line">
  5. <div class="icon-text">
  6. <span class="title">
  7. {{ hoursTip }}
  8. <!-- <span class="title-days">77天</span> -->
  9. </span>
  10. <div class="second-line">点亮在商城的每一天</div>
  11. </div>
  12. <button class="btn signedin-btn">
  13. <span @click="goToSignIn" v-if="dataInfo.signStatus==0" class="btn-text sign-text">去签到</span>
  14. <span v-else class="btn-text signed-text">已签到</span>
  15. </button>
  16. </div>
  17. </div>
  18. <div class="signin-tip sidebar-block">
  19. <div class="avatar">
  20. <el-avatar fit="fill" :size="65" :src="avatarUrl"></el-avatar>
  21. <span class="name">{{ dataInfo.userName }}</span>
  22. </div>
  23. <div class="info">
  24. <div class="info-item">
  25. <div class="item-title">部门:</div>
  26. <div :title="dataInfo.deptName" class="item-content" style="line-height: 1.5rem;">{{ dataInfo.deptName }}</div>
  27. </div>
  28. <div class="info-item">
  29. <div class="item-title">积分:</div>
  30. <div class="item-content blue">{{ dataInfo.surplusIntegral }}</div>
  31. </div>
  32. <div class="info-item">
  33. <div class="item-title">排行:</div>
  34. <div class="item-content blue">{{ dataInfo.nowtop }}</div>
  35. </div>
  36. <!-- <div class="info-item">
  37. <div class="item-title">勋章:</div>
  38. <div class="item-content blue">{{ dataInfo.medalCount }}枚</div>
  39. </div> -->
  40. </div>
  41. </div>
  42. <div class="sidebar-block sticky-block">
  43. <div class="avatar">
  44. <el-avatar :size="65" :src="avatarUrl"></el-avatar>
  45. <span class="name">{{ dataInfo.userName }}</span>
  46. </div>
  47. <div class="info">
  48. <div class="info-item">
  49. <div class="item-title">部门:</div>
  50. <div :title="dataInfo.deptName" class="item-content">{{ dataInfo.deptName }}</div>
  51. </div>
  52. <div class="info-item">
  53. <div class="item-title">积分:</div>
  54. <div class="item-content blue">{{ dataInfo.surplusIntegral }}</div>
  55. </div>
  56. <div class="info-item">
  57. <div class="item-title">排行:</div>
  58. <div class="item-content blue">{{ dataInfo.nowtop }}</div>
  59. </div>
  60. <!-- <div class="info-item">
  61. <div class="item-title">勋章:</div>
  62. <div class="item-content blue">{{ dataInfo.medalCount }}枚</div>
  63. </div> -->
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import { useInfo } from "@/api/allApi";
  70. export default {
  71. data() {
  72. return {
  73. hoursTip:'你好!',
  74. isActive: false,
  75. dataInfo:{},
  76. avatarUrl: "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
  77. };
  78. },
  79. created() {
  80. this.getUserInfo();
  81. this.getHoursTip()
  82. },
  83. methods: {
  84. goToSignIn(){
  85. this.$router.push({
  86. path: '/home/signIn',
  87. });
  88. },
  89. getUserInfo(){
  90. useInfo().then(response=>{
  91. this.dataInfo = response.data.data;
  92. this.avatarUrl = this.dataInfo.httpFile + this.dataInfo.headImage;
  93. })
  94. },
  95. getHoursTip() {
  96. let date = new Date();
  97. if (date.getHours() >= 0 && date.getHours() < 12) {
  98. this.hoursTip = "上午好!"
  99. } else if (date.getHours() >= 12 && date.getHours() < 18) {
  100. this.hoursTip = "下午好!"
  101. } else {
  102. this.hoursTip = "晚上好!"
  103. }
  104. },
  105. // 保存滚动值,这是兼容的写法
  106. handleScroll() {
  107. var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  108. if (scrollTop >= 550) {
  109. this.isActive = true
  110. } else {
  111. this.isActive = false
  112. }
  113. },
  114. },
  115. mounted() {
  116. window.addEventListener('scroll', this.handleScroll)
  117. },
  118. destroyed() {
  119. // 离开该页面需要移除这个监听的事件,不然会报错
  120. window.removeEventListener('scroll', this.handleScroll)
  121. }
  122. }
  123. </script>
  124. <style>
  125. .aside {
  126. position: absolute;
  127. top: 0;
  128. right: 0;
  129. z-index: 1;
  130. }
  131. .aside.index-aside {
  132. width: 16.3rem;
  133. }
  134. .hot-list-wrap {
  135. /* padding: 1.33rem 0 0.66rem; */
  136. background-color: #fff;
  137. border-radius: 4px;
  138. margin-bottom: 1.25rem;
  139. }
  140. .timeline-index-view.sidebar-block {
  141. box-shadow: none;
  142. }
  143. .sidebar-block {
  144. background-color: #fff;
  145. box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05);
  146. border-radius: 2px;
  147. margin-bottom: 1rem;
  148. font-size: 1.16rem;
  149. line-height: 1.29;
  150. border-radius: 4px;
  151. color: #333;
  152. }
  153. .signin-tip {
  154. padding: 20px;
  155. background-color: #fff;
  156. box-sizing: border-box;
  157. }
  158. .first-line {
  159. display: flex;
  160. flex-direction: row;
  161. align-items: center;
  162. justify-content: space-between;
  163. }
  164. .first-line .icon-text {
  165. display: flex;
  166. flex-direction: column;
  167. }
  168. .first-line .btn {
  169. cursor: pointer;
  170. border-radius: 4px;
  171. height: 36px;
  172. width: 74px;
  173. box-sizing: border-box;
  174. display: flex;
  175. flex-direction: row;
  176. align-items: center;
  177. justify-content: center;
  178. border: 1px solid rgba(30, 128, 255, .3);
  179. background-color: rgba(30, 128, 255, .05);
  180. }
  181. .first-line .signed-text {
  182. color: #abcdff;
  183. }
  184. .first-line .sign-text {
  185. color: #1e80ff;
  186. }
  187. .first-line .btn-text {
  188. font-size: 14px;
  189. font-weight: 400;
  190. white-space: nowrap;
  191. }
  192. .first-line .title {
  193. color: #1d2129;
  194. font-size: 16px;
  195. font-weight: 600;
  196. line-height: 24px;
  197. }
  198. .second-line {
  199. color: #8a919f;
  200. font-size: 12px;
  201. font-weight: 400;
  202. line-height: 24px;
  203. margin-top: 2px;
  204. }
  205. .first-line .title-days {
  206. margin-left: 4px;
  207. color: #1e80ff;
  208. }
  209. .sidebar-block .avatar {
  210. display: flex;
  211. flex-direction: column;
  212. justify-content: center;
  213. align-items: center;
  214. }
  215. .avatar .name {
  216. margin-top: 2px;
  217. font-size: 1rem;
  218. font-weight: 600;
  219. color: #252933;
  220. }
  221. .sidebar-block .info {
  222. margin-top: 5px;
  223. }
  224. .info .info-item {
  225. font-size: 1rem;
  226. display: flex;
  227. justify-content: space-between;
  228. line-height: 1.5rem;
  229. }
  230. .info-item .item-title{
  231. width: 62px;
  232. }
  233. .info-item .text-overflow {
  234. white-space: nowrap;
  235. overflow: hidden;
  236. text-overflow: ellipsis;
  237. }
  238. .info-item .blue {
  239. color: #1e80ff;
  240. }
  241. .sidebar-block.sticky-block {
  242. padding: 20px;
  243. background-color: #fff;
  244. box-sizing: border-box;
  245. position: fixed;
  246. box-shadow: none;
  247. opacity: 0;
  248. transition: all .2s;
  249. width: 16.3rem;
  250. z-index: -1;
  251. top: 67px;
  252. pointer-events: none;
  253. }
  254. .index-aside.sticky.top .sticky-block {
  255. top: 20px;
  256. }
  257. .index-aside.sticky .sticky-block {
  258. opacity: 1;
  259. top: 80px;
  260. z-index: 5;
  261. pointer-events: all;
  262. }
  263. .el-avatar>img {
  264. width: 100%;
  265. }
  266. </style>