xiangjie.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="word-view-page words-details-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">单词详解</text>
  6. </view>
  7. <view class="ezy-page-body words-details-body">
  8. <view class="ezy-border-body ">
  9. <view class="details-word">{{pageInfo.name}}</view>
  10. <view class="details-content-box">
  11. <text class="details-title">通用释义</text>
  12. <view class="tysy-content" v-for="(item,index) in pageInfo.xiangyi" :key="index">{{item}}</view>
  13. </view>
  14. <view class="details-content-box">
  15. <text class="details-title">实用口语</text>
  16. <view v-for="(item,index) in pageInfo.kouyu" :key="index" class="syky-content">
  17. <view class="details-en-content">
  18. <rich-text :nodes="highlightWord(item.en)"></rich-text>
  19. <!-- <text>{{item.en}}</text> -->
  20. <!-- 变色 word-color-->
  21. <!-- <text class="word-color">{{item.en}}</text>
  22. <text>{{item.en}}</text> -->
  23. </view>
  24. <view class="details-cn-content">{{item.zn}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script setup>
  32. import {
  33. reactive,
  34. ref,
  35. onMounted
  36. } from 'vue';
  37. import {
  38. getDanciChanpinWordInfo
  39. } from "@/api/chaojidanci.js"
  40. import {
  41. onLoad
  42. } from '@dcloudio/uni-app';
  43. import {
  44. getUserIdentity,
  45. } from "@/utils/common.js"
  46. const goXiangjie = () => {
  47. }
  48. const pageInfo = ref({
  49. kouyu: [],
  50. xiangyi: [],
  51. name: ''
  52. })
  53. const data = ref(null)
  54. onLoad((options) => {
  55. getInfo(options)
  56. data.value = options
  57. })
  58. const highlightWord = (text) => {
  59. if (!text || !pageInfo.value.name) {
  60. return text
  61. }
  62. const word = pageInfo.value.name;
  63. const regex = /<([^>]+)>/g;
  64. console.log('pageInfo.value.name', pageInfo.value.name);
  65. return text.replace(regex, (match) => {
  66. return `<span style="color: #3a7fe9;">${match.replace(/[<>]/g, "")}</span>`;
  67. });
  68. }
  69. const handleBack = () => {
  70. uni.redirectTo({
  71. url: `/pages/chaojidanci/newEnglish/index?danyuanId=${data.value.danyuanId}&wordId=${data.value.wordId}`
  72. });
  73. }
  74. const getInfo = (data) => {
  75. let req = {
  76. danyuanId: data.danyuanId,
  77. wordId: data.wordId
  78. }
  79. getDanciChanpinWordInfo(req).then(res => {
  80. console.log('res', res);
  81. pageInfo.value = res.data
  82. })
  83. }
  84. </script>
  85. <style>
  86. </style>