yingyangdetail.vue
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
<div class="containerbox">
<div class="sharetop flextwo" @click="back">
<div class="leftrow">
<img src="../../../assets/leftrow.png" alt />
</div>
<div class="sharemiddle">图文类</div>
<div class="flexone" @click.stop="collect">
<div class="sharebtn" style="margin-right:0.5rem;width:0.4rem;height:0.4rem">
<img src="../../../assets/nostar.png" alt v-if="yingyangdetail.is_favorite==0" />
<img src="../../../assets/star.png" alt v-else />
</div>
<div class="sharebtn">
<img src="../../../assets/sharebtn.png" alt />
</div>
</div>
</div>
<div class="yingyangbox">
<div class="yingyangtitle">{{yingyangdetail.title}}</div>
<div class="yingyangcontent" v-html="yingyangdetail.content"></div>
</div>
</div>
</template>
<script>
import { Toast } from 'vant';
export default {
data() {
return {
id: '',
yingyangdetail: '',
}
},
created() {
this.id = this.$route.query.id;
},
methods: {
back() {
this.$router.go(-1)
},
getdetail() {
let that = this;
var url = "/api/index/knowledge_detail";
let param = {
knowledge_id: that.id
};
that.$axios
.post(url, param)
.then(function (res) {
console.log(res);
that.yingyangdetail = res.data.knowledge
})
.catch(function (err) {
console.log(err);
});
},
collect() {
let that = this;
var url = "/api/user/favorite";
let param = {
type: 1,
favorite_id: that.id
};
that.$axios
.post(url, param)
.then(function (res) {
console.log(res);
if (that.yingyangdetail.is_favorite == 0) {
Toast('收藏成功')
that.yingyangdetail.is_favorite = 1;
that.yingyangdetailt = that.yingyangdetail
} else {
Toast('取消收藏成功')
that.yingyangdetail.is_favorite = 0;
that.yingyangdetail = that.yingyangdetail
}
})
.catch(function (err) {
console.log(err);
});
},
},
created() {
document.title = '唐元集公众号'
this.id = this.$route.query.id;
this.getdetail()
}
}
</script>
<style scoped>
.containerbox {
padding: 0.32rem;
box-sizing: border-box;
background: #fff;
}
.yingyangtitle {
color: #02170b;
font-size: 0.4rem;
}
.yingyangcontent {
color: #666e69;
font-size: 0.32rem;
}
.yingyangbox {
margin-top: 0.6rem;
}
</style>