123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- <template>
- <view style="width: 100%;height: 100%;padding: 32rpx 28rpx;background-color: #FFFFFF;">
- <!-- 头部 -->
- <view class="title">
- <!-- 标题左边 -->
- <view style="width: 80%;height: auto;">
- <view class="l">{{title}}</view>
- <view style="color: #999999;font-size: 22rpx;">发布时间:{{info.created_at}}</view>
- </view>
- <!-- 标题右边 -->
- <view class="r">
- <view class="shoucang" @click="sc">
- <image :src="imgsrc" style="width: 24rpx; height: 24rpx;margin-right: 15rpx;"></image>
- <text style="font-size: 26rpx;color: #666666;">收藏</text>
- </view>
- </view>
- </view>
- <!-- 文章内容 -->
- <view class="content">
- {{info.content}}
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- title: '',
- id: "",
- info: {},
- imgsrc: "../../../static/img/start_gray.png"
- }
- },
- mounted() {
- this.getdetailes()
- },
- methods: {
- //收藏点击事件
- sc: async function() {
- let res = await this.$request.post("/api/v1/collection/submitCollect", {
- type: 2,
- relation_id: this.info.id
- })
- console.log(res)
- if (res.status == 0) {
- if (res.data.is_collect == 0) {
- this.imgsrc = "../../../static/img/start_gray.png"
- uni.showToast({
- title: "取消成功",
- icon: "none"
- })
- } else {
- this.imgsrc = "../../../static/img/start.png"
- uni.showToast({
- title: "收藏成功",
- icon: "none"
- })
- }
- }
- },
- getdetailes: async function() {
- let res = await this.$request.post("/api/v1/article/articleDetail", {
- article_id: this.id
- })
- if (res.status == 0) {
- this.info = res.data
- }
- if (this.info.is_collect == 0) {
- this.imgsrc = "../../../static/img/start_gray.png"
- } else {
- this.imgsrc = "../../../static/img/start.png"
- }
- }
- },
- onLoad: function(option) { //option为object类型,会序列化上个页面传递的参数
- this.title = option.title
- uni.setNavigationBarTitle({
- title: this.title
- })
- this.id = option.id
- }
- }
- </script>
- <style lang="scss">
- .title {
- display: flex;
- padding-bottom: 40rpx;
- //左
- .l {
- font-size: 45rpx;
- font-weight: bold;
- margin-bottom: 10rpx;
- }
- //右
- .r {
- width: 20%;
- height: 100rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- //收藏
- .shoucang {
- height: 48rpx;
- width: 136rpx;
- border-radius: 27rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- border: 1px solid #C0C0C0;
- }
- }
- }
- .content {
- color: #999999;
- font-size: 32rpx;
- background: #F6F6F6;
- line-height: 32px;
- }
- </style>
|