Sanakey
2020-11-06 65c4a68484a8d6fee25d3bb94bb7a24da6dfc147
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
// pages/refund/refund.js
var listData = require('../../data/test-data.js');
var utils = require("../../utils/util.js");
var app = getApp();
 
// var sourceType = [['camera'], ['album'], ['camera', 'album']]
// var sizeType = [['compressed'], ['original'], ['compressed', 'original']]
 
var doccode = "";
let formid = '';
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    imageList: [],
    // 退货理由
    reason: [],
    opened: [
      {
        id: 0,
        name: '未开封'
      },
      {
        id: 1,
        name: '已开封'
      }
    ],
    index:"",
    index2:""
  },
  // sourceTypeChange: function (e) {
  //   this.setData({
  //     sourceTypeIndex: e.detail.value
  //   })
  // },
  // sizeTypeChange: function (e) {
  //   this.setData({
  //     sizeTypeIndex: e.detail.value
  //   })
  // },
  // countChange: function (e) {
  //   this.setData({
  //     countIndex: e.detail.value
  //   })
  // },
  chooseImage: function () {
    var that = this
    wx.chooseImage({
      // sourceType: sourceType[this.data.sourceTypeIndex],
      // sizeType: sizeType[this.data.sizeTypeIndex],
      // count: this.data.count[this.data.countIndex],
      count: 5, // 默认9
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
      success: function (res) {
        console.log(res)
        that.setData({
          imageList: res.tempFilePaths
        })
      }
    })
  },
  previewImage: function (e) {
    var current = e.target.dataset.src
    wx.previewImage({
      current: current,
      urls: this.data.imageList
    })
  },
  deleteImg: function (e) {
    var imgs = this.data.imageList;
    var index = e.currentTarget.dataset.index;
    imgs.splice(index, 1);
    this.setData({
      imageList: imgs
    });
  },
 
  // 退货理由选择
  bindPickerChange: function (e) {
    console.log(e)
    this.setData({
      index: e.detail.value
    })
  },
 
// 是否开封
  bindPickerChange2: function (e) {
    console.log(e)
    this.setData({
      index2: e.detail.value
    })
  },
 
  // inputChange:function(e){
  //   var length = e.detail.value.length;
  //   this.setData({
  //     inputLength:length
  //   })
  // },
 
 
 
  // 提交按钮
  submitForm:function(e){
    let reasonid = e.detail.value.why;
    let memo = e.detail.value.explain;
 
    var that = this;
    var imageList = this.data.imageList;
    console.log(e.detail.value);
    if (e.detail.value.why == null || e.detail.value.why == ""){
      utils.showTopTips(this,"请选择取消理由");
      return false;
    }
    wx.showModal({
      title: '提示',
      content: '取消后不能撤回,确定要取消订单吗?',
      success (res) {
        if (res.confirm) {
          console.log('用户点击确定')
          cancleOrder()
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
 
    function cancleOrder(){
      
      let orderTemplateId = app.globalData.orderNoticeTemplateIdList;
      utils.subscribeMessage({
        ids:[orderTemplateId.cancelOrderNoticeTemplateId],
        callback:()=>{
          // wx.navigateTo({
          //   url: '../orderlistGuide/orderlistGuide',
          // })
          
          // if (imageList.length==0){
          //   utils.showTopTips(this,"请选择上传图片");
          //   return false;
          // }
          wx.showLoading({
            title: '提交中',
            mask:false
          })
 
          wx.request({
            url: utils.getUrl( '/shopping/confirm.do?m=cancelOrder'),
            header: {
              "Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
            },
            data:{
              doccode: doccode,
              reasonid: reasonid,
              memo: memo,
              formid
            },
            success: res => {
              wx.hideLoading();
              if(!utils.requestError(res)){
                return false;
              };
 
              wx.showToast({
                title: '提交成功!',
                icon: 'success',
                duration: 1000,
                success: ()=>{
                  setTimeout(()=>{
                    wx.redirectTo({
                      url: '../returnInfo/returnInfo',
                    })
                    // wx.navigateBack({
                    //   delta: 1
                    // })
                  },1000);
                }
              })
 
            },
            fail: function (errmsg) {
              utils.requestFail(errmsg,'/shopping/confirm.do?m=cancelOrder');
            }
          })
        }
      })
    }
 
    
 
 
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
 
    wx.request({
      url: utils.getUrl('/shopping/confirm.do?m=getCancelOrderReasonList'),
      header: {
        "Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
      },
      success: res => {
        if(!utils.requestError(res)){
          return false;
        }
 
        this.setData({
          reason: res.data.list
        })
 
      },
      fail: function (errmsg) {
        utils.requestFail(errmsg,'/shopping/confirm.do?m=getCancelOrderReasonList');
      }
    })
 
 
    doccode = options.doccode;
    formid = options.formid;
    wx.showLoading();
    wx.request({
      url: utils.getUrl( '/shopping/orderdetail.do?doccode=' + doccode),
      header: {
        "Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
      },
      data:{
        formid
      },
      success: res => {
        wx.hideLoading();
        if(!utils.requestError(res)){
          return false;
        }
 
        this.setData({
          orderDetail: res.data
        })
 
      },
      fail: function (errmsg) {
        utils.requestFail(errmsg,'/shopping/orderdetail.do');
      }
    })
  },
 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
 
  },
 
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
 
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
 
  },
 
  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {
 
  // }
})