diff --git a/app.json b/app.json index 979bee0..cdd6154 100644 --- a/app.json +++ b/app.json @@ -51,7 +51,9 @@ "pages/set/password", "pages/member/member", "pages/aftersales/aftersales", - "pages/aftersales/index" + "pages/aftersales/index", + "pages/aftersales/apply", + "pages/aftersales/asdetail" ], "window": { "backgroundTextStyle": "light", diff --git a/components/uploadImages/uploadImg.js b/components/uploadImages/uploadImg.js new file mode 100644 index 0000000..d972710 --- /dev/null +++ b/components/uploadImages/uploadImg.js @@ -0,0 +1,143 @@ +// uploadImages/uploadImg.js +const WXAPI = require('../../utils/config.js') +Component({ + /** + * 组件的属性列表 + */ + properties: { + count: { //最多选择图片的张数,默认9张 + type: Number, + value: 9 + }, + uploadUrl: { //图片上传的服务器路径 + type: String, + value: '' + }, + showUrl: { //图片的拼接路径 + type: String, + value: '' + }, + albumType: { //album 从相册选图,camera 使用相机,默认二者都有 + type: String, + value: '' + }, + detailPics: { + type: Array, + value: [] + } + }, + + /** + * 组件的初始数据 + */ + data: { + detailPics: [], //上传的结果图片集合 + }, + onShow() { + console.log(1) + }, + /** + * 组件的方法列表 + */ + methods: { + /** + * 上传详细图片 + */ + uploadDetailImage: function (e) { //这里是选取图片的方法 + var that = this; + var pics = []; + var detailPics = that.data.detailPics; + if (detailPics.length >= that.data.count) { + wx.showToast({ + title: '最多选择' + that.data.count + '张!', + }) + return; + } + wx.chooseMedia({ + count: that.data.count, // 最多可以选择的图片张数,默认9 + sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有 + sourceType: that.data.albumType == '0' ? ['camera'] : ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有 + success: function (res) { + var imgs = res.tempFiles; + var ticket = wx.getStorageSync('ticket'); + var urlArr = [] + for (var i = 0; i < imgs.length; i++) { + pics.push(imgs[i]) + var url = imgs[i].tempFilePath + //取得文件的后缀 + var extensiton = url.substr(url.lastIndexOf('.') + 1).toLowerCase(); + // 根据时间戳生成唯一的主文件名称 + var mainname = '' + Date.now() + Math.ceil(Math.random() * 9999); + var uploadUrl = WXAPI.API_BASE_URL + 'Common/UploadUserFile?ticket=' + ticket + '&name=' + mainname + '.' + extensiton; + urlArr.push(uploadUrl) + } + that.uploadImg({ + url: urlArr, //这里是你图片上传的接口 + path: pics, //这里是选取的图片的地址数组 + }); + }, + }) + }, + //多张图片上传 + uploadImg: function (data) { + // console.log(this.globalData.openId) + wx.showLoading({ + title: '上传中...', + mask: true, + }) + var that = this, + i = data.i ? data.i : 0, + success = data.success ? data.success : 0, + fail = data.fail ? data.fail : 0; + wx.uploadFile({ + url: data.url[i], + header: { 'content-type': 'multipart/form-data' }, + filePath: data.path[i].tempFilePath, + name: 'image', + formData: { "openid": '1' }, + success: (resp) => { + wx.hideLoading(); + success++; + var info = JSON.parse(resp.data);//返回的结果,可能不同项目结果不一样 + // console.log(info) + var picName = that.data.showUrl + info.data.url; + var detailPics = that.data.detailPics; + detailPics.push(picName) + that.setData({ + detailPics: detailPics + }) + }, + fail: (res) => { + fail++; + console.log('fail:' + i + "fail:" + fail); + }, + complete: () => { + i++; + if (i == data.path.length) { //当图片传完时,停止调用 + console.log('执行完毕'); + // console.log('成功:' + success + " 失败:" + fail); + var eventDetail = { + picsList: that.data.detailPics + } // detail对象,提供给事件监听函数 + var eventOption = {} // 触发事件的选项 + that.triggerEvent('event', eventDetail, eventOption) + } else { //若图片还没有传完,则继续调用函数 + data.i = i; + data.success = success; + data.fail = fail; + that.uploadImg(data); + } + } + }); + }, + //预览图片 + imagePreview: function (e) { + console.log(e.target.dataset) + var current = e.target.dataset.src; + wx.previewImage({ + current: current, // 当前显示图片的http链接 + urls: this.data.detailPics // 需要预览的图片http链接列表 + }) + }, + } +}) diff --git a/components/uploadImages/uploadImg.json b/components/uploadImages/uploadImg.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/components/uploadImages/uploadImg.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/uploadImages/uploadImg.wxml b/components/uploadImages/uploadImg.wxml new file mode 100644 index 0000000..f253009 --- /dev/null +++ b/components/uploadImages/uploadImg.wxml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/uploadImages/uploadImg.wxss b/components/uploadImages/uploadImg.wxss new file mode 100644 index 0000000..37aa7e0 --- /dev/null +++ b/components/uploadImages/uploadImg.wxss @@ -0,0 +1,76 @@ +/* uploadImages/uploadImg.wxss */ +page { + background-color: #f1f0f5; +} + +.content { + width: 100%; + background-color: #fff; +} + +.img-box { + width: 100%; + margin-left: 35rpx; + margin-right: 35rpx; +} + +.img-list { + display: flex; + display: -webkit-flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; + /* flex-wrap: wrap; */ +} + +.img-item { + width: 150rpx; + text-align: left; + margin-right: 20rpx; + margin-bottom: 10rpx; +} + +.img-item image { + width: 150rpx; + height: 150rpx; +} + +.chooseImg { + background-color: #fff; +} + +.weui-uploader__input-box { + float: left; + position: relative; + margin-right: 9px; + margin-bottom: 9px; + width: 150rpx; + height: 150rpx; + /* border: 1px solid #d9d9d9; */ +} + +/* .weui-uploader__input-box:after, .weui-uploader__input-box:before { + content: " "; + position: absolute; + top: 50%; + left: 50%; + -webkit-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + background-color: #d9d9d9; +} */ + +.weui-uploader__input-box:before { + width: 2px; + height: 35px; +} + +.weui-uploader__input-box:after { + width: 35px; + height: 2px; +} + +.tips { + color: #666; + font-size: 25rpx; + padding-bottom: 20rpx; +} diff --git a/images/delete.png b/images/delete.png index a34f81d..353da47 100644 Binary files a/images/delete.png and b/images/delete.png differ diff --git a/images/gouhei.png b/images/gouhei.png new file mode 100644 index 0000000..3e6b343 Binary files /dev/null and b/images/gouhei.png differ diff --git a/images/xiangji.png b/images/xiangji.png new file mode 100644 index 0000000..f9189a6 Binary files /dev/null and b/images/xiangji.png differ diff --git a/pages/aftersales/aftersales.js b/pages/aftersales/aftersales.js index abf9944..ec0a154 100644 --- a/pages/aftersales/aftersales.js +++ b/pages/aftersales/aftersales.js @@ -12,6 +12,7 @@ Page({ exchange_goods_status:false, isbatch: false, orderType:'', + orderId: '', }, actionSheetTap: function () { var that = this; @@ -59,6 +60,7 @@ Page({ if (res.code == 200) { var data = res.data that.setData({ + orderId: orderId, order: data.list, status: data.status, refund_only_status: data.refund_only_status, @@ -87,7 +89,6 @@ Page({ }); return; } - if (formId != 'the formId is a mock one') { app.request.wxRequest({ @@ -99,37 +100,13 @@ Page({ } }) } - - wx.request({ - url: app.d.ceshiUrl + '&action=order&m=ReturnData', - method: 'post', - data: { - id: that.data.id, - oid: that.data.oid, - otype: that.data.otype, - re_type: that.data.tapIndex, - back_remark: remark, - }, - header: { - 'Content-Type': 'application/x-www-form-urlencoded' - }, - success: function (res) { - var status = res.data.status; - if (status == 1) { - wx.showToast({ - title: res.data.succ, - success: 2000 - }); - wx.redirectTo({ - url: '/pages/aftersales/index?currentTab=0&otype=whole', - }); - } else { - wx.showToast({ - title: res.data.err, - duration: 2000 - }); - } - }, - }); + }, + navToApply: function(e){ + console.log(e) + var type = e.currentTarget.dataset.type; + var that = this + wx.navigateTo({ + url:"/pages/aftersales/apply?refund_type=" + type + "&orderId=" + that.data.orderId + }) } }) \ No newline at end of file diff --git a/pages/aftersales/aftersales.wxml b/pages/aftersales/aftersales.wxml index f25bd68..6a7caa2 100644 --- a/pages/aftersales/aftersales.wxml +++ b/pages/aftersales/aftersales.wxml @@ -19,7 +19,7 @@ - + @@ -29,7 +29,7 @@ - + @@ -40,7 +40,7 @@ - + diff --git a/pages/aftersales/apply.js b/pages/aftersales/apply.js new file mode 100644 index 0000000..47267ce --- /dev/null +++ b/pages/aftersales/apply.js @@ -0,0 +1,214 @@ +// pages/aftersales/apply.js +var app = getApp() +var WXAPI = require('../../utils/server.js'); +Page({ + + /** + * 页面的初始数据 + */ + data: { + refund_type: '', // 区分退款方式1退货退款,2仅退款, 3换货 + order: "", + r_status: '', // 商品当前状态 + content: '', + orderId: '', + srcList: [], + re_price: '', + remark: '', + return_suess: false, + order: {}, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + console.log(options) + this.setData({ + refund_type: options.refund_type, + orderId:options.orderId + }); + this.loadData(options.orderId); + }, + loadData: function (orderId) { + var that = this; + WXAPI.returnMethod({ + accessId: app.globalData.accessId, + storeId: 239, + storeType: 1, + order_details_id: orderId, + }).then(res => { + if (res.code == 200) { + var data = res.data + that.setData({ + re_price: data.refund_price, + refund_price: data.refund_price, + order: data.list, + status: data.status, + refund_only_status: data.refund_only_status, + return_refund_status: data.return_refund_status, + exchange_goods_status: data.exchange_goods_status, + orderType: data.orderType + }); + } + }) + }, + refundPriceInput: function(e) { + this.setData({ + re_price: e.detail.value + }) + }, + chooseImage: function (e) { + var that = this; + // 选择图片 + wx.chooseMedia({ + count: 3, // 默认9 + sizeType: ['original', 'compressed'], // original 原图,compressed 压缩图,默认二者都有 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 + success: function (res) { + var tempFiles = res.tempFiles; + var images = that.data.srcList; + if (images.length > 2) { + wx.showToast({ + title: '亲!最多上传3张哦!', + icon: 'none', + duration: 2000 + }); + } else { + if (images) { + images = images.concat(tempFiles); + } else { + images = tempFiles; + } + that.setData({ + srcList: images, + }); + } + } + }) + }, + deleteAct: function (e) { + var index = e.currentTarget.dataset.index; + var that = this; + if (that.data.srcList.length > 0) { + that.data.srcList.splice(index, 1) + that.setData({ + srcList: that.data.srcList + }); + } else { + return; + } + }, + remarkInput: function(e) { + this.setData({ + remark: e.detail.value + }) + }, + confirmAct() { + var that = this + if (that.data.srcList.length == 0) { + WXAPI.returnData({ + accessId: app.globalData.accessId, + storeId: 239, + storeType: 1, + order_details_id: that.data.orderId, + refund_amount: that.data.refund_price, + explain: that.data.remark, + type: that.data.refund_type, + refund_apply_money: that.data.re_price, + }).then(res => { + if (res.code == 200) { + var data = res.data + that.setData({ + return_suess: true, + order: data + }); + } + }) + } else { + wx.uploadFile({ + url: 'https://mall.gylservice.com/gw?api=app.order.ReturnData', + filePath: this.data.srcList[0].tempFilePath, + name: 'file', + header: { + 'content-type': 'multipart/form-data' + }, // 设置请求的 header + formData: { + accessId: app.globalData.accessId, + storeId: 239, + storeType: 1, + order_details_id: that.data.orderId, + refund_amount: that.data.refund_price, + explain: that.data.remark, + type: that.data.refund_type, + upload_z_num: 1, + upload_num: 0, + refund_apply_money: that.data.re_price, + }, // HTTP 请求中其他额外的 form data + success: function (res) { + console.log(res); + var data = JSON.parse(res.data) + that.setData({ + return_suess: true, + order: data + }); + }, + fail: function (res) { + console.log(res); + } + }) + } + }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + if (this.data.return_suess == true) { + wx.navigateBack({ + delta: 1 + }) + } + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/pages/aftersales/apply.json b/pages/aftersales/apply.json new file mode 100644 index 0000000..76036fa --- /dev/null +++ b/pages/aftersales/apply.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "申请售后" +} \ No newline at end of file diff --git a/pages/aftersales/apply.wxml b/pages/aftersales/apply.wxml new file mode 100644 index 0000000..adebdb4 --- /dev/null +++ b/pages/aftersales/apply.wxml @@ -0,0 +1,123 @@ + + + + + + + + {{ item.p_name }} + + + ¥{{item.p_price}} + + x{{ item.num }} + + {{ item.size }} + + + + + + + + + 售后类型: + + 仅退款 + 退货退款 + 换货 + + + + + + 退款金额: + + + + + 最多¥{{ refund_price }} + + + + + + + 退款说明: + + ddfddf + + + + + {{ r_status != 3 ? ( refund_type != 3 ? '退款说明:' : '申请原因:' ) : '申请原因:' }} + + +