index.vue 9.6 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
  46. class="policy-content-item"
  47. v-for="(item, idx) in policyData"
  48. :key="idx"
  49. @click="enterPolicyDeatil(item.id)"
  50. >
  51. <p class="policy-content-item-left-title" style="height: 86rpx">
  52. {{ item.title }}
  53. </p>
  54. <view class="policy-content-item-left-time">
  55. <p class="moment">{{ item.publish_time | globalTime }}</p>
  56. <p class="maxMony" v-if="item.project_money!=='-' && item.project_money ">{{ item.project_money }}</p>
  57. <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">
  58. 剩{{ Math.floor(new Date(new Date(item.project_end_date).getTime() -new Date().getTime()).getTime() /(1 * 24 * 60 * 60 * 1000)) + 1}}天
  59. </p>
  60. <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 ">
  61. 申报结束
  62. </p>
  63. <p class="leftDay" v-if="!item.project_end_date">长期可申报</p>
  64. </view>
  65. <!-- <view class="policy-content-item-img">
  66. <image :src="item.pic_url" alt="" mode="aspectFill"/>
  67. </view> -->
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import md5 from "@/common/md5.js";
  75. export default {
  76. data() {
  77. return {
  78. swiperList: [],
  79. policyList: ["省级政策", "市级政策", "新区政策", "新城政策"],
  80. active: 0,
  81. searchVal: "",
  82. policyData: new Array(5).fill({
  83. title:
  84. "工业金额信息化部办公厅 组织开2021念工业互联网平台创新互联网工业文化产业项目征集工作。",
  85. moment: "2021-07-12",
  86. maxMony: "最高500.00万",
  87. leftDay: "剩5天",
  88. img: "/static/policy/u388.jpg",
  89. }),
  90. };
  91. },
  92. onLoad() {
  93. this.getPolicySwiper();
  94. this.getPolicyList();
  95. },
  96. methods: {
  97. search() {
  98. uni.navigateTo({
  99. url: "./search?val=" + this.searchVal,
  100. });
  101. },
  102. searchPolicy(val) {
  103. uni.navigateTo({
  104. url: "./search?val=" + val,
  105. })
  106. },
  107. enterPolicyDeatil(id) {
  108. uni.navigateTo({
  109. url: "/pages/policy/policy_deatil?id=" + id,
  110. });
  111. },
  112. changePolicyTabs(idx) {
  113. let that = this;
  114. that.active = idx;
  115. switch (idx) {
  116. case 0:
  117. that.getPolicyList("1");
  118. break;
  119. case 1:
  120. that.getPolicyList("2");
  121. break;
  122. case 2:
  123. that.getPolicyList("3");
  124. break;
  125. case 3:
  126. that.getPolicyList("4");
  127. break;
  128. }
  129. },
  130. getPolicySwiper() {
  131. let md5Sign = md5(
  132. "method=" +
  133. "common" +
  134. "&timestamp=" +
  135. getApp().globalData.globalTimestamp +
  136. "&secret=" +
  137. getApp().globalData.secret
  138. );
  139. let url =
  140. getApp().globalData.shareUrl +
  141. "api/api.php" +
  142. "?method=common&source=policy_pics&action=list&timestamp=" +
  143. getApp().globalData.globalTimestamp +
  144. "&sign=" +
  145. md5Sign;
  146. uni.request({
  147. url: url,
  148. method: "POST",
  149. header: {
  150. "content-type": "application/x-www-form-urlencoded",
  151. },
  152. data: {
  153. order_by: "weight desc",
  154. s_status: 1,
  155. // page: 1,
  156. // page_size: 7,
  157. },
  158. success: (res) => {
  159. console.log(res);
  160. if (res.data.code === 200) {
  161. res.data.data.list.forEach((item) => {
  162. item.pic_path = getApp().globalData.shareUrl + item.pic_path;
  163. });
  164. this.swiperList = res.data.data.list;
  165. }
  166. },
  167. fail: () => {
  168. console.log("连接失败");
  169. },
  170. });
  171. },
  172. getPolicyList(level) {
  173. let md5Sign = md5(
  174. "method=" +
  175. "common" +
  176. "&timestamp=" +
  177. getApp().globalData.globalTimestamp +
  178. "&secret=" +
  179. getApp().globalData.secret
  180. );
  181. let url =
  182. getApp().globalData.shareUrl +
  183. "api/api.php" +
  184. "?method=common&source=policy&action=list&timestamp=" +
  185. getApp().globalData.globalTimestamp +
  186. "&sign=" +
  187. md5Sign;
  188. uni.request({
  189. url: url,
  190. method: "POST",
  191. header: {
  192. "content-type": "application/x-www-form-urlencoded",
  193. },
  194. data: {
  195. s_level: level || "1", //1.省 2.市 3.区 4.新城
  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>