lilishop-uniapp/pages/order/afterSales/afterSales.vue

607 lines
15 KiB
Vue
Raw Normal View History

2021-05-13 11:03:32 +08:00
<template>
<view class="content">
<view class="u-tabs-box">
2022-03-10 17:15:59 +08:00
<u-tabs
bg-color="#fff"
:list="list"
:is-scroll="false"
:current="current"
@change="change"
:active-color="$lightColor"
></u-tabs>
2021-05-13 11:03:32 +08:00
</view>
<div class="u-tabs-search">
2022-03-10 17:15:59 +08:00
<u-search
2023-10-16 18:33:52 +08:00
placeholder="请输入订单编号/商品名称/售后单号"
2022-03-10 17:15:59 +08:00
@search="submitSearchOrderList(current)"
2023-10-16 18:33:52 +08:00
@clear="clear(current)"
2022-03-10 17:15:59 +08:00
@custom="submitSearchOrderList(current)"
2023-10-16 18:33:52 +08:00
v-model="keywords"
>
</u-search>
</div>
2021-05-13 11:03:32 +08:00
<scroll-view class="body-view" scroll-y @scrolltolower="renderDate">
2022-03-10 17:15:59 +08:00
<view
class="seller-view"
v-for="(order, orderIndex) in orderList"
:key="orderIndex"
>
2021-05-13 11:03:32 +08:00
<!-- 店铺名称 -->
<view class="seller-info u-flex u-row-between" v-if="current == 0">
<view class="seller-name">
<view class="name">{{ order.storeName }}</view>
</view>
2022-03-10 17:15:59 +08:00
<view class="order-sn">订单编号:{{ order.sn }}</view>
2021-05-13 11:03:32 +08:00
</view>
<!-- 申请记录 选项卡 -->
<view class="seller-info u-flex u-row-between" v-if="current != 0">
2022-03-10 17:15:59 +08:00
<view class="order-sn"
>售后单号{{ order.service_sn || order.sn }}</view
>
2021-05-13 11:03:32 +08:00
<view class="order-sn">{{ order.serviceType_text }}</view>
</view>
<view v-for="(sku, goodsIndex) in order.orderItems" :key="goodsIndex">
2022-03-10 17:15:59 +08:00
<view class="goods-item-view" @click="onDetail(order, sku)">
2021-05-13 11:03:32 +08:00
<view class="goods-img">
2022-03-10 17:15:59 +08:00
<u-image
border-radius="6"
width="100%"
height="100%"
:src="sku.image"
></u-image>
2021-05-13 11:03:32 +08:00
</view>
<view class="goods-info">
<view class="goods-title u-line-2">{{ sku.name }}</view>
<!-- 如果商品多个则不显示每个商品价格-->
<view class="goods-price" v-if="order.orderItems.length <= 1">
{{ order.flowPrice | unitPrice }}
</view>
</view>
<view class="goods-num">
<view>x{{ sku.num }}</view>
</view>
</view>
<view class="description">
<!-- 售后申请 -->
<view v-if="current === 0 && sku.afterSaleStatus">
2022-03-10 17:15:59 +08:00
<view
v-if="sku.afterSaleStatus.includes('ALREADY_APPLIED')"
class="cannot_apply not_center"
2022-03-10 17:15:59 +08:00
>
2021-05-13 11:03:32 +08:00
<u-icon class="icon" name="info-circle-fill"></u-icon>
该商品已申请售后服务
</view>
</view>
<view v-if="current === 0 && sku.afterSaleStatus">
2022-03-10 17:15:59 +08:00
<view
v-if="sku.afterSaleStatus.includes('EXPIRED')"
class="cannot_apply not_center"
2022-03-10 17:15:59 +08:00
@click="tipsShow = true"
>
2021-05-13 11:03:32 +08:00
<u-icon class="icon" name="info-circle-fill"></u-icon>
该商品无法申请售后
</view>
</view>
2021-05-13 11:03:32 +08:00
<div v-if="current === 1 || current === 2">
<!-- 申请中 -->
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'RETURN_GOODS'"
>
退货处理-{{ order.serviceStatus | serviceStatusList }}</view
>
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'SUPPLY_AGAIN_GOODS'"
>
补发商品-{{ order.serviceStatus | serviceStatusList }}</view
>
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'RETURN_MONEY'"
>
退款-{{ order.serviceStatus | serviceStatusList }}</view
>
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'EXCHANGE_GOODS'"
>
换货-{{ order.serviceStatus | serviceStatusList }}</view
>
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'CANCEL'"
>
取消订单-{{ order.serviceStatus | serviceStatusList }}</view
>
</div>
2022-03-10 17:15:59 +08:00
<!-- 申请记录 -->
</view>
<view class="btn-view u-flex u-row-right">
<!-- 售后申请 -->
<div class="sale" v-if="current === 0 && sku.afterSaleStatus">
<div
v-if="
2022-08-25 12:46:52 +08:00
order.flowPrice != 0 &&
sku.afterSaleStatus.includes('NOT_APPLIED') ||
sku.afterSaleStatus.includes('PART_AFTER_SALE')
"
@click="applyService(sku.sn, order, sku)"
>
<view class="default-btn border"> 申请售后 </view>
</div>
2022-03-10 17:15:59 +08:00
</div>
2021-05-13 11:03:32 +08:00
<view class="after-line">
<!-- 申请中 -->
2022-03-10 17:15:59 +08:00
<view
class="default-btn border"
v-if="
2021-05-13 11:03:32 +08:00
current === 2 &&
order.serviceStatus &&
order.serviceStatus == 'PASS' &&
order.serviceType != 'RETURN_MONEY'
2022-03-10 17:15:59 +08:00
"
@click="onExpress(order, sku)"
>
2021-05-13 11:03:32 +08:00
提交物流
</view>
2022-03-10 17:15:59 +08:00
<view
@click="close(order, sku)"
v-if="current === 1"
class="default-btn close"
>
取消售后
</view>
2022-03-10 17:15:59 +08:00
<view
@click="afterDetails(order, sku)"
v-if="current === 1 || current === 2"
class="default-btn border"
>
2021-05-13 11:03:32 +08:00
售后详情
</view>
</view>
</view>
</view>
2022-03-10 17:15:59 +08:00
<view
v-if="
current === 0 &&
order.groupAfterSaleStatus &&
2021-05-13 11:03:32 +08:00
order.groupAfterSaleStatus != 'ALREADY_APPLIED' &&
order.orderItems.length >= 1
2022-03-10 17:15:59 +08:00
"
class="btn-view u-flex u-row-between"
>
2021-05-13 11:03:32 +08:00
<!-- 多个商品显示订单总价格 -->
<view class="cannot_apply">
2022-03-10 17:15:59 +08:00
订单总金额:<span class="countMoney"
>{{ order.flowPrice | unitPrice }}</span
>
2021-05-13 11:03:32 +08:00
</view>
</view>
</view>
<u-loadmore bg-color="#f8f8f8" :status="status" />
</scroll-view>
2022-03-10 17:15:59 +08:00
<u-modal
show-cancel-button
@confirm="closeService"
v-model="cancelShow"
content="确认取消售后"
></u-modal>
<u-modal
v-model="tipsShow"
content="当订单未确认收货|已过售后服务有效期|已申请售后服务时,不能申请售后"
></u-modal>
2021-05-13 11:03:32 +08:00
</view>
</template>
<script>
import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
import { getAfterSaleList, cancelAfterSale } from "@/api/after-sale.js";
2021-05-13 11:03:32 +08:00
import { getOrderList } from "@/api/order.js";
2022-02-10 18:57:17 +08:00
import storage from "@/utils/storage";
2021-05-13 11:03:32 +08:00
export default {
components: {
uniLoadMore,
},
data() {
return {
list: [
2021-05-17 18:19:26 +08:00
//tab表头
2021-05-13 11:03:32 +08:00
{
name: "售后申请",
},
{
name: "申请中",
},
{
name: "申请记录",
},
],
2021-05-17 18:19:26 +08:00
current: 0, //当前表头索引
tipsShow: false, //提示开关
cancelShow: false, //取消显示开关
selectedOrder: "", //选中的order
2021-05-17 18:19:26 +08:00
orderList: [], //订单集合
2021-05-13 11:03:32 +08:00
params: {
pageNumber: 1,
pageSize: 10,
sort: "createTime",
flowPrice: 0,
order: "desc",
2021-05-13 11:03:32 +08:00
},
2021-05-17 18:19:26 +08:00
2021-05-13 11:03:32 +08:00
logParams: {
pageNumber: 1,
pageSize: 10,
},
status: "loadmore",
2023-10-16 18:33:52 +08:00
keywords: "", // 搜索订单sn
2021-05-13 11:03:32 +08:00
};
},
onLoad(options) {
2021-05-13 11:03:32 +08:00
this.orderList = [];
this.params.pageNumber = 1;
2023-10-16 18:33:52 +08:00
if (options.orderSn) this.params.keywords = options.orderSn;
2022-03-10 17:15:59 +08:00
this.searchOrderList(this.current);
2021-05-13 11:03:32 +08:00
},
onPullDownRefresh() {
this.change(this.current);
},
methods: {
2022-03-10 17:15:59 +08:00
/**
* 点击搜索执行搜索
*/
submitSearchOrderList(current) {
this.params.pageNumber = 1;
this.logParams.pageNumber = 1;
this.orderList = [];
2022-03-10 17:15:59 +08:00
this.searchOrderList(current);
},
2023-10-16 18:33:52 +08:00
// 清空
clear(current){
this.params.pageNumber = 1;
this.logParams.pageNumber = 1;
this.params.keywords = ''
this.orderList = [];
this.searchOrderList(current);
},
2021-05-17 18:19:26 +08:00
/**
* 切换tab页时初始化数据
*/
2021-05-13 11:03:32 +08:00
change(index) {
this.current = index;
this.params = {
pageNumber: 1,
pageSize: 10,
};
this.orderList = [];
//如果是2 则读取售后申请记录列表
2022-03-10 17:15:59 +08:00
this.searchOrderList(index);
uni.stopPullDownRefresh();
},
/**
* 搜索初始化
* 根据当前tab传值的索引进行更改
*/
searchOrderList(index) {
2021-05-13 11:03:32 +08:00
if (index == 0) {
2023-10-16 18:33:52 +08:00
this.keywords ? (this.params.keywords = this.keywords) : "";
2022-03-10 17:15:59 +08:00
this.getOrderList();
2021-05-13 11:03:32 +08:00
} else {
this.logParams = {
pageNumber: 1,
pageSize: 10,
sort: "createTime",
order: "desc",
2021-05-13 11:03:32 +08:00
};
if (index === 1) {
this.logParams.serviceStatus = "APPLY";
}
2023-10-16 18:33:52 +08:00
this.keywords ? (this.logParams.keywords = this.keywords) : "";
2021-05-13 11:03:32 +08:00
this.orderList = [];
this.getAfterSaleLogList();
}
},
2021-05-17 18:19:26 +08:00
/**
* 获取订单列表
*/
2022-03-10 17:15:59 +08:00
getOrderList() {
2021-05-13 11:03:32 +08:00
uni.showLoading({
title: "加载中",
mask: true,
});
getOrderList(this.params).then((res) => {
if (this.$store.state.isShowToast){ uni.hideLoading() };
const orderList = res.data.result.records;
if (orderList.length > 0) {
this.orderList = this.orderList.concat(orderList);
2021-05-13 11:03:32 +08:00
this.params.pageNumber += 1;
}
if (orderList.length < 10) {
2021-05-13 11:03:32 +08:00
this.status = "nomore";
} else {
this.status = "loading";
}
});
},
close(order, sku) {
console.log(order, sku);
this.selectedOrder = order;
this.cancelShow = true;
},
async closeService() {
uni.showLoading({
title: "加载中",
});
console.log(this.selectedOrder);
let res = await cancelAfterSale(this.selectedOrder.sn);
if (res.data.success) {
uni.showToast({
title: "取消成功!",
duration: 2000,
icon: "none",
});
}
this.orderList = [];
2022-03-10 17:15:59 +08:00
this.searchOrderList(this.current);
if (this.$store.state.isShowToast){ uni.hideLoading() };
},
2021-05-17 18:19:26 +08:00
/**
* 售后详情
*/
2021-05-13 11:03:32 +08:00
afterDetails(order) {
uni.navigateTo({
url: "./applyDetail?sn=" + order.sn,
});
},
2021-05-17 18:19:26 +08:00
/**
* 申请记录列表
*/
2021-05-13 11:03:32 +08:00
getAfterSaleLogList() {
getAfterSaleList(this.logParams).then((res) => {
let afterSaleLogList = res.data.result.records;
afterSaleLogList.forEach((item) => {
item.orderItems = [
{
image: item.goodsImage,
skuId: item.skuId,
name: item.goodsName,
num: item.num,
price: item.flowPrice,
},
];
});
this.orderList = this.orderList.concat(afterSaleLogList);
if (afterSaleLogList.length < 10) {
this.status = "nomore";
} else {
this.status = "loading";
}
});
},
2021-05-17 18:19:26 +08:00
/**
* 申请售后
*/
2021-05-13 11:03:32 +08:00
applyService(sn, order, sku) {
let data = {
...order,
...sku,
};
2022-02-10 18:57:17 +08:00
storage.setAfterSaleData(data);
2021-05-13 11:03:32 +08:00
uni.navigateTo({
2022-02-10 18:57:17 +08:00
url: `/pages/order/afterSales/afterSalesSelect?sn=${sn}`,
2021-05-13 11:03:32 +08:00
});
},
2021-05-17 18:19:26 +08:00
/**
* 提交物流信息
*/
2021-05-13 11:03:32 +08:00
onExpress(order, sku) {
sku.storeName = order.storeName;
let data = {
...order,
...sku,
};
2021-05-13 11:03:32 +08:00
2022-02-10 18:57:17 +08:00
storage.setAfterSaleData(data);
2021-05-13 11:03:32 +08:00
uni.navigateTo({
2022-02-10 18:57:17 +08:00
url: `./afterSalesDetailExpress?serviceSn=${order.sn}`,
2021-05-13 11:03:32 +08:00
});
},
2021-05-17 18:19:26 +08:00
/**
* 查看详情
*/
2021-11-03 11:54:38 +08:00
onDetail(goods, sku) {
2021-10-12 16:31:03 +08:00
// 售后申请
2021-11-03 11:54:38 +08:00
if (this.current == 0) {
2021-05-13 11:03:32 +08:00
uni.navigateTo({
2021-11-03 11:54:38 +08:00
url: `/pages/product/goods?id=${sku.skuId}&goodsId=${
sku.goodsId || sku.goodsId
}`,
2021-05-13 11:03:32 +08:00
});
2021-11-03 11:54:38 +08:00
} else {
2021-10-12 16:31:03 +08:00
uni.navigateTo({
2021-11-03 11:54:38 +08:00
url: `/pages/product/goods?id=${goods.skuId}&goodsId=${
goods.goodsId || goods.goodsId
}`,
2021-10-12 16:31:03 +08:00
});
}
2021-05-13 11:03:32 +08:00
},
2021-05-17 18:19:26 +08:00
/**
* 底部加载数据
*/
2021-05-13 11:03:32 +08:00
renderDate() {
if (this.current === 0) {
this.params.pageNumber += 1;
this.getOrderList();
} else {
this.logParams.pageNumber += 1;
this.getAfterSaleLogList();
}
},
},
};
</script>
<style lang="scss">
page,
.content {
background: $page-color-base;
height: 100%;
}
2021-05-13 11:03:32 +08:00
.body-view {
overflow-y: auto;
height: calc(100vh - 44px - 80rpx - 104rpx);
}
.u-tabs-search {
padding: 20rpx;
background: #fff;
2021-05-13 11:03:32 +08:00
}
2021-05-13 11:03:32 +08:00
.countMoney {
margin-left: 7rpx;
color: $main-color;
font-size: 28rpx;
}
2021-05-13 11:03:32 +08:00
.seller-view {
background-color: #fff;
margin: 20rpx 0rpx;
padding: 0rpx 20rpx;
border-radius: 20rpx;
2021-05-13 11:03:32 +08:00
.seller-info {
height: 70rpx;
2021-05-13 11:03:32 +08:00
.seller-name {
font-size: 28rpx;
display: flex;
flex-direction: row;
2021-05-13 11:03:32 +08:00
.name {
margin-left: 15rpx;
margin-top: -2rpx;
}
}
2021-05-13 11:03:32 +08:00
.order-sn {
font-size: 22rpx;
color: #909399;
}
}
.goods-item-view {
display: flex;
flex-direction: row;
padding: 10rpx 10rpx;
.goods-img {
width: 131rpx;
height: 131rpx;
}
.goods-info {
padding-left: 30rpx;
flex: 1;
.goods-title {
margin-bottom: 10rpx;
color: #333333;
}
.goods-specs {
font-size: 24rpx;
margin-bottom: 10rpx;
color: #cccccc;
}
.goods-price {
font-size: 28rpx;
margin-bottom: 10rpx;
color: #ff5a10;
}
}
.goods-num {
width: 60rpx;
color: $main-color;
}
}
2021-05-13 11:03:32 +08:00
.btn-view {
padding: 16rpx 0;
.after-line {
display: flex;
line-height: 90rpx;
}
}
}
2021-05-13 11:03:32 +08:00
.description {
color: #909399;
size: 25rpx;
}
2021-05-13 11:03:32 +08:00
.cannot_apply {
text-align: center;
font-size: 22rpx;
color: #999999;
height: 70rpx;
line-height: 70rpx;
}
.not_center {
text-align: left;
}
2021-05-13 11:03:32 +08:00
.icon {
margin-right: 10rpx;
}
.sale {
width: 100%;
display: flex;
justify-content: flex-end;
2021-05-13 11:03:32 +08:00
}
.default-btn {
2021-05-13 11:03:32 +08:00
background-color: #ffffff;
margin-left: 15rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 24rpx;
padding: 0 24rpx;
border-radius: 200px;
}
.close {
color: $light-color;
}
.border {
border: 2rpx solid $light-color;
color: $light-color;
}
2021-05-13 11:03:32 +08:00
</style>