index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view>
  3. <u-tabs
  4. :list="types"
  5. :activeStyle="{ fontWeight: 'bold', color: '#C30D23' }"
  6. lineColor="#C30D23"
  7. keyName="classname"
  8. @change="tabsChange"
  9. />
  10. <view class="search-box">
  11. <view hover-class="navigator-hover" class="switch" @click="changeStatus">
  12. <view class="status" :class="activeStatus == '全部' ? 'active' : ''">
  13. 全部
  14. </view>
  15. <view class="status" :class="activeStatus != '全部' ? 'active' : ''">
  16. 未读
  17. </view>
  18. </view>
  19. <u-search
  20. placeholder="搜索关键字"
  21. bgColor="#fff"
  22. v-model="keyword"
  23. @search="onSearch"
  24. @clear="onSearch"
  25. :showAction="false"
  26. />
  27. </view>
  28. <My_listbox ref="List" @getlist="getList">
  29. <view style="height: 5px" />
  30. <navigator
  31. :url="'/packageA/affiche/detail?id=' + item.sat_noticeid"
  32. class="item"
  33. v-for="item in list"
  34. :key="item.sat_noticeid"
  35. hover-class="navigator-hover"
  36. >
  37. <view class="title">{{ item.title }}</view>
  38. <view class="line" />
  39. <view class="date">{{ item.checkdate }}</view>
  40. <view
  41. class="readstatus"
  42. :style="{
  43. color: colors[item.readstatus].color,
  44. background: colors[item.readstatus].back,
  45. }"
  46. >{{ item.readstatus }}</view
  47. >
  48. </navigator>
  49. </My_listbox>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. activeStatus: "全部",
  57. keyword: "",
  58. list: [],
  59. types: [],
  60. content: {
  61. where: {
  62. condition: "",
  63. sat_notice_classid: "",
  64. isread: "", //0:已读.1:已知,2:未读
  65. },
  66. },
  67. colors: {
  68. 已读: {
  69. color: "#E3041F",
  70. back: "#FFF0F2",
  71. },
  72. 未读: {
  73. color: "#FFFFFF",
  74. back: "#E3041F",
  75. },
  76. 已知: {
  77. color: "#999999",
  78. back: "#EEEEEE",
  79. },
  80. },
  81. };
  82. },
  83. onLoad() {
  84. uni.setNavigationBarTitle({
  85. title: "企业公告",
  86. });
  87. this.getTypes();
  88. this.getList();
  89. },
  90. onShow() {
  91. this.updateList();
  92. },
  93. methods: {
  94. getTypes() {
  95. this.$Http
  96. .basic({
  97. id: "20221101094603",
  98. content: {
  99. pageNumber: 1,
  100. pageSize: 9999,
  101. where: {
  102. condition: "",
  103. isenable: 1,
  104. },
  105. },
  106. })
  107. .then((res) => {
  108. console.log("获取通告分类", res);
  109. if (this.cutoff(res.msg)) return;
  110. if (res.data.length > 1) {
  111. res.data.unshift({
  112. classname: "全部",
  113. sat_notice_classid: "",
  114. });
  115. this.types = res.data;
  116. }
  117. });
  118. },
  119. getList(init = false) {
  120. if (this.paging(this.content, init)) return;
  121. this.$Http
  122. .basic({
  123. id: "20221111090904",
  124. content: this.content,
  125. })
  126. .then((res) => {
  127. this.$refs.List.RefreshToComplete();
  128. console.log("获取通告列表", res);
  129. if (this.cutoff(res.msg)) return;
  130. this.list =
  131. res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  132. this.content = this.$refs.List.paging(this.content, res);
  133. });
  134. },
  135. updateList() {
  136. if (this.content.pageNumber && this.content.pageNumber >= 2) {
  137. let content = this.paging(this.content, true, true);
  138. this.$Http
  139. .basic({
  140. id: "20221111090904",
  141. content,
  142. })
  143. .then((res) => {
  144. console.log("更新通告列表", res);
  145. if (this.cutoff(res.msg)) return;
  146. this.list = res.data;
  147. this.$refs.List.paging(content, res, true);
  148. });
  149. }
  150. },
  151. changeStatus() {
  152. this.activeStatus = this.activeStatus == "全部" ? "未读" : "全部";
  153. this.content.where.isread = this.activeStatus == "全部" ? "" : 2;
  154. this.getList(true);
  155. },
  156. tabsChange(e) {
  157. this.content.where.sat_notice_classid = e.sat_notice_classid;
  158. this.getList(true);
  159. },
  160. onSearch(e) {
  161. this.content.where.condition = e || "";
  162. this.getList(true);
  163. },
  164. },
  165. };
  166. </script>
  167. <style lang="scss">
  168. /deep/ .u-search__content {
  169. height: 30px !important;
  170. .uni-input-wrapper {
  171. font-size: 14px;
  172. }
  173. .u-icon__icon {
  174. font-size: 22px !important;
  175. }
  176. }
  177. .search-box {
  178. display: flex;
  179. align-items: center;
  180. padding: 0 10px;
  181. margin-top: 10px;
  182. margin-bottom: 5px;
  183. box-sizing: border-box;
  184. .switch {
  185. display: flex;
  186. width: 96px;
  187. height: 30px;
  188. background: #fff;
  189. margin-right: 10px;
  190. border-radius: 15px;
  191. .status {
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. height: 30px;
  196. width: 48px;
  197. border-radius: 15px;
  198. font-family: Source Han Sans SC, Source Han Sans SC;
  199. font-size: 14px;
  200. color: #666666;
  201. background: #fff;
  202. }
  203. .active {
  204. background: #c30d23;
  205. color: #fff;
  206. }
  207. }
  208. }
  209. .item {
  210. position: relative;
  211. width: 355px;
  212. background: #ffffff;
  213. border-radius: 8px;
  214. margin: 0 auto 8px;
  215. padding: 15px 10px;
  216. box-sizing: border-box;
  217. .title {
  218. width: 281px;
  219. font-family: Source Han Sans SC, Source Han Sans SC;
  220. font-weight: bold;
  221. font-size: 14px;
  222. color: #333333;
  223. }
  224. .line {
  225. width: 335px;
  226. height: 1px;
  227. background: #eeeeee;
  228. margin-top: 15px;
  229. }
  230. .date {
  231. line-height: 20px;
  232. font-size: 14px;
  233. color: #666666;
  234. margin-top: 10px;
  235. }
  236. .readstatus {
  237. position: absolute;
  238. top: 10px;
  239. right: 0;
  240. width: 44px;
  241. height: 24px;
  242. line-height: 24px;
  243. font-size: 12px;
  244. text-align: center;
  245. border-radius: 12px 0px 0px 12px;
  246. }
  247. }
  248. </style>