|
@@ -1,11 +1,18 @@
|
|
|
<template>
|
|
|
<div class="word-card" v-loading="loading">
|
|
|
<div class="word-card-top">
|
|
|
- <span class="progress">1 / 10</span>
|
|
|
+ <ul>
|
|
|
+ <li class="active">
|
|
|
+ <label>本文释义</label>
|
|
|
+ <span></span>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
<div class="btn-box">
|
|
|
- <svg-icon icon-class="arrow-left-line"></svg-icon>
|
|
|
- <svg-icon icon-class="arrow-right-line"></svg-icon>
|
|
|
- <svg-icon icon-class="like-line"></svg-icon>
|
|
|
+ <svg-icon icon-class="arrow-left-line" :class="[phraseActiveIndex===0?'not-allow':'']" v-if="wordList&&wordList.length>0" @click="changeIndex('-')"></svg-icon>
|
|
|
+ <span class="progress" v-if="wordList&&wordList.length>0">{{(phraseActiveIndex+1)+' / '+wordList.length}}</span>
|
|
|
+ <svg-icon icon-class="arrow-right-line" :class="[phraseActiveIndex===wordList.length-1?'not-allow':'']" v-if="wordList&&wordList.length>0" @click="changeIndex('+')"></svg-icon>
|
|
|
+ <svg-icon icon-class="like-line" className="icon-like" v-if="!data.collect" @click="handleCollect(data)"></svg-icon>
|
|
|
+ <svg-icon icon-class="like" className="icon-like active" v-else @click="handleCollect(data)"></svg-icon>
|
|
|
<i class="el-icon-close" @click="closeWord"></i>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -120,7 +127,7 @@ import { getLogin } from "@/api/ajax";
|
|
|
export default {
|
|
|
//import引入的组件需要注入到对象中才能使用
|
|
|
components: { },
|
|
|
- props: ["data"],
|
|
|
+ props: ["dataObj","wordList","activeObjIndex","likePhrase"],
|
|
|
data() {
|
|
|
//这里存放数据
|
|
|
return {
|
|
@@ -135,6 +142,8 @@ export default {
|
|
|
voicePlaySrc: require("../../../assets/voice-play-gray.png"),
|
|
|
sentKwicData: null,
|
|
|
allList: [],
|
|
|
+ phraseActiveIndex: this.activeObjIndex, //JSON.parse(JSON.stringify(this.activeObjIndex))
|
|
|
+ data: JSON.parse(JSON.stringify(this.dataObj))
|
|
|
}
|
|
|
},
|
|
|
//计算属性 类似于data概念
|
|
@@ -211,6 +220,75 @@ export default {
|
|
|
.catch(() => {
|
|
|
this.loading = false
|
|
|
});
|
|
|
+ },
|
|
|
+ handleCollect(item){
|
|
|
+ if(item.collect){
|
|
|
+ let MethodName = "/ShopServer/Client/CollectManager/CancelCollect_Word";
|
|
|
+ let data = {
|
|
|
+ word: item.word,
|
|
|
+ }
|
|
|
+ getLogin(MethodName, data)
|
|
|
+ .then((res) => {
|
|
|
+ this.loading = false
|
|
|
+ if(res.status===1){
|
|
|
+ item.collect = false
|
|
|
+ this.$forceUpdate()
|
|
|
+ this.$message({
|
|
|
+ message: "取消收藏",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ this.likePhrase.splice(this.likePhrase.indexOf(item.word),1)
|
|
|
+ this.$emit('changeLike','likeWordList',this.likePhrase)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ let MethodName = "/ShopServer/Client/CollectManager/AddCollect_Word";
|
|
|
+ let data = {
|
|
|
+ word: item.word,
|
|
|
+ pinyin: item.symbol,
|
|
|
+ explain: JSON.stringify(item.paraList),
|
|
|
+ is_new: "true",
|
|
|
+ audio_file_id: item.word_explain&&item.word_explain.ph_mp3_id?item.word_explain.ph_mp3_id:'',
|
|
|
+ audio_file_url: item.word_explain&&item.word_explain.ph_file_url?item.word_explain.ph_file_url:'',
|
|
|
+ article_id: this.$route.query.id,
|
|
|
+ word_id: item.id
|
|
|
+ }
|
|
|
+ getLogin(MethodName, data)
|
|
|
+ .then((res) => {
|
|
|
+ this.loading = false
|
|
|
+ if(res.status===1){
|
|
|
+ item.collect = true
|
|
|
+ this.$forceUpdate()
|
|
|
+ this.$message({
|
|
|
+ message: "收藏成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ this.likePhrase.push(item.word)
|
|
|
+ this.$emit('changeLike','likeWordList',this.likePhrase)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ changeIndex(type){
|
|
|
+ if(type==='-'){
|
|
|
+ if(this.phraseActiveIndex>0){
|
|
|
+ this.phraseActiveIndex--
|
|
|
+ this.data = this.wordList[this.phraseActiveIndex]
|
|
|
+ }else{
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(this.phraseActiveIndex<this.wordList.length-1){
|
|
|
+ this.phraseActiveIndex++
|
|
|
+ this.data = this.wordList[this.phraseActiveIndex]
|
|
|
+ }else{
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
@@ -274,6 +352,15 @@ export default {
|
|
|
cursor: pointer;
|
|
|
width: 32px;
|
|
|
height: 16px;
|
|
|
+ &.not-allow{
|
|
|
+ color: rgba(78, 89, 105, 0.3);
|
|
|
+ cursor: not-allowed;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .icon-like{
|
|
|
+ &.active{
|
|
|
+ color: #F2555A;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|