index.vue 10 KB

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