index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  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 type="text" placeholder="请输入政策关键词搜索" confirm-type="search" @confirm="searchPoliy()" v-model="searchVal" @focus="search"/>
  23. </view>
  24. <view class="policy-box">
  25. <view class="policy-title"><p>最新政策</p></view>
  26. <view class="policy-item-box">
  27. <view
  28. v-for="(item, idx) in policyList"
  29. :key="idx"
  30. :class="{ active: active === idx }"
  31. class="policy-item-name"
  32. @click="changePolicyTabs(idx)"
  33. >
  34. {{ item }}
  35. </view>
  36. </view>
  37. <view class="policy-content">
  38. <view
  39. class="policy-content-item"
  40. v-for="(item, idx) in policyData"
  41. :key="idx"
  42. @click="enterPolicyDeatil(item.id)"
  43. >
  44. <view class="policy-content-item-left">
  45. <p class="policy-content-item-left-title" style="height: 70rpx;">{{ item.title }}</p>
  46. <view class="policy-content-item-left-time">
  47. <p class="moment">{{ item.publish_time | globalTime }}</p>
  48. <p class="maxMony">{{ item.project_money }}</p>
  49. <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">
  50. 剩{{Math.floor(new Date(new Date(item.project_end_date).getTime() -new Date().getTime()).getTime() / (1 * 24 * 60 * 60 * 1000)) + 1}}天
  51. </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. 申报结束
  54. </p>
  55. <p class="leftDay" v-if="!item.project_end_date">
  56. 长期可申报
  57. </p>
  58. </view>
  59. </view>
  60. <view class="policy-content-item-img">
  61. <image :src="item.pic_url" alt="" />
  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. ],
  75. policyList: ["省级政策", "市级政策", "区级政策", "新城政策"],
  76. active: 0,
  77. searchVal:'',
  78. policyData: new Array(5).fill({
  79. title:"工业金额信息化部办公厅 组织开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.redirectTo({
  94. url: "./search",
  95. });
  96. },
  97. enterPolicyDeatil(id) {
  98. uni.navigateTo({
  99. url: "/pages/policy/policy_deatil?id=" + id,
  100. });
  101. },
  102. changePolicyTabs(idx){
  103. let that = this;
  104. that.active = idx;
  105. switch (idx){
  106. case 0:
  107. that.getPolicyList('1')
  108. break;
  109. case 1:
  110. that.getPolicyList('2')
  111. break;
  112. case 2:
  113. that.getPolicyList('3')
  114. break;
  115. case 3:
  116. that.getPolicyList('4')
  117. break;
  118. }
  119. },
  120. getPolicySwiper() {
  121. let md5Sign = md5(
  122. "method=" +
  123. "common" +
  124. "&timestamp=" +
  125. getApp().globalData.globalTimestamp +
  126. "&secret=" +
  127. getApp().globalData.secret
  128. );
  129. let url =
  130. getApp().globalData.shareUrl +
  131. "api/api.php" +
  132. "?method=common&source=policy_pics&action=list&timestamp=" +
  133. getApp().globalData.globalTimestamp +
  134. "&sign=" +
  135. md5Sign;
  136. uni.request({
  137. url: url,
  138. method: "POST",
  139. header: {
  140. "content-type": "application/x-www-form-urlencoded",
  141. },
  142. data: {
  143. order_by: "weight desc",
  144. s_status: 1,
  145. // page: 1,
  146. // page_size: 7,
  147. },
  148. success: (res) => {
  149. console.log(res);
  150. if (res.data.code === 200) {
  151. res.data.data.list.forEach((item) => {
  152. item.pic_path = getApp().globalData.shareUrl + item.pic_path;
  153. });
  154. this.swiperList = res.data.data.list;
  155. }
  156. },
  157. fail: () => {
  158. console.log("连接失败");
  159. },
  160. });
  161. },
  162. getPolicyList(level) {
  163. let md5Sign = md5(
  164. "method=" +
  165. "common" +
  166. "&timestamp=" +
  167. getApp().globalData.globalTimestamp +
  168. "&secret=" +
  169. getApp().globalData.secret
  170. );
  171. let url = getApp().globalData.shareUrl +"api/api.php" +"?method=common&source=policy&action=list&timestamp=" +getApp().globalData.globalTimestamp +"&sign=" +md5Sign;
  172. uni.request({
  173. url: url,
  174. method: "POST",
  175. header: {
  176. "content-type": "application/x-www-form-urlencoded",
  177. },
  178. data: {
  179. s_level:level || '1' //1.省 2.市 3.区 4.新城
  180. },
  181. success: (res) => {
  182. console.log(res);
  183. if (res.data.code === 200) {
  184. res.data.data.list.forEach((item) => {
  185. item.pic_url = getApp().globalData.shareUrl + item.pic_url;
  186. });
  187. this.policyData = res.data.data.list;
  188. }
  189. },
  190. fail: () => {
  191. console.log("连接失败");
  192. },
  193. });
  194. },
  195. },
  196. };
  197. </script>
  198. <style lang="scss">
  199. .content {
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. justify-content: center;
  204. box-sizing: border-box;
  205. .input-box {
  206. width: 100%;
  207. height: 100rpx;
  208. background-color: #02a7f0;
  209. display: flex;
  210. justify-content: center;
  211. align-items: center;
  212. position: relative;
  213. image {
  214. position: absolute;
  215. left: 72rpx;
  216. width: 30rpx;
  217. height: 30rpx;
  218. }
  219. input {
  220. background-color: #ffffff;
  221. width: 90%;
  222. height: 70%;
  223. border-radius: 50rpx;
  224. padding: 3rpx;
  225. font-size: 26rpx;
  226. padding-left: 80rpx;
  227. box-sizing: border-box;
  228. }
  229. }
  230. .policy-box {
  231. margin-top: 50rpx;
  232. width: 100%;
  233. display: flex;
  234. flex-direction: column;
  235. .policy-title {
  236. width: 100%;
  237. p {
  238. background-color: #02a7f0;
  239. width: 190rpx;
  240. height: 70rpx;
  241. color: #ffffff;
  242. border-radius: 0 40rpx 40rpx 0rpx;
  243. font-size: 28rpx;
  244. display: flex;
  245. justify-content: center;
  246. align-items: center;
  247. }
  248. }
  249. .policy-item-box {
  250. display: flex;
  251. justify-content: space-between;
  252. margin: 0 20rpx;
  253. margin-top: 20rpx;
  254. .policy-item-name {
  255. padding-bottom: 10rpx;
  256. font-size: 27rpx;
  257. }
  258. .active {
  259. font-weight: 600;
  260. border-bottom: 7rpx solid #02a7f0;
  261. }
  262. }
  263. .policy-content {
  264. width: 100%;
  265. display: flex;
  266. box-sizing: border-box;
  267. flex-direction: column;
  268. margin-top: 10rpx;
  269. .policy-content-item {
  270. margin: 0 20rpx;
  271. display: flex;
  272. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  273. border-radius: 32rpx;
  274. padding-bottom: 10rpx;
  275. margin-top: 20rpx;
  276. padding: 30rpx;
  277. justify-content: space-between;
  278. .policy-content-item-left {
  279. display: flex;
  280. flex-direction: column;
  281. width: 70%;
  282. .policy-content-item-left-title {
  283. text-overflow: -o-ellipsis-lastline;
  284. overflow: hidden;
  285. text-overflow: ellipsis;
  286. display: -webkit-box;
  287. -webkit-line-clamp: 2;
  288. line-clamp: 2;
  289. -webkit-box-orient: vertical;
  290. font-size: 25rpx;
  291. margin-bottom: 10rpx;
  292. }
  293. .policy-content-item-left-time {
  294. width: 100%;
  295. display: flex;
  296. align-items: center;
  297. .moment {
  298. color: #c1c1c1;
  299. font-size: 20rpx;
  300. margin-right: 20rpx;
  301. }
  302. .maxMony {
  303. font-size: 20rpx;
  304. color: #00bfbf;
  305. border: 1px solid #00bfbf;
  306. padding: 10rpx;
  307. margin-right: 20rpx;
  308. border-radius: 12rpx;
  309. }
  310. .leftDay {
  311. font-size: 20rpx;
  312. background: #f7bbc3;
  313. color: #e32579;
  314. padding: 10rpx;
  315. border: 1px solid #f7bbc3;
  316. border-radius: 12rpx;
  317. }
  318. }
  319. }
  320. .policy-content-item-img {
  321. image {
  322. width: 180rpx;
  323. height: 120rpx;
  324. border-radius: 12rpx;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. }
  331. </style>