index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. uni.request({
  89. url: url,
  90. method: "POST",
  91. header: {
  92. "content-type": "application/x-www-form-urlencoded",
  93. },
  94. data: postData,
  95. success: (res) => {
  96. if (res.data.code === 200) {
  97. // console.log(res.data.data.list);
  98. this.noticeList = res.data.data.list.map((item) => {
  99. switch (item.type) {
  100. case "1":
  101. item.icon = "/static/navList/activity-icon.png";
  102. item.title = "活动预告 | " + item.title;
  103. break;
  104. case "2":
  105. item.icon = "/static/navList/policy-icon.png";
  106. item.title = "政策速览 | " + item.title;
  107. break;
  108. case "3":
  109. item.icon = "/static/navList/notice-icon.png";
  110. item.title = "通知公告 | " + item.title;
  111. break;
  112. }
  113. return item;
  114. });
  115. // this.noticeList = res.data.data.list;
  116. }
  117. },
  118. fail: () => {
  119. console.log("连接失败");
  120. },
  121. });
  122. },
  123. },
  124. };
  125. </script>
  126. <style lang="scss" scoped>
  127. .content {
  128. display: flex;
  129. flex-direction: column;
  130. align-items: center;
  131. justify-content: center;
  132. width: 100%;
  133. .notices {
  134. display: flex;
  135. // justify-content: center;
  136. align-items: center;
  137. flex-direction: column;
  138. .notice-content-box {
  139. width: 100%;
  140. display: flex;
  141. padding: 30rpx;
  142. background-color: #ffffff;
  143. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  144. border-radius: 32rpx;
  145. margin-top: 20rpx;
  146. // justify-content: space-between;
  147. .notice-content-font {
  148. margin-left: 40rpx;
  149. font-size: 26rpx;
  150. color: #0d1937;
  151. font-weight: 600;
  152. overflow: hidden;
  153. text-overflow: ellipsis;
  154. white-space: nowrap;
  155. }
  156. .attract-content {
  157. color: #697594;
  158. font-weight: 600;
  159. font-size: 20rpx;
  160. margin-top: 8rpx;
  161. overflow: hidden;
  162. text-overflow: ellipsis;
  163. white-space: nowrap;
  164. }
  165. .notice-content-time {
  166. margin-left: 40rpx;
  167. font-size: 18rpx;
  168. letter-spacing: 0.02em;
  169. color: #cfcfcf;
  170. margin-right: 14rpx;
  171. }
  172. }
  173. }
  174. .input-box {
  175. width: 100%;
  176. height: 100rpx;
  177. display: flex;
  178. justify-content: center;
  179. align-items: center;
  180. position: relative;
  181. image {
  182. position: absolute;
  183. left: 72rpx;
  184. width: 40rpx;
  185. height: 40rpx;
  186. }
  187. input {
  188. background-color: rgba($color: #000000, $alpha: 0.1);
  189. width: 90%;
  190. height: 70%;
  191. border-radius: 50rpx;
  192. padding: 3rpx;
  193. font-size: 26rpx;
  194. padding-left: 80rpx;
  195. box-sizing: border-box;
  196. }
  197. }
  198. }
  199. </style>