Index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <div class="timeline-container">
  3. <div class="timeline-content">
  4. <div class="timeline-entry-list">
  5. <!-- <img src="@/assets/image/banner4.png" alt="banner" class="banner"> -->
  6. <div class="hot-list-wrap">
  7. <el-empty :image-size="60" v-if="publicizeBanner.length < 1"></el-empty>
  8. <el-carousel indicator-position="none" height="120px" :interval="5000" v-if="publicizeBanner.length > 0">
  9. <el-carousel-item v-for="(item, index) in publicizeBanner" :key="index">
  10. <router-link :to="item.remark">
  11. <img style="width: 100%; height: 100%" :src="item.dictValue" class="banner" />
  12. </router-link>
  13. </el-carousel-item>
  14. </el-carousel>
  15. </div>
  16. <div class="hot-list-wrap">
  17. <el-empty :image-size="60" v-if="activityBanner.length < 1"></el-empty>
  18. <el-carousel indicator-position="none" height="120px" :interval="5000" v-if="activityBanner.length > 0">
  19. <el-carousel-item v-for="(item, index) in activityBanner" :key="index">
  20. <router-link :to="item.remark">
  21. <img style="width: 100%; height: 100%" :src="item.dictValue" class="banner" />
  22. </router-link>
  23. </el-carousel-item>
  24. </el-carousel>
  25. </div>
  26. <!-- <div class="entry-list-container" style="margin-bottom: 20px;">
  27. <div class="tab-header" style="border-bottom:none">
  28. <span class="tab-title">特价商品</span>
  29. </div>
  30. <div class="special-goods-list">
  31. <div class="special-goods-item" v-for="(item,index) in specialGoodsList" :key="index">
  32. <img width="100%" :src="item.url" alt="">
  33. <div class="ctrl-box">
  34. <a class="label" :href="item.path">
  35. <span>{{ item.name }}</span>
  36. </a>
  37. <a class="status" href="/">
  38. <span>已参与</span>
  39. </a>
  40. </div>
  41. </div>
  42. </div>
  43. </div> -->
  44. <div class="entry-list-container">
  45. <div class="tab-header">
  46. <span class="tab-title">最新通知</span>
  47. </div>
  48. <el-empty v-if="dataList.length==0" :image-size="200"></el-empty>
  49. <div v-else class="entry-list">
  50. <div v-for="(item,index) in dataList" :key="index" @click="handleClickMag(item.msgId)" class="list-item">
  51. <div class="meta-container">
  52. <div class="user-message">
  53. {{ item.type==2 ? '生日祝福' : '系统通知'}}
  54. </div>
  55. <div class="dividing"></div>
  56. <div class="date">{{ item.createTime }}</div>
  57. </div>
  58. <div class="main">
  59. <div class="info-box">
  60. <div class="title">
  61. {{ item.title }}
  62. </div>
  63. <div class="description">
  64. {{ item.subTitle }}
  65. </div>
  66. </div>
  67. <img v-if="item.imgUrl" :src="item.imgUrl" :alt="item.title" class="lazy thumb">
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <SiderInfo></SiderInfo>
  74. </div>
  75. </div>
  76. </template>
  77. <script scoped>
  78. import { msgList,dictList } from "@/api/allApi";
  79. import SiderInfo from '@/components/SiderInfo.vue';
  80. import { debounce } from '@/utils/index';
  81. export default{
  82. components: {
  83. SiderInfo
  84. },
  85. data() {
  86. return {
  87. dataInfo:'',
  88. publicizeBanner:[],
  89. activityBanner:[],
  90. bannerList: [],
  91. specialGoodsList:[
  92. {
  93. id:1,
  94. path:'/home/pointsMall/redeem?id=20&name=goodsNotice&type=8',
  95. url:'https://xiaoyou.dgtis.com/images/image/2023/07/05/pjwrhbotzayyny9vk1be.jpg',
  96. name:'特价商品',
  97. },
  98. {
  99. id:2,
  100. path:'/home/pointsMall/redeem?id=19&name=goodsNotice&type=8',
  101. url:'https://xiaoyou.dgtis.com/images/image/2023/07/05/pjwrhbotzayyny9vk1be.jpg',
  102. name:'限时商品',
  103. },
  104. {
  105. id:3,
  106. path:'/home/pointsMall/redeem?id=18&name=goodsNotice&type=8',
  107. url:'https://xiaoyou.dgtis.com/images/image/2023/07/05/pjwrhbotzayyny9vk1be.jpg',
  108. name:'团购商品',
  109. },
  110. ],
  111. dataList:[],
  112. page:1,
  113. pages:1,
  114. };
  115. },
  116. created(){
  117. this.getDataList();
  118. this.getBannerList();
  119. },
  120. methods:{
  121. getBannerList(){
  122. dictList({dictType:'publicize_banner'}).then(response=>{
  123. this.publicizeBanner = response.data.data;
  124. })
  125. dictList({dictType:'activity_banner'}).then(response=>{
  126. this.activityBanner = response.data.data;
  127. })
  128. },
  129. handleClickMag(id) {
  130. this.$router.push({
  131. path: '/home/index/msgDetail',
  132. query: {
  133. id: id,
  134. }
  135. });
  136. },
  137. getDataList(){
  138. let data = {
  139. limit:10,
  140. page:this.page,
  141. type:'0,2',
  142. };
  143. msgList(data).then(response=>{
  144. if(this.page==1){
  145. this.dataList = response.data.data.list;
  146. this.page = response.data.data.pageNum;
  147. this.pages = response.data.data.pages;
  148. }else{
  149. this.dataList = [
  150. ...this.dataList,
  151. ...response.data.data.list
  152. ]
  153. }
  154. ++this.page
  155. })
  156. },
  157. // 保存滚动值,这是兼容的写法
  158. handleScroll () {
  159. //变量scrollTop是滚动条滚动时,距离顶部的距离
  160. var scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
  161. //变量windowHeight是可视区的高度
  162. var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
  163. //变量scrollHeight是滚动条的总高度
  164. var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
  165. //滚动条到底部的条件
  166. console.log("距顶部---"+scrollTop+"可视区高度---"+windowHeight+"滚动条总高度---"+scrollHeight);
  167. if(scrollHeight - (scrollTop+windowHeight) < 1){
  168. if(this.page > this.pages){
  169. return
  170. }else{
  171. this.getDataList();
  172. }
  173. }
  174. },
  175. },
  176. mounted () {
  177. window.addEventListener('scroll', debounce(this.handleScroll,500));
  178. },
  179. destroyed () {
  180. // 离开该页面需要移除这个监听的事件,不然会报错
  181. window.removeEventListener('scroll', this.handleScroll);
  182. }
  183. }
  184. </script>
  185. <style scoped>
  186. .banner {
  187. width: 100%;
  188. height: 100px;
  189. background-color: #2c82fe;
  190. border-radius: 4px;
  191. margin-bottom: 15px;
  192. display: block;
  193. }
  194. .timeline-container{
  195. margin: 0 auto;
  196. }
  197. .timeline-entry-list{
  198. margin-right: 17.5rem;
  199. border-radius: 2px;
  200. width: 720px;
  201. position: relative;
  202. }
  203. .entry-list-container{
  204. background-color: #fff;
  205. border-radius: 4px;
  206. }
  207. .entry-list-container .tab-header {
  208. display: flex;
  209. align-items: center;
  210. justify-content: space-between;
  211. padding: 20px 20px 16px;
  212. border-bottom: 1px solid #e5e6eb;
  213. overflow: hidden;
  214. }
  215. .tab-header .tab-title {
  216. white-space: nowrap;
  217. font-size: 18px;
  218. font-weight: 600;
  219. }
  220. .entry-list{
  221. width: 100%;
  222. background-color: #fff;
  223. position: relative;
  224. }
  225. .list-item:hover {
  226. background: #fafafa;
  227. }
  228. .list-item{
  229. position: relative;
  230. cursor: pointer;
  231. padding: 12px 20px 0;
  232. }
  233. .list-item .meta-container{
  234. display: flex;
  235. align-items: center;
  236. }
  237. .list-item .meta-container .user-message{
  238. max-width: 162px;
  239. font-size: 13px;
  240. line-height: 22px;
  241. color: #4e5969;
  242. white-space: nowrap;
  243. overflow: hidden;
  244. text-overflow: ellipsis;
  245. word-break: break-all;
  246. }
  247. .list-item .meta-container .dividing{
  248. line-height: 22px;
  249. width: 1px;
  250. height: 14px;
  251. background: #e5e6eb;
  252. margin: 0 8px;
  253. }
  254. .list-item .meta-container .date{
  255. line-height: 22px;
  256. font-size: 13px;
  257. color: #86909c;
  258. }
  259. .list-item .main{
  260. margin-top: 6px;
  261. padding-bottom: 12px;
  262. display: flex;
  263. border-bottom: 1px solid #e5e6eb;
  264. }
  265. .list-item .main .info-box{
  266. flex-grow: 1;
  267. }
  268. .list-item .main .info-box .title:visited {
  269. color: #86909c;
  270. }
  271. .list-item .main .info-box .title{
  272. font-weight: 700;
  273. font-size: 16px;
  274. line-height: 24px;
  275. color: #1d2129;
  276. margin-bottom: 8px;
  277. display: -webkit-box;
  278. overflow: hidden;
  279. text-overflow: ellipsis;
  280. -webkit-box-orient: vertical;
  281. -webkit-line-clamp: 1;
  282. }
  283. .list-item .main .info-box .description{
  284. font-weight: 400;
  285. font-size: 13px;
  286. line-height: 22px;
  287. color: #86909c;
  288. display: -webkit-box;
  289. overflow: hidden;
  290. text-overflow: ellipsis;
  291. -webkit-box-orient: vertical;
  292. -webkit-line-clamp: 2;
  293. }
  294. .list-item .thumb{
  295. flex: 0 0 auto;
  296. width: 120px;
  297. height: 80px;
  298. margin-left: 24px;
  299. border-radius: 2px;
  300. }
  301. .special-goods-list{
  302. display: flex;
  303. justify-content: space-between;
  304. align-items: center;
  305. }
  306. .special-goods-list .special-goods-item{
  307. position: relative;
  308. /* padding: 0 6px; */
  309. width: 230px;
  310. height: 169px;
  311. min-width: 0;
  312. }
  313. .special-goods-item .ctrl-box .label{
  314. position: absolute;
  315. left: 20px;
  316. top: 40px;
  317. line-height: 32px;
  318. height: 32px;
  319. width: 100px;
  320. text-align: center;
  321. font-size: 16px;
  322. z-index: 1;
  323. color: black;
  324. background-color: #fff;
  325. border: 1px solid #fff;
  326. /* border-radius: 6px; */
  327. font-weight: 800;
  328. }
  329. .special-goods-item .ctrl-box .status{
  330. position: absolute;
  331. left: 20px;
  332. top: 70px;
  333. line-height: 32px;
  334. height: 32px;
  335. width: 100px;
  336. text-align: center;
  337. font-size: 16px;
  338. z-index: 1;
  339. color: #fff;
  340. background-color: rgba(0, 0, 0, .2);
  341. border: 1px solid #fff;
  342. border-radius: 6px;
  343. font-weight: 300;
  344. }
  345. /* .special-goods-item .ctrl-box .label:hover {
  346. background-color: rgba(0, 0, 0, .4);
  347. }
  348. .special-goods-item .ctrl-box .status:hover {
  349. background-color: rgba(0, 0, 0, .4);
  350. } */
  351. </style>