search.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="content">
  3. <view class="input-box">
  4. <image src="/static/policy/u377.png" alt="" @click="searchPolicy(searchVal)"/>
  5. <input type="text" placeholder="请输入政策关键词搜索" confirm-type="search" @confirm="searchPolicy()" v-model="searchVal"/>
  6. </view>
  7. <view class="policy-box">
  8. <view class="policy-content">
  9. <view class="policy-content-item" v-for="(item, idx) in policyData" :key="idx" @click="enterPolicyDeatil(item.id)" >
  10. <p class="policy-content-item-left-title" style="height: 86rpx">
  11. {{ item.title }}
  12. </p>
  13. <view class="policy-content-item-left-time" v-if="item.level != '5'">
  14. <p class="moment">{{ item.publish_time | globalTime }}</p>
  15. <p class="maxMony" v-if="item.project_money!=='-' && item.project_money ">{{ item.project_money }}</p>
  16. <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">
  17. 剩{{ Math.floor(new Date(new Date(item.project_end_date).getTime() -new Date().getTime()).getTime() /(1 * 24 * 60 * 60 * 1000)) + 1}}天
  18. </p>
  19. <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 ">
  20. 申报结束
  21. </p>
  22. <p class="leftDay" v-if="!item.project_end_date">长期可申报</p>
  23. <!-- <p class="leftDay" v-if="!item.project_end_date">剩{{ Math.floor(new Date(new Date().getTime() - new Date(item.publish_time * 1000).getTime()).getTime() /(1 * 24 * 60 * 60 * 1000)) + 1}}天</p> -->
  24. </view>
  25. <view class="policy-content-item-left-time" v-if="item.level == '5'">
  26. <p class="moment">{{ item.publish_time | globalTime }}</p>
  27. </view>
  28. <!-- <view class="policy-content-item-img">
  29. <image :src="item.pic_url" alt="" mode="aspectFill"/>
  30. </view> -->
  31. </view>
  32. </view>
  33. </view>
  34. <image src="../../static/nodata.svg" mode="aspectFit" style="width: 100%;" v-if="policyData.length === 0"></image>
  35. </view>
  36. </template>
  37. <script>
  38. import md5 from "@/common/md5.js";
  39. export default {
  40. data() {
  41. return {
  42. active: 0,
  43. searchVal:'',
  44. policyData: [],
  45. };
  46. },
  47. onLoad(option) {
  48. if(option.val){
  49. uni.showLoading({
  50. title:'加载中...'
  51. })
  52. this.searchPolicy(option.val)
  53. }
  54. },
  55. // onBackPress(event){
  56. // uni.navigateBack();
  57. // },
  58. methods: {
  59. enterPolicyDeatil(id) {
  60. uni.navigateTo({
  61. url: "/pages/policy/policy_deatil?id=" + id,
  62. });
  63. },
  64. searchPolicy(val){
  65. let md5Sign = md5(
  66. "method=" +
  67. "common" +
  68. "&timestamp=" +
  69. getApp().globalData.globalTimestamp +
  70. "&secret=" +
  71. getApp().globalData.secret
  72. );
  73. let url = getApp().globalData.shareUrl +"api/api.php" +"?method=common&source=policy&action=list&timestamp=" +getApp().globalData.globalTimestamp +"&sign=" +md5Sign;
  74. uni.request({
  75. url: url,
  76. method: "POST",
  77. header: {
  78. "content-type": "application/x-www-form-urlencoded",
  79. },
  80. data: {
  81. ss_content_text:val || this.searchVal,//1.省 2.市 3.区 4.新城 5.解读
  82. order_by : 'project_sort_time asc'
  83. },
  84. success: (res) => {
  85. if (res.data.code === 200) {
  86. this.policyData = res.data.data.list;
  87. uni.hideLoading()
  88. }
  89. },
  90. fail: () => {
  91. console.log("连接失败");
  92. },
  93. });
  94. },
  95. },
  96. };
  97. </script>
  98. <style lang="scss">
  99. .content {
  100. display: flex;
  101. flex-direction: column;
  102. align-items: center;
  103. justify-content: center;
  104. box-sizing: border-box;
  105. .input-box {
  106. width: 100%;
  107. height: 100rpx;
  108. background-color: #02a7f0;
  109. display: flex;
  110. justify-content: center;
  111. align-items: center;
  112. position: relative;
  113. image {
  114. position: absolute;
  115. left: 72rpx;
  116. width: 30rpx;
  117. height: 30rpx;
  118. }
  119. input {
  120. background-color: #ffffff;
  121. width: 90%;
  122. height: 70%;
  123. border-radius: 50rpx;
  124. padding: 3rpx;
  125. font-size: 28rpx;
  126. padding-left: 80rpx;
  127. box-sizing: border-box;
  128. }
  129. }
  130. .policy-box {
  131. margin-top: 50rpx;
  132. width: 100%;
  133. display: flex;
  134. flex-direction: column;
  135. .policy-title {
  136. width: 100%;
  137. p {
  138. background-color: #02a7f0;
  139. width: 190rpx;
  140. height: 70rpx;
  141. color: #ffffff;
  142. border-radius: 0 40rpx 40rpx 0rpx;
  143. font-size: 30rpx;
  144. display: flex;
  145. justify-content: center;
  146. align-items: center;
  147. }
  148. }
  149. .policy-item-box {
  150. display: flex;
  151. justify-content: space-between;
  152. margin: 0 20rpx;
  153. margin-top: 20rpx;
  154. .policy-item-name {
  155. padding-bottom: 10rpx;
  156. font-size: 30rpx;
  157. }
  158. .active {
  159. font-weight: 600;
  160. border-bottom: 7rpx solid #02a7f0;
  161. }
  162. }
  163. .policy-content {
  164. width: 100%;
  165. display: flex;
  166. box-sizing: border-box;
  167. flex-direction: column;
  168. margin-top: 10rpx;
  169. .policy-content-item {
  170. margin: 0 20rpx;
  171. display: flex;
  172. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  173. border-radius: 32rpx;
  174. padding-bottom: 10rpx;
  175. margin-top: 20rpx;
  176. padding: 30rpx;
  177. justify-content: space-between;
  178. align-items: center;
  179. flex-direction: column;
  180. .policy-content-item-left-title {
  181. width: 100%;
  182. text-overflow: -o-ellipsis-lastline;
  183. overflow: hidden;
  184. text-overflow: ellipsis;
  185. display: -webkit-box;
  186. -webkit-line-clamp: 2;
  187. line-clamp: 2;
  188. -webkit-box-orient: vertical;
  189. font-size: 32rpx;
  190. margin-bottom: 10rpx;
  191. }
  192. .policy-content-item-left-time {
  193. width: 100%;
  194. display: flex;
  195. align-items: center;
  196. .moment {
  197. color: #c1c1c1;
  198. font-size: 24rpx;
  199. margin-right: 20rpx;
  200. white-space: nowrap;
  201. }
  202. .maxMony {
  203. font-size: 24rpx;
  204. color: #00bfbf;
  205. border: 1px solid #00bfbf;
  206. padding: 10rpx;
  207. margin-right: 20rpx;
  208. border-radius: 12rpx;
  209. overflow: hidden;
  210. text-overflow: ellipsis;
  211. white-space: nowrap;
  212. // width: 46%;
  213. // text-align: center;
  214. }
  215. .leftDay {
  216. font-size: 24rpx;
  217. background: #f7bbc3;
  218. color: #e32579;
  219. padding: 10rpx;
  220. border: 1px solid #f7bbc3;
  221. border-radius: 12rpx;
  222. white-space: nowrap;
  223. }
  224. }
  225. .policy-content-item-img {
  226. image {
  227. width: 170rpx;
  228. height: 120rpx;
  229. border-radius: 12rpx;
  230. }
  231. }
  232. }
  233. }
  234. }
  235. }
  236. </style>