forked from nsjcy/frontEnd/nsjcy

liuwh
2020-03-31 b72fc1b10b08cf2fea1626d32e1ca2cccabe2edd
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
// pages/zhgk/zhgk.js
var app = getApp()
var WxParse = require('../wxParse/wxParse.js');
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    user: app.globalData.imgUrl + '/image/user.svg',
    yes: app.globalData.imgUrl + '/image/yes.svg',
    add: app.globalData.imgUrl + '/image/add.svg',
    del: app.globalData.imgUrl + '/image/del.svg',
    wjgk: './../../images/wjgk.jpg',
    data: {},
    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',
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    wx.request({
      url: app.globalData.url + '/api/article/findByName',
      data: {
        typeName: '未检概况',
      },
      success: function(res) {
        wx.hideLoading();
        console.log(res)
        if (res.data.code == 0) {
          // var article = res.data.data;
          // WxParse.wxParse('article', 'html', article, that, 5);
          var attList = res.data.data.maps;
          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)
          that.setData({
            data: res.data.data,
            attList,
          })
        } else {
          wx.showModal({
            title: '提示',
            content: "请求失败!"
          })
        }
      }
    })
  },
 
  //预览图片
  previewImage: function(e) {
    app.previewImage(e)
  },
 
  // 预览附件
  open: function(e) {
    var path = e.currentTarget.dataset.path;
    console.log(path)
    wx.downloadFile({
      url: path,
      success: function(res) {
        console.log(res)
        const filePath = res.tempFilePath
        wx.openDocument({
          filePath: filePath,
          success: function(res) {
            console.log('打开文档成功')
          }
        })
      }
    })
 
  }
 
 
})