wormcase.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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="$imageURL+ '/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="$imageURL+ '/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. uni.navigateBack({
  64. delta:1
  65. })
  66. },
  67. introduce(id) {
  68. uni.navigateTo({
  69. url: "./introduce?id=" + id + "&title=" + this.title
  70. })
  71. },
  72. top() {
  73. uni.pageScrollTo({
  74. scrollTop: 0,
  75. duration: 500
  76. })
  77. },
  78. searchinput() { //搜索
  79. Debounce(() => {
  80. this.search()
  81. }, 1000)()
  82. },
  83. search() { //搜索按钮
  84. this.content = []
  85. if (this.title == "虫情百科") {
  86. this.data.code = 2
  87. this.data.page = 1
  88. this.data.name = this.inputdata
  89. this.getCooperation(this.data)
  90. } else {
  91. this.data.code = 1
  92. this.data.page = 1
  93. this.data.name = this.inputdata
  94. this.getCooperation(this.data)
  95. }
  96. },
  97. },
  98. onLoad(option) {
  99. this.title = option.name
  100. if (option.name == "虫情百科") {
  101. this.data.code = 2
  102. this.data.page = 1
  103. this.data.name = this.inputdata
  104. this.getCooperation(this.data)
  105. this.placeholder = "请输入害虫名称"
  106. } else {
  107. this.data.code = 1
  108. this.data.page = 1
  109. this.data.name = this.inputdata
  110. this.getCooperation(this.data)
  111. this.placeholder = "请输入病害名称"
  112. }
  113. },
  114. onReachBottom() {
  115. this.data.page++
  116. this.getCooperation(this.data)
  117. },
  118. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  119. if (e.scrollTop > 200) { //距离大于200时显示
  120. this.isTop = true
  121. } else { //距离小于200时隐藏
  122. this.isTop = false
  123. }
  124. },
  125. }
  126. </script>
  127. <style lang="scss">
  128. .particulars {
  129. width: 100%;
  130. position: relative;
  131. top: 148rpx;
  132. display: flex;
  133. flex-wrap: wrap;
  134. .particulars_item {
  135. width: 50%;
  136. padding: 20rpx;
  137. box-sizing: border-box;
  138. .imgs {
  139. width: 100%;
  140. height: 220rpx;
  141. position: relative;
  142. .imgbg {
  143. width: 50%;
  144. height: 50%;
  145. position: absolute;
  146. top: 25%;
  147. left: 25%;
  148. }
  149. .imgs_img {
  150. width: 100%;
  151. height: 100%;
  152. position: absolute;
  153. top: 0;
  154. left: 0;
  155. }
  156. }
  157. .info {
  158. font-size: 28rpx;
  159. text-align: center;
  160. margin-top: 20rpx;
  161. }
  162. }
  163. }
  164. .bases_search {
  165. width: 100%;
  166. position: fixed;
  167. top: 88px;
  168. z-index: 100;
  169. background-color: #FFFFFF;
  170. .bases_search_text {
  171. width: 90%;
  172. margin: 0 auto;
  173. background-color: #F8F8F8;
  174. height: 60rpx;
  175. border-radius: 30rpx;
  176. display: flex;
  177. line-height: 60rpx;
  178. .search {
  179. padding: 0 20rpx;
  180. font-size: 34rpx;
  181. }
  182. input {
  183. width: 80%;
  184. margin-top: 10rpx;
  185. font-size: 28rpx;
  186. }
  187. }
  188. }
  189. .top {
  190. position: fixed;
  191. right: 30px;
  192. bottom: 100px;
  193. z-index: 100;
  194. image {
  195. width: 100rpx;
  196. height: 100rpx;
  197. }
  198. }
  199. </style>