wormcase.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 64px;">
  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="particulars">
  9. <view class="particulars_item" v-for="(item,index) in content" :key="index" @click="introduce(item.id)">
  10. <view class="imgs">
  11. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/loading-2.gif'" mode="" class="imgbg"></image>
  12. <image :src="item.img_urls" mode="" class="imgs_img"></image>
  13. </view>
  14. <p>{{item.name}}</p>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="top" v-if="isTop" @click="top">
  19. <image :src="'http://static.yfpyx.com/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. title: '',
  28. content: [],
  29. data: {
  30. code: null,
  31. page: null
  32. },
  33. isTop:false
  34. }
  35. },
  36. methods: {
  37. async getCooperation(data) {
  38. const res = await this.$myRequest({
  39. url: '/api/api_gateway?method=pest.pests.pests_search',
  40. data: {
  41. code: data.code,
  42. page: data.page
  43. }
  44. })
  45. this.content = this.content.concat(res.data)
  46. },
  47. clickLeft() {
  48. uni.navigateTo({
  49. url: "./index"
  50. })
  51. },
  52. introduce(id) {
  53. uni.navigateTo({
  54. url: "./introduce?id=" + id + "&title=" + this.title
  55. })
  56. },
  57. top() {
  58. uni.pageScrollTo({
  59. scrollTop: 0,
  60. duration: 500
  61. })
  62. },
  63. },
  64. onLoad(option) {
  65. this.title = option.name
  66. if (option.name == "虫情百科") {
  67. this.data.code = 2
  68. this.data.page = 1
  69. this.getCooperation(this.data)
  70. } else {
  71. this.data.code = 1
  72. this.data.page = 1
  73. this.getCooperation(this.data)
  74. }
  75. },
  76. onReachBottom() {
  77. this.data.page++
  78. this.getCooperation(this.data)
  79. },
  80. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  81. if (e.scrollTop > 200) { //距离大于200时显示
  82. this.isTop = true
  83. } else { //距离小于200时隐藏
  84. this.isTop = false
  85. }
  86. },
  87. }
  88. </script>
  89. <style lang="scss">
  90. .particulars {
  91. width: 100%;
  92. position: relative;
  93. top: 88rpx;
  94. display: flex;
  95. flex-wrap: wrap;
  96. .particulars_item {
  97. width: 50%;
  98. padding: 20rpx;
  99. box-sizing: border-box;
  100. .imgs {
  101. width: 100%;
  102. height: 220rpx;
  103. position: relative;
  104. .imgbg {
  105. width: 50%;
  106. height: 50%;
  107. position: absolute;
  108. top: 25%;
  109. left: 25%;
  110. }
  111. .imgs_img {
  112. width: 100%;
  113. height: 100%;
  114. position: absolute;
  115. top: 0;
  116. left: 0;
  117. }
  118. }
  119. p {
  120. font-size: 24rpx;
  121. }
  122. }
  123. }
  124. .top {
  125. position: fixed;
  126. right: 30px;
  127. bottom: 100px;
  128. z-index: 100;
  129. image {
  130. width: 100rpx;
  131. height: 100rpx;
  132. }
  133. }
  134. </style>