index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="content">
  3. <view class="input-box">
  4. <image src="/static/policy/u377.png" alt="" />
  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: 34px; height: 34px"
  24. ></image>
  25. <view class="notice-content display-around-column">
  26. <view class="notice-content-font">{{
  27. item.title
  28. }}</view>
  29. <view class="notice-content-time">{{
  30. item.publish_time | globalTime
  31. }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import md5 from "@/common/md5.js";
  39. export default {
  40. data() {
  41. return {
  42. noticeList: [
  43. // {
  44. // url: "/static/navList/policy-icon.png",
  45. // title: "政策速览 | 小微企业、个体工商户税费...",
  46. // time: "2021-08-05",
  47. // },
  48. // {
  49. // url: "/static/navList/activity-icon.png",
  50. // title: "活动预告 | 想了解跨境电商?8月5日带...",
  51. // time: "2021-08-04",
  52. // },
  53. // {
  54. // url: "/static/navList/notice-icon.png",
  55. // title: "通知公告 | 2022年首批次重点新材料扶...",
  56. // time: "2021-08-03",
  57. // },
  58. ],
  59. input: "",
  60. imgUrl: [
  61. "/static/navList/activity-icon.png", //活动 1
  62. "/static/navList/policy-icon.png", //政策 type2
  63. "/static/navList/notice-icon.png", //通知 3
  64. ],
  65. titleList: ["活动预告 | ", "政策速览 | ", "通知公告 | "],
  66. };
  67. },
  68. onLoad() {
  69. this.getNotice();
  70. },
  71. methods: {
  72. goNoticeDeatil(id) {
  73. uni.navigateTo({
  74. url: "/pages/notice/notice_deatil?id=" + id,
  75. });
  76. },
  77. getNotice() {
  78. let md5Sign = md5(
  79. "method=" +
  80. "common" +
  81. "&timestamp=" +
  82. getApp().globalData.globalTimestamp +
  83. "&secret=" +
  84. getApp().globalData.secret
  85. );
  86. let url =
  87. getApp().globalData.shareUrl +
  88. "api/api.php" +
  89. "?method=common&source=notice&action=list&timestamp=" +
  90. getApp().globalData.globalTimestamp +
  91. "&sign=" +
  92. md5Sign;
  93. let postData = {
  94. // s_title: this.input,
  95. };
  96. uni.request({
  97. url: url,
  98. method: "POST",
  99. header: {
  100. "content-type": "application/x-www-form-urlencoded",
  101. },
  102. data: postData,
  103. success: (res) => {
  104. if (res.data.code === 200) {
  105. // console.log(res.data.data.list);
  106. this.noticeList = res.data.data.list.map((item) => {
  107. switch (item.type) {
  108. case "1":
  109. item.icon = "/static/navList/activity-icon.png";
  110. item.title = "活动预告 | " + item.title;
  111. break;
  112. case "2":
  113. item.icon = "/static/navList/policy-icon.png";
  114. item.title = "政策速览 | " + item.title;
  115. break;
  116. case "3":
  117. item.icon = "/static/navList/notice-icon.png";
  118. item.title = "通知公告 | " + item.title;
  119. break;
  120. }
  121. return item;
  122. });
  123. // this.noticeList = res.data.data.list;
  124. }
  125. },
  126. fail: () => {
  127. console.log("连接失败");
  128. },
  129. });
  130. },
  131. },
  132. };
  133. </script>
  134. <style lang="scss" scoped>
  135. .content {
  136. display: flex;
  137. flex-direction: column;
  138. align-items: center;
  139. justify-content: center;
  140. width: 100%;
  141. .notices {
  142. display: flex;
  143. // justify-content: center;
  144. align-items: center;
  145. flex-direction: column;
  146. .notice-content-box {
  147. width: 100%;
  148. display: flex;
  149. padding: 30rpx;
  150. background-color: #ffffff;
  151. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  152. border-radius: 32rpx;
  153. margin-top: 20rpx;
  154. // justify-content: space-between;
  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. .attract-content {
  165. color: #697594;
  166. font-weight: 600;
  167. font-size: 20rpx;
  168. margin-top: 8rpx;
  169. overflow: hidden;
  170. text-overflow: ellipsis;
  171. white-space: nowrap;
  172. }
  173. .notice-content-time {
  174. margin-left: 40rpx;
  175. font-size: 18rpx;
  176. letter-spacing: 0.02em;
  177. color: #cfcfcf;
  178. margin-right: 14rpx;
  179. }
  180. }
  181. }
  182. .input-box {
  183. width: 100%;
  184. height: 100rpx;
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. position: relative;
  189. image {
  190. position: absolute;
  191. left: 72rpx;
  192. width: 40rpx;
  193. height: 40rpx;
  194. }
  195. input {
  196. background-color: rgba($color: #000000, $alpha: 0.1);
  197. width: 90%;
  198. height: 70%;
  199. border-radius: 50rpx;
  200. padding: 3rpx;
  201. font-size: 26rpx;
  202. padding-left: 80rpx;
  203. box-sizing: border-box;
  204. }
  205. }
  206. }
  207. </style>