Sanakey
2020-10-20 0da8db73585b015a7bbaf3500b77142d41b7c2ff
提交 | 用户 | age
d98d05 1 // pages/refund/refund.js
S 2 var listData = require('../../data/test-data.js');
3 var utils = require("../../utils/util.js");
4 var app = getApp();
5
6 // var sourceType = [['camera'], ['album'], ['camera', 'album']]
7 // var sizeType = [['compressed'], ['original'], ['compressed', 'original']]
8
9 var doccode = "";
0da8db 10 let formid = '';
d98d05 11 Page({
S 12
13   /**
14    * 页面的初始数据
15    */
16   data: {
17     imageList: [],
18     // 退货理由
19     reason: [],
20     opened: [
21       {
22         id: 0,
23         name: '未开封'
24       },
25       {
26         id: 1,
27         name: '已开封'
28       }
29     ],
30     index:"",
31     index2:""
32   },
33   // sourceTypeChange: function (e) {
34   //   this.setData({
35   //     sourceTypeIndex: e.detail.value
36   //   })
37   // },
38   // sizeTypeChange: function (e) {
39   //   this.setData({
40   //     sizeTypeIndex: e.detail.value
41   //   })
42   // },
43   // countChange: function (e) {
44   //   this.setData({
45   //     countIndex: e.detail.value
46   //   })
47   // },
48   chooseImage: function () {
49     var that = this
50     wx.chooseImage({
51       // sourceType: sourceType[this.data.sourceTypeIndex],
52       // sizeType: sizeType[this.data.sizeTypeIndex],
53       // count: this.data.count[this.data.countIndex],
54       count: 5, // 默认9
55       sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
56       sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
57       success: function (res) {
58         console.log(res)
59         that.setData({
60           imageList: res.tempFilePaths
61         })
62       }
63     })
64   },
65   previewImage: function (e) {
66     var current = e.target.dataset.src
67     wx.previewImage({
68       current: current,
69       urls: this.data.imageList
70     })
71   },
72   deleteImg: function (e) {
73     var imgs = this.data.imageList;
74     var index = e.currentTarget.dataset.index;
75     imgs.splice(index, 1);
76     this.setData({
77       imageList: imgs
78     });
79   },
80
81   // 退货理由选择
82   bindPickerChange: function (e) {
83     console.log(e)
84     this.setData({
85       index: e.detail.value
86     })
87   },
88
89 // 是否开封
90   bindPickerChange2: function (e) {
91     console.log(e)
92     this.setData({
93       index2: e.detail.value
94     })
95   },
96
97   // inputChange:function(e){
98   //   var length = e.detail.value.length;
99   //   this.setData({
100   //     inputLength:length
101   //   })
102   // },
103
104
105
106   // 提交按钮
107   submitForm:function(e){
108     let reasonid = e.detail.value.why;
109     let memo = e.detail.value.explain;
110
111     var that = this;
112     var imageList = this.data.imageList;
113     console.log(e.detail.value);
114     if (e.detail.value.why == null || e.detail.value.why == ""){
115       utils.showTopTips(this,"请选择取消理由");
116       return false;
117     }
118     wx.showModal({
119       title: '提示',
120       content: '取消后不能撤回,确定要取消订单吗?',
121       success (res) {
122         if (res.confirm) {
123           console.log('用户点击确定')
124           cancleOrder()
125         } else if (res.cancel) {
126           console.log('用户点击取消')
127         }
128       }
129     })
130
131     function cancleOrder(){
132       
133       let orderTemplateId = app.globalData.orderNoticeTemplateIdList;
134       utils.subscribeMessage({
135         ids:[orderTemplateId.cancelOrderNoticeTemplateId],
136         callback:()=>{
137           // wx.navigateTo({
138           //   url: '../orderlistGuide/orderlistGuide',
139           // })
140           
141           // if (imageList.length==0){
142           //   utils.showTopTips(this,"请选择上传图片");
143           //   return false;
144           // }
145           wx.showLoading({
146             title: '提交中',
147             mask:false
148           })
149
150           wx.request({
151             url: utils.getUrl( '/shopping/confirm.do?m=cancelOrder'),
152             header: {
153               "Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
154             },
155             data:{
156               doccode: doccode,
157               reasonid: reasonid,
0da8db 158               memo: memo,
S 159               formid
d98d05 160             },
S 161             success: res => {
162               wx.hideLoading();
163               if(!utils.requestError(res)){
164                 return false;
165               };
166
167               wx.showToast({
168                 title: '提交成功!',
169                 icon: 'success',
170                 duration: 1000,
171                 success: ()=>{
172                   setTimeout(()=>{
173                     wx.redirectTo({
174                       url: '../returnInfo/returnInfo',
175                     })
176                     // wx.navigateBack({
177                     //   delta: 1
178                     // })
179                   },1000);
180                 }
181               })
182
183             },
184             fail: function (errmsg) {
185               utils.requestFail(errmsg,'/shopping/confirm.do?m=cancelOrder');
186             }
187           })
188         }
189       })
190     }
191
192     
193
194
195   },
196   /**
197    * 生命周期函数--监听页面加载
198    */
199   onLoad: function (options) {
200
201     wx.request({
202       url: utils.getUrl('/shopping/confirm.do?m=getCancelOrderReasonList'),
203       header: {
204         "Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
205       },
206       success: res => {
207         if(!utils.requestError(res)){
208           return false;
209         }
210
211         this.setData({
212           reason: res.data.list
213         })
214
215       },
216       fail: function (errmsg) {
217         utils.requestFail(errmsg,'/shopping/confirm.do?m=getCancelOrderReasonList');
218       }
219     })
220
221
222     doccode = options.doccode;
0da8db 223     formid = options.formid;
d98d05 224     wx.showLoading();
S 225     wx.request({
226       url: utils.getUrl( '/shopping/orderdetail.do?doccode=' + doccode),
227       header: {
228         "Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID')
229       },
0da8db 230       data:{
S 231         formid
232       },
d98d05 233       success: res => {
S 234         wx.hideLoading();
235         if(!utils.requestError(res)){
236           return false;
237         }
238
239         this.setData({
240           orderDetail: res.data
241         })
242
243       },
244       fail: function (errmsg) {
245         utils.requestFail(errmsg,'/shopping/orderdetail.do');
246       }
247     })
248   },
249
250   /**
251    * 生命周期函数--监听页面初次渲染完成
252    */
253   onReady: function () {
254
255   },
256
257   /**
258    * 生命周期函数--监听页面显示
259    */
260   onShow: function () {
261
262   },
263
264   /**
265    * 生命周期函数--监听页面隐藏
266    */
267   onHide: function () {
268
269   },
270
271   /**
272    * 生命周期函数--监听页面卸载
273    */
274   onUnload: function () {
275
276   },
277
278   /**
279    * 页面相关事件处理函数--监听用户下拉动作
280    */
281   onPullDownRefresh: function () {
282
283   },
284
285   /**
286    * 页面上拉触底事件的处理函数
287    */
288   onReachBottom: function () {
289
290   },
291
292   /**
293    * 用户点击右上角分享
294    */
295   // onShareAppMessage: function () {
296
297   // }
298 })