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