introduce.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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="详情"></uni-nav-bar>
  7. </view>
  8. <view class="img_box">
  9. <image :src="$imageURL+'/bigdata_app'+'/image/loading-2.gif'" mode="" class="imgbg"></image>
  10. <image :src="wormcasedata.img_urls" mode="" class="img" @click="examine(wormcasedata.img_urls)"></image>
  11. </view>
  12. <p class="name">{{wormcasedata.name}}</p>
  13. <view v-for="(item,index) in preventionArr" :key="index" class="prevention">
  14. <view class="prevention_title">
  15. <u-icon name="play-right-fill" size="24" color="#55A92D"></u-icon>
  16. <p>{{regexptitle[index]}}:</p>
  17. </view>
  18. <p class="prevention_con">{{item}}</p>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. wormcasedata: {},
  28. unititle: '',
  29. wormdata: { //虫子数据
  30. },
  31. disease: { //病害数据
  32. },
  33. preventionArr: [],
  34. regexptitle: []
  35. }
  36. },
  37. methods: {
  38. async getIntroduce(data) {
  39. const res = await this.$myRequest({
  40. url: '/api/api_gateway?method=pest.pests.pests_info',
  41. data: {
  42. pest_id: data
  43. }
  44. })
  45. console.log(res)
  46. this.wormcasedata = res
  47. var regex2 = /\[(.+?)\]/g; // [] 中括号
  48. var str = this.wormcasedata.prevention
  49. var arr = str.match(regex2)
  50. var arrindex = []
  51. for (var i = 0; i < arr.length; i++) {
  52. arrindex.push(str.indexOf(arr[i]))
  53. }
  54. for (var i = 0; i < arr.length; i++) {
  55. this.preventionArr.push(str.slice(arrindex[i] + arr[i].length, arrindex[i + 1]))
  56. }
  57. for (var i = 0; i < arr.length; i++) {
  58. arr[i] = arr[i].slice(1, arr[i].length - 1)
  59. }
  60. this.regexptitle = arr
  61. },
  62. clickLeft() {
  63. // uni.navigateTo({
  64. // url: "./wormcase?name=" + this.unititle
  65. // })
  66. uni.navigateBack({
  67. delta:1
  68. })
  69. },
  70. examine(url) {
  71. var imgarr =[]
  72. imgarr.push(url)
  73. console.log(imgarr)
  74. uni.previewImage({
  75. urls: imgarr
  76. });
  77. }
  78. },
  79. onLoad(option) {
  80. console.log(option)
  81. this.unititle = option.title
  82. this.getIntroduce(option.id)
  83. }
  84. }
  85. </script>
  86. <style lang="scss">
  87. .name {
  88. font-size: 34rpx;
  89. font-weight: 700;
  90. width: 95%;
  91. margin: 100rpx auto 0;
  92. }
  93. .img_box{
  94. width: 100%;
  95. height: 320rpx;
  96. position: relative;
  97. top: 44px;
  98. .imgbg{
  99. width: 30%;
  100. height: 50%;
  101. position: absolute;
  102. top: 25%;
  103. left: 35%;
  104. }
  105. .img{
  106. width: 100%;
  107. height: 100%;
  108. position: absolute;
  109. }
  110. }
  111. .prevention {
  112. font-size: 28rpx;
  113. color: #919191;
  114. width: 95%;
  115. margin: 20rpx auto;
  116. .prevention_title {
  117. display: flex;
  118. p {
  119. margin-left: 20rpx;
  120. color: #000000;
  121. font-size: 28rpx;
  122. font-weight: 700;
  123. }
  124. }
  125. .prevention_con {
  126. padding-left: 6%;
  127. }
  128. }
  129. </style>