Blame view

src/views/GrowUp/StoryDetail.vue 3.39 KB
c0087cf1   夏洋涛   feat:创建项目
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
<template>
  <div class="storyDetail" v-if="detailData">
    <div class="content">
      <h3 class="title">{{ detailData.title }}</h3>
      <div class="info">
        <div class="name">
          <p>{{ detailData.name }}</p>
          <p>{{ detailData.intime.substring(0, 10) }}</p>
        </div>
        <p class="like" @click.prevent="zanbtn(detailData.id, detailData.likeId)">
          <img v-if="detailData.likeId > 0" src="@/assets/service/like_on.png" alt="" />
          <img v-else src="@/assets/service/like_off.png" alt="" />
          <span>{{ detailData.likeCount }}</span>
        </p>
      </div>
      <div class="cont">
        {{ detailData.content }}
        <img :src="n.imgUrl" v-for="n in detailData.imgList" :key="n.id" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      userInfo: '',
      detailData: '',
      plList: [],
      plCont: '',
      storyId: '',
    }
  },
  created() {
0713eff5   夏洋涛   feat:适老化
37
    var userInfo = sessionStorage.getItem('userInfo')
c0087cf1   夏洋涛   feat:创建项目
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
    if (userInfo) {
      this.userInfo = JSON.parse(userInfo)
    }
    console.log(this.userInfo)
    var id = (this.storyId = this.$route.query.id)
    this.GetStory(id)
  },
  methods: {
    zanbtn(id, likeId) {
      if (likeId > 0) {
        this.DeleteStoryLike(id)
      } else {
        this.AddStoryLike(id)
      }
    },
    AddStoryLike(id) {
      var that = this
      this.http
        .AddStoryLike({
          type: 1,
          storyId: id,
          userId: this.userInfo ? this.userInfo.centerNo : 0,
        })
        .then((res) => {
          if (res.status == 1) {
            let newDetailData = this.detailData
            newDetailData.likeId = 1
            newDetailData.likeCount++
            this.detailData = newDetailData
          }
        })
    },
    DeleteStoryLike(id) {
      var that = this
      this.http
        .DeleteStoryLike({
          type: 1,
          id: id,
          userId: this.userInfo ? this.userInfo.centerNo : 0,
        })
        .then((res) => {
          if (res.status == 1) {
            let newDetailData = this.detailData
            newDetailData.likeId = 0
            newDetailData.likeCount--
            this.detailData = newDetailData
          }
        })
    },

    GetStory(id) {
      var that = this
      this.http
        .GetStory({
          id: id,
          userId: this.userInfo ? this.userInfo.centerNo : 0,
        })
        .then(function (res) {
          if (res.status == 1) {
            that.detailData = res.data
          }
        })
    },
  },
}
</script>

<style lang="scss" scoped>
.storyDetail {
  .content {
    padding: 40px;
    box-sizing: border-box;
    .title {
      font-size: 2.4rem;
    }
    .info {
      .name {
        display: inline-block;
        vertical-align: middle;
        color: #9d9d9d;
        font-size: 30px;
        p {
          margin: 10px 0;
        }
        p:first-child {
          color: #494949;
          margin: 0;
        }
      }
      .like {
        display: inline-block;
        position: absolute;
        right: 0;
        img {
          width: 32px;
          margin-right: 10px;
        }
        span {
          font-size: 26px;
          margin-right: 10px;
          vertical-align: top;
        }
      }
    }
    .cont {
      padding: 40px 0;
      font-size: 1.4rem;
      img {
        width: 100%;
        margin-top: 20px;
      }
    }
  }
}
</style>
c72c87c8   夏洋涛   feat:审核问题修改,标题栏,适老化