闫增涛
2025-03-28 abbd7d18ea431ee8b6b8e634abf3e8ccb1fbb1b3
pages/digitalCourses/digitalCoursesDetails/components/note/note.js
@@ -1,5 +1,8 @@
// pages/bookServices/detail/components/note/note.js
const app = getApp();
import {
  loginInfo
} from '../../../../../assets/js/login';
Component({
  /**
   * 组件的属性列表
@@ -15,8 +18,7 @@
   * 组件的初始数据
   */
  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 编辑
@@ -64,10 +66,15 @@
      });
    },
    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({
@@ -144,63 +151,81 @@
    },
    // 获取笔记列表
    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() {
@@ -342,4 +367,4 @@
      });
    },
  },
});
});