riku
2022-09-06 bf580d5477d65f5eefb70a8fb9a6b37eaf0ae9bb
pages/module_consult/consulthome/consulthome.js
@@ -22,6 +22,9 @@
      name: '条目',
      tag: 0
    }, {
      name: '问答',
      tag: 0
    }, {
      name: '案例',
      tag: 0
    }],
@@ -31,7 +34,11 @@
      [],
      [],
      [],
    ]
      [],
    ],
    //案例所涉及的要点
    caseTag: []
  },
  /**
@@ -39,7 +46,6 @@
   */
  onLoad: function (options) {
    this.getHotTopic()
    this.getTopicItem()
  },
  /**
@@ -56,12 +62,14 @@
  },
  // 搜索
  gotoSearch() {
    wx.navigateTo({
      url: "/pages/module_consult/consultsearch/consultsearch"
    })
  },
  // 功能按钮
  goto(e) {
    var url = ""
    var index = e.currentTarget.dataset.index
@@ -95,13 +103,14 @@
   */
  getHotTopic() {
    var that = this
    // 1. 热门法律法规
    consultservice.getTopicLaw(app.globalData.accessToken.userId, {
      success(res) {
        res.forEach(r => {
          r.mfKeywordLv1 = r.mfKeywordLv1.split('、').slice(0, 5)
          r.mfReleaseDate = that.formateTime(r.mfReleaseDate)
          r.mfEffectiveDate = that.formateTime(r.mfEffectiveDate)
          r.mfClosingDate = that.formateTime(r.mfClosingDate)
          r.mfReleaseDate = that.formatTime(r.mfReleaseDate)
          r.mfEffectiveDate = that.formatTime(r.mfEffectiveDate)
          r.mfClosingDate = that.formatTime(r.mfClosingDate)
        });
        that.setData({
          'pageList[0]': res,
@@ -109,27 +118,48 @@
        })
      }
    })
  },
  getTopicItem() {
    var that = this
    // 2. 热门法律法规条目
    consultservice.getTopicItem(app.globalData.accessToken.userId, {
      success(res) {
        res.forEach(r => {
          r.miItemContent = r.miItemContent.replace('\\n', '<br/>')
          // r.mfKeywordLv1 = r.mfKeywordLv1.split('、').slice(0, 5)
          // r.mfReleaseDate = that.formateTime(r.mfReleaseDate)
          // r.mfEffectiveDate = that.formateTime(r.mfEffectiveDate)
          // r.mfClosingDate = that.formateTime(r.mfClosingDate)
          r.miItemContent = r.miItemContent.replaceAll('\\n', '<br/>')
        });
        that.setData({
          'pageList[2]': res
        })
      }
    })
    // 3. 热门问答
    consultservice.getTopicQA(app.globalData.accessToken.userId, {
      success(res) {
        res.forEach(r => {
          r.cqCreateTime = that.formatTime(r.cqCreateTime)
        });
        that.setData({
          'pageList[3]': res
        })
      }
    })
    // 4. 热门案例
    consultservice.getTopicCase(app.globalData.accessToken.userId, {
      success(res) {
        res.forEach(r => {
          r.ecSummary = r.ecSummary.replaceAll('\\n', '<br/>')
          r.ecMeaning = r.ecMeaning.replaceAll('\\n', '<br/>')
          r.ecExamined = r.ecExamined.replaceAll('\\n', '<br/>')
          r.ecEnlightenment = r.ecEnlightenment.replaceAll('\\n', '<br/>')
          r.ecOccurDate = that.formatTime(r.ecOccurDate)
        });
        that.setData({
          'pageList[4]': res
        })
        console.log(that.data.pageList);
      }
    })
  },
  // 去往文件详情
  gotoFile(e) {
    const iList = e.currentTarget.dataset.index.split(',')
    const i1 = iList[0]
@@ -146,6 +176,7 @@
    })
  },
  // 去往条目详情
  gotoItem(e) {
    const iList = e.currentTarget.dataset.index.split(',')
    const i1 = iList[0]
@@ -162,9 +193,43 @@
    })
  },
  formateTime(t) {
  // 去往问答详情
  gotoQA(e) {
    const iList = e.currentTarget.dataset.index.split(',')
    const i1 = iList[0]
    const i2 = iList[1]
    var qId = this.data.pageList[i1][i2].cqGuid
    wx.navigateTo({
      url: '/pages/module_consult/consultdetailqa/consultdetailqa',
      success: (res) => {
        // 通过 eventChannel 向被打开页面传送数据
        res.eventChannel.emit('acceptDataFromOpenerPage', {
          qId: qId
        })
      },
    })
  },
  // 去往案例详情
  gotoCase(e) {
    const iList = e.currentTarget.dataset.index.split(',')
    const i1 = iList[0]
    const i2 = iList[1]
    var caseId = this.data.pageList[i1][i2].ecGuid
    wx.navigateTo({
      url: '/pages/module_consult/consultdetailcase/consultdetailcase',
      success: (res) => {
        // 通过 eventChannel 向被打开页面传送数据
        res.eventChannel.emit('acceptDataFromOpenerPage', {
          caseId: caseId
        })
      },
    })
  },
  formatTime(t) {
    if (t) {
      return moment(t).format("YYYY年MM月DD日")
      return moment(t).format("YYYY.MM.DD")
    } else {
      return undefined
    }