// 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 = ""; var rowid = ""; var mIndex = ""; 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 hdmemo = 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; } let orderTemplateId = app.globalData.orderNoticeTemplateIdList; utils.subscribeMessage({ ids:[orderTemplateId.returnsNoticeTemplateId], 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/pay/refund.do'), header: { "Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID') }, data:{ doccode: doccode, reasonid: reasonid, opened: this.data.index2, hdmemo: hdmemo, rowid: rowid }, success: res => { wx.hideLoading(); if(!utils.requestError(res)){ return false; }; wx.showToast({ title: '提交成功!', icon: 'success', duration: 1000, success: ()=>{ setTimeout(()=>{ wx.redirectTo({ url: '../returnInfo/returnInfo', }) },1000); } }) }, fail: function (errmsg) { utils.requestFail(errmsg,'/shopping/pay/refund.do'); } }) } }) // for循环上传每张图,filePath的值只能是字符串,不能是数组 // for (var i in imageList){ // wx.uploadFile({ // url: "https://14592619.qcloud.la/upload", // filePath: imageList[i], // name: 'data', // success: function (res) { // console.log('uploadImage success, res is:', res) // wx.hideLoading() // wx.navigateTo({ // url: '../returnInfo/returnInfo?msg=true', // }) // }, // fail: function ({ errMsg }) { // console.log('uploadImage fail, errMsg is', errMsg) // wx.hideLoading() // wx.navigateTo({ // url: '../returnInfo/returnInfo?msg=false', // }) // } // }) // } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // var refundGoods = listData.refundGoods; // var sumPrice = 0; // for(var i in refundGoods){ // sumPrice += parseInt(refundGoods[i].price); // } // this.setData({ // refundGoods:refundGoods, // price:sumPrice // }) wx.request({ url: utils.getUrl('/shopping/pay/getReturnReasonList.do'), 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/pay/getReturnReasonList.do'); } }) doccode = options.id; rowid = options.rowid; mIndex = options.index; formid = options.formid; wx.showLoading(); wx.request({ url: utils.getUrl( '/shopping/orderdetail.do?doccode=' + options.id), header: { "Cookie": "JSESSIONID=" + wx.getStorageSync('sessionID') }, data:{ formid }, success: res => { wx.hideLoading(); if(!utils.requestError(res)){ return false; } this.setData({ orderDetail: res.data, goodsItem: res.data.list[mIndex] }) }, fail: function (errmsg) { utils.requestFail(errmsg,'/shopping/orderdetail.do'); } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ // onShareAppMessage: function () { // } })