123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- const net = require("../../utils/net.js");
- const utils = require("../../utils/util.js");
- const { api_material_like } = require("../../utils/api.js");
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- subId: {
- type: Number,
- value: 0,
- },
- isLike: {
- type: Number,
- value: 0,
- observer: function (newVal) {
- // 属性值变化时执行
- this.setData({
- isAttention: newVal || 0,
- });
- },
- },
- likeNum: {
- type: Number,
- value: 0,
- },
- commentNum: {
- type: Number,
- value: 0,
- },
- isAuthor: {
- type: Number,
- value: 0,
- },
- placeholder: {
- type: String,
- value: "说点什么…",
- },
- },
- /**
- * 组件的初始数据
- */
- data: {
- isAttention: 0,
- },
- /**
- * 组件的方法列表
- */
- methods: {
- tapLikeAction: function () {
- const userinfo = utils.getStorageSync("USERINFO");
- if (userinfo && userinfo.token) {
- let params = {};
- params.url = api_material_like;
- params.data = {
- id: this.properties.subId,
- };
- net.req(params, true).then(
- (data) => {
- this.triggerEvent("like", {
- isLike: data.isLike == 1 ? false : true,
- likeNum: data.likeNum,
- });
- this.setData({
- isAttention: this.data.isAttention == 1 ? 0 : 1,
- });
- },
- (e) => {
- utils.showToast({
- title: e.msg,
- });
- }
- );
- } else {
- wx.navigateTo({ url: `/pages/login/login` });
- }
- },
- tapPostAction: function () {
- this.triggerEvent("poster");
- },
- tapDeleteAction() {},
- tapReplyAction() {
- this.triggerEvent("reply", { isComment: true });
- },
- tapCommentAction() {
- this.triggerEvent("message");
- },
- },
- });
|