introduce.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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="详情"></uni-nav-bar>
  7. </view>
  8. <view class="img_box">
  9. <image :src="'http://static.yfpyx.com/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. },
  67. examine(url) {
  68. var imgarr =[]
  69. imgarr.push(url)
  70. console.log(imgarr)
  71. uni.previewImage({
  72. urls: imgarr
  73. });
  74. }
  75. },
  76. onLoad(option) {
  77. console.log(option)
  78. this.unititle = option.title
  79. this.getIntroduce(option.id)
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .name {
  85. font-size: 34rpx;
  86. font-weight: 700;
  87. width: 95%;
  88. margin: 100rpx auto 0;
  89. }
  90. .img_box{
  91. width: 100%;
  92. height: 320rpx;
  93. position: relative;
  94. top: 44px;
  95. .imgbg{
  96. width: 30%;
  97. height: 50%;
  98. position: absolute;
  99. top: 25%;
  100. left: 35%;
  101. }
  102. .img{
  103. width: 100%;
  104. height: 100%;
  105. position: absolute;
  106. }
  107. }
  108. .prevention {
  109. font-size: 28rpx;
  110. color: #919191;
  111. width: 95%;
  112. margin: 20rpx auto;
  113. .prevention_title {
  114. display: flex;
  115. p {
  116. margin-left: 20rpx;
  117. color: #000000;
  118. font-size: 28rpx;
  119. font-weight: 700;
  120. }
  121. }
  122. .prevention_con {
  123. padding-left: 6%;
  124. }
  125. }
  126. </style>