forked from nsjcy/frontEnd/nsjcy

liyj
2020-02-11 e60e253cb3ce0597ded89b56a414c731e28c4ff1
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
var app = getApp()
Page({
  data: {
    nature: ['请选择类型', '在线建议', '在线投诉', '在线信访', '其他'],
    src: app.globalData.imgUrl + '/image/bg.jpg',
    itemIcon: app.globalData.imgUrl + '/image/ceshi.jpg',
    icon: app.globalData.imgUrl + '/image/fzl.svg',
    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',
    id: '',
    icon1: false,
    excess: '',
    disabled: false,
    evalList: {},
    dataSet: {},
    showTime: Date.now(),
    status: 0,
    auditOpinion: ''
  },
 
  // 页面跳转
  personInfo: function() {
    wx.navigateTo({
      url: '../complaintAdviceUserInfo/complaintAdviceUserInfo?' + 'disabled=' + this.data.disabled + '&id=' + this.data.id + '&status=' + this.data.status + '&url=' + '/complaintAdvice/complaintAdvice' + '&businessType=22&complaintType=' + this.data.dataSet.complaintType
    })
  },
 
  onLoad: function(option) {
    this.setData({
      id: option.id
    })
    var that = this;
    wx.request({
      url: app.globalData.url + '/api/complaintProposal/find?id=' + that.data.id,
      success: function(res) {
        if (res.data.code == 0) {
          var data = res.data.data.complaintProposal;
          var evalList1012 = data.attList || [];
          var evalList = {
            evalList1012,
          }
          for (var i in evalList) {
            evalList[i] = evalList[i].map(({
              imgPath: pic,
              attId: id
            }) => ({
              pic,
              id
            }))
          }
          var status = data.status;
          var disabled = app.judgeDisable(status);
          that.setData({
            dataSet: data,
            icon1: res.data.data.icon1,
            id: data.id,
            evalList,
            showTime: app.formatDate(data.createTime),
            disabled,
            status,
            auditOpinion: res.data.data.auditOpinion || ''
          })
        } else {
          wx.showModal({
            title: '提示',
            content: "请求失败!"
          })
        }
      }
    })
  },
 
  inputChange: function(e) {
    var name = e.currentTarget.dataset.name;
    this.setData({
      dataSet: {
        ...this.data.dataSet,
        [name]: e.detail.value
      }
    })
  },
 
  selectChange: function(e) {
    var name = e.currentTarget.dataset.name;
    this.setData({
      dataSet: {
        ...this.data.dataSet,
        [name]: e.detail.value
      }
    })
    console.log(this.data.dataSet)
  },
 
  submit: function(e) {
    var status = e.currentTarget.dataset.type;
    var userinfo = wx.getStorageSync("user");
    var dataSet = this.data.dataSet;
    dataSet.createId = userinfo.id;
    dataSet.status = status;
    if (status == 1) {
      var dataSet = this.data.dataSet;
      if (!dataSet.complaintType) {
        return app.showModal("请选择投诉建议类型!");
      }
      if (!this.data.icon1) {
        return app.showModal("请填写个人信息!");
      }
      if (!dataSet.content) {
        return app.showModal("请填写投诉建议内容!");
      }
      const {
        evalList1012
      } = this.data.evalList;
      if (evalList1012.length == 0) {
        return app.showModal("请上传相关材料!");
      }
    }
 
    var that = this;
    wx.request({
      url: app.globalData.url + '/api/complaintProposal/save',
      data: dataSet,
      method: 'POST',
      header: {
        "Content-Type": "application/json"
      },
      success: function(res) {
        if (res.data.code == 0) {
          if (status == 1) {
            wx.showToast({
              title: '提交成功!',
              icon: 'success',
              duration: 2000
            })
          } else {
            wx.showToast({
              title: '保存草稿箱成功!',
              icon: 'success',
              duration: 2000
            })
          }
          setTimeout(function() {
            wx.reLaunch({
              url: '../index/index',
            })
          }, 2000)
        } else {
          wx.showModal({
            title: '提示',
            content: "提交失败!"
          })
        }
      }
    })
  },
  //添加图片
  joinPicture: function(e) {
    var that = this;
    app.joinPicture(e, that)
  },
 
  // 删除图片
  clearImg: function(e) {
    var that = this;
    app.clearImg(e, that)
  },
 
  //预览图片
  previewImage: function(e) {
    app.previewImage(e);
  },
 
  goback: function() {
    wx.navigateBack({
      changed: true
    }); //返回上一页
  }
 
})