index.vue 9.7 KB

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