mytiezi.vue 12.4 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 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 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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
<template>
  <div>
    <!-- 我的关注 -->
      <div class="tiezhlist" v-if="fenlei==1">
      <div
        class="tieziitem"
        v-for="(item, index) in tiezilist"
        :key="index"
       
      >
        <div class="tiezitop flexone">
          <div class="tieziimg">
            <img :src="item.avatar ? item.avatar : item.to_user.avatar" alt="" />
          </div>
          <div class="tieziright">
            <div class="tiezirighttop flex">
              <div class="timeright">
                <div class="tieziming">
                  {{ item.nickname ? item.nickname : item.to_user.nickname }}
                </div>
                <div class="tiezifen">{{item.to_user.createtime}}</div>
              </div>

              <div>
                <div class="vipimg">
                  <img src="../assets/vip_icon@2x.png" alt="" />
                  <div class="vipname">{{ item.to_user.level.name1 }}</div>
                </div>
                <div class="tiezizhuan" v-for="(item,index) in item.to_user.label" :key="index" >{{item.name_label}}</div>
              </div>
              <img
                :src="item.logo_image"
                class="banggongimg"
                alt=""
                v-for="(item, index) in item.to_user.label"
                :key="index"
              />
              <!-- <img
                src="../assets/peisong_icon@2x.png"
                class="banggongimg"
                alt=""
              /> -->
              <img
                src="../assets/yirenzheng_icon@2x.png"
                class="banggongimg"
                alt=""
                v-if="item.to_user.is_card == 1"
              />
            </div>
            <div class="tiezibto flexone"></div>
          </div>
        </div>
        <div class="tiezicontent">
          <div class="teizicontenttop flextwo">
            <div class="tiezicontentname">{{ item.to_user.title }}</div>
            
          </div>
          <div class="tieziwordbox" v-html="item.to_user.content"></div>

          <div
            class="teiziimgbox flexone"
            v-if="item.video != null"
            @click.stop="govideo(item.to_user.video)"
          >
            <div class="videoimg">
              <img :src="item.to_user.video_image" alt="" />
              <img src="../assets/bofang_icon@2x.png" alt="" class="videobtn" />
            </div>
          </div>
          <div class="teiziimgbox flexone" v-if="item.to_user.images != null">
            <div
              class="tieziimgimg"
              v-for="(item, indexk) in item.to_user.images"
              :key="indexk"
              @click.stop="previewimg(index, indexk, item)"
            >
              <img :src="item" alt="" />
            </div>
          </div>
          
        </div>
      </div>
    </div>
    <!-- 其余三个种类 -->
    <div class="tiezhlist" v-else>
      <div
        class="tieziitem"
        v-for="(item, index) in tiezilist"
        :key="index"
        @click="fenlei != 3 ? luntandetail(item) : ''"
      >
        <div class="tiezitop flexone">
          <div class="tieziimg">
            <img :src="item.avatar ? item.avatar : item.user.avatar" alt="" />
          </div>
          <div class="tieziright">
            <div class="tiezirighttop flex">
              <div class="timeright">
                <div class="tieziming">
                  {{ item.nickname ? item.nickname : item.user.nickname }}
                </div>
                <div class="tiezifen">{{item.createtime}}</div>
              </div>

              <div>
                <div class="vipimg" v-if="item.forum_type == 1">
                  <img src="../assets/vip_icon@2x.png" alt="" />
                  <div class="vipname">{{ item.user.level.name1 }}</div>
                </div>
                <div class="tiezizhuan" v-for="(item,index) in item.user.label" :key="index" >{{item.name_label}}</div>
              </div>
              <img
                :src="item.logo_image"
                class="banggongimg"
                alt=""
                v-for="(item, index) in item.user.label"
                :key="index"
              />
              <!-- <img
                src="../assets/peisong_icon@2x.png"
                class="banggongimg"
                alt=""
              /> -->
              <img
                src="../assets/yirenzheng_icon@2x.png"
                class="banggongimg"
                alt=""
                v-if="item.is_card == 1"
              />
            </div>
            <div class="tiezibto flexone"></div>
          </div>
        </div>
        <div class="tiezicontent">
          <div class="teizicontenttop flextwo">
            <div class="tiezicontentname">{{ item.title }}</div>
            <img
                  src="../assets/xingxing_icon@2x.png"
                  alt=""
                  class="starimg"
                  v-if="item.is_collect==1"
                  @click.stop="collect(index,item.id)"
                />
                <img  src="../assets/weishoucang_icon@2x.png"
                  alt=""
                  class="starimg"
                  v-else
                   @click.stop="collect(index,item.id)"
                />
          </div>
          <div class="tieziwordbox" v-html="item.content"></div>

          <div
            class="teiziimgbox flexone"
            v-if="item.video != null"
            @click.stop="govideo(item.video)"
          >
            <div class="videoimg">
              <img :src="item.video_image" alt="" />
              <img src="../assets/bofang_icon@2x.png" alt="" class="videobtn" />
            </div>
          </div>
          <div class="teiziimgbox flexone" v-if="item.images != null">
            <div
              class="tieziimgimg"
              v-for="(item, indexk) in item.images"
              :key="indexk"
              @click.stop="previewimg(index, indexk, item)"
            >
              <img :src="item" alt="" />
            </div>
          </div>
          <div class="tiezipingbot">
            <div
              class="teizipingitem flexone"
              v-if="item.comment != 0 && fenlei != 3"
            >
              <img src="../assets/pinglun_icon@2x.png" alt="" class="lunimg" />
              {{ item.comment }}
            </div>
            <div
              class="teizipingitem flexone"
              @click.stop="
                fenlei != 3 ? praisedian(item, index) : pingpraise(item, index)
              "
            >
              <img
                src="../assets/zan_icon@2x.png"
                alt=""
                class="lunimg zanimg"
                v-if="item.is_praise == 1"
              />
              <img
                src="../assets/nodianzan.png"
                alt=""
                class="lunimg zanimg"
                v-if="item.is_praise == 2"
              />
              {{ item.praise }}
            </div>
            <div class="teizipingitem flexone">
              <img
                src="../assets/number.png"
                alt=""
                class="lunimg zanimg"
              />
              {{item.view}}
            </div>
             <div class="teizipingitem flexone" v-if="fenlei==0" @click.stop="del(item)">
              <img
                src="../assets/del.png"
                alt=""
                class="lunimg zanimg"
              />
             
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import wx from "weixin-js-sdk";
import Vue from "vue";
import { Toast,Dialog } from "vant";
Vue.use(Toast);
export default {
  props: ["tiezilist", "showpull", "fenlei"],
  dta() {
    return {
      tiezilist: []
    };
  },
  created() {
    this.getappid();
  },
  methods: {
    // 获取appid
    getappid() {
      let that = this;
      console.log(34734894890);
      let urlk = window.location.href;
      var url = "/api/user/get_jssdk";
      let param = {
        url: urlk
      };

      that.$axios
        .post(url, param)
        .then(function (res) {
          console.log(res, "jssdkjsskd");
          wx.config({
            debug: false,
            appId: res.data.appId, // 和获取Ticke的必须一样------必填,公众号的唯一标识
            timestamp: res.data.timestamp, // 必填,生成签名的时间戳
            nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
            signature: res.data.signature, // 必填,签名,见附录1
            //需要分享的列表项:发送给朋友,分享到朋友圈,分享到QQ,分享到QQ空间
            jsApiList: ["previewImage"]
          });
        })
        .catch(function (err) {
          console.log(err);
        });
    },

     // 收藏和取消收藏
    collect(index,id){
      let that = this;
      var url = "/api/forum/collect";
      var params = {
        forum_id: id
      };
      console.log("7766554", params);
      that.$axios
        .post(url, params)
        .then(res => {
          let newtiezilist=that.tiezilist;
          if( newtiezilist[index].is_collect==2){
              newtiezilist[index].is_collect=1;
              Toast("收藏成功")
          }else{
            newtiezilist[index].is_collect=2;
              Toast("取消收藏成功")
          }
         
          that.tiezilist=newtiezilist;
          that.$forceUpdate()
          that.bannertop = res.data;
        })
        .catch(err => {
          console.log(err);
        });
    },
   

    // 点赞和取消点赞
    praisedian(item, index) {
      let that = this;
      if (that.tiezilist[index].is_praise == 2) {
        Toast("点赞成功");
        that.tiezilist[index].is_praise = 1;
        that.tiezilist[index].praise = that.tiezilist[index].praise + 1;
      } else {
        Toast("取消点赞成功");
        that.tiezilist[index].is_praise = 2;
        that.tiezilist[index].praise = that.tiezilist[index].praise - 1;
      }

      that.tiezilist = that.tiezilist;

      var url = "/api/forum/praise";
      var params = {
        forum_id: item.id
      };
      console.log("参数", params);
      that.$axios
        .post(url, params)
        .then(res => {
          console.log(res);
        })
        .catch(err => {
          console.log(err);
        });
    },
    // 我的评论赞

    pingpraise(item, index) {
      let that = this;
      console.log(item, index);
      if (this.tiezilist[index].is_praise == 2) {
        Toast("点赞成功");
        this.tiezilist[index].is_praise = 1;
        this.tiezilist[index].praise = this.tiezilist[index].praise + 1;
      } else {
        this.tiezilist[index].is_praise = 2;
        this.tiezilist[index].praise = this.tiezilist[index].praise - 1;
        Toast("取消点赞成功");
      }
      this.tiezilist = this.tiezilist;
      var url = "/api/comments/praise";
      var params = {
        comments_id: item.id
      };
      console.log("参数", params);
      that.$axios
        .post(url, params)
        .then(res => { })
        .catch(err => {
          console.log(err);
        });
    },
    // 论坛详情
    luntandetail(item) {
      this.$router.push({
        path: "/tiezidetail",
        query: { id: item.id }
      });
    },
    // 进入video
    govideo(src) {
      console.log(src);
      this.$router.push({
        path: "/videoplay",
        query: { url: src }
      });
    },
    // 预览图片
    previewimg(index, indexk, item) {
     
      wx.previewImage({
        current: item, // 当前显示图片的http链接
        urls: this.tiezilist[index].images // 需要预览的图片http链接列表
      });
    },
    del(item) {
				let that = this;
        console.log(3443893489809)
         Dialog.confirm({
        title: "是否撤销帖子"
      })
        .then(res => {
          console.log(3489348);
          let that = this;
          var url = "/api/forum/delete_forum";
          let param = {
           	forum_id: item.id
          };

          that.$axios
            .post(url, param)
            .then(function (res) {
              console.log(res);
             that.tiezilist.forEach(function(value,index,array){
                if(value.id==item.id){
                   that.tiezilist.splice(index,1)
                }
             })
             that.tiezilist=that.tiezilist;
             that.$forceUpdate()
            })
            .catch(function (err) {
              console.log(err);
            });
          // on confirm
        })
        .catch(res => {
          // on cancel
        });
				
			},
  }
};
</script>
<style scoped>
@import "./style/homepage.css";
</style>