12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- (function(){
- //点赞
- $("body").on("click", ".dianzan .like", function(){
- if($(this).hasClass("hasDian")){
- alertInfo("您已经给该信息点过赞!");
- }else{
- var infoId = $(this).attr("data-id");
- $.get("/article/like", {id: infoId}, function(res){
- if(res.code === 0){
- console.log("点赞成功!");
- $(".like").text("赞" + (parseInt($(".like").attr("data-count"))+1)).addClass("hasDian");
- } else {
- alertInfo(res.msg);
- }
- });
- }
- });
- }());
- //相关阅读
- var articleRelated = new Vue({
- el: "#articleRelated",
- data: {
- infoId: $("#articleId").val()?$("#articleId").val()*1:0,
- relatedList: []
- },
- methods: {
- getRelatedList: function () {
- var _self = this;
- if(this.infoId ===0){return;}
- $.getJSON("/article/related",{id: this.infoId}).done(function (r) {
- if (r.code === 0 && r.data) {
- _self.relatedList = r.data;
- }
- });
- },
- },
- created: function () {
- this.infoId = $("#articleId").val() ? $("#articleId").val()*1 : 0;
- // 获取相关阅读
- this.getRelatedList();
- },
- mounted: function () {
- var _self = this;
- }
- });
|