Skip to content
business-detail.ts 2.29 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import {Component, ElementRef, Renderer2, ViewChild} from '@angular/core';
import {IonicPage, ModalController, NavController, NavParams} from 'ionic-angular';
import {AppGlobal} from "../../../../service/http.service";
import {DomSanitizer} from "@angular/platform-browser";
import {TabsService} from "../../../tabs/tabs.service";
import {Storage} from "@ionic/storage";
import {CommonService} from "../../../../provide/common.service";
import {CommentComponent} from "../../../../components/comment/comment";
import {ReplyComponent} from "../../../../components/reply/reply";
import {ServeService} from "../../serve.service";
wangqinghua's avatar
wangqinghua committed

@Component({
  selector: 'page-business-detail',
  templateUrl: 'business-detail.html',
})
export class BusinessDetailPage {

wangqinghua's avatar
wangqinghua committed
  @ViewChild('like') like: ElementRef;
  @ViewChild('collection') collection: ElementRef;

  picture: string = AppGlobal.picture;

  stuffId;   //文章id
  content: string;   //评论内容
  userId;  //用户id
  username;   //用户姓名
  stuffObj;   //文章对象

  //点赞,评价,收藏对象;
  countObj;

  footerView: boolean;
  comment: boolean = false;

  url = AppGlobal.domain + '/wisdomgroup';

  attachments;   //附件
  replyText = '';
  replyItem;
  reply = false;
  replyContent;

  constructor(public navCtrl: NavController, public navParams: NavParams, public sanitizer: DomSanitizer,
              public renderer: Renderer2, private modalCtrl: ModalController,
              public serveSer: ServeService, public storage: Storage, public commonSer: CommonService) {
wangqinghua's avatar
wangqinghua committed
  }

  ionViewDidLoad() {
wangqinghua's avatar
wangqinghua committed
    this.storage.get('userLoginInfo').then((value) => {
      this.userId = value.userid;
      this.username = value.loginName;
      // this.lookHandle();
    });
    this.stuffId = this.navParams.get('id');
    this.getStuff();
    setTimeout(() => {
      this.footerView = true;
    }, 300)
wangqinghua's avatar
wangqinghua committed
  }

wangqinghua's avatar
wangqinghua committed
  //获取文章信息
  getStuff() {
    this.serveSer.businessDetail(this.stuffId).subscribe(
        (res) => {
          this.stuffObj = res.data;
          this.countObj = res.data;   //防止点赞,评论,收藏之后页面刷新
          this.attachments = res.data.attachments;
          let con = this.stuffObj.content.replace(/\r?\n/g, "<br />");
          this.stuffObj.content = this.sanitizer.bypassSecurityTrustHtml(con);
        }
    )
  }


wangqinghua's avatar
wangqinghua committed
}