wormcase.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 44px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" :title="title"></uni-nav-bar>
  7. </view>
  8. <view class="bases_search">
  9. <view class="bases_search_text">
  10. <u-icon name="search" class="search" @click="search"></u-icon>
  11. <input type="text" v-model="inputdata" :placeholder="placeholder" @input="searchinput" />
  12. </view>
  13. </view>
  14. <view class="particulars">
  15. <view class="particulars_item" v-for="(item,index) in content" :key="index" @click="introduce(item.id)">
  16. <view class="imgs">
  17. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/cb/jiazai.ui.gif'" mode="" class="imgbg"></image>
  18. <image :src="item.img_urls" mode="" class="imgs_img"></image>
  19. </view>
  20. <p class="info">{{item.name}}</p>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="top" v-if="isTop" @click="top">
  25. <image :src="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. Debounce,
  32. Throttle
  33. } from "../../util/anitthro.js"
  34. export default {
  35. data() {
  36. return {
  37. title: '',
  38. content: [],
  39. data: {
  40. code: null,
  41. page: null
  42. },
  43. isTop: false,
  44. inputdata: ""
  45. }
  46. },
  47. methods: {
  48. async getCooperation(data) {
  49. const res = await this.$myRequest({
  50. url: '/api/api_gateway?method=pest.pests.pests_search',
  51. data: {
  52. code: data.code,
  53. page: data.page,
  54. name: data.name
  55. }
  56. })
  57. this.content = this.content.concat(res.data)
  58. },
  59. clickLeft() {
  60. uni.navigateTo({
  61. url: "./index"
  62. })
  63. },
  64. introduce(id) {
  65. uni.navigateTo({
  66. url: "./introduce?id=" + id + "&title=" + this.title
  67. })
  68. },
  69. top() {
  70. uni.pageScrollTo({
  71. scrollTop: 0,
  72. duration: 500
  73. })
  74. },
  75. searchinput() { //搜索
  76. Debounce(() => {
  77. this.search()
  78. }, 1000)()
  79. },
  80. search() { //搜索按钮
  81. this.content = []
  82. if (this.title == "虫情百科") {
  83. this.data.code = 2
  84. this.data.page = 1
  85. this.data.name = this.inputdata
  86. this.getCooperation(this.data)
  87. } else {
  88. this.data.code = 1
  89. this.data.page = 1
  90. this.data.name = this.inputdata
  91. this.getCooperation(this.data)
  92. }
  93. },
  94. },
  95. onLoad(option) {
  96. this.title = option.name
  97. if (option.name == "虫情百科") {
  98. this.data.code = 2
  99. this.data.page = 1
  100. this.data.name = this.inputdata
  101. this.getCooperation(this.data)
  102. this.placeholder = "请输入害虫名称"
  103. } else {
  104. this.data.code = 1
  105. this.data.page = 1
  106. this.data.name = this.inputdata
  107. this.getCooperation(this.data)
  108. this.placeholder = "请输入病害名称"
  109. }
  110. },
  111. onReachBottom() {
  112. this.data.page++
  113. this.getCooperation(this.data)
  114. },
  115. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  116. if (e.scrollTop > 200) { //距离大于200时显示
  117. this.isTop = true
  118. } else { //距离小于200时隐藏
  119. this.isTop = false
  120. }
  121. },
  122. }
  123. </script>
  124. <style lang="scss">
  125. .particulars {
  126. width: 100%;
  127. position: relative;
  128. top: 148rpx;
  129. display: flex;
  130. flex-wrap: wrap;
  131. .particulars_item {
  132. width: 50%;
  133. padding: 20rpx;
  134. box-sizing: border-box;
  135. .imgs {
  136. width: 100%;
  137. height: 220rpx;
  138. position: relative;
  139. .imgbg {
  140. width: 50%;
  141. height: 50%;
  142. position: absolute;
  143. top: 25%;
  144. left: 25%;
  145. }
  146. .imgs_img {
  147. width: 100%;
  148. height: 100%;
  149. position: absolute;
  150. top: 0;
  151. left: 0;
  152. }
  153. }
  154. .info {
  155. font-size: 28rpx;
  156. text-align: center;
  157. margin-top: 20rpx;
  158. }
  159. }
  160. }
  161. .bases_search {
  162. width: 100%;
  163. position: fixed;
  164. top: 88px;
  165. z-index: 100;
  166. background-color: #FFFFFF;
  167. .bases_search_text {
  168. width: 90%;
  169. margin: 0 auto;
  170. background-color: #F8F8F8;
  171. height: 60rpx;
  172. border-radius: 30rpx;
  173. display: flex;
  174. line-height: 60rpx;
  175. .search {
  176. padding: 0 20rpx;
  177. font-size: 34rpx;
  178. }
  179. input {
  180. width: 80%;
  181. margin-top: 10rpx;
  182. font-size: 28rpx;
  183. }
  184. }
  185. }
  186. .top {
  187. position: fixed;
  188. right: 30px;
  189. bottom: 100px;
  190. z-index: 100;
  191. image {
  192. width: 100rpx;
  193. height: 100rpx;
  194. }
  195. }
  196. </style>