index.vue 9.5 KB

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