dingdong-mall/pages/my/components/modal/apply-after-service-goods.vue

322 lines
8.4 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="cu-modal" :class="show?'show':''">
<view class="cu-dialog bg-white">
<view class="cu-bar">
<view class="content">售后申请</view>
<view class="action" @click="hideModal">
<text class="cuIcon-close text-red"></text>
</view>
</view>
<view class="padding text-left">
<view class="flex justify-start align-center">
<view class="title">选择子单</view>
<my-uni-combox class="form-val-area inline-input" :candidates="detailList" placeholder="请选择" :showField="'remark'"
v-model="detailObj">
</my-uni-combox>
</view>
<view class="flex justify-start align-center margin-top-sm">
<view class="title">售后类型</view>
<my-uni-combox class="form-val-area inline-input" :candidates="afterServiceTypeArr" placeholder="请选择" :showField="'name'"
v-model="afterServiceType">
</my-uni-combox>
</view>
<view class="flex justify-start align-center margin-top-sm">
<view class="title">申请原因</view>
<my-uni-combox class="form-val-area inline-input" :candidates="customerReasonTypeArr" placeholder="请选择" :showField="'name'"
v-model="customerReasonType">
</my-uni-combox>
</view>
<view class="margin-top-sm flex justify-start align-center margin-top-sm" v-if="operType === 1">
<text>最大退款金额:</text>
<text class="text-price text-red">{{detailObj ? detailObj.payMoney : 0}}</text>
</view>
<view class="margin-top-sm flex justify-start align-center margin-top-sm" v-if="operType === 1">
<view>退款金额:</view>
<input type="digit" class="radius-input inline-input" v-model="refund" style="flex-basis: 70%;"></input>
</view>
<view class="margin-top-sm flex justify-start margin-top-sm">
<view>具体原因:</view>
<textarea style="height: 200rpx;" class="solid radius text-left padding-sm inline-input"
v-model="remark" maxlength="-1"></textarea>
</view>
<!-- 上传图片 -->
<view class="padding-top">
<view class="grid col-3 grid-square flex-sub margin-top-sm">
<view class="bg-img" v-for="(item,index) in imgList" :key="index"
@tap="viewImage($event, imgList)" :data-url="item">
<image :src="item" mode="aspectFill"></image>
<view class="cu-tag bg-red" @tap.stop="delImg($event, imgList)" :data-index="index">
<text class='cuIcon-close'></text>
</view>
</view>
<view class="solids" @tap="chooseImgList(e, imgList)" v-if="imgList.length < 3">
<text class='cuIcon-cameraadd'></text>
</view>
</view>
</view>
</view>
<view class="cu-bar solid-top">
<view class="action margin-0 flex-sub text-black" @click="hideModal">取消</view>
<view class="action margin-0 flex-sub text-main-color solid-left" @click="apply">确认</view>
</view>
</view>
</view>
</template>
<script>
import myUniCombox from '@/components/uni-combox/my-uni-combox.vue';
export default {
name: 'applyAfterSale',
components: {
myUniCombox
},
props: {
data: {
type: Object,
default: () => {}
}
},
data() {
return {
show: false,
operType: 2, // 1为申请退款2为发起售后
afterServiceType: null,
afterServiceTypeArr: [
{
code: 1,
name: '未收到货,我要退单退款!'
},
{
code: 2,
name: '未收到货(发货在途),我要退款!'
},
{
code: 3,
name: '已收到货,我要退款退货!'
},
],
customerReasonTypeArr: [],
customerReasonType: null,
refund: null,
remark: null,
imgList: [],
detailList: [],
detailObj: null,
toUpdateStatus: false
}
},
watch: {
afterServiceType() {
if(this.afterServiceType) {
this.customerReasonType = null
if(this.afterServiceType.code == 3) {
this.customerReasonTypeArr = [
{
code: 1,
name: '不想要了'
},{
code: 2,
name: '买错型号尺寸了'
},{
code: 3,
name: '材质与商品描述不符'
},
{
code: 4,
name: '大小尺寸与商品描述不符'
},
{
code: 5,
name: '颜色、款式、型号与描述不符'
},
{
code: 6,
name: '出现质量问题'
},
{
code: 7,
name: '收到商品少件(少配件)'
},
{
code: 8,
name: '商家发错货'
},
{
code: 9,
name: '商品破损或污渍'
}
]
} else {
this.customerReasonTypeArr = [
{
code: 1,
name: '不想要了'
},{
code: 10,
name: '未按承诺时间发货'
},{
code: 11,
name: '未见快递/物流有信息'
},
{
code: 12,
name: '其它原因'
}
]
}
}
}
},
methods: {
async init(curOrder) {
let res = await this.$request.getDetailListByMasterId({
orderMasterId: curOrder.orderMasterId
});
if (res && res.code === 0) {
this.detailList = res.data;
}
},
showModal(curOrder, params) {
this.init(curOrder);
this.operType = params.afterServiceType
// this.afterServiceType = params.afterServiceType;
this.toUpdateStatus = params.toUpdateStatus;
this.show = true;
},
hideModal(e) {
this.resetData();
this.$emit('cancel');
this.show = false;
},
resetData() {
this.operType = null
this.afterServiceType = null;
this.customerReasonType = null;
this.data = null;
this.refund = null;
this.imgList = [];
this.remark = null;
},
chooseImgList(e, imgList) {
uni.chooseImage({
count: 3 - imgList.length, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: (res) => {
uni.showLoading({
title: '上传中',
mask: true
});
res.tempFilePaths.forEach((tmpUrl, index) => {
this.$request.uploadFile(tmpUrl).then((url) => {
imgList.push(url);
if (index === res.tempFilePaths.length - 1) {
uni.hideLoading();
}
});
});
}
});
},
viewImage(e, imgList) {
uni.previewImage({
urls: imgList,
current: e.currentTarget.dataset.url
});
},
delImg(e, imgList) {
uni.showModal({
title: '',
content: '确定要删除这张图片吗?',
cancelText: '取消',
confirmText: '确定',
success: res => {
if (res.confirm) {
imgList.splice(e.currentTarget.dataset.index, 1)
}
}
})
},
validData() {
let errMsg = null;
if (!this.detailObj) {
errMsg = "请选择子单";
}
if(!this.afterServiceType) {
errMsg = "请选择售后类型";
}
if(!this.customerReasonType) {
errMsg = "请选择申请原因";
}
if (errMsg) {
uni.showToast({
title: errMsg,
duration: 1500,
icon: 'none'
})
return false;
}
return true;
},
async apply() {
if (!this.validData()) {
return;
}
let imgObjList = [];
this.imgList.forEach(url => {
imgObjList.push({
imgUrl: url,
imgUploadBy: 1
})
})
let res = await this.$request.addAfterServiceRecord({
customerReasonType: this.customerReasonType.code,
customerReason: this.remark,
orderDetailId: this.detailObj.orderDetailId,
afterServiceType: this.afterServiceType.code,
refund: this.refund,
operType: this.operType,
imgsList: imgObjList,
createBy: 1,
updateBy: 1,
afterServiceCategory: 2
});
if (res && res.code === 0) {
let updateStatusRes = {
code: 0
}
if (this.toUpdateStatus) {
updateStatusRes = await this.$request.updateOrder({
id: this.data.orderMasterId,
orderStatus: 3
});
}
if (updateStatusRes && updateStatusRes.code === 0) {
this.hideModal();
this.$emit('confirmFeedback');
uni.showToast({
title: '已发起售后,进度可在订单详情内查看',
icon: 'none',
duration: 2000
})
return;
}
}
uni.showToast({
title: '无法对同一个订单重复发起售后或退款',
icon: 'none',
duration: 2000
})
}
},
}
</script>
<style scoped>
.inline-input {
flex-basis: 74%;
}
</style>