feat: 商品申请评分+逆向退款申请
This commit is contained in:
parent
c9de557000
commit
f7f14e59cb
77
api/order.js
77
api/order.js
@ -124,4 +124,81 @@ export const apiGetOrderCount = (data) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 申请退款
|
||||||
|
export const apiApplyRefund = (data) => {
|
||||||
|
return httpRequest.post(
|
||||||
|
`${baseUrl}/reverse/add`,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 申请评价
|
||||||
|
export const apiApplyComment = (data) => {
|
||||||
|
return httpRequest.post(
|
||||||
|
`${baseUrl}/comment/add`,
|
||||||
|
data
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 上传图片(支持批量上传)
|
||||||
|
export const apiUploadFile = (fileList) => {
|
||||||
|
// uni.request不支持FormData和文件上传,需要使用uni.uploadFile
|
||||||
|
// fileList应该是文件对象数组,格式:[{path:'xxx'}] 或 [{tempFilePath:'xxx'}]
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// 获取用户信息用于添加token
|
||||||
|
let user_info = uni.getStorageSync("user_info") || {};
|
||||||
|
if (typeof user_info === "string") {
|
||||||
|
try {
|
||||||
|
user_info = JSON.parse(user_info) || {};
|
||||||
|
} catch (e) {
|
||||||
|
user_info = {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 批量上传所有文件
|
||||||
|
const uploadPromises = fileList.map((file, index) => {
|
||||||
|
return new Promise((fileResolve, fileReject) => {
|
||||||
|
const filePath = file.path || file.tempFilePath || file.path || file;
|
||||||
|
if (!filePath) {
|
||||||
|
fileReject({ msg: `第${index + 1}个文件路径无效` });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uni.uploadFile({
|
||||||
|
url: `${baseUrl}/upload/file`,
|
||||||
|
filePath: filePath,
|
||||||
|
name: 'files',
|
||||||
|
header: {
|
||||||
|
token: user_info.token || '',
|
||||||
|
buyerId: user_info.buyerId || '',
|
||||||
|
flag: user_info.flag || ''
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
try {
|
||||||
|
const data = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
fileResolve(data);
|
||||||
|
} else {
|
||||||
|
fileReject({ code: res.statusCode, msg: data.msg || '上传失败', data });
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
fileReject({ code: res.statusCode, msg: '解析响应数据失败', data: res.data });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
fileReject({ msg: err.errMsg || '上传失败', err });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 等待所有文件上传完成
|
||||||
|
Promise.all(uploadPromises)
|
||||||
|
.then(results => {
|
||||||
|
resolve(results);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,12 +3,10 @@
|
|||||||
<view class="goods-list">
|
<view class="goods-list">
|
||||||
<view class="goods-item" v-for="(item, index) in goodsList" :key="index">
|
<view class="goods-item" v-for="(item, index) in goodsList" :key="index">
|
||||||
<!-- 商品详情 -->
|
<!-- 商品详情 -->
|
||||||
<view class="goods-main">
|
<!-- <view class="goods-main">
|
||||||
<!-- 商品图片 -->
|
|
||||||
<view class="goods-image">
|
<view class="goods-image">
|
||||||
<image class="image" :src="item.goods_image" mode="scaleToFill"></image>
|
<image class="image" :src="item.goods_image" mode="scaleToFill"></image>
|
||||||
</view>
|
</view>
|
||||||
<!-- 商品信息 -->
|
|
||||||
<view class="goods-content">
|
<view class="goods-content">
|
||||||
<view class="goods-title"><text class="twoline-hide">{{ item.goods_name }}</text></view>
|
<view class="goods-title"><text class="twoline-hide">{{ item.goods_name }}</text></view>
|
||||||
<view class="goods-props clearfix">
|
<view class="goods-props clearfix">
|
||||||
@ -17,7 +15,6 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 交易信息 -->
|
|
||||||
<view class="goods-trade">
|
<view class="goods-trade">
|
||||||
<view class="goods-price">
|
<view class="goods-price">
|
||||||
<text class="unit">¥</text>
|
<text class="unit">¥</text>
|
||||||
@ -27,22 +24,22 @@
|
|||||||
<text>×{{ item.total_num }}</text>
|
<text>×{{ item.total_num }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<!-- 选择评价 -->
|
<!-- 选择评价 -->
|
||||||
<view class="score-row">
|
<view class="score-row">
|
||||||
<view class="score-item score-praise" :class="{ active: formData[index].score == 10 }" @click="setScore(index, 10)">
|
<view class="score-item score-praise" :class="{ active: formData[index].level == 'good' }" @click="setScore(index, 'good')">
|
||||||
<view class="score">
|
<view class="score">
|
||||||
<text class="score-icon iconfont icon-haoping"></text>
|
<text class="score-icon iconfont icon-haoping"></text>
|
||||||
<text class="score-text">好评</text>
|
<text class="score-text">好评</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="score-item score-review" :class="{ active: formData[index].score == 20 }" @click="setScore(index, 20)">
|
<view class="score-item score-review" :class="{ active: formData[index].level == 'common' }" @click="setScore(index, 'common')">
|
||||||
<view class="score">
|
<view class="score">
|
||||||
<text class="score-icon iconfont icon-zhongping"></text>
|
<text class="score-icon iconfont icon-zhongping"></text>
|
||||||
<text class="score-text">中评</text>
|
<text class="score-text">中评</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="score-item score-negative" :class="{ active: formData[index].score == 30 }" @click="setScore(index, 30)">
|
<view class="score-item score-negative" :class="{ active: formData[index].level == 'notgood' }" @click="setScore(index, 'notgood')">
|
||||||
<view class="score">
|
<view class="score">
|
||||||
<text class="score-icon iconfont icon-chaping"></text>
|
<text class="score-icon iconfont icon-chaping"></text>
|
||||||
<text class="score-text">差评</text>
|
<text class="score-text">差评</text>
|
||||||
@ -50,9 +47,52 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 评分详情 -->
|
||||||
|
<view class="rating-detail">
|
||||||
|
<view class="rating-item">
|
||||||
|
<text class="rating-label">商品分:</text>
|
||||||
|
<view class="rating-stars">
|
||||||
|
<u-rate
|
||||||
|
:current="formData[index].descMatch || 5"
|
||||||
|
:count="5"
|
||||||
|
:size="28"
|
||||||
|
active-color="#FFD700"
|
||||||
|
inactive-color="#E0E0E0"
|
||||||
|
@change="(val) => setGoodsScore(index, val)"
|
||||||
|
></u-rate>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="rating-item">
|
||||||
|
<text class="rating-label">卖家服务评分:</text>
|
||||||
|
<view class="rating-stars">
|
||||||
|
<u-rate
|
||||||
|
:current="formData[index].sellerService || 5"
|
||||||
|
:count="5"
|
||||||
|
:size="28"
|
||||||
|
active-color="#FFD700"
|
||||||
|
inactive-color="#E0E0E0"
|
||||||
|
@change="(val) => setServiceScore(index, val)"
|
||||||
|
></u-rate>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="rating-item">
|
||||||
|
<text class="rating-label">物流评分:</text>
|
||||||
|
<view class="rating-stars">
|
||||||
|
<u-rate
|
||||||
|
:current="formData[index].logisticsService || 5"
|
||||||
|
:count="5"
|
||||||
|
:size="28"
|
||||||
|
active-color="#FFD700"
|
||||||
|
inactive-color="#E0E0E0"
|
||||||
|
@change="(val) => setLogisticsScore(index, val)"
|
||||||
|
></u-rate>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 评价内容 -->
|
<!-- 评价内容 -->
|
||||||
<view class="form-content">
|
<view class="form-content">
|
||||||
<textarea class="textarea" v-model="formData[index].content" maxlength="500" placeholder="请输入评价内容 (留空则不评价)"></textarea>
|
<textarea class="textarea" v-model="formData[index].serviceComment" maxlength="500" placeholder="请输入评价内容 (留空则不评价)"></textarea>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 图片列表 -->
|
<!-- 图片列表 -->
|
||||||
@ -81,41 +121,33 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import * as UploadApi from '@/api/upload'
|
|
||||||
import * as OrderCommentApi from '@/api/order/comment'
|
import * as OrderCommentApi from '@/api/order/comment'
|
||||||
|
import * as OrderApi from '@/api/order'
|
||||||
|
|
||||||
const maxImageLength = 6
|
const maxImageLength = 6
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 正在加载
|
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
// 当前订单ID
|
|
||||||
orderId: null,
|
orderId: null,
|
||||||
// 待评价商品列表
|
goodsList: [{}],
|
||||||
goodsList: [],
|
|
||||||
// 表单数据
|
|
||||||
formData: [],
|
formData: [],
|
||||||
// 最大图片数量
|
|
||||||
maxImageLength,
|
maxImageLength,
|
||||||
// 按钮禁用
|
disabled: false,
|
||||||
disabled: false
|
trackNumber: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
onLoad({ tradeOrderId, trackNumber }) {
|
||||||
/**
|
this.orderId = tradeOrderId
|
||||||
* 生命周期函数--监听页面加载
|
this.trackNumber = trackNumber
|
||||||
*/
|
this.initFormData()
|
||||||
onLoad({ orderId }) {
|
this.isLoading = false
|
||||||
this.orderId = orderId
|
// this.getGoodsList()
|
||||||
// 获取待评价商品列表
|
|
||||||
this.getGoodsList()
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
/* // 获取待评价商品列表
|
||||||
// 获取待评价商品列表
|
|
||||||
getGoodsList() {
|
getGoodsList() {
|
||||||
const app = this
|
const app = this
|
||||||
app.isLoading = true
|
app.isLoading = true
|
||||||
@ -125,29 +157,41 @@
|
|||||||
app.initFormData()
|
app.initFormData()
|
||||||
app.isLoading = false
|
app.isLoading = false
|
||||||
})
|
})
|
||||||
},
|
}, */
|
||||||
|
|
||||||
// 初始化form数据
|
// 初始化form数据
|
||||||
initFormData() {
|
initFormData() {
|
||||||
const { goodsList } = this
|
const { goodsList } = this
|
||||||
const formData = goodsList.map(item => {
|
const formData = goodsList.map(item => {
|
||||||
return {
|
return {
|
||||||
goods_id: item.goods_id,
|
trackNumber: this.trackNumber,
|
||||||
order_goods_id: item.order_goods_id,
|
level: 'good',
|
||||||
score: 10,
|
descMatch: 0, // 商品分,默认5
|
||||||
content: '',
|
sellerService: 0, // 卖家服务评分,默认2
|
||||||
|
logisticsService: 0, // 物流评分,默认3
|
||||||
|
serviceComment: '',
|
||||||
|
commentDetailList: '',
|
||||||
imageList: [],
|
imageList: [],
|
||||||
uploaded: []
|
uploaded: []
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.formData = formData
|
this.formData = formData
|
||||||
},
|
},
|
||||||
|
|
||||||
// 设置评分
|
// 设置评分
|
||||||
setScore(index, score) {
|
setScore(index, level) {
|
||||||
this.formData[index].score = score
|
this.formData[index].level = level
|
||||||
|
},
|
||||||
|
// 设置商品分
|
||||||
|
setGoodsScore(index, score) {
|
||||||
|
this.formData[index].descMatch = score
|
||||||
|
},
|
||||||
|
// 设置卖家服务评分
|
||||||
|
setServiceScore(index, score) {
|
||||||
|
this.formData[index].sellerService = score
|
||||||
|
},
|
||||||
|
// 设置物流评分
|
||||||
|
setLogisticsScore(index, score) {
|
||||||
|
this.formData[index].logisticsService = score
|
||||||
},
|
},
|
||||||
|
|
||||||
// 选择图片
|
// 选择图片
|
||||||
chooseImage(index) {
|
chooseImage(index) {
|
||||||
const app = this
|
const app = this
|
||||||
@ -163,29 +207,26 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 删除图片
|
// 删除图片
|
||||||
deleteImage(index, imageIndex) {
|
deleteImage(index, imageIndex) {
|
||||||
this.formData[index].imageList.splice(imageIndex, 1)
|
this.formData[index].imageList.splice(imageIndex, 1)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 表单提交
|
// 表单提交
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
const app = this
|
const app = this
|
||||||
// 判断是否重复提交
|
|
||||||
if (app.disabled === true) return false
|
if (app.disabled === true) return false
|
||||||
// 按钮禁用
|
|
||||||
app.disabled = true
|
app.disabled = true
|
||||||
// 判断是否需要上传图片
|
|
||||||
const imagesLength = app.getImagesLength()
|
const imagesLength = app.getImagesLength()
|
||||||
if (imagesLength > 0) {
|
if (imagesLength > 0) {
|
||||||
app.uploadFile()
|
const imageList = app.formData.map(item => item.imageList)
|
||||||
.then(() => {
|
OrderApi.apiUploadFile(imageList.flat())
|
||||||
console.log('then')
|
.then(results => {
|
||||||
app.onSubmit()
|
app.formData[0].commentDetailList = results.map(result => {
|
||||||
|
return {"commentUrl":result.data[0].url,"type":"image"}
|
||||||
|
});
|
||||||
|
app.onSubmit();
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log('catch')
|
|
||||||
app.disabled = false
|
app.disabled = false
|
||||||
if (err.statusCode !== 0) {
|
if (err.statusCode !== 0) {
|
||||||
app.$toast(err.errMsg)
|
app.$toast(err.errMsg)
|
||||||
@ -196,61 +237,31 @@
|
|||||||
app.onSubmit()
|
app.onSubmit()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 统计图片数量
|
// 统计图片数量
|
||||||
getImagesLength() {
|
getImagesLength() {
|
||||||
const { formData } = this
|
const { formData } = this
|
||||||
let imagesLength = 0
|
let imagesLength = 0
|
||||||
formData.forEach(item => {
|
formData.forEach(item => {
|
||||||
if (item.content.trim()) {
|
if (item.serviceComment.trim()) {
|
||||||
imagesLength += item.imageList.length
|
imagesLength += item.imageList.length
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return imagesLength
|
return imagesLength
|
||||||
},
|
},
|
||||||
|
|
||||||
// 提交到后端
|
// 提交到后端
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
const app = this
|
const app = this
|
||||||
OrderCommentApi.submit(app.orderId, app.formData)
|
const params = { ...app.formData[0], imageList: undefined }
|
||||||
|
OrderApi.apiApplyComment(params)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
app.$toast(result.message)
|
app.$toast(result.msg)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
app.disabled = false
|
app.disabled = false
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, 1500)
|
}, 1500)
|
||||||
})
|
})
|
||||||
.catch(err => app.disabled = false)
|
.catch(err => app.disabled = false)
|
||||||
},
|
|
||||||
|
|
||||||
// 上传图片
|
|
||||||
uploadFile() {
|
|
||||||
const app = this
|
|
||||||
const { formData } = app
|
|
||||||
// 整理上传文件路径
|
|
||||||
const files = []
|
|
||||||
formData.forEach((item, index) => {
|
|
||||||
if (item.content.trim() && item.imageList.length) {
|
|
||||||
const images = item.imageList.map(image => image)
|
|
||||||
files.push({ formDataIndex: index, images })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 批量上传
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
Promise.all(files.map((file, index) => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
UploadApi.image(file.images)
|
|
||||||
.then(fileIds => {
|
|
||||||
app.formData[index].uploaded = fileIds
|
|
||||||
resolve(fileIds)
|
|
||||||
})
|
|
||||||
.catch(reject)
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
.then(resolve, reject)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -364,6 +375,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 评分详情
|
||||||
|
.rating-detail {
|
||||||
|
padding: 20rpx 20rpx;
|
||||||
|
margin-top: 10rpx;
|
||||||
|
|
||||||
|
.rating-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #333;
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating-label {
|
||||||
|
width: 200rpx;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating-stars {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 评价内容
|
// 评价内容
|
||||||
.form-content {
|
.form-content {
|
||||||
padding: 14rpx 10rpx;
|
padding: 14rpx 10rpx;
|
||||||
|
|||||||
@ -82,7 +82,7 @@
|
|||||||
<view class="goods-title"><text class="twoline-hide">{{ goods.productName }}</text></view>
|
<view class="goods-title"><text class="twoline-hide">{{ goods.productName }}</text></view>
|
||||||
<view class="goods-props clearfix">
|
<view class="goods-props clearfix">
|
||||||
<view class="goods-props-item" v-for="(props, idx) in goods.skuInfo" :key="idx">
|
<view class="goods-props-item" v-for="(props, idx) in goods.skuInfo" :key="idx">
|
||||||
<text>{{ props.value.name }}</text>
|
<text>{{ props.propertyName }}: {{ props.propertyValue }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -179,7 +179,7 @@
|
|||||||
<view v-if="!['apply_cancel', 'close', 'cancel', 'refund'].includes(orderDetail.tradeOrderEntity.status)" class="footer-fixed">
|
<view v-if="!['apply_cancel', 'close', 'cancel', 'refund'].includes(orderDetail.tradeOrderEntity.status)" class="footer-fixed">
|
||||||
<view class="btn-wrapper">
|
<view class="btn-wrapper">
|
||||||
<block v-for="(action, idx) in orderDetail.orderActionList" :key="idx">
|
<block v-for="(action, idx) in orderDetail.orderActionList" :key="idx">
|
||||||
<view :class="['btn-item', { 'active': ['pay', 'delivered', 'shipped'].some(key => action.interfaceUri.includes(key)) }]" @click="onClickBtn(item.tradeOrderEntity.tradeOrderId, action)">{{ action.desc }}</view>
|
<view :class="['btn-item', { 'active': ['pay', 'delivered', 'shipped'].some(key => action.interfaceUri.includes(key)) }]" @click="onClickBtn(orderId, orderDetail.vvPackageEntity.trackNumber, action)">{{ action.desc }}</view>
|
||||||
</block>
|
</block>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -305,47 +305,29 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 跳转到申请售后页面
|
// 跳转到申请售后页面
|
||||||
handleApplyRefund(orderGoodsId) {
|
handleApplyRefund(orderGoodsId, trackNumber) {
|
||||||
this.$goPageByToken('pages/refund/apply', { orderGoodsId })
|
this.$goPageByToken('pages/refund/apply', { orderGoodsId, trackNumber })
|
||||||
},
|
},
|
||||||
|
|
||||||
// 取消订单
|
onClick(orderId, url, tip) {
|
||||||
onCancel(orderId) {
|
|
||||||
const app = this
|
const app = this
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '友情提示',
|
title: '友情提示',
|
||||||
content: '确认要取消该订单吗?',
|
content: tip,
|
||||||
success(o) {
|
success(o) {
|
||||||
if (o.confirm) {
|
if (o.confirm) {
|
||||||
OrderApi.cancel(orderId)
|
OrderApi.apiActionOrder(url, { tradeOrderId: orderId })
|
||||||
.then(result => {
|
.then(result => {
|
||||||
// 显示成功信息
|
app.$toast(result.msg)
|
||||||
app.$toast(result.message)
|
const timer = setTimeout(() => {
|
||||||
// 刷新当前订单数据
|
clearTimeout(timer);
|
||||||
setTimeout(() => app.getOrderDetail(true), 1500)
|
uni.navigateBack();
|
||||||
|
}, 1500);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onReceipt(orderId, url) {
|
|
||||||
const app = this
|
|
||||||
uni.showModal({
|
|
||||||
title: '友情提示',
|
|
||||||
content: '确认要确认收货吗?',
|
|
||||||
success(o) {
|
|
||||||
if (o.confirm) {
|
|
||||||
OrderApi.apiActionOrder(url, { tradeOrderId: orderId })
|
|
||||||
.then(result => {
|
|
||||||
// 显示成功信息
|
|
||||||
app.$toast(result.msg)
|
|
||||||
// 刷新订单列表
|
|
||||||
app.onRefreshList()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 确认收货
|
// 确认收货
|
||||||
/* async onReceipt(orderId) {
|
/* async onReceipt(orderId) {
|
||||||
const app = this
|
const app = this
|
||||||
@ -440,22 +422,26 @@
|
|||||||
this.$goPageByToken('pages/checkout/cashier/index', { orderId })
|
this.$goPageByToken('pages/checkout/cashier/index', { orderId })
|
||||||
},
|
},
|
||||||
// 跳转到订单评价页
|
// 跳转到订单评价页
|
||||||
handleTargetComment(orderId) {
|
handleTargetComment(orderId, trackNumber) {
|
||||||
this.$goPageByToken('pages/order/comment/index', { orderId })
|
this.$goPageByToken('pages/order/comment/index', { tradeOrderId: orderId, trackNumber })
|
||||||
},
|
},
|
||||||
|
onClickBtn(orderId, trackNumber, action) {
|
||||||
|
console.warn('----- my data is orderId, action: ', orderId, trackNumber, action)
|
||||||
|
const tip = [{ name: '/applyCancel', tip: '确认要取消该订单吗?' }, { name: '/receipt', tip: '确认要收货吗?' }, { name: '/shipped', tip: '确认要收货吗?' }]
|
||||||
|
if (action.interfaceUri.includes('/pay')) {
|
||||||
|
this.onPay(orderId)
|
||||||
|
} else if (action.interfaceUri.includes('/comment')) {
|
||||||
|
this.handleTargetComment(orderId, trackNumber)
|
||||||
|
} else if (action.interfaceUri.includes('/refund')) {
|
||||||
|
this.handleApplyRefund(orderId, trackNumber)
|
||||||
|
} else if (action.interfaceUri.includes('/logistics')) {
|
||||||
|
this.handleTargetExpress(trackNumber)
|
||||||
|
} else {
|
||||||
|
const tipContent = tip.find(item => action.interfaceUri.includes(item.name))?.tip
|
||||||
|
this.onClick(orderId, action.interfaceUri, tipContent)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onClickBtn(orderId, action) {
|
|
||||||
console.warn('----- my data is orderId, action: ', orderId, action)
|
|
||||||
if (action.interfaceUri === '/app/order/applyCancel') {
|
|
||||||
this.onCancel(orderId, action.interfaceUri)
|
|
||||||
} else if (action.interfaceUri.includes('/pay')) {
|
|
||||||
this.onPay(orderId)
|
|
||||||
} else if (action.interfaceUri.includes('/receipt')) {
|
|
||||||
this.onReceipt(orderId, action.interfaceUri)
|
|
||||||
} else if (action.interfaceUri.includes('/comment')) {
|
|
||||||
this.handleTargetComment(orderId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,7 @@
|
|||||||
<view v-if="item.order_status != OrderStatusEnum.CANCELLED.value" class="order-handle">
|
<view v-if="item.order_status != OrderStatusEnum.CANCELLED.value" class="order-handle">
|
||||||
<view class="btn-group clearfix">
|
<view class="btn-group clearfix">
|
||||||
<block v-for="(action, i) in item.orderActionList" :key="action.interfaceUri">
|
<block v-for="(action, i) in item.orderActionList" :key="action.interfaceUri">
|
||||||
<view :class="['btn-item', i && 'active']" @click="onClickBtn(item.tradeOrderEntity.tradeOrderId, action)">{{ action.desc }}</view>
|
<view :class="['btn-item', i && 'active']" @click="onClickBtn(item.tradeOrderEntity.tradeOrderId, item.vvPackageEntity.trackNumber, action)">{{ action.desc }}</view>
|
||||||
</block>
|
</block>
|
||||||
<!-- 未支付取消订单 -->
|
<!-- 未支付取消订单 -->
|
||||||
<!-- <block v-if="item.interfaceUri == PayStatusEnum.PENDING.value">
|
<!-- <block v-if="item.interfaceUri == PayStatusEnum.PENDING.value">
|
||||||
@ -295,33 +295,42 @@
|
|||||||
this.mescroll.resetUpScroll()
|
this.mescroll.resetUpScroll()
|
||||||
}, 120)
|
}, 120)
|
||||||
},
|
},
|
||||||
|
|
||||||
onClickBtn(orderId, action) {
|
// 跳转到物流跟踪页面
|
||||||
console.warn('----- my data is orderId, action: ', orderId, action)
|
handleTargetExpress(trackNumber) {
|
||||||
if (action.interfaceUri === '/app/order/applyCancel') {
|
this.$goPageByToken('pages/order/express/index', { trackNumber })
|
||||||
this.onCancel(orderId, action.interfaceUri)
|
},
|
||||||
} else if (action.interfaceUri.includes('/pay')) {
|
// 跳转到退款/售后页面
|
||||||
this.onPay(orderId)
|
handleApplyRefund(orderId, trackNumber) {
|
||||||
} else if (action.interfaceUri.includes('/receipt')) {
|
this.$goPageByToken('pages/refund/apply', { orderId, trackNumber })
|
||||||
this.onReceipt(orderId, action.interfaceUri)
|
},
|
||||||
} else if (action.interfaceUri.includes('/comment')) {
|
onClickBtn(orderId, trackNumber, action) {
|
||||||
this.handleTargetComment(orderId)
|
console.warn('----- my data is orderId, trackNumber, action: ', orderId, trackNumber, action)
|
||||||
}
|
const tip = [{ name: '/applyCancel', tip: '确认要取消该订单吗?' }, { name: '/receipt', tip: '确认要收货吗?' }, { name: '/shipped', tip: '确认要收货吗?' }]
|
||||||
|
if (action.interfaceUri.includes('/pay')) {
|
||||||
|
this.onPay(orderId)
|
||||||
|
} else if (action.interfaceUri.includes('/comment')) {
|
||||||
|
this.handleTargetComment(orderId, trackNumber)
|
||||||
|
} else if (action.interfaceUri.includes('/refund')) {
|
||||||
|
this.handleApplyRefund(orderId, trackNumber)
|
||||||
|
} else if (action.interfaceUri.includes('/logistics')) {
|
||||||
|
this.handleTargetExpress(trackNumber)
|
||||||
|
} else {
|
||||||
|
const tipContent = tip.find(item => action.interfaceUri.includes(item.name))?.tip
|
||||||
|
this.onClick(orderId, action.interfaceUri, tipContent)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 取消订单
|
// 取消订单
|
||||||
onCancel(orderId, url) {
|
onClick(orderId, url, tip) {
|
||||||
const app = this
|
const app = this
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '友情提示',
|
title: '友情提示',
|
||||||
content: '确认要取消该订单吗?',
|
content: tip,
|
||||||
success(o) {
|
success(o) {
|
||||||
if (o.confirm) {
|
if (o.confirm) {
|
||||||
OrderApi.apiActionOrder(url, { tradeOrderId: orderId })
|
OrderApi.apiActionOrder(url, { tradeOrderId: orderId })
|
||||||
.then(result => {
|
.then(result => {
|
||||||
// 显示成功信息
|
|
||||||
app.$toast(result.msg)
|
app.$toast(result.msg)
|
||||||
// 刷新订单列表
|
|
||||||
app.onRefreshList()
|
app.onRefreshList()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -339,27 +348,9 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 跳转到订单评价页
|
// 跳转到订单评价页
|
||||||
handleTargetComment(orderId) {
|
handleTargetComment(orderId, trackNumber) {
|
||||||
this.$goPageByToken('pages/order/comment/index', { tradeOrderId: orderId })
|
this.$goPageByToken('pages/order/comment/index', { tradeOrderId: orderId, trackNumber })
|
||||||
},
|
},
|
||||||
onReceipt(orderId, url) {
|
|
||||||
const app = this
|
|
||||||
uni.showModal({
|
|
||||||
title: '友情提示',
|
|
||||||
content: '确认要确认收货吗?',
|
|
||||||
success(o) {
|
|
||||||
if (o.confirm) {
|
|
||||||
OrderApi.apiActionOrder(url, { tradeOrderId: orderId })
|
|
||||||
.then(result => {
|
|
||||||
// 显示成功信息
|
|
||||||
app.$toast(result.msg)
|
|
||||||
// 刷新订单列表
|
|
||||||
app.onRefreshList()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
// 确认收货
|
// 确认收货
|
||||||
async onReceipt(orderIndex) {
|
async onReceipt(orderIndex) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<view v-if="!isLoading" class="container" :style="appThemeStyle">
|
<view v-if="!isLoading" class="container" :style="appThemeStyle">
|
||||||
|
|
||||||
<!-- 商品详情 -->
|
<!-- 商品详情 -->
|
||||||
<view class="goods-detail b-f dis-flex flex-dir-row">
|
<!-- <view class="goods-detail b-f dis-flex flex-dir-row">
|
||||||
<view class="left">
|
<view class="left">
|
||||||
<image class="goods-image" :src="goods.goods_image"></image>
|
<image class="goods-image" :src="goods.goods_image"></image>
|
||||||
</view>
|
</view>
|
||||||
@ -22,12 +22,12 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
-->
|
||||||
<!-- 服务类型 -->
|
<!-- 服务类型 -->
|
||||||
<view class="row-service b-f m-top20">
|
<view class="row-service b-f m-top20">
|
||||||
<view class="row-title">服务类型</view>
|
<view class="row-title">服务类型</view>
|
||||||
<view class="service-switch dis-flex">
|
<view class="service-switch dis-flex">
|
||||||
<view class="switch-item" v-for="(item, index) in RefundTypeEnum.data" :key="index" :class="{ active: formData.type == item.value }"
|
<view class="switch-item" v-for="(item, index) in RefundTypeEnum" :key="index" :class="{ active: formData.refundType == item.value }"
|
||||||
@click="onSwitchService(item.value)">{{ item.name }}</view>
|
@click="onSwitchService(item.value)">{{ item.name }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -36,15 +36,15 @@
|
|||||||
<view class="row-textarea b-f m-top20">
|
<view class="row-textarea b-f m-top20">
|
||||||
<view class="row-title">申请原因</view>
|
<view class="row-title">申请原因</view>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<textarea class="textarea" v-model="formData.content" maxlength="2000" placeholder="请详细填写申请原因,注意保持商品的完好,建议您先与卖家沟通"
|
<textarea class="textarea" v-model="formData.refundReason" maxlength="2000" placeholder="请详细填写申请原因,注意保持商品的完好,建议您先与卖家沟通"
|
||||||
placeholderStyle="color:#ccc"></textarea>
|
placeholderStyle="color:#ccc"></textarea>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 退款金额 -->
|
<!-- 退款金额 -->
|
||||||
<view v-if="formData.type == RefundTypeEnum.RETURN.value" class="row-money b-f m-top20 dis-flex">
|
<view v-if="formData.refundType == 2" class="row-money b-f m-top20 dis-flex">
|
||||||
<view class="row-title">退款金额</view>
|
<view class="row-title">退款金额</view>
|
||||||
<view class="money col-m">¥{{ goods.total_pay_price }}</view>
|
<view class="money col-m">¥{{ reFundPrice }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 上传凭证 -->
|
<!-- 上传凭证 -->
|
||||||
@ -75,68 +75,59 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { RefundTypeEnum } from '@/common/enum/order/refund'
|
|
||||||
import * as UploadApi from '@/api/upload'
|
import * as UploadApi from '@/api/upload'
|
||||||
import * as RefundApi from '@/api/refund'
|
import * as RefundApi from '@/api/refund'
|
||||||
|
import * as OrderApi from '@/api/order'
|
||||||
|
|
||||||
const maxImageLength = 6
|
const maxImageLength = 6
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 枚举类
|
RefundTypeEnum: [
|
||||||
RefundTypeEnum,
|
{ name: '仅退款', value: 1, show: true },
|
||||||
// 正在加载
|
{ name: '退货退款', value: 2, show: false }
|
||||||
|
],
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
// 订单商品id
|
|
||||||
orderGoodsId: null,
|
orderGoodsId: null,
|
||||||
// 订单商品详情
|
|
||||||
goods: {},
|
goods: {},
|
||||||
// 表单数据
|
|
||||||
formData: {
|
formData: {
|
||||||
// 图片上传成功的文件ID集
|
resourceDTOList: [],
|
||||||
images: [],
|
refundType: 1,
|
||||||
// 服务类型
|
refundReason: ''
|
||||||
type: 10,
|
|
||||||
// 申请原因
|
|
||||||
content: ''
|
|
||||||
},
|
},
|
||||||
// 用户选择的图片列表
|
// 用户选择的图片列表
|
||||||
imageList: [],
|
imageList: [],
|
||||||
// 最大图片数量
|
// 最大图片数量
|
||||||
maxImageLength,
|
maxImageLength,
|
||||||
// 按钮禁用
|
// 按钮禁用
|
||||||
disabled: false
|
disabled: false,
|
||||||
|
reFundPrice: 0,
|
||||||
|
trackNumber: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
onLoad({ orderGoodsId }) {
|
onLoad({ orderGoodsId, trackNumber }) {
|
||||||
this.orderGoodsId = orderGoodsId
|
this.orderGoodsId = orderGoodsId
|
||||||
|
if (trackNumber) {
|
||||||
|
this.RefundTypeEnum[1].show = true
|
||||||
|
this.trackNumber = trackNumber
|
||||||
|
}
|
||||||
// 获取订单商品详情
|
// 获取订单商品详情
|
||||||
this.getGoodsDetail()
|
OrderApi.apiGetOrderDetail({ tradeOrderLineIdList: [orderGoodsId] }).then(res => {
|
||||||
|
if (res.data.length) {
|
||||||
|
this.reFundPrice = res.data[0].payAmount
|
||||||
|
this.isLoading = false
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
// 获取订单商品详情
|
|
||||||
getGoodsDetail() {
|
|
||||||
const app = this
|
|
||||||
app.isLoading = true
|
|
||||||
RefundApi.goods(app.orderGoodsId)
|
|
||||||
.then(result => {
|
|
||||||
app.goods = result.data.goods
|
|
||||||
app.isLoading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
// 切换类型
|
// 切换类型
|
||||||
onSwitchService(value) {
|
onSwitchService(value) {
|
||||||
this.formData.type = value
|
this.formData.refundType = value
|
||||||
},
|
},
|
||||||
|
|
||||||
// 选择图片
|
// 选择图片
|
||||||
chooseImage() {
|
chooseImage() {
|
||||||
const app = this
|
const app = this
|
||||||
@ -148,6 +139,7 @@
|
|||||||
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
||||||
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
||||||
success({ tempFiles }) {
|
success({ tempFiles }) {
|
||||||
|
console.warn('----- my data is 2222: ', tempFiles)
|
||||||
// tempFiles = [{path:'xxx', size:100}]
|
// tempFiles = [{path:'xxx', size:100}]
|
||||||
app.imageList = oldImageList.concat(tempFiles)
|
app.imageList = oldImageList.concat(tempFiles)
|
||||||
},
|
},
|
||||||
@ -172,12 +164,10 @@
|
|||||||
})
|
})
|
||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
|
|
||||||
// 删除图片
|
// 删除图片
|
||||||
deleteImage(imageIndex) {
|
deleteImage(imageIndex) {
|
||||||
this.imageList.splice(imageIndex, 1)
|
this.imageList.splice(imageIndex, 1)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 表单提交
|
// 表单提交
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
const app = this
|
const app = this
|
||||||
@ -185,7 +175,7 @@
|
|||||||
// 判断是否重复提交
|
// 判断是否重复提交
|
||||||
if (app.disabled === true) return false
|
if (app.disabled === true) return false
|
||||||
// 表单验证
|
// 表单验证
|
||||||
if (!app.formData.content.trim().length) {
|
if (!app.formData.refundReason.trim().length) {
|
||||||
app.$toast('请填写申请原因')
|
app.$toast('请填写申请原因')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -193,53 +183,37 @@
|
|||||||
app.disabled = true
|
app.disabled = true
|
||||||
// 判断是否需要上传图片
|
// 判断是否需要上传图片
|
||||||
if (imageList.length > 0) {
|
if (imageList.length > 0) {
|
||||||
app.uploadFile()
|
OrderApi.apiUploadFile(imageList)
|
||||||
.then(() => app.onSubmit())
|
.then(results => {
|
||||||
.catch(err => {
|
app.formData.resourceDTOList = results.map(result => {
|
||||||
app.disabled = false
|
return result.data[0].url;
|
||||||
if (err.statusCode !== 0) {
|
});
|
||||||
app.$toast(err.errMsg)
|
app.onSubmit();
|
||||||
}
|
|
||||||
console.log('err', err)
|
|
||||||
})
|
})
|
||||||
|
.catch(err => {
|
||||||
|
app.disabled = false;
|
||||||
|
const errMsg = err.msg || err.errMsg || '上传失败';
|
||||||
|
app.$toast(errMsg);
|
||||||
|
console.log('上传失败', err);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
app.onSubmit()
|
app.onSubmit();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 提交到后端
|
// 提交到后端
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
const app = this
|
const app = this
|
||||||
RefundApi.apply(app.orderGoodsId, app.formData)
|
const params = {...app.formData, trackNumber: app.trackNumber, tradeOrderId: app.trackNumber ? undefined : app.orderGoodsId }
|
||||||
|
OrderApi.apiApplyRefund(params)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
app.$toast(result.message)
|
app.$toast(result.msg)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
app.disabled = false
|
app.disabled = false
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
}, 1500)
|
}, 1500)
|
||||||
})
|
})
|
||||||
.catch(err => app.disabled = false)
|
.catch(err => app.disabled = false)
|
||||||
},
|
|
||||||
|
|
||||||
// 上传图片
|
|
||||||
uploadFile() {
|
|
||||||
const app = this
|
|
||||||
const { imageList } = app
|
|
||||||
// 批量上传
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (imageList.length > 0) {
|
|
||||||
UploadApi.image(imageList)
|
|
||||||
.then(fileIds => {
|
|
||||||
app.formData.images = fileIds
|
|
||||||
resolve(fileIds)
|
|
||||||
})
|
|
||||||
.catch(reject)
|
|
||||||
} else {
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user