index.vue 8.2 KB

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