diff --git a/colorui/main.css b/colorui/main.css index 6b5081a..e463a14 100644 --- a/colorui/main.css +++ b/colorui/main.css @@ -843,9 +843,10 @@ button.cuIcon.lg { position: absolute; top: -10upx; left: -10upx; - font-size: 20upx; - padding: 10upx; + font-size: 28upx; + padding: 22upx; height: 40upx; + font-weight: 200; color: #ffffff; } diff --git a/common/api.js b/common/api.js index 34b0861..7dbd03c 100644 --- a/common/api.js +++ b/common/api.js @@ -17,6 +17,18 @@ export const API_ORDER_DETAILS = '/api/order/detail'; //确认订单详情 export const API_COFIRMORDER_DETAILS = '/api/order/confirm'; +//订单退款申请落地页 +export const API_APPLY_DETAILS = '/api/refund/view'; + +//订单退款详情 +export const API_APPLYPAGE_DETAILS = '/api/refund/detail'; + +//提交订单退款申请 +export const API_SUBMIT_APPLY = '/api/refund/apply'; + +//退款申请图片上传 +export const API_UPPLOAD_APPLY = '/api/refund/uploadImg' + /* 商品详情相关 */ export const API_GOODS_DETAIL = '/api/goods/detail'; // 商品详情 export const API_COLLECT_DEAL = '/api/collect/deal'; // 商品收藏 diff --git a/common/uploadFile.js b/common/uploadFile.js new file mode 100644 index 0000000..92949c8 --- /dev/null +++ b/common/uploadFile.js @@ -0,0 +1,74 @@ +/* + *上传文件 + *@param - filePath :图片的本地资源路径 + *@param - dir:表示要传到哪个目录下 + *@param - successc:成功回调 + *@param - failc:失败回调 + */ +const uploadFile = function (filePath, successc, failc) { + if (!filePath || filePath.length < 9) { + wx.showModal({ + title: '图片错误', + content: '请重试', + showCancel: false, + }) + return; + } + + // 上传的服务器地址 + let url = this.API.DEVURL; + if (this.API.DEV == 'prod') { + url = this.API.PRODURL; + } + const url_a = this.API.API_UPPLOAD_APPLY; + + // 上传图片的目录 + var nowTime = formatTime(new Date()); + const dir = 'wxmini/images/' + nowTime + '/'; + + // 获取上传的文件类型 fileType + let fileTypeIndex = filePath.lastIndexOf('.'); + let fileType = filePath.substring(fileTypeIndex); + + uni.uploadFile({ + url: url + url_a,//开发者服务器 url + filePath: filePath,//要上传文件资源的路径 + name: 'image', + formData: { + token: uni.getStorageSync('userinfo').token + }, + + success: function (res) { + console.log('上传文件...', res) + if (res.statusCode != 200 || !res.data) { + failc(new Error('上传错误:' + JSON.stringify(res))) + return; + } + let res_data = JSON.parse(res.data); + successc && successc(res_data.data); + }, + fail: function (err) { + failc(err); + }, + }) +} + +// 获取当前日期(年-月-日),并不足十位补零 +function formatTime(date) { + const year = date.getFullYear() + const month = date.getMonth() + 1 + const day = date.getDate() + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + return [year, month, day].map(formatNumber).join('-') + // + ' ' + [hour, minute, second].map(formatNumber).join(':') +} +const formatNumber = n => { + n = n.toString() + return n[1] ? n : '0' + n +} + +module.exports = { + uploadFile +}; \ No newline at end of file diff --git a/components/me-tabs/me-tabs.vue b/components/me-tabs/me-tabs.vue index 14c344e..ff528aa 100644 --- a/components/me-tabs/me-tabs.vue +++ b/components/me-tabs/me-tabs.vue @@ -175,7 +175,6 @@ color: black; background-color: white; border-radius: 10px; - margin: 2px 0; height: 27px!important; line-height: 27px!important; } @@ -185,7 +184,7 @@ // 平分的方式显示item .tabs-flex { display: flex; - + align-items: center; .tab-item { flex: 1; background-color: #FE9903; diff --git a/main.js b/main.js index 89a4a70..4f07de6 100644 --- a/main.js +++ b/main.js @@ -3,6 +3,7 @@ import App from './App' import mixin from '@/common/mixin.js'; import * as API from '@/common/api.js'; import * as $shared from '@/common/shared.js'; +import { uploadFile } from '@/common/uploadFile.js' Vue.config.productionTip = false @@ -14,6 +15,8 @@ Vue.prototype.API = API; // 全局共享方法 Vue.prototype.$shared = $shared; +Vue.prototype.uploadFile = uploadFile + // 引入全局uView import uView from 'uview-ui' Vue.use(uView); diff --git a/pages/order/apply-details.vue b/pages/order/apply-details.vue index a08931b..4b55fc1 100644 --- a/pages/order/apply-details.vue +++ b/pages/order/apply-details.vue @@ -6,19 +6,19 @@ - + - 网红辣椒棒 魔鬼辣椒挑战全网第一辣 网红优惠季 + {{orderDetails.order.goods.name}} - 数量 x1 + 数量 x {{orderDetails.order.number}} - 19.90 + {{orderDetails.order.selling_price}} - + @@ -32,19 +32,19 @@ 订单金额 - 19.90 + {{orderDetails.order.amount}} 扣费率 - 30% + {{orderDetails.refund_rate}}% 扣费金额 - 3.90 + {{orderDetails.refund_rate_amount}} @@ -56,14 +56,14 @@ 可退金额 - 16.00 + {{orderDetails.refund_amount}} 订单编号 - 67432428794847982374 - 复制 + {{orderDetails.order_sn}} + 复制 @@ -74,7 +74,7 @@ - 由于产品的特殊性,在申请的过程中,供应商会向您收取部分费用。如有疑问可参与产品的《售后说明》或咨询客服 + {{checkArea}} @@ -83,19 +83,13 @@ 退款说明 - 看着不是很新鲜了,然后还有一些都烂了!!!看着不是很新鲜了,然后还有一些都烂了!!!看着不是很新鲜了,然后还有一些都烂了!!!看着不是很新鲜了,然后还有一些都烂了!!!看着不是很新鲜了,然后还有一些都烂了!!! + {{orderDetails.comment}} - - - - - - - - + + @@ -114,46 +108,41 @@ hostImg: '', // 已上传服务器的图片名称 serverImg:'', + orderId:1, + orderDetails: {}, + checkArea: '', + images: [] } }, computed: { }, onLoad(e) { - setTimeout(()=>{ - this.skeletonLoading = false - },1000) + this.orderId = e.orderid + if(this.orderId) { + this.getOrderDetails() + } }, methods: { - // 选择图片 - ChooseImage(e) { - uni.chooseImage({ - count: 1, - success: e => { - this.hostImg = e.tempFilePaths[0]; + getOrderDetails() { + this.$http(this.API.API_APPLYPAGE_DETAILS, {order_id: this.orderId}).then(res => { + if(res.code == 0) { + this.orderDetails = res.data.refund + this.checkArea = res.data.agreement.tips + this.images = res.data.refund.images + this.skeletonLoading = false } + + }).catch(err => { + }); }, - // 预览图片 showImg() { uni.previewImage({ urls: ['../../static/tu.png'] }); }, - - // 删除图片 - DelImg() { - uni.showModal({ - title: '提示', - content: '即将取消上传这张图片,请确认?', - success: e => { - if (!e.confirm) return; - this.hostImg = ''; - this.serverImg = ''; - } - }); - }, // 点击复制 copy(text) { uni.setClipboardData({ diff --git a/pages/order/apply-refund.vue b/pages/order/apply-refund.vue index f4f4f25..f9782bc 100644 --- a/pages/order/apply-refund.vue +++ b/pages/order/apply-refund.vue @@ -6,16 +6,16 @@ - + - 网红辣椒棒 魔鬼辣椒挑战全网第一辣 网红优惠季 + {{applyDetails.order.goods.name}} - 数量 x1 + 数量 x{{applyDetails.order.number}} - 19.90 + {{applyDetails.order.selling_price}} @@ -30,19 +30,19 @@ 订单金额 - 19.90 + {{applyDetails.order.amount}} 扣费率 - 30% + {{applyDetails.order.refund_rate}}% 扣费金额 - 3.90 + {{applyDetails.order.refund_rate_amount}} @@ -55,19 +55,19 @@ 可退金额 - 16.00 + {{applyDetails.order.refund_amount}} 订单编号 - 67432428794847982374 - 复制 + {{applyDetails.order.order_sn}} + 复制 退款说明 - + @@ -76,7 +76,7 @@ - 由于产品的特殊性,在申请的过程中,供应商会向您收取部分费用。如有疑问可参与产品的《售后说明》或咨询客服 + {{applyDetails.agreement.tips}} @@ -87,17 +87,28 @@ + + + + + + + + + + + - @@ -116,56 +127,194 @@ hostImg: '', // 已上传服务器的图片名称 serverImg:'', + orderId: 1, + applyDetails: {}, + applyInfo: '', + imageOnline: '', + is_wx_reduce: true, + img_list: [], // 反馈问题图片 } }, computed: { }, onLoad(e) { + this.orderId = e.orderId + if(this.orderId) { + this.getApplyDetails() + } setTimeout(()=>{ this.skeletonLoading = false },1000) }, methods: { + getApplyDetails() { + this.$http(this.API.API_APPLY_DETAILS, {order_id: this.orderId}).then(res => { + if(res.code == 0) { + this.applyDetails = res.data + this.skeletonLoading = false + console.log(this.applyDetails) + } + + }).catch(err => { + + }); + }, + checkImgInfo(tempFilePath, suc){ + uni.getImageInfo({ + src: tempFilePath, + success (res) { + let type = res.type; + console.log('checkImgInfo...', type); + if(type == 'png' || type == 'jpeg' || type == 'jpg'){ + suc && suc(true); + } else { + suc && suc(false); + } + }, + fail(err) { + suc && suc(false); + } + }) + }, + subimitApply() { + if(!this.applyInfo) { + this.$msg('请先输入反馈信息!') + return + } + this.upload() + }, // 选择图片 ChooseImage(e) { + let that = this; uni.chooseImage({ count: 1, - success: e => { - this.hostImg = e.tempFilePaths[0]; - this.upload(this.hostImg) + sizeType: ['original'], // 可以指定是原图original还是压缩图compressed ,默认二者都有 + sourceType: ['album', 'camera'], // album 从相册选图,camera 使用相机,默认二者都有 + success: res => { + that.hostImg = res.tempFilePaths[0]; + console.log('元数据') + console.log(res) + // this.upload(this.hostImg) + + + let tempFile = res.tempFiles.shift(); + let tempFilePath = res.tempFilePaths.shift(); + that.checkImgInfo(tempFilePath, (res) => { + // 过滤不是图片不是png、jpeg 格式 + if(res){ + if(tempFile.size > 10000000){ + uni.showModal({ + title: '', + content: '您选择的图片过大:'+ (tempFile.size / 1024000).toFixed(2) +"M,请点击确定重新上传", + success: res2 => { + if(res2.confirm){ + uni.chooseImage({ + count: 1, + sizeType: ['compressed'], + sourceType: ['album', 'camera'], + success: (res3) => { + let tempFilePath = res3.tempFilePaths.shift(); + that.is_wx_reduce = true; + that.img_list.push(tempFilePath); + } + }) + } + } + }) + } else{ + that.img_list.push(tempFilePath); + } + } else { + uni.showModal({ + title: '', + content: '选择的图片须为jpg、jpeg或png格式', + showCancel: false, + confirmColor: '#1697EE' + }) + } + }); } }); }, // 上传图片到服务器 upload(url){ - this.$http.upload({ - url: '/user/api/file/image', - data: url, - }).then(res=>{ - let imgurl = JSON.parse(res.data) - this.serverImg=imgurl.data; + let that = this; + let uploads = []; + // 商品banner图上传 + if (that.img_list.length > 0) { + for (let i = 0; i < that.img_list.length; i++) { + let upload_img = new Promise((resolve, reject) => { + that.uploadFile(that.img_list[i], (res) => { + resolve(res); + }, (err) => { + reject(err); + }); + }) + uploads.push(upload_img); + } + } + Promise.all(uploads).then((result) => { + console.log('图片上传...', result) + let img_url_list = []; + if(result.length > 0){ + img_url_list = JSON.stringify(result); + } + if(img_url_list) { + that.realSubmitInfo(img_url_list); + } + + + }).catch(err => { + console.log(err) + that.is_publish = false; // 恢复提交按钮 + uni.showModal({ + title: '', + content: '图片上传失败,请重新提交', + confirmColor: '#1697EE' + }) }) }, - + // 提交反馈 + realSubmitInfo(img_url_list){ + let that = this; + uni.showToast({ + title: '请求中', + icon: "loading", + duration: 10000 + }) + that.$http(that.API.API_SUBMIT_APPLY, {order_id: that.orderId,comment: that.applyInfo,images:img_url_list}).then(res => { + if(res.code == 0) { + that.$msg('提交成功') + that.img_list = [] + that.applyInfo = '' + setTimeout(() => { + that.$routerGo('/pages/order/apply-details?orderId='+that.orderId) + },1000) + } + + }).catch(err => { + + }); + }, // 预览图片 - showImg() { + showImg(image) { + // let image = this.img_list[index]; uni.previewImage({ - urls: [this.hostImg] + urls: [image], }); }, // 删除图片 - DelImg() { + DelImg(index) { uni.showModal({ title: '提示', content: '即将取消上传这张图片,请确认?', success: e => { if (!e.confirm) return; - this.hostImg = ''; - this.serverImg = ''; + this.img_list.splice(index, 1); } }); }, diff --git a/pages/order/confirm-order.vue b/pages/order/confirm-order.vue index 73cf1bf..ad7ea47 100644 --- a/pages/order/confirm-order.vue +++ b/pages/order/confirm-order.vue @@ -151,7 +151,14 @@ submit(){ if(this.ifchoose == true) { if(this.ifCheck == false) { - this.$routerGo('/pages/login/index?type=phone') + uni.showModal({ + title: '提示', + content: '是否同意前往手机授权?', + success: e => { + if (!e.confirm) return; + this.$routerGo('/pages/login/index?type=phone') + } + }); }else { this.$http(this.API.API_PRPAID, { goods_id: this.goods_id, diff --git a/pages/order/index.vue b/pages/order/index.vue index 16b6314..864ec05 100644 --- a/pages/order/index.vue +++ b/pages/order/index.vue @@ -2,15 +2,15 @@ - + - + - + - + {{item.state_text.text}} {{item.goods.name}} @@ -34,7 +34,7 @@ {{item.created_at_text}} - 请在10分钟内付款 + {{item.comment_text}} @@ -113,11 +113,18 @@ // 切换tab change(index) { this.current = index; + this.getUserOrder(); }, - goDetails(item) { + goDetails(tabIndex,index) { + // this.$routerGo('/pages/order/order-details?orderid=55') + + console.log(tabIndex,index) + let item = this.tab_list[tabIndex].list[index] if (item.state == 1) { this.$routerGo('/pages/order/unpay-details?orderid=' + item.id) - } else { + } else if(item.state == 4){ + this.$routerGo('/pages/order/apply-details?orderid=' + item.id) + }else { this.$routerGo('/pages/order/order-details?orderid=' + item.id) } @@ -201,6 +208,13 @@