xiangjie.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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-tab-border 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. getWordInfo,
  39. getWordInfoYk
  40. } from "@/api/word.js"
  41. import {
  42. onLoad
  43. } from '@dcloudio/uni-app';
  44. import {
  45. getUserIdentity,
  46. } from "@/utils/common.js"
  47. const goXiangjie = () => {
  48. }
  49. const pageInfo = ref({
  50. kouyu: [],
  51. xiangyi: [],
  52. name: ''
  53. })
  54. const data = ref(null)
  55. const userCode = getUserIdentity();
  56. onLoad((options) => {
  57. if (userCode !== 'Visitor') {
  58. getInfo(options)
  59. data.value = options
  60. } else {
  61. getCommonInfo(options)
  62. data.value = options
  63. }
  64. })
  65. const highlightWord = (text) => {
  66. if (!text || !pageInfo.value.name) {
  67. return text
  68. }
  69. const word = pageInfo.value.name;
  70. const regex = new RegExp(word, 'gi');
  71. console.log('pageInfo.value.name', pageInfo.value.name);
  72. return text.replace(regex, (match) => {
  73. return `<span style="color: #3a7fe9;">${match}</span>`;
  74. });
  75. }
  76. const handleBack = () => {
  77. if (userCode !== 'Visitor') {
  78. uni.redirectTo({
  79. url: `/pages/newEnglish/index?jieId=${data.value.jieId}&wordId=${data.value.wordId}`
  80. });
  81. } else {
  82. console.log('data123',data);
  83. uni.redirectTo({
  84. url: `/pages/newEnglish/index?jieId=${data.value.jieId}&wordId=${data.value.wordId}&levelId=${data.value.levelId}&typeId=${data.value.typeId}&subjectId=${data.value.subjectId}&tipFlag=${data.value.tipFlag}&youkeZhangId=${data.value.youkeZhangId}`
  85. });
  86. }
  87. }
  88. const getInfo = (data) => {
  89. let req = {
  90. jieId: data.jieId,
  91. wordId: data.wordId
  92. }
  93. getWordInfo(req).then(res => {
  94. console.log('res', res);
  95. pageInfo.value = res.data
  96. })
  97. }
  98. const getCommonInfo = (data) => {
  99. let req = {
  100. jieId: data.jieId,
  101. wordId: data.wordId
  102. }
  103. getWordInfoYk(req).then(res => {
  104. console.log('res', res);
  105. pageInfo.value = res.data
  106. })
  107. }
  108. </script>
  109. <style>
  110. </style>