|
|
@@ -1,9 +1,33 @@
|
|
|
const _Http = getApp().globalData.http;
|
|
|
Component({
|
|
|
+ lifetimes: {
|
|
|
+ attached: function () {
|
|
|
+ _Http[this.data.ownerid] = {
|
|
|
+ changeReply: function (replyid = 0) {
|
|
|
+ this.setData({
|
|
|
+ replyid: replyid == this.data.replyid ? 0 : replyid
|
|
|
+ })
|
|
|
+ }.bind(this),
|
|
|
+ updateCommentList: function () {
|
|
|
+ this.triggerEvent("updateCommentList", {
|
|
|
+ "ownertable": this.data.ownertable, //数据表
|
|
|
+ "ownerid": this.data.ownerid,
|
|
|
+ })
|
|
|
+ }.bind(this)
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ userid: wx.getStorageSync('userMsg').userid
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ detached: function () {
|
|
|
+ delete _Http[this.data.ownerid]
|
|
|
+ },
|
|
|
+ },
|
|
|
properties: {
|
|
|
- title: {
|
|
|
- type: String,
|
|
|
- value: '评论(0)'
|
|
|
+ quantity: {
|
|
|
+ type: [String, Number],
|
|
|
+ value: 0
|
|
|
},
|
|
|
comments: {
|
|
|
type: Array,
|
|
|
@@ -21,16 +45,15 @@ Component({
|
|
|
}
|
|
|
},
|
|
|
data: {
|
|
|
- show: true,
|
|
|
- content: {
|
|
|
- comment: '',
|
|
|
- reply: ''
|
|
|
- }
|
|
|
+ loading: false,
|
|
|
+ show: false,
|
|
|
+ comment: '',
|
|
|
+ replyid: 0,
|
|
|
},
|
|
|
methods: {
|
|
|
onInput(e) {
|
|
|
this.setData({
|
|
|
- [`content.${e.currentTarget.dataset.key}`]: e.detail.value
|
|
|
+ comment: e.detail.value
|
|
|
})
|
|
|
},
|
|
|
onSend() {
|
|
|
@@ -42,8 +65,8 @@ Component({
|
|
|
"content": {
|
|
|
"ownertable": this.data.ownertable, //数据表
|
|
|
"ownerid": this.data.ownerid,
|
|
|
- "content": this.data.content.comment,
|
|
|
- "replyid": "0"
|
|
|
+ "content": this.data.comment,
|
|
|
+ replyid: 0
|
|
|
}
|
|
|
}).then(res => {
|
|
|
console.log("发送评论", res)
|
|
|
@@ -56,44 +79,9 @@ Component({
|
|
|
})
|
|
|
if (res.code == '1') {
|
|
|
this.setData({
|
|
|
- 'content.comment': ""
|
|
|
- })
|
|
|
- this.triggerEvent("updateCommentList", {
|
|
|
- "ownertable": this.data.ownertable,
|
|
|
- "ownerid": this.data.ownerid,
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- deleteItem(e) {
|
|
|
- const {
|
|
|
- item
|
|
|
- } = e.currentTarget.dataset,
|
|
|
- that = this;
|
|
|
- wx.showModal({
|
|
|
- title: '提示',
|
|
|
- content: `是否确定删除该评论`,
|
|
|
- complete: ({
|
|
|
- confirm
|
|
|
- }) => {
|
|
|
- if (confirm) _Http.basic({
|
|
|
- "id": 20240429161701,
|
|
|
- "content": {
|
|
|
- "sys_datacommentid": item.sys_datacommentid
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- console.log("删除评论", res)
|
|
|
- wx.showToast({
|
|
|
- title: res.msg == '成功' ? '删除成功' : res.msg,
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- if (res.msg == '成功') {
|
|
|
- that.triggerEvent("updateCommentList", {
|
|
|
- "ownertable": that.data.ownertable,
|
|
|
- "ownerid": that.data.ownerid,
|
|
|
- })
|
|
|
- }
|
|
|
+ comment: ""
|
|
|
})
|
|
|
+ _Http[this.data.ownerid].updateCommentList();
|
|
|
}
|
|
|
})
|
|
|
},
|