forked from nsjcy/frontEnd/nsjcy

liuwh
2020-06-09 5a887acf1924950715086633d329db045223b5c4
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
// lawPublicityDetail.js
const app = getApp();
var WxParse = require('../wxParse/wxParse.js');
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    content: '',
    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/publicMsgDetails?msgId=' + options.id,
      success: function (res) {
        wx.hideLoading();
        console.log(res)
        if (res.data.code == 0) {
          that.setData({
            data: {
              ...res.data.data,
              createTime: app.formatDate(res.data.data.createTime),
            }
          })
        } else {
          wx.showModal({
            title: '提示',
            content: "请求失败!"
          })
        }
      }
    })
  },
 
  // 预览附件
  open: function (e) {
    var path = e.currentTarget.dataset.path;
    console.log(path)
    wx.downloadFile({
      url: path,
      success: function (res) {
        const filePath = res.tempFilePath
        wx.openDocument({
          filePath: filePath,
          success: function (res) {
            console.log('打开文档成功')
          }
        })
      }
    })
 
  }
 
})
7