Index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div class="timeline-container">
  3. <div class="timeline-content">
  4. <div class="timeline-entry-list">
  5. <div class="hot-list-wrap">
  6. <el-empty :image-size="200" v-if="bannerList.length < 1"></el-empty>
  7. <el-carousel arrow="never" indicator-position="none" height="150px" trigger="click" :interval="5000" v-if="bannerList.length > 0">
  8. <el-carousel-item v-for="(item, index) in bannerList" :key="index">
  9. <router-link to="/productTrials"><img style="width: 100%; height: 100%" :src="item.url" /></router-link>
  10. </el-carousel-item>
  11. </el-carousel>
  12. </div>
  13. </div>
  14. <div class="index-aside aside" :class="{'sticky top':isActive}">
  15. <div class="signin-tip sidebar-block signin">
  16. <div class="first-line">
  17. <div class="icon-text">
  18. <span class="title">
  19. 连续签到<span class="title-days">77天</span>
  20. </span>
  21. <div class="second-line">点亮在社区的每一天</div>
  22. </div>
  23. <button class="btn signedin-btn">
  24. <span class="btn-text signed-text">已签到</span>
  25. </button>
  26. </div>
  27. </div>
  28. <div class="signin-tip sidebar-block">
  29. <div class="avatar">
  30. <el-avatar :size="50" :src="circleUrl"></el-avatar>
  31. <span class="name">兔子爱吃香蕉皮儿</span>
  32. </div>
  33. <div class="info">
  34. <div class="info-item">
  35. <div class="item-itle">部门:</div>
  36. <div class="item-content">软件工程院</div>
  37. </div>
  38. <div class="info-item">
  39. <div class="item-itle">我的积分:</div>
  40. <div class="item-content blue">10000积分</div>
  41. </div>
  42. <div class="info-item">
  43. <div class="item-itle">我的勋章:</div>
  44. <div class="item-content blue">50个</div>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="sidebar-block sticky-block">
  49. <div class="avatar">
  50. <el-avatar :size="50" :src="circleUrl"></el-avatar>
  51. <span class="name">兔子爱吃香蕉皮儿</span>
  52. </div>
  53. <div class="info">
  54. <div class="info-item">
  55. <div class="item-itle">部门:</div>
  56. <div class="item-content">软件工程院</div>
  57. </div>
  58. <div class="info-item">
  59. <div class="item-itle">我的积分:</div>
  60. <div class="item-content blue">10000积分</div>
  61. </div>
  62. <div class="info-item">
  63. <div class="item-itle">我的勋章:</div>
  64. <div class="item-content blue">50个</div>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </template>
  72. <script lang="ts">
  73. export default {
  74. name: 'AppSidebar',
  75. data() {
  76. return {
  77. isActive:false,
  78. circleUrl: "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png",
  79. bannerList: [
  80. {
  81. url: require('@/assets/image/banner.png')
  82. },
  83. {
  84. url: require('@/assets/image/banner1.png')
  85. }
  86. ],
  87. };
  88. },
  89. methods:{
  90. // 保存滚动值,这是兼容的写法
  91. handleScroll () {
  92. var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
  93. if(scrollTop >= 550){
  94. this.isActive = true
  95. }else{
  96. this.isActive = false
  97. }
  98. },
  99. },
  100. mounted () {
  101. window.addEventListener('scroll', this.handleScroll, true)
  102. },
  103. destroyed () {
  104. // 离开该页面需要移除这个监听的事件,不然会报错
  105. window.removeEventListener('scroll', this.handleScroll)
  106. }
  107. }
  108. </script>
  109. <style>
  110. .timeline-container{
  111. margin: 0 auto;
  112. height: 1500px;
  113. }
  114. .timeline-entry-list{
  115. margin-right: 17.5rem;
  116. border-radius: 2px;
  117. width: 720px;
  118. position: relative;
  119. }
  120. .aside{
  121. position: absolute;
  122. top: 0;
  123. right: 0;
  124. z-index: 1;
  125. }
  126. .aside.index-aside{
  127. width: 16.3rem;
  128. }
  129. .hot-list-wrap{
  130. /* padding: 1.33rem 0 0.66rem; */
  131. background-color: #fff;
  132. border-radius: 4px;
  133. margin-bottom: 1.66rem;
  134. }
  135. .timeline-index-view.sidebar-block {
  136. box-shadow: none;
  137. }
  138. .sidebar-block{
  139. background-color: #fff;
  140. box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);
  141. border-radius: 2px;
  142. margin-bottom: 1rem;
  143. font-size: 1.16rem;
  144. line-height: 1.29;
  145. border-radius: 4px;
  146. color: #333;
  147. }
  148. .signin-tip{
  149. padding: 20px;
  150. background-color: #fff;
  151. box-sizing: border-box;
  152. }
  153. .first-line{
  154. display: flex;
  155. flex-direction: row;
  156. align-items: center;
  157. justify-content: space-between;
  158. }
  159. .first-line .icon-text{
  160. display: flex;
  161. flex-direction: column;
  162. }
  163. .first-line .btn{
  164. border-radius: 4px;
  165. height: 36px;
  166. width: 74px;
  167. box-sizing: border-box;
  168. display: flex;
  169. flex-direction: row;
  170. align-items: center;
  171. justify-content: center;
  172. border: 1px solid rgba(30,128,255,.3);
  173. background-color: rgba(30,128,255,.05);
  174. }
  175. .first-line .signed-text{
  176. color: #abcdff;
  177. }
  178. .first-line .btn-text{
  179. color: #1e80ff;
  180. font-size: 14px;
  181. font-weight: 400;
  182. white-space: nowrap;
  183. }
  184. .first-line .title{
  185. color: #1d2129;
  186. font-size: 16px;
  187. font-weight: 600;
  188. line-height: 24px;
  189. }
  190. .second-line{
  191. color: #8a919f;
  192. font-size: 12px;
  193. font-weight: 400;
  194. line-height: 24px;
  195. margin-top: 2px;
  196. }
  197. .first-line .title-days{
  198. margin-left: 4px;
  199. color: #1e80ff;
  200. }
  201. .sidebar-block .avatar{
  202. display: flex;
  203. flex-direction: column;
  204. justify-content: center;
  205. align-items: center;
  206. }
  207. .avatar .name{
  208. margin-top: 2px;
  209. font-size: 1rem;
  210. font-weight: 600;
  211. color: #252933;
  212. }
  213. .sidebar-block .info{
  214. margin-top: 5px;
  215. }
  216. .info .info-item{
  217. font-size: 1rem;
  218. display: flex;
  219. justify-content: space-between;
  220. line-height: 2rem;
  221. }
  222. .info-item .blue{
  223. color: #1e80ff;
  224. }
  225. .sidebar-block.sticky-block{
  226. padding: 20px;
  227. background-color: #fff;
  228. box-sizing: border-box;
  229. position: fixed;
  230. box-shadow: none;
  231. opacity: 0;
  232. transition: all .2s;
  233. width: 16.3rem;
  234. z-index: -1;
  235. top: 67px;
  236. pointer-events: none;
  237. }
  238. .index-aside.sticky.top .sticky-block{
  239. top: 20px;
  240. }
  241. .index-aside.sticky .sticky-block{
  242. opacity: 1;
  243. top: 80px;
  244. z-index: 5;
  245. pointer-events: all;
  246. }
  247. </style>