Commit 1f9f4860 authored by wangqinghua's avatar wangqinghua

点赞收藏特效 提示

parent ee91e14d
...@@ -376,3 +376,19 @@ a[disabled], button[disabled], [ion-button][disabled], ...@@ -376,3 +376,19 @@ a[disabled], button[disabled], [ion-button][disabled],
position: relative; position: relative;
letter-spacing: 1px; letter-spacing: 1px;
} }
//点赞动画
.animation{
animation: toBig 500ms;
}
@keyframes toBig {
0%{
font-size: 2.5rem;
}
50%{
font-size: 3.5rem;
}
100%{
font-size: 2.5rem;
}
}
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<div class="stuff-attachments"> <div class="stuff-attachments">
<ng-container *ngFor="let item of attachments"> <ng-container *ngFor="let item of attachments">
<div style="height: 160px;" *ngIf="item.resourceType == 2 || item.resourceType == 1"> <div style="height: 160px;" *ngIf="item.resourceType == 1">
<img style="height: 160px;" [src]="url + item.path" alt=""> <img style="height: 160px;" [src]="url + item.path" alt="">
</div> </div>
<div *ngIf="item.resourceType == 3"> <div *ngIf="item.resourceType == 3">
...@@ -63,15 +63,15 @@ ...@@ -63,15 +63,15 @@
</ion-col> </ion-col>
<ion-col col-2> <ion-col col-2>
<ion-icon name="chatboxes"></ion-icon> <ion-icon name="chatboxes"></ion-icon>
<span class="tip-num">{{stuffObj?.commentCount}}</span> <span class="tip-num">{{countObj?.commentCount}}</span>
</ion-col> </ion-col>
<ion-col col-2 (click)="updateNum(3,1)"> <ion-col col-2 (click)="collectionHandle()">
<ion-icon [ngClass]="stuffObj?.collection == true?'main-color':''" name="heart"></ion-icon> <ion-icon #collection [ngClass]="countObj?.collection == true?'main-color':''" name="heart"></ion-icon>
<span class="tip-num">{{stuffObj?.collectionCount}}</span> <span class="tip-num">{{countObj?.collectionCount}}</span>
</ion-col> </ion-col>
<ion-col col-2 (click)="updateNum(2,1)"> <ion-col col-2 (click)="likeHandle()">
<ion-icon [ngClass]="stuffObj?.like == true?'main-color':''" name="thumbs-up"></ion-icon> <ion-icon #like [ngClass]="countObj?.like == true?'main-color':''" name="thumbs-up"></ion-icon>
<span class="tip-num">{{stuffObj?.likeCount}}</span> <span class="tip-num">{{countObj?.likeCount}}</span>
</ion-col> </ion-col>
</ion-row> </ion-row>
</div> </div>
......
import {Component} from '@angular/core'; import {Component, ElementRef, Renderer2, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular'; import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {TabsService} from "../../tabs/tabs.service"; import {TabsService} from "../../tabs/tabs.service";
import {Storage} from "@ionic/storage"; import {Storage} from "@ionic/storage";
...@@ -12,21 +12,27 @@ import {AppGlobal} from "../../../service/http.service"; ...@@ -12,21 +12,27 @@ import {AppGlobal} from "../../../service/http.service";
templateUrl: 'stuff-detail.html', templateUrl: 'stuff-detail.html',
}) })
export class StuffDetailPage { export class StuffDetailPage {
@ViewChild('like') like: ElementRef;
@ViewChild('collection') collection: ElementRef;
stuffId; //文章id stuffId; //文章id
content:string; //评论内容 content: string; //评论内容
userId; //用户id userId; //用户id
username; //用户姓名 username; //用户姓名
stuffObj; //文章对象 stuffObj; //文章对象
//点赞,评价,收藏对象;
countObj;
footerView: boolean; footerView: boolean;
comment: boolean = false; comment: boolean = false;
url = AppGlobal.domain +'/wisdomgroup'; url = AppGlobal.domain + '/wisdomgroup';
attachments; //附件 attachments; //附件
constructor(public navCtrl: NavController, public navParams: NavParams,public sanitizer: DomSanitizer, constructor(public navCtrl: NavController, public navParams: NavParams, public sanitizer: DomSanitizer,
public renderer: Renderer2,
public tabSer: TabsService, public storage: Storage, public commonSer: CommonService) { public tabSer: TabsService, public storage: Storage, public commonSer: CommonService) {
} }
...@@ -34,13 +40,13 @@ export class StuffDetailPage { ...@@ -34,13 +40,13 @@ export class StuffDetailPage {
this.storage.get('userLoginInfo').then((value) => { this.storage.get('userLoginInfo').then((value) => {
this.userId = value.userid; this.userId = value.userid;
this.username = value.loginName; this.username = value.loginName;
this.updateNum(1, 1); this.lookHandle();
}) })
this.stuffId = this.navParams.get('id'); this.stuffId = this.navParams.get('id');
this.getStuff(); this.getStuff();
setTimeout(()=>{ setTimeout(() => {
this.footerView = true; this.footerView = true;
},300) }, 300)
//增加浏览量 //增加浏览量
} }
...@@ -49,6 +55,7 @@ export class StuffDetailPage { ...@@ -49,6 +55,7 @@ export class StuffDetailPage {
this.tabSer.stuffInfo(this.stuffId).subscribe( this.tabSer.stuffInfo(this.stuffId).subscribe(
(res) => { (res) => {
this.stuffObj = res.data; this.stuffObj = res.data;
this.countObj = res.data; //防止点赞,评论,收藏之后页面刷新
this.attachments = res.data.attachments; this.attachments = res.data.attachments;
let con = this.stuffObj.content.replace(/\r?\n/g, "<br />"); let con = this.stuffObj.content.replace(/\r?\n/g, "<br />");
this.stuffObj.content = this.sanitizer.bypassSecurityTrustHtml(con); this.stuffObj.content = this.sanitizer.bypassSecurityTrustHtml(con);
...@@ -62,34 +69,97 @@ export class StuffDetailPage { ...@@ -62,34 +69,97 @@ export class StuffDetailPage {
//更新浏览 点赞 收藏 评论 //更新浏览 点赞 收藏 评论
//根据类型,修改数量(1浏览,2点赞,3收藏,4评论) //根据类型,修改数量(1浏览,2点赞,3收藏,4评论)
updateNum(type, num) { //浏览
if (type == 2) num = this.stuffObj.like == true ? '-1' : 1; lookHandle() {
if (type == 3) num = this.stuffObj.collection == true ? '-1' : 1;
const data = { const data = {
id: this.stuffId, id: this.stuffId,
type: type, type: 1,
num: 1,
userid: this.userId,
content: this.content,
}
this.tabSer.updateNumByType(data).subscribe(
(res) => {
if (res.errcode == '1000') {
this.commonSer.log('浏览数 +1')
}
}
)
}
//点赞
likeHandle() {
let num = this.countObj.like == true ? '-1' : 1;
const data = {
id: this.stuffId,
type: 2,
num: ~~num, num: ~~num,
userid: this.userId, userid: this.userId,
content: this.content, content: this.content,
} }
this.tabSer.updateNumByType(data).subscribe( this.tabSer.updateNumByType(data).subscribe(
(res) => { (res) => {
if (res.errcode == '1000') { if (res.errcode == '1000') {
this.getStuff(); this.tabSer.stuffInfo(this.stuffId).subscribe(
(res) => {
if (num == 1) {
this.commonSer.toastTime('谢谢点赞','1000');
this.renderer.addClass(this.like.nativeElement, 'animation');
}
if (num == -1){
this.commonSer.toastTime('点赞已取消','1000');
this.renderer.removeClass(this.like.nativeElement, 'animation');
}
this.countObj = res.data; //防止点赞,评论,收藏之后文章信息刷新刷新
}
)
}
}
)
}
//收藏
collectionHandle() {
let message;
let num = this.countObj.collection == true ? '-1' : 1;
const data = {
id: this.stuffId,
type: 3,
num: ~~num,
userid: this.userId,
content: this.content,
};
this.tabSer.updateNumByType(data).subscribe(
(res) => {
if (res.errcode == '1000') {
this.tabSer.stuffInfo(this.stuffId).subscribe(
(res) => {
if (num == 1) {
this.renderer.addClass(this.collection.nativeElement, 'animation');
this.commonSer.toastTime('功崇惟志,业广惟勤', '1000')
}
if (num == -1) {
this.renderer.removeClass(this.collection.nativeElement, 'animation');
this.commonSer.toastTime('收藏已取消', '1000')
}
this.countObj = res.data; //防止点赞,评论,收藏之后文章信息刷新刷新
}
)
} }
} }
) )
} }
//确定发布 //确定发布
sure(){ sure() {
const data = { const data = {
userid: this.userId, userid: this.userId,
content: this.content, content: this.content,
id: this.stuffId, id: this.stuffId,
num:1, num: 1,
type:4, type: 4,
username:this.username username: this.username
} }
this.tabSer.updateNumByType(data).subscribe( this.tabSer.updateNumByType(data).subscribe(
(res) => { (res) => {
...@@ -103,7 +173,7 @@ export class StuffDetailPage { ...@@ -103,7 +173,7 @@ export class StuffDetailPage {
} }
//取消发布 //取消发布
cancel(){ cancel() {
this.content = ''; this.content = '';
this.comment = false; this.comment = false;
} }
......
...@@ -15,8 +15,8 @@ export class AppGlobal { ...@@ -15,8 +15,8 @@ export class AppGlobal {
//接口基地址 //接口基地址
// static domain = "http://101.89.112.92:80"; //正式环境 // static domain = "http://101.89.112.92:80"; //正式环境
// static domain = "http://180.168.156.212:2931"; //测试环境 // static domain = "http://180.168.156.212:2931"; //测试环境
static domain = "http://47.103.35.216:8080"; //阿里云地址 // static domain = "http://47.103.35.216:8080"; //阿里云地址
// static domain = ""; //本地环境 static domain = ""; //本地环境
//图片地址 //图片地址
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment