wormcase.vue 4.3 KB

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