SiderInfo.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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 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 :size="50" :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-itle">部门:</div>
  26. <div class="item-content">{{ dataInfo.deptName }}</div>
  27. </div>
  28. <div class="info-item">
  29. <div class="item-itle">积分:</div>
  30. <div class="item-content blue">{{ dataInfo.surplusIntegral }}积分</div>
  31. </div>
  32. <div class="info-item">
  33. <div class="item-itle">排行:</div>
  34. <div class="item-content blue">5名</div>
  35. </div>
  36. <div class="info-item">
  37. <div class="item-itle">勋章:</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="50" :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-itle">部门:</div>
  50. <div class="item-content">{{ dataInfo.deptName }}</div>
  51. </div>
  52. <div class="info-item">
  53. <div class="item-itle">积分:</div>
  54. <div class="item-content blue">{{ dataInfo.surplusIntegral }}积分</div>
  55. </div>
  56. <div class="info-item">
  57. <div class="item-itle">排行:</div>
  58. <div class="item-content blue">5名</div>
  59. </div>
  60. <div class="info-item">
  61. <div class="item-itle">勋章:</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. getUserInfo(){
  85. const parmas = {
  86. userId:13683797487
  87. }
  88. useInfo(parmas).then(response=>{
  89. this.dataInfo = response.data.data;
  90. this.avatarUrl = this.dataInfo.httpFile + this.dataInfo.headImage;
  91. })
  92. },
  93. getHoursTip() {
  94. let date = new Date();
  95. if (date.getHours() >= 0 && date.getHours() < 12) {
  96. this.hoursTip = "上午好!"
  97. } else if (date.getHours() >= 12 && date.getHours() < 18) {
  98. this.hoursTip = "下午好!"
  99. } else {
  100. this.hoursTip = "晚上好!"
  101. }
  102. },
  103. // 保存滚动值,这是兼容的写法
  104. handleScroll() {
  105. var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  106. if (scrollTop >= 550) {
  107. this.isActive = true
  108. } else {
  109. this.isActive = false
  110. }
  111. },
  112. },
  113. mounted() {
  114. window.addEventListener('scroll', this.handleScroll)
  115. },
  116. destroyed() {
  117. // 离开该页面需要移除这个监听的事件,不然会报错
  118. window.removeEventListener('scroll', this.handleScroll)
  119. }
  120. }
  121. </script>
  122. <style>
  123. .aside {
  124. position: absolute;
  125. top: 0;
  126. right: 0;
  127. z-index: 1;
  128. }
  129. .aside.index-aside {
  130. width: 16.3rem;
  131. }
  132. .hot-list-wrap {
  133. /* padding: 1.33rem 0 0.66rem; */
  134. background-color: #fff;
  135. border-radius: 4px;
  136. margin-bottom: 1.25rem;
  137. }
  138. .timeline-index-view.sidebar-block {
  139. box-shadow: none;
  140. }
  141. .sidebar-block {
  142. background-color: #fff;
  143. box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05);
  144. border-radius: 2px;
  145. margin-bottom: 1rem;
  146. font-size: 1.16rem;
  147. line-height: 1.29;
  148. border-radius: 4px;
  149. color: #333;
  150. }
  151. .signin-tip {
  152. padding: 20px;
  153. background-color: #fff;
  154. box-sizing: border-box;
  155. }
  156. .first-line {
  157. display: flex;
  158. flex-direction: row;
  159. align-items: center;
  160. justify-content: space-between;
  161. }
  162. .first-line .icon-text {
  163. display: flex;
  164. flex-direction: column;
  165. }
  166. .first-line .btn {
  167. cursor: pointer;
  168. border-radius: 4px;
  169. height: 36px;
  170. width: 74px;
  171. box-sizing: border-box;
  172. display: flex;
  173. flex-direction: row;
  174. align-items: center;
  175. justify-content: center;
  176. border: 1px solid rgba(30, 128, 255, .3);
  177. background-color: rgba(30, 128, 255, .05);
  178. }
  179. .first-line .signed-text {
  180. color: #abcdff;
  181. }
  182. .first-line .sign-text {
  183. color: #1e80ff;
  184. }
  185. .first-line .btn-text {
  186. font-size: 14px;
  187. font-weight: 400;
  188. white-space: nowrap;
  189. }
  190. .first-line .title {
  191. color: #1d2129;
  192. font-size: 16px;
  193. font-weight: 600;
  194. line-height: 24px;
  195. }
  196. .second-line {
  197. color: #8a919f;
  198. font-size: 12px;
  199. font-weight: 400;
  200. line-height: 24px;
  201. margin-top: 2px;
  202. }
  203. .first-line .title-days {
  204. margin-left: 4px;
  205. color: #1e80ff;
  206. }
  207. .sidebar-block .avatar {
  208. display: flex;
  209. flex-direction: column;
  210. justify-content: center;
  211. align-items: center;
  212. }
  213. .avatar .name {
  214. margin-top: 2px;
  215. font-size: 1rem;
  216. font-weight: 600;
  217. color: #252933;
  218. }
  219. .sidebar-block .info {
  220. margin-top: 5px;
  221. }
  222. .info .info-item {
  223. font-size: 1rem;
  224. display: flex;
  225. justify-content: space-between;
  226. line-height: 2rem;
  227. }
  228. .info-item .blue {
  229. color: #1e80ff;
  230. }
  231. .sidebar-block.sticky-block {
  232. padding: 20px;
  233. background-color: #fff;
  234. box-sizing: border-box;
  235. position: fixed;
  236. box-shadow: none;
  237. opacity: 0;
  238. transition: all .2s;
  239. width: 16.3rem;
  240. z-index: -1;
  241. top: 67px;
  242. pointer-events: none;
  243. }
  244. .index-aside.sticky.top .sticky-block {
  245. top: 20px;
  246. }
  247. .index-aside.sticky .sticky-block {
  248. opacity: 1;
  249. top: 80px;
  250. z-index: 5;
  251. pointer-events: all;
  252. }</style>