| | |
| | | // pages/bookServices/detail/components/note/note.js |
| | | const app = getApp(); |
| | | import { |
| | | loginInfo |
| | | } from '../../../../../assets/js/login'; |
| | | Component({ |
| | | /** |
| | | * 组件的属性列表 |
| | |
| | | * 组件的初始数据 |
| | | */ |
| | | data: { |
| | | inputStyle: |
| | | "border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding:16rpx", |
| | | inputStyle: "border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding:16rpx", |
| | | placeholderstyle: "font-size:28rpx", |
| | | flag: false, // 输入框是否显示 |
| | | submitType: "new", // 新建 or 编辑 |
| | |
| | | }); |
| | | }, |
| | | openDialog() { |
| | | this.setData({ |
| | | submitTitle: this.properties.bookInfo.name, |
| | | showNoteDialog: true, |
| | | }); |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (token) { |
| | | this.setData({ |
| | | submitTitle: this.properties.bookInfo.name, |
| | | showNoteDialog: true, |
| | | }); |
| | | } else { |
| | | loginInfo(app, (data) => {}) |
| | | } |
| | | }, |
| | | closeDialog() { |
| | | this.setData({ |
| | |
| | | }, |
| | | // 获取笔记列表 |
| | | async getNoteList() { |
| | | if (!this.data.isMore) { |
| | | this.setData({ |
| | | loading: true, |
| | | }); |
| | | } |
| | | this.setData({ |
| | | noList: false, |
| | | }); |
| | | let topicId; |
| | | await app.MG.ugc |
| | | .getProductUserSubmitTopic({ |
| | | productId: this.properties.bookInfo.id, |
| | | appRefCode: app.config.appRefCode, |
| | | }) |
| | | .then((res) => { |
| | | if (res) { |
| | | topicId = res.id; |
| | | } else { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "查询失败", |
| | | }); |
| | | } |
| | | }); |
| | | // loadings.value.bookResource = true |
| | | let query = { |
| | | start: 0, |
| | | size: this.data.pageCount.page * 5, |
| | | messageType: "note", |
| | | sort: { |
| | | type: "Desc", |
| | | field: "CreateDate", |
| | | }, |
| | | appRefCode: app.config.appRefCode, |
| | | topicIdOrRefCode: topicId + "", |
| | | }; |
| | | await app.MG.ugc.getTopicMessageList(query).then((res) => { |
| | | if (!res.datas.length) { |
| | | return this.setData({ |
| | | loading: false, |
| | | noList: true, |
| | | noteList: res.datas, |
| | | const getFun = async () => { |
| | | if (!this.data.isMore) { |
| | | this.setData({ |
| | | loading: true, |
| | | }); |
| | | } |
| | | // notePage.value.total = res.totalSize |
| | | res.datas.forEach((item) => { |
| | | item.compliceHover = false; |
| | | item.deleteHover = false; |
| | | item.createDate = this.convertTimestamp(item.createDate); |
| | | }); |
| | | this.setData({ |
| | | "pageCount.total": res.totalSize, |
| | | noteList: res.datas, |
| | | loading: false, |
| | | noList: false, |
| | | }); |
| | | }); |
| | | let topicId; |
| | | await app.MG.ugc |
| | | .getProductUserSubmitTopic({ |
| | | productId: this.properties.bookInfo.id, |
| | | appRefCode: app.config.appRefCode, |
| | | }) |
| | | .then((res) => { |
| | | if (res) { |
| | | topicId = res.id; |
| | | } else { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: "查询失败", |
| | | }); |
| | | } |
| | | }); |
| | | let query = { |
| | | start: 0, |
| | | size: this.data.pageCount.page * 5, |
| | | messageType: "note", |
| | | sort: { |
| | | type: "Desc", |
| | | field: "CreateDate", |
| | | }, |
| | | appRefCode: app.config.appRefCode, |
| | | topicIdOrRefCode: topicId + "", |
| | | }; |
| | | await app.MG.ugc.getTopicMessageList(query).then((res) => { |
| | | if (!res.datas.length) { |
| | | return this.setData({ |
| | | loading: false, |
| | | noList: true, |
| | | noteList: res.datas, |
| | | }); |
| | | } |
| | | // notePage.value.total = res.totalSize |
| | | res.datas.forEach((item) => { |
| | | item.compliceHover = false; |
| | | item.deleteHover = false; |
| | | item.createDate = this.convertTimestamp(item.createDate); |
| | | }); |
| | | this.setData({ |
| | | "pageCount.total": res.totalSize, |
| | | noteList: res.datas, |
| | | loading: false, |
| | | noList: false, |
| | | }); |
| | | }); |
| | | } |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (data) { |
| | | getFun() |
| | | } else { |
| | | this.setData({ |
| | | loading: false, |
| | | noList: true, |
| | | noteList: [], |
| | | }); |
| | | } |
| | | }) |
| | | } else { |
| | | getFun() |
| | | } |
| | | |
| | | }, |
| | | // 新建笔记接口 |
| | | async makeNote() { |
| | |
| | | }); |
| | | }, |
| | | }, |
| | | }); |
| | | }); |