|
|
@@ -0,0 +1,101 @@
|
|
|
+const _Http = getApp().globalData.http;
|
|
|
+Component({
|
|
|
+ properties: {
|
|
|
+ title: {
|
|
|
+ type: String,
|
|
|
+ value: '评论(0)'
|
|
|
+ },
|
|
|
+ comments: {
|
|
|
+ type: Array,
|
|
|
+ value: []
|
|
|
+ },
|
|
|
+ ownertable: {
|
|
|
+ type: String,
|
|
|
+ value: 'sys_datafollowup'
|
|
|
+ },
|
|
|
+ ownerid: {
|
|
|
+ type: String
|
|
|
+ },
|
|
|
+ updateCommentList: {
|
|
|
+ type: Function
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ show: true,
|
|
|
+ content: {
|
|
|
+ comment: '',
|
|
|
+ reply: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onInput(e) {
|
|
|
+ this.setData({
|
|
|
+ [`content.${e.currentTarget.dataset.key}`]: e.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onSend() {
|
|
|
+ this.setData({
|
|
|
+ loading: true
|
|
|
+ })
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20240429161601,
|
|
|
+ "content": {
|
|
|
+ "ownertable": this.data.ownertable, //数据表
|
|
|
+ "ownerid": this.data.ownerid,
|
|
|
+ "content": this.data.content.comment,
|
|
|
+ "replyid": "0"
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("发送评论", res)
|
|
|
+ this.setData({
|
|
|
+ loading: false
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: res.code == '1' ? '评论成功' : res.msg,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ 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,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ }
|
|
|
+})
|