index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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="" />
  22. <input
  23. type="text"
  24. placeholder="请输入政策关键词搜索"
  25. confirm-type="search"
  26. @confirm="searchPoliy()"
  27. v-model="searchVal"
  28. @focus="search"
  29. />
  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: 70rpx">
  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="" />
  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.redirectTo({
  137. url: "./search",
  138. });
  139. },
  140. enterPolicyDeatil(id) {
  141. uni.navigateTo({
  142. url: "/pages/policy/policy_deatil?id=" + id,
  143. });
  144. },
  145. changePolicyTabs(idx) {
  146. let that = this;
  147. that.active = idx;
  148. switch (idx) {
  149. case 0:
  150. that.getPolicyList("1");
  151. break;
  152. case 1:
  153. that.getPolicyList("2");
  154. break;
  155. case 2:
  156. that.getPolicyList("3");
  157. break;
  158. case 3:
  159. that.getPolicyList("4");
  160. break;
  161. }
  162. },
  163. getPolicySwiper() {
  164. let md5Sign = md5(
  165. "method=" +
  166. "common" +
  167. "&timestamp=" +
  168. getApp().globalData.globalTimestamp +
  169. "&secret=" +
  170. getApp().globalData.secret
  171. );
  172. let url =
  173. getApp().globalData.shareUrl +
  174. "api/api.php" +
  175. "?method=common&source=policy_pics&action=list&timestamp=" +
  176. getApp().globalData.globalTimestamp +
  177. "&sign=" +
  178. md5Sign;
  179. uni.request({
  180. url: url,
  181. method: "POST",
  182. header: {
  183. "content-type": "application/x-www-form-urlencoded",
  184. },
  185. data: {
  186. order_by: "weight desc",
  187. s_status: 1,
  188. // page: 1,
  189. // page_size: 7,
  190. },
  191. success: (res) => {
  192. console.log(res);
  193. if (res.data.code === 200) {
  194. res.data.data.list.forEach((item) => {
  195. item.pic_path = getApp().globalData.shareUrl + item.pic_path;
  196. });
  197. this.swiperList = res.data.data.list;
  198. }
  199. },
  200. fail: () => {
  201. console.log("连接失败");
  202. },
  203. });
  204. },
  205. getPolicyList(level) {
  206. let md5Sign = md5(
  207. "method=" +
  208. "common" +
  209. "&timestamp=" +
  210. getApp().globalData.globalTimestamp +
  211. "&secret=" +
  212. getApp().globalData.secret
  213. );
  214. let url =
  215. getApp().globalData.shareUrl +
  216. "api/api.php" +
  217. "?method=common&source=policy&action=list&timestamp=" +
  218. getApp().globalData.globalTimestamp +
  219. "&sign=" +
  220. md5Sign;
  221. uni.request({
  222. url: url,
  223. method: "POST",
  224. header: {
  225. "content-type": "application/x-www-form-urlencoded",
  226. },
  227. data: {
  228. s_level: level || "1", //1.省 2.市 3.区 4.新城
  229. },
  230. success: (res) => {
  231. console.log(res);
  232. if (res.data.code === 200) {
  233. res.data.data.list.forEach((item) => {
  234. item.pic_url = getApp().globalData.shareUrl + item.pic_url;
  235. });
  236. this.policyData = res.data.data.list;
  237. }
  238. },
  239. fail: () => {
  240. console.log("连接失败");
  241. },
  242. });
  243. },
  244. },
  245. };
  246. </script>
  247. <style lang="scss">
  248. .content {
  249. display: flex;
  250. flex-direction: column;
  251. align-items: center;
  252. justify-content: center;
  253. box-sizing: border-box;
  254. .input-box {
  255. width: 100%;
  256. height: 100rpx;
  257. background-color: #02a7f0;
  258. display: flex;
  259. justify-content: center;
  260. align-items: center;
  261. position: relative;
  262. image {
  263. position: absolute;
  264. left: 72rpx;
  265. width: 30rpx;
  266. height: 30rpx;
  267. }
  268. input {
  269. background-color: #ffffff;
  270. width: 90%;
  271. height: 70%;
  272. border-radius: 50rpx;
  273. padding: 3rpx;
  274. font-size: 26rpx;
  275. padding-left: 80rpx;
  276. box-sizing: border-box;
  277. }
  278. }
  279. .policy-box {
  280. margin-top: 50rpx;
  281. width: 100%;
  282. display: flex;
  283. flex-direction: column;
  284. .policy-title {
  285. width: 100%;
  286. p {
  287. background-color: #02a7f0;
  288. width: 190rpx;
  289. height: 70rpx;
  290. color: #ffffff;
  291. border-radius: 0 40rpx 40rpx 0rpx;
  292. font-size: 28rpx;
  293. display: flex;
  294. justify-content: center;
  295. align-items: center;
  296. }
  297. }
  298. .policy-item-box {
  299. display: flex;
  300. justify-content: space-between;
  301. margin: 0 20rpx;
  302. margin-top: 20rpx;
  303. .policy-item-name {
  304. padding-bottom: 10rpx;
  305. font-size: 27rpx;
  306. }
  307. .active {
  308. font-weight: 600;
  309. border-bottom: 7rpx solid #02a7f0;
  310. }
  311. }
  312. .policy-content {
  313. width: 100%;
  314. display: flex;
  315. box-sizing: border-box;
  316. flex-direction: column;
  317. margin-top: 10rpx;
  318. .policy-content-item {
  319. margin: 0 20rpx;
  320. display: flex;
  321. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  322. border-radius: 32rpx;
  323. padding-bottom: 10rpx;
  324. margin-top: 20rpx;
  325. padding: 30rpx;
  326. justify-content: space-between;
  327. .policy-content-item-left {
  328. display: flex;
  329. flex-direction: column;
  330. width: 70%;
  331. .policy-content-item-left-title {
  332. text-overflow: -o-ellipsis-lastline;
  333. overflow: hidden;
  334. text-overflow: ellipsis;
  335. display: -webkit-box;
  336. -webkit-line-clamp: 2;
  337. line-clamp: 2;
  338. -webkit-box-orient: vertical;
  339. font-size: 25rpx;
  340. margin-bottom: 10rpx;
  341. }
  342. .policy-content-item-left-time {
  343. width: 100%;
  344. display: flex;
  345. align-items: center;
  346. .moment {
  347. color: #c1c1c1;
  348. font-size: 20rpx;
  349. margin-right: 20rpx;
  350. }
  351. .maxMony {
  352. font-size: 20rpx;
  353. color: #00bfbf;
  354. border: 1px solid #00bfbf;
  355. padding: 10rpx;
  356. margin-right: 20rpx;
  357. border-radius: 12rpx;
  358. }
  359. .leftDay {
  360. font-size: 20rpx;
  361. background: #f7bbc3;
  362. color: #e32579;
  363. padding: 10rpx;
  364. border: 1px solid #f7bbc3;
  365. border-radius: 12rpx;
  366. }
  367. }
  368. }
  369. .policy-content-item-img {
  370. image {
  371. width: 180rpx;
  372. height: 120rpx;
  373. border-radius: 12rpx;
  374. }
  375. }
  376. }
  377. }
  378. }
  379. }
  380. </style>