You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

141 line
4.2 KiB

  1. <template>
  2. <view class="translation">
  3. <view style="width: 690rpx;height: 64rpx;margin: 0 auto;margin-top: 30rpx;background: #F2F2F2;border-radius: 32rpx;
  4. display: flex;align-items: center;">
  5. <view style="width: 10%;height: 64rpx;display: flex;align-items: center;">
  6. <image style="width: 28rpx;height: 28rpx;margin-left: 30rpx;" src="/static/images/search.png" mode=""></image>
  7. </view>
  8. <view style="width: 90%;height: 64rpx;display: flex;align-items: center;">
  9. <input type="text" @input="searchinfo" :disabled="disabled" v-model="keyword" placeholder="请输入关键字"
  10. style="width: 100%;color: #999999;font-size: 24rpx;"/>
  11. </view>
  12. </view>
  13. <view style="width: 690rpx;margin: 0 auto;margin-top: 10rpx;">
  14. <view style="width: 100%;border-bottom: 1px solid #E0E0E0;display: flex;padding-bottom: 10rpx;margin-top: 40rpx;"
  15. v-for="(item,index) in listarr" :key='index' @click="toaidoinfo(item.Content,item.corpusId,item.index)">
  16. <view style="width: 26rpx;height: 36rpx;margin-top: 4rpx;">
  17. <image style="width: 26rpx;height: 28rpx;" src="/static/images/testimg.png" mode=""></image>
  18. </view>
  19. <view v-html="item.Content.text" style="color: #666666;font-size: 28rpx;line-height: 36rpx;margin-left: 10rpx;width: 80%;"></view>
  20. <view style="font-size: 28rpx;width: 10%;width: 14%;text-align: right;">{{item.Content.time}}</view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. var util = require("../../../utils/util.js");
  27. var config = require("../../../config");
  28. export default {
  29. data() {
  30. return {
  31. customerId:'',
  32. listarr:[],
  33. keyword:'',
  34. skpl:'',
  35. disabled:false
  36. };
  37. },
  38. onLoad: function(options) {
  39. this.customerId = options.customerId;
  40. this.keyword=options.keyword;
  41. this.skpl=options.skpl;
  42. },
  43. methods: {
  44. formatTime(num) {
  45. //格式化时间格式
  46. num = num.toFixed(0);
  47. let second = num % 60;
  48. if (second < 10) second = '0' + second;
  49. let min = Math.floor(num / 60);
  50. if (min < 10) min = '0' + min;
  51. return min + ":" + second;
  52. },
  53. searchinfo(){
  54. if(this.keyword.length==0){
  55. return
  56. }else{
  57. let parames={
  58. keyword:this.keyword,
  59. customerId:this.customerId
  60. }
  61. this.$u.post("/corpus/keyWordsMatching", parames).then(res => {
  62. res.forEach(item=>{
  63. item.Content=JSON.parse(item.transferContent)
  64. })
  65. res.forEach(cet=>{
  66. cet.Content.time=this.formatTime(cet.Content.bg/1000)
  67. cet.Content.text=this.brightKeyword(cet.Content.onebest)
  68. })
  69. this.listarr=res;
  70. })
  71. }
  72. },
  73. //替换方法
  74. brightKeyword(val) {
  75. if (val.indexOf(this.keyword) !== -1) {
  76. return val.replace(this.keyword, `<font style='color: red'>${this.keyword}</font>`);
  77. } else {
  78. return val;
  79. }
  80. },
  81. //跳转
  82. toaidoinfo(item,id,index){
  83. item.customerId=this.customerId;
  84. item.id=id;
  85. item.index=index;
  86. if(this.skpl==2){
  87. this.infostust(item)
  88. }else{
  89. let pages = getCurrentPages() //获取当前页面栈的信息
  90. let prevPage = pages[pages.length - 2] //获取上一个页面
  91. prevPage.setData({ //把需要回传的值保存到上一个页面
  92. info: item
  93. });
  94. wx.navigateBack({ //然后返回上一个页面
  95. delta: 1
  96. })
  97. }
  98. },
  99. //只有一条的时候
  100. infostust(item){
  101. let d = JSON.parse(JSON.stringify([item]))
  102. var itemobjhh={
  103. bg:d[0].bg,
  104. customerId:d[0].customerId,
  105. id:'',
  106. onebest:d[0].onebest,
  107. }
  108. const parames = {
  109. pageNum: 1,
  110. pageSize: 100,
  111. query: {
  112. customerId: this.customerId,
  113. }
  114. }
  115. console.log(item)
  116. this.$u.post("/corpus/findByPage", parames).then(res => {
  117. if(res[0].merge==0){
  118. let newobj = res[0];
  119. uni.navigateTo({
  120. url: `/pages/learning/Thefulltext/index2?customerId=${newobj.customerId}&status=${newobj.status}&itemobj=${JSON.stringify(itemobjhh)}&stateisshow=${'2'}`
  121. })
  122. }else{
  123. let newobj = res[0];
  124. uni.navigateTo({
  125. url: `/pages/learning/Thefulltext/index?customerId=${newobj.customerId}&status=${newobj.status}&itemobj=${JSON.stringify(itemobjhh)}&stateisshow=${'2'}`
  126. })
  127. }
  128. })
  129. },
  130. },
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. </style>