11
QYF-GitLab1
2025-01-08 67a890445ceac9785ee62877b1e656fa4aeb0d5e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// packageCourse/components/baseClass/index.js
const app = getApp()
import moment from "moment"
import {
  getPublicImage
} from '../../../assets/js/middleGround/tool'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    classId: {
      type: Number,
      default: 0
    },
    bookRefCode: {
      type: String,
      default: ''
    }
  },
 
  /**
   * 组件的初始数据
   */
  data: {
    noticeList: [],
    detailInfo: null,
    messageInfo: null,
    homeworkCount: 0,
    userData: null,
    bookData: null,
    defaultCmsPath: ''
  },
 
  ready() {
    const data = wx.getStorageSync('website-front-userInfo')
    if (data) {
      this.setData({
        userData: JSON.parse(data),
        defaultCmsPath: this.properties.bookRefCode != 'null' ? 'jsek_digitalTextbooks' : 'defaultGoodsStore3'
      })
    }
    this.getData()
  },
 
  /**
   * 组件的方法列表
   */
  methods: {
    // 获取班级
    getData() {
      app.MG.edu
        .getCourseClass({
          ClassIdOrRefCode: String(this.properties.classId)
        })
        .then((res) => {
          if (res) {
            res.bookName = res.linkProductDto.product.name
            res.bookId = res.linkProductDto.product.id
            res.bookIcon = getPublicImage(res.linkProductDto.product.icon, 100)
            res.classTime =
              moment(res.beginDate).format('YYYY.MM.DD') +
              '--' +
              moment(res.endDate).format('YYYY.MM.DD')
          }
          this.setData({
            detailInfo: res
          })
          this.getTopicInfo()
          this.getBookDetail(res.bookId)
        })
    },
 
    // 获取教材详情
    getBookDetail(shopId) {
      let query = {
        path: this.data.defaultCmsPath,
        queryType: '*',
        productId: String(shopId),
        storeInfo: this.data.defaultCmsPath,
        coverSize: {
          height: 300,
          width: 210
        },
        fields: {
          seriesName: [],
          author: [],
          isbn: [],
          publicationDate: []
        }
      }
      app.MG.store.getProductDetail(query).then(async (res) => {
        if (res?.datas) {
          if (!res.datas.author) {
            res.datas.author = '-'
          }
          this.setData({
            bookData: res.datas
          })
        }
 
      })
    },
 
    // 获取topic
    getTopicInfo() {
      const pramas = {
        classId: this.properties.classId,
        refCodes: [app.config.refCodes.message]
      }
      app.MG.edu.getClassTopic(pramas).then((res) => {
        const data = res.find((item) => item.refCode == app.config.refCodes.message)
        this.setData({
          messageInfo: data
        })
        if (data.id) {
          wx.setStorageSync('messageId', data.id)
          this.getNotice()
        }
      })
    },
 
    // 获取班级通知
    getNotice() {
      const data = {
        start: 0,
        size: 3,
        appRefCode: app.config.appRefCode,
        topicIdOrRefCode: String(this.data.messageInfo.id),
        sort: {
          type: 'Desc',
          field: 'CreateDate',
          subSorts: []
        }
      }
      app.MG.ugc.getTopicMessageList(data).then((res) => {
        const list = res.datas.map((item) => {
          return {
            ...item,
            createDate: moment(item.createDate).format('YYYY-MM-DD')
          }
        })
        this.setData({
          noticeList: list
        })
      })
    },
 
    //复制
    copyCode() {
      wx.setClipboardData({
        data: this.data.detailInfo.refCode,
        success(res) {
          wx.hideToast()
          wx.showToast({
            title: '邀请码已复制',
            duration: 1000,
            icon: 'none',
          })
        }
      })
    }
  }
})