index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="content">
  3. <view class="swiper-box" style="width: 100%">
  4. <swiper
  5. class="swiper"
  6. indicator-dots="true"
  7. autoplay="true"
  8. duration="500"
  9. style="height: 300rpx"
  10. >
  11. <swiper-item v-for="(item, index) in swiperList" :key="index">
  12. <image
  13. :src="item.pic_path"
  14. mode="aspectFill"
  15. style="width: 100%; height: 100%"
  16. ></image>
  17. </swiper-item>
  18. </swiper>
  19. </view>
  20. <view class="input-box">
  21. <image src="/static/policy/u377.png" alt="" mode="aspectFit" @click="searchPolicy(searchVal)"/>
  22. <input
  23. type="text"
  24. placeholder="请输入政策关键词搜索"
  25. confirm-type="search"
  26. @confirm="searchPolicy(searchVal)"
  27. v-model="searchVal"
  28. />
  29. <!-- @focus="search" -->
  30. </view>
  31. <view class="policy-box">
  32. <view class="policy-title"><p>最新政策</p></view>
  33. <view class="policy-item-box">
  34. <view
  35. v-for="(item, idx) in policyList"
  36. :key="idx"
  37. :class="{ active: active === idx }"
  38. class="policy-item-name"
  39. @click="changePolicyTabs(idx)"
  40. >
  41. {{ item }}
  42. </view>
  43. </view>
  44. <view class="policy-content">
  45. <view class="policy-content-item" v-for="(item, idx) in policyData" :key="idx" @click="enterPolicyDeatil(item.id)" >
  46. <p class="policy-content-item-left-title" style="height: 86rpx">
  47. {{ item.title }}
  48. </p>
  49. <view class="policy-content-item-left-time" v-if="item.level != '5'">
  50. <p class="moment">{{ item.publish_time | globalTime }}</p>
  51. <p class="maxMony" v-if="item.project_money!=='-' && item.project_money ">{{ item.project_money }}</p>
  52. <p class="leftDay" v-if=" item.project_end_date && Math.floor( new Date( new Date(item.project_end_date).getTime() -new Date().getTime()).getTime() /(1 * 24 * 60 * 60 * 1000) ) +1 >= 1">
  53. 剩{{ Math.floor(new Date(new Date(item.project_end_date).getTime() -new Date().getTime()).getTime() /(1 * 24 * 60 * 60 * 1000)) + 1}}天
  54. </p>
  55. <p class="leftDay" v-if="item.project_end_date && Math.floor(new Date(new Date(item.project_end_date).getTime() - new Date().getTime()).getTime() / (1 * 24 * 60 * 60 * 1000)) + 1 < 1 ">
  56. 申报结束
  57. </p>
  58. <p class="leftDay" v-if="!item.project_end_date">长期可申报</p>
  59. <!-- <p class="leftDay" v-if="!item.project_end_date">剩{{ Math.floor(new Date(new Date().getTime() - new Date(item.publish_time * 1000).getTime()).getTime() /(1 * 24 * 60 * 60 * 1000)) + 1}}天</p> -->
  60. </view>
  61. <view class="policy-content-item-left-time" v-if="item.level == '5'">
  62. <p class="moment">{{ item.publish_time | globalTime }}</p>
  63. </view>
  64. <!-- <view class="policy-content-item-img">
  65. <image :src="item.pic_url" alt="" mode="aspectFill"/>
  66. </view> -->
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </template>
  72. <script>
  73. import md5 from "@/common/md5.js";
  74. export default {
  75. data() {
  76. return {
  77. swiperList: [],
  78. policyList: ["市级政策", "新区政策", "新城政策","政策解读"],
  79. active: 2,
  80. searchVal: "",
  81. policyData: new Array(5).fill({
  82. title:
  83. "工业金额信息化部办公厅 组织开2021念工业互联网平台创新互联网工业文化产业项目征集工作。",
  84. moment: "2021-07-12",
  85. maxMony: "最高500.00万",
  86. leftDay: "剩5天",
  87. img: "/static/policy/u388.jpg",
  88. }),
  89. };
  90. },
  91. onLoad() {
  92. this.getPolicySwiper();
  93. this.getPolicyList();
  94. },
  95. methods: {
  96. search() {
  97. uni.navigateTo({
  98. url: "./search?val=" + this.searchVal,
  99. });
  100. },
  101. searchPolicy(val) {
  102. uni.navigateTo({
  103. url: "./search?val=" + val,
  104. })
  105. },
  106. enterPolicyDeatil(id) {
  107. uni.navigateTo({
  108. url: "/pages/policy/policy_deatil?id=" + id,
  109. });
  110. },
  111. changePolicyTabs(idx) {
  112. let that = this;
  113. that.active = idx;
  114. switch (idx) {
  115. case 0:
  116. that.getPolicyList("2");
  117. break;
  118. case 1:
  119. that.getPolicyList("3");
  120. break;
  121. case 2:
  122. that.getPolicyList("4");
  123. break;
  124. case 3:
  125. that.getPolicyList("5");
  126. break;
  127. }
  128. },
  129. getPolicySwiper() {
  130. let md5Sign = md5(
  131. "method=" +
  132. "common" +
  133. "&timestamp=" +
  134. getApp().globalData.globalTimestamp +
  135. "&secret=" +
  136. getApp().globalData.secret
  137. );
  138. let url =
  139. getApp().globalData.shareUrl +
  140. "api/api.php" +
  141. "?method=common&source=policy_pics&action=list&timestamp=" +
  142. getApp().globalData.globalTimestamp +
  143. "&sign=" +
  144. md5Sign;
  145. uni.request({
  146. url: url,
  147. method: "POST",
  148. header: {
  149. "content-type": "application/x-www-form-urlencoded",
  150. },
  151. data: {
  152. order_by: "weight desc",
  153. s_status: 1,
  154. // page: 1,
  155. // page_size: 7,
  156. },
  157. success: (res) => {
  158. console.log(res);
  159. if (res.data.code === 200) {
  160. res.data.data.list.forEach((item) => {
  161. item.pic_path = getApp().globalData.shareUrl + item.pic_path;
  162. });
  163. this.swiperList = res.data.data.list;
  164. }
  165. },
  166. fail: () => {
  167. console.log("连接失败");
  168. },
  169. });
  170. },
  171. getPolicyList(level) {
  172. let md5Sign = md5(
  173. "method=" +
  174. "common" +
  175. "&timestamp=" +
  176. getApp().globalData.globalTimestamp +
  177. "&secret=" +
  178. getApp().globalData.secret
  179. );
  180. let url =
  181. getApp().globalData.shareUrl +
  182. "api/api.php" +
  183. "?method=common&source=policy&action=list&timestamp=" +
  184. getApp().globalData.globalTimestamp +
  185. "&sign=" +
  186. md5Sign;
  187. uni.request({
  188. url: url,
  189. method: "POST",
  190. header: {
  191. "content-type": "application/x-www-form-urlencoded",
  192. },
  193. data: {
  194. s_level: level || "4", //1.省 2.市 3.区 4.新城 5.解读
  195. order_by : 'project_sort_time asc'
  196. },
  197. success: (res) => {
  198. console.log(res);
  199. if (res.data.code === 200) {
  200. // res.data.data.list.forEach((item) => {
  201. // item.pic_url = getApp().globalData.shareUrl + item.pic_url;
  202. // });
  203. this.policyData = res.data.data.list;
  204. }
  205. },
  206. fail: () => {
  207. console.log("连接失败");
  208. },
  209. });
  210. },
  211. },
  212. };
  213. </script>
  214. <style lang="scss">
  215. .content {
  216. display: flex;
  217. flex-direction: column;
  218. align-items: center;
  219. justify-content: center;
  220. box-sizing: border-box;
  221. .input-box {
  222. width: 100%;
  223. height: 100rpx;
  224. background-color: #02a7f0;
  225. display: flex;
  226. justify-content: center;
  227. align-items: center;
  228. position: relative;
  229. image {
  230. position: absolute;
  231. left: 72rpx;
  232. width: 30rpx;
  233. height: 30rpx;
  234. }
  235. input {
  236. background-color: #ffffff;
  237. width: 90%;
  238. height: 70%;
  239. border-radius: 50rpx;
  240. padding: 3rpx;
  241. font-size: 28rpx;
  242. padding-left: 80rpx;
  243. box-sizing: border-box;
  244. }
  245. }
  246. .policy-box {
  247. margin-top: 50rpx;
  248. width: 100%;
  249. display: flex;
  250. flex-direction: column;
  251. .policy-title {
  252. width: 100%;
  253. p {
  254. background-color: #02a7f0;
  255. width: 190rpx;
  256. height: 70rpx;
  257. color: #ffffff;
  258. border-radius: 0 40rpx 40rpx 0rpx;
  259. font-size: 30rpx;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. }
  264. }
  265. .policy-item-box {
  266. display: flex;
  267. justify-content: space-between;
  268. margin: 0 20rpx;
  269. margin-top: 20rpx;
  270. .policy-item-name {
  271. padding-bottom: 10rpx;
  272. font-size: 30rpx;
  273. }
  274. .active {
  275. font-weight: 600;
  276. border-bottom: 7rpx solid #02a7f0;
  277. }
  278. }
  279. .policy-content {
  280. width: 100%;
  281. display: flex;
  282. box-sizing: border-box;
  283. flex-direction: column;
  284. margin-top: 10rpx;
  285. .policy-content-item {
  286. margin: 0 20rpx;
  287. display: flex;
  288. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  289. border-radius: 32rpx;
  290. padding-bottom: 10rpx;
  291. margin-top: 20rpx;
  292. padding: 30rpx;
  293. justify-content: space-between;
  294. align-items: center;
  295. flex-direction: column;
  296. .policy-content-item-left-title {
  297. width: 100%;
  298. text-overflow: -o-ellipsis-lastline;
  299. overflow: hidden;
  300. text-overflow: ellipsis;
  301. display: -webkit-box;
  302. -webkit-line-clamp: 2;
  303. line-clamp: 2;
  304. -webkit-box-orient: vertical;
  305. font-size: 32rpx;
  306. margin-bottom: 10rpx;
  307. }
  308. .policy-content-item-left-time {
  309. width: 100%;
  310. display: flex;
  311. align-items: center;
  312. .moment {
  313. color: #c1c1c1;
  314. font-size: 24rpx;
  315. margin-right: 20rpx;
  316. white-space: nowrap;
  317. }
  318. .maxMony {
  319. font-size: 24rpx;
  320. color: #00bfbf;
  321. border: 1px solid #00bfbf;
  322. padding: 10rpx;
  323. margin-right: 20rpx;
  324. border-radius: 12rpx;
  325. overflow: hidden;
  326. text-overflow: ellipsis;
  327. white-space: nowrap;
  328. // width: 46%;
  329. // text-align: center;
  330. }
  331. .leftDay {
  332. font-size: 24rpx;
  333. background: #f7bbc3;
  334. color: #e32579;
  335. padding: 10rpx;
  336. border: 1px solid #f7bbc3;
  337. border-radius: 12rpx;
  338. white-space: nowrap;
  339. }
  340. }
  341. .policy-content-item-img {
  342. image {
  343. width: 170rpx;
  344. height: 120rpx;
  345. border-radius: 12rpx;
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. </style>