wormcase.vue 5.1 KB

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