index.vue 6.21 KB
Newer Older
Esteban Choque's avatar
Esteban Choque committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<template>
  <section
    class="container page">

    <div class="page-header">
      <div
        class="page-img-main"
        :style="{ 'background-image': `url(`+forum.img_dest+`)` }"></div>
      <div class="page-title">
        <h1 v-html=" post_title "></h1>
        <div class="page-title-details">
          <nuxt-link
            :to="$i18n.path(`participa/`)">
            Participa
          </nuxt-link> /
          <nuxt-link
            :to="$i18n.path(`participa/`+$route.params.id_forum+`/`+$route.params.name_forum)">
            {{ foro_nombre }}
          </nuxt-link> /
          <nuxt-link
            :to="$i18n.path(`participa/`+$route.params.id_forum+`/`+$route.params.name_forum)">
            {{ categoria_nombre }}
          </nuxt-link> /
24
          Publicado por <span> {{ post_nombre }} el {{ $datetime.format(post_fecha_publicacion, 'dd de MMM del YYYY a las HH:mm') }}</span>
Esteban Choque's avatar
Esteban Choque committed
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
        </div>
      </div>
    </div>

    <div
      class="page-content">
      <p>{{ post_body }}</p>
      <h3 class="subtitle">
        Respuestas
      </h3>
      <div
        v-for="topic in forum.topics"
        :key="topic.id_topic"
        class="publicacion2">
        <div
          v-for="post in topic.posts"
          :key="post.id_post">
          <div
            v-for="replie in post.replies"
            :key="replie.id_replie">
45
            <p class="info_post">Publicado por {{ replie.nombre }} el {{ $datetime.format(replie.fecha_publicacion, 'dd de MMM del YYYY a las HH:mm') }}</p>
Esteban Choque's avatar
Esteban Choque committed
46
47
48
49
50
51
52
53
            <p>{{ replie.body }}</p>
            <hr class="separador_post">
          </div>
        </div>
      </div>
      <h3 class="subtitle">
        Respuesta a: {{ post_title }}
      </h3>
54
55
      <p class="tu_info">Tu Información:</p>
      <span class="demo-input-label">Nombre (requerido):</span>
Esteban Choque's avatar
Esteban Choque committed
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
      <el-input 
        placeholder="Escribe tu nombre"
        v-model="nombre"></el-input>
      <span class="demo-input-label">Email (no será publicado)(requerido):</span>
      <el-input 
        placeholder="Escribe tu correo"
        v-model="correo"></el-input>
      <span class="demo-input-label">Contenido de la respuesta:</span>
      <el-input
        type="textarea"
        :autosize="{ minRows: 4, maxRows: 8}"
        placeholder="Escribe contenido para la respuesta"
        v-model="contenido">
      </el-input>
      <el-row 
        type="flex"
        class="row-bg"
        justify="center">
        <el-button
          @click="sendReplie"
          type="info"
          class="btn_nuevo_debate">Enviar</el-button>
      </el-row>

    </div>
  </section>
</template>

<script>
import axios from 'axios';
export default {
  head () {
    return {
      title: this.post_title
    };
  },
  data() {
    return {
      forum: [],
      id_publicacion:'',
      nombre: '',
      correo: '',
      titulo: '',
      contenido: '',
      page_tit: '',
      post_title: '',
      post_nombre: '',
      post_body: '',
      post_fecha_publicacion: '',
      foro_nombre: '',
      categoria_nombre: ''
    };
  },
  mounted () {
    this.$store.commit('CLOSE_MENU');
    this.$util.setBackgroundImage();
    this.getTopic();
113
    //console.log('url '+this.$foro.url);
Esteban Choque's avatar
Esteban Choque committed
114
115
116
  },
  methods: {
    getTopic() {
117
118
     //axios.get('http://localhost/wordpress/index.php?rest_route=/getPost/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/'+this.$route.params.id_post)
     axios.get(this.$foro.url+'/getPost/v1/'+this.$route.params.id_forum+'/'+this.$route.params.id_topic+'/'+this.$route.params.id_post)
Esteban Choque's avatar
Esteban Choque committed
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
      .then(response => {
        this.forum = response.data[this.$route.params.id_forum];
        this.page_tit = this.forum.topics[this.$route.params.id_topic].name;
        
        this.post_title = this.forum.topics[this.$route.params.id_topic].posts[this.$route.params.id_post].title;
        this.post_nombre = this.forum.topics[this.$route.params.id_topic].posts[this.$route.params.id_post].nombre;
        this.post_body = this.forum.topics[this.$route.params.id_topic].posts[this.$route.params.id_post].body;
        this.post_fecha_publicacion = this.forum.topics[this.$route.params.id_topic].posts[this.$route.params.id_post].fecha_publicacion;
        
        this.foro_nombre = this.forum.name;
        this.categoria_nombre = this.forum.topics[this.$route.params.id_topic].name;

        //console.log(response.data); // ex.: { user: 'Your User'}
        console.log(response.status); // ex.: 200
     }); 
    },
    sendReplie() {
      this.params = {
        id_publicacion: this.$route.params.id_post,
        nombre: this.nombre,
        correo: this.correo,
        post_title: this.titulo,
        the_content: this.contenido
      };
143
144
      //axios.post('http://localhost/wordpress/index.php?rest_route=/addTopicPost/v1/', this.params)
      axios.post(this.$foro.url+'/addTopicPost/v1/', this.params)
Esteban Choque's avatar
Esteban Choque committed
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
      .then(response => {
        /*this.replies = response.data;
        console.log("metodo post "+this.replies);*/
        console.log("metodo post "+response.data);
        console.log(response.status); // ex.: 200
        this.getTopic();
        this.nombre = "";
        this.correo = "";
        this.titulo = "";
        this.contenido = "";
     });
    }
  }
};
</script>


<style lang="scss" src="./page.scss"></style>
<style lang="scss">
.publicacion
{
  background: #ffffff;
  padding-left: 25px;
  padding-bottom: 15px;
  border-bottom:1px solid #e8e8e8;
  display: block;
  margin-top: -25px;
  margin-left: -25px;
  margin-right: -25px;
}
.demo-input-label {
    display: inline-block;
    /*width: 130px;*/
  }
.btn_nuevo_debate
{
  margin-top:20px;
}
.respuesta{
  border-top:1px solid #e8e8e8;
  border-bottom:1px solid #e8e8e8;
}
.separador_post
{
  display: block !important;
  margin-top: 0.5em !important;
  margin-bottom: 0.5em !important;
  margin-left: auto !important;
  margin-right: auto !important;
  border-style: inset !important;
  border-width: 1px !important;
  border-top: 1px solid #e8e8e8 !important;
}
.subtitle
{
  background: #024f9b;
  color:#fff;
  margin-left: -25px;
  margin-right: -25px;
  padding-top: 15px;
  padding-right: 25px;
  padding-bottom: 15px;
  padding-left: 25px;
  text-align: left;
}
210
211
212
213
214
215
216
217
218
219
.info_post
{
  font-style: italic;
  color: #333333;
  font-size: 1.0rem;
}
.tu_info
{
  font-weight: bold;
}
Esteban Choque's avatar
Esteban Choque committed
220
</style>