news.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <!--消息-->
  2. <template>
  3. <div id="news">
  4. <Nav :title="$t('news.title')" :iconType="false"></Nav>
  5. <div class="content">
  6. <template v-if="newsList.length||noticeList.length">
  7. <div class="cell" v-for="item,index in newsList" :key="index">
  8. <div class="top" @click="goDetails(item)">
  9. <span>{{item.title}}</span>
  10. </div>
  11. <div class="center" @click="goDetails(item)">
  12. <span v-html="item.content"></span>
  13. </div>
  14. <div class="bottom">
  15. <span>{{item.createTime}}</span>
  16. <!-- <van-icon @click="deletes(item)" name="delete-o" color="#999999" size="14" /> -->
  17. </div>
  18. </div>
  19. <div class="cell" v-for="item,index in noticeList" :key="index+'s'">
  20. <div class="top" @click="goDetails(item)">
  21. <span>{{item.title}}</span>
  22. </div>
  23. <div class="center" @click="goDetails(item)">
  24. <span v-html="item.content"></span>
  25. </div>
  26. <div class="bottom">
  27. <span>{{item.createTime}}</span>
  28. <!-- <van-icon @click="deletes(item)" name="delete-o" color="#999999" size="14" /> -->
  29. </div>
  30. </div>
  31. </template>
  32. <template v-else>
  33. <van-empty :description="$t('news.none')"></van-empty>
  34. </template>
  35. </div>
  36. <van-overlay :show="loading" @click="loading = false">
  37. <div class="wrapper" @click.stop>
  38. <div class="block">
  39. <van-loading color="#1989fa" size="50" />
  40. </div>
  41. </div>
  42. </van-overlay>
  43. </div>
  44. </template>
  45. <script>
  46. import Nav from "@/components/pages/nav";
  47. import { getCustomerNotice } from "@/api/comp/news.js";
  48. export default {
  49. data() {
  50. return {
  51. newsList: [],
  52. noticeList: [],
  53. loading: true,
  54. };
  55. },
  56. mounted() {
  57. this.getData();
  58. // setTimeout(() => {
  59. // for (let i = 0; i < 5; i++) {
  60. // this.newsList.push({
  61. // title: "活动信息标题",
  62. // text: "活动信息活动信息活动信息活动信息活动信息活动信息活动信息活动信息活动信息活动信息",
  63. // time: "2022-08-12",
  64. // id: 1,
  65. // });
  66. // }
  67. // this.loading = false;
  68. // }, 1000);
  69. },
  70. methods: {
  71. getData() {
  72. this.loading = true;
  73. getCustomerNotice().then((res) => {
  74. if (res.code == 200) {
  75. this.newsList = res.data.notice;
  76. this.noticeList = res.data.customerNotice;
  77. this.loading = false;
  78. }
  79. });
  80. },
  81. goDetails(data) {
  82. if (data.title == this.$t('news.orderInformation')) {
  83. this.$router.push({
  84. path: "/toBePaid",
  85. query: { type: 2 }
  86. });
  87. } else {
  88. this.$router.push({ path: "/details", query: { data: data } });
  89. }
  90. },
  91. deletes(item) {
  92. this.$dialog
  93. .confirm({
  94. title: this.$t('news.tips'),
  95. message: this.$t('news.confirmTips'),
  96. confirmButtonText: this.$t('news.delete'),
  97. cancelButtonText: this.$t('news.cancel'),
  98. })
  99. .then(() => {
  100. // this.loading = true;
  101. // removeShopCarList(item.id).then((res) => {
  102. // if (res.code == 200) {
  103. // this.$toast({
  104. // type: "success",
  105. // message: "删除成功",
  106. // });
  107. // this.loading = false;
  108. // this.getData();
  109. // }
  110. // });
  111. })
  112. .catch(() => {
  113. this.$notify({ type: "warning", message: this.$t('news.massage') });
  114. });
  115. },
  116. },
  117. components: {
  118. Nav,
  119. },
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. #news {
  124. .content {
  125. background: #f9f9f9;
  126. padding: 0.12rem /* 12/100 */;
  127. box-sizing: border-box;
  128. color: #333333;
  129. min-height: calc(100vh - 1.28rem /* 128/100 */);
  130. .cell {
  131. width: 100%;
  132. background: #fff;
  133. border-radius: 0.05rem /* 5/100 */;
  134. box-shadow: 0px 0px 5px #e9e9e9;
  135. padding: 0.12rem /* 12/100 */;
  136. box-sizing: border-box;
  137. text-align: left;
  138. margin-bottom: 0.12rem /* 12/100 */;
  139. .top {
  140. font-size: 0.15rem /* 15/100 */;
  141. font-weight: bold;
  142. }
  143. .center {
  144. font-size: 0.14rem /* 14/100 */;
  145. // padding: 0.12rem /* 12/100 */ 0;
  146. margin: 0.12rem 0;
  147. overflow: hidden;
  148. text-overflow: ellipsis;
  149. width: 100%;
  150. display: -webkit-box;
  151. -webkit-box-orient: vertical;
  152. -webkit-line-clamp: 3; // 超过3行则显示省略号
  153. word-break: break-all;
  154. }
  155. .bottom {
  156. border-top: 1px solid #eeeeee;
  157. font-size: 0.13rem /* 13/100 */;
  158. padding: 0.12rem /* 12/100 */ 0;
  159. display: flex;
  160. justify-content: space-between;
  161. align-items: center;
  162. > span {
  163. color: #999999;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. </style>
  170. <style>
  171. #news .content .cell .center p {
  172. margin: 0;
  173. }
  174. #news img{
  175. display: none!important;
  176. }
  177. </style>