introduce.vue 2.1 KB

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