forked from nsjcy/frontEnd/nsjcy

LAPTOP-RI7D261L\Mr Ke
2020-03-09 a2d1b9886b00b5f4d4722c3379d3bd4f2f94b421
SunshineLnsMinApp/pages/fzxktDetail/fzxktDetail.js
@@ -8,72 +8,37 @@
   */
  data: {
    content: '',
    attList: {},
    excelSrc: app.globalData.imgUrl +'/image/fileIcon/excel.svg',
    fileSrc: app.globalData.imgUrl +'/image/fileIcon/file.svg',
    mp3Src: app.globalData.imgUrl +'/image/fileIcon/mp3.svg',
    mp4Src: app.globalData.imgUrl +'/image/fileIcon/mp4.svg',
    pdfSrc: app.globalData.imgUrl +'/image/fileIcon/pdf.svg',
    pictureSrc: app.globalData.imgUrl +'/image/fileIcon/picture.svg',
    pptSrc: app.globalData.imgUrl +'/image/fileIcon/ppt.svg',
    wordSrc: app.globalData.imgUrl +'/image/fileIcon/word.svg',
    zipSrc: app.globalData.imgUrl +'/image/fileIcon/zip.svg',
    data: {},
    excelSrc: app.globalData.imgUrl + '/image/fileIcon/excel.svg',
    fileSrc: app.globalData.imgUrl + '/image/fileIcon/file.svg',
    mp3Src: app.globalData.imgUrl + '/image/fileIcon/mp3.svg',
    mp4Src: app.globalData.imgUrl + '/image/fileIcon/mp4.svg',
    pdfSrc: app.globalData.imgUrl + '/image/fileIcon/pdf.svg',
    pictureSrc: app.globalData.imgUrl + '/image/fileIcon/picture.svg',
    pptSrc: app.globalData.imgUrl + '/image/fileIcon/ppt.svg',
    wordSrc: app.globalData.imgUrl + '/image/fileIcon/word.svg',
    zipSrc: app.globalData.imgUrl + '/image/fileIcon/zip.svg',
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options.id)
    var that = this;
    wx.request({
      url: app.globalData.url + '/api/article/legalServiceInfo?articleId=' + options.id,
      success: function(res) {
        if (res.data.code == 0){
          var article = res.data.data.content;
          WxParse.wxParse('article', 'html', article, that, 5);
          var attList = res.data.data.attList;
          var attList21 = app.where(attList, { type: 21 }) || [];
          attList21.forEach(e => {
            e.iconSrc = that.data.mp4Src
          })
          var attList22 = app.where(attList, { type: 22 }) || [];
          attList22.forEach(e => {
            e.iconSrc = that.data.pictureSrc
          })
          var attList23 = app.where(attList, { type: 23 }) || [];
          attList23.forEach(e => {
            e.iconSrc = that.data.wordSrc
          })
          var attList24 = app.where(attList, { type: 24 }) || [];
          attList24.forEach(e => {
            e.iconSrc = that.data.excelSrc
          })
          var attList25 = app.where(attList, { type: 25 }) || [];
          attList25.forEach(e => {
            e.iconSrc = that.data.pptSrc
          })
          var attList26 = app.where(attList, { type: 26 }) || [];
          attList26.forEach(e => {
            e.iconSrc = that.data.pdfSrc
          })
          var attList27 = app.where(attList, { type: 27 }) || [];
          attList27.forEach(e => {
            e.iconSrc = that.data.zipSrc
          })
          var attList28 = app.where(attList, { type: 28 }) || [];
          attList28.forEach(e => {
            e.iconSrc = that.data.fileSrc
          })
          var attList99 = app.where(attList, { type: 99 }) || [];
          attList99.forEach(e => {
            e.iconSrc = that.data.fileSrc
          })
          var attList = { attList21, attList22, attList23, attList24, attList25, attList26, attList27, attList28, attList99 };
          console.log(attList)
      url: app.globalData.url + '/api/article/publicMsgDetails?msgId=' + options.id,
      success: function (res) {
        wx.hideLoading();
        console.log(res)
        if (res.data.code == 0) {
          that.setData({
            attList
            data: {
              ...res.data.data,
              createTime: app.formatDate(res.data.data.createTime),
            }
          })
        } else{
        } else {
          wx.showModal({
            title: '提示',
            content: "请求失败!"
@@ -84,7 +49,7 @@
  },
  // 预览附件
  open:function(e) {
  open: function (e) {
    var path = e.currentTarget.dataset.path;
    console.log(path)
    wx.downloadFile({
@@ -99,7 +64,7 @@
        })
      }
    })
  }
})