introduce.vue 2.3 KB

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