index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="content">
  3. <view class="input-box">
  4. <image src="/static/policy/u377.png" alt="" class="search-icon" />
  5. <input
  6. type="text"
  7. placeholder="请输入关键字搜索"
  8. v-model="input"
  9. @confirm="getNotice"
  10. />
  11. </view>
  12. <view class="notices">
  13. <view
  14. class="notice-content-box"
  15. v-for="(item, index) in noticeList"
  16. :key="index"
  17. confirm-type="search"
  18. @click="goNoticeDeatil(item.id)"
  19. >
  20. <image
  21. :src="item.icon"
  22. mode="aspectFit"
  23. style="width: 100rpx; height: 100rpx"
  24. class="type-icon"
  25. ></image>
  26. <view class="notice-content display-around-column">
  27. <view class="notice-content-font">{{ item.title }}</view>
  28. <view class="notice-content-time">{{
  29. item.publish_time | globalTime
  30. }}</view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import md5 from "@/common/md5.js";
  38. export default {
  39. data() {
  40. return {
  41. noticeList: [],
  42. input: "",
  43. };
  44. },
  45. onLoad() {
  46. this.getNotice();
  47. },
  48. methods: {
  49. goNoticeDeatil(id) {
  50. uni.navigateTo({
  51. url: "/pages/notice/notice_deatil?id=" + id,
  52. });
  53. },
  54. getNotice() {
  55. let md5Sign = md5(
  56. "method=" +
  57. "common" +
  58. "&timestamp=" +
  59. getApp().globalData.globalTimestamp +
  60. "&secret=" +
  61. getApp().globalData.secret
  62. );
  63. let url =
  64. getApp().globalData.shareUrl +
  65. "api/api.php" +
  66. "?method=common&source=notice&action=list&timestamp=" +
  67. getApp().globalData.globalTimestamp +
  68. "&sign=" +
  69. md5Sign;
  70. let postData = {
  71. s_title: this.input,
  72. };
  73. if (!this.input) {
  74. postData = {};
  75. }
  76. uni.request({
  77. url: url,
  78. method: "POST",
  79. header: {
  80. "content-type": "application/x-www-form-urlencoded",
  81. },
  82. data: postData,
  83. success: (res) => {
  84. if (res.data.code === 200) {
  85. console.log(res.data.data.list);
  86. this.noticeList = res.data.data.list.map((item) => {
  87. switch (item.type) {
  88. case "1":
  89. item.icon = "/static/navList/activity-icon.png";
  90. item.title = "活动预告 | " + item.title;
  91. break;
  92. case "2":
  93. item.icon = "/static/navList/policy-icon.png";
  94. item.title = "政策速览 | " + item.title;
  95. break;
  96. case "3":
  97. item.icon = "/static/navList/notice-icon.png";
  98. item.title = "通知公告 | " + item.title;
  99. break;
  100. }
  101. return item;
  102. });
  103. // this.noticeList = res.data.data.list;
  104. }
  105. },
  106. fail: () => {
  107. console.log("连接失败");
  108. },
  109. });
  110. },
  111. },
  112. };
  113. </script>
  114. <style lang="scss" scoped>
  115. .content {
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. justify-content: center;
  120. width: 100%;
  121. .notices {
  122. display: flex;
  123. // justify-content: center;
  124. align-items: center;
  125. flex-direction: column;
  126. width: 83%;
  127. .notice-content-box {
  128. width: 100%;
  129. display: flex;
  130. padding: 30rpx;
  131. background-color: #ffffff;
  132. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  133. border-radius: 32rpx;
  134. margin-top: 20rpx;
  135. .type-icon {
  136. display: block;
  137. }
  138. .notice-content {
  139. // flex: 1;
  140. width: 100%;
  141. color: #697594;
  142. font-weight: 600;
  143. font-size: 20rpx;
  144. margin-top: 8rpx;
  145. overflow: hidden;
  146. text-overflow: ellipsis;
  147. white-space: nowrap;
  148. .notice-content-time {
  149. margin-left: 40rpx;
  150. font-size: 18rpx;
  151. letter-spacing: 0.02em;
  152. color: #cfcfcf;
  153. margin-right: 14rpx;
  154. }
  155. .notice-content-font {
  156. margin-left: 40rpx;
  157. font-size: 26rpx;
  158. color: #0d1937;
  159. font-weight: 600;
  160. overflow: hidden;
  161. text-overflow: ellipsis;
  162. white-space: nowrap;
  163. }
  164. }
  165. }
  166. }
  167. .input-box {
  168. width: 100%;
  169. height: 100rpx;
  170. display: flex;
  171. justify-content: center;
  172. align-items: center;
  173. position: relative;
  174. .search-icon {
  175. position: absolute;
  176. left: 72rpx;
  177. width: 40rpx;
  178. height: 40rpx;
  179. }
  180. input {
  181. background-color: rgba($color: #000000, $alpha: 0.1);
  182. width: 90%;
  183. height: 70%;
  184. border-radius: 50rpx;
  185. padding: 3rpx;
  186. font-size: 26rpx;
  187. padding-left: 80rpx;
  188. box-sizing: border-box;
  189. }
  190. }
  191. }
  192. </style>