修改部分bug

master
lemon橪 2022-03-10 17:15:59 +08:00
parent 2ce90ba008
commit ea60742d82
3 changed files with 338 additions and 240 deletions

View File

@ -1,31 +1,53 @@
<template>
<view class="content">
<view class="u-tabs-box">
<u-tabs bg-color="#fff" :list="list" :is-scroll="false" :current="current" @change="change"
:active-color="$lightColor"></u-tabs>
<u-tabs
bg-color="#fff"
:list="list"
:is-scroll="false"
:current="current"
@change="change"
:active-color="$lightColor"
></u-tabs>
</view>
<div class="u-tabs-search">
<u-search placeholder="请输入订单编号" @search="handleGetOrderList(current)" @clear="handleGetOrderList(current)"
@custom="handleGetOrderList(current)" v-model="params.orderSn"></u-search>
<u-search
placeholder="请输入订单编号"
@search="submitSearchOrderList(current)"
@clear="submitSearchOrderList(current)"
@custom="submitSearchOrderList(current)"
v-model="orderSn"
></u-search>
</div>
<scroll-view class="body-view" scroll-y @scrolltolower="renderDate">
<view class="seller-view" v-for="(order, orderIndex) in orderList" :key="orderIndex">
<view
class="seller-view"
v-for="(order, orderIndex) in orderList"
:key="orderIndex"
>
<!-- 店铺名称 -->
<view class="seller-info u-flex u-row-between" v-if="current == 0">
<view class="seller-name">
<view class="name">{{ order.storeName }}</view>
</view>
<view class="order-sn">订单编号:{{order.sn}}</view>
<view class="order-sn">订单编号:{{ order.sn }}</view>
</view>
<!-- 申请记录 选项卡 -->
<view class="seller-info u-flex u-row-between" v-if="current != 0">
<view class="order-sn">售后单号{{ order.service_sn || order.sn }}</view>
<view class="order-sn"
>售后单号{{ order.service_sn || order.sn }}</view
>
<view class="order-sn">{{ order.serviceType_text }}</view>
</view>
<view v-for="(sku, goodsIndex) in order.orderItems" :key="goodsIndex">
<view class="goods-item-view" @click="onDetail(order,sku)">
<view class="goods-item-view" @click="onDetail(order, sku)">
<view class="goods-img">
<u-image border-radius="6" width="100%" height="100%" :src="sku.image"></u-image>
<u-image
border-radius="6"
width="100%"
height="100%"
:src="sku.image"
></u-image>
</view>
<view class="goods-info">
<view class="goods-title u-line-2">{{ sku.name }}</view>
@ -41,77 +63,136 @@
<view class="btn-view u-flex u-row-between">
<view class="description">
<!-- 售后申请 -->
<view v-if="
current === 0 && order.groupAfterSaleStatus &&
order.groupAfterSaleStatus.includes('ALREADY_APPLIED')
" class="cannot_apply">
<view
v-if="
current === 0 &&
order.groupAfterSaleStatus &&
order.groupAfterSaleStatus.includes('ALREADY_APPLIED')
"
class="cannot_apply"
>
<u-icon class="icon" name="info-circle-fill"></u-icon>
该商品已申请售后服务
</view>
<view class="cannot_apply"
v-if="current === 0 && order.groupAfterSaleStatus && order.groupAfterSaleStatus.includes('EXPIRED') "
@click="tipsShow = true">
<view
class="cannot_apply"
v-if="
current === 0 &&
order.groupAfterSaleStatus &&
order.groupAfterSaleStatus.includes('EXPIRED')
"
@click="tipsShow = true"
>
<u-icon class="icon" name="info-circle-fill"></u-icon>
该商品无法申请售后
</view>
<div v-if="current === 1 || current === 2">
<!-- 申请中 -->
<view class="cannot_apply" v-if="order.serviceType == 'RETURN_GOODS'">
退货处理-{{ order.serviceStatus | serviceStatusList }}</view>
<view class="cannot_apply" v-if="order.serviceType == 'SUPPLY_AGAIN_GOODS'">
补发商品-{{ order.serviceStatus | serviceStatusList }}</view>
<view class="cannot_apply" v-if="order.serviceType == 'RETURN_MONEY'">
退款-{{ order.serviceStatus | serviceStatusList }}</view>
<view class="cannot_apply" v-if="order.serviceType == 'EXCHANGE_GOODS'">
换货-{{ order.serviceStatus | serviceStatusList }}</view>
<view
class="cannot_apply"
v-if="order.serviceType == 'RETURN_GOODS'"
>
退货处理-{{ order.serviceStatus | serviceStatusList }}</view
>
<view
class="cannot_apply"
v-if="order.serviceType == 'SUPPLY_AGAIN_GOODS'"
>
补发商品-{{ order.serviceStatus | serviceStatusList }}</view
>
<view
class="cannot_apply"
v-if="order.serviceType == 'RETURN_MONEY'"
>
退款-{{ order.serviceStatus | serviceStatusList }}</view
>
<view
class="cannot_apply"
v-if="order.serviceType == 'EXCHANGE_GOODS'"
>
换货-{{ order.serviceStatus | serviceStatusList }}</view
>
<view class="cannot_apply" v-if="order.serviceType == 'CANCEL'">
取消订单-{{ order.serviceStatus | serviceStatusList }}</view>
取消订单-{{ order.serviceStatus | serviceStatusList }}</view
>
</div>
<!-- 申请记录 -->
</view>
<!-- 售后申请 -->
<div v-if="current === 0 && sku.afterSaleStatus && (sku.afterSaleStatus.includes('NOT_APPLIED') || sku.afterSaleStatus.includes('PART_AFTER_SALE')) " @click="applyService(sku.sn, order, sku)" class="sale">
<view class=" default-btn border" >
申请售后
</view>
</div>
<!-- 售后申请 -->
<div
v-if="
current === 0 &&
sku.afterSaleStatus &&
(sku.afterSaleStatus.includes('NOT_APPLIED') ||
sku.afterSaleStatus.includes('PART_AFTER_SALE'))
"
@click="applyService(sku.sn, order, sku)"
class="sale"
>
<view class="default-btn border"> 申请售后 </view>
</div>
<view class="after-line">
<!-- 申请中 -->
<view class="default-btn border" v-if="
<view
class="default-btn border"
v-if="
current === 2 &&
order.serviceStatus &&
order.serviceStatus == 'PASS' &&
order.serviceType != 'RETURN_MONEY'
" @click="onExpress(order, sku)">
"
@click="onExpress(order, sku)"
>
提交物流
</view>
<view @click="close(order,sku)" v-if="current === 1" class="default-btn close">
<view
@click="close(order, sku)"
v-if="current === 1"
class="default-btn close"
>
取消售后
</view>
<view @click="afterDetails(order, sku)" v-if="current === 1 || current === 2" class="default-btn border">
<view
@click="afterDetails(order, sku)"
v-if="current === 1 || current === 2"
class="default-btn border"
>
售后详情
</view>
</view>
</view>
</view>
<view v-if="
current === 0 && order.groupAfterSaleStatus &&
<view
v-if="
current === 0 &&
order.groupAfterSaleStatus &&
order.groupAfterSaleStatus != 'ALREADY_APPLIED' &&
order.orderItems.length >= 1
" class="btn-view u-flex u-row-between">
"
class="btn-view u-flex u-row-between"
>
<!-- 多个商品显示订单总价格 -->
<view class="cannot_apply">
订单总金额:<span class="countMoney">{{ order.flowPrice | unitPrice }}</span>
订单总金额:<span class="countMoney"
>{{ order.flowPrice | unitPrice }}</span
>
</view>
</view>
</view>
<u-loadmore bg-color="#f8f8f8" :status="status" />
</scroll-view>
<u-modal show-cancel-button @confirm="closeService" v-model="cancelShow" content="确认取消售后"></u-modal>
<u-modal v-model="tipsShow" content="当订单未确认收货|已过售后服务有效期|已申请售后服务时,不能申请售后"></u-modal>
<u-modal
show-cancel-button
@confirm="closeService"
v-model="cancelShow"
content="确认取消售后"
></u-modal>
<u-modal
v-model="tipsShow"
content="当订单未确认收货|已过售后服务有效期|已申请售后服务时,不能申请售后"
></u-modal>
</view>
</template>
@ -148,7 +229,7 @@ export default {
pageNumber: 1,
pageSize: 10,
sort: "createTime",
flowPrice: 1,
flowPrice: 1,
order: "desc",
},
@ -157,21 +238,27 @@ export default {
pageSize: 10,
},
status: "loadmore",
orderSn: "", // sn
};
},
onLoad(options) {
this.orderList = [];
this.params.pageNumber = 1;
if (options.orderSn) this.params.orderSn = options.orderSn;
this.getOrderList(this.current);
this.searchOrderList(this.current);
},
onPullDownRefresh() {
this.change(this.current);
},
methods: {
handleGetOrderList(current) {
/**
* 点击搜索执行搜索
*/
submitSearchOrderList(current) {
this.params.pageNumber = 1;
this.logParams.pageNumber = 1;
this.orderList = [];
this.getOrderList(current);
this.searchOrderList(current);
},
/**
* 切换tab页时初始化数据
@ -184,8 +271,18 @@ export default {
};
this.orderList = [];
//2
this.searchOrderList(index);
uni.stopPullDownRefresh();
},
/**
* 搜索初始化
* 根据当前tab传值的索引进行更改
*/
searchOrderList(index) {
if (index == 0) {
this.getOrderList(index);
this.orderSn ? (this.params.orderSn = this.orderSn) : "";
this.getOrderList();
} else {
this.logParams = {
pageNumber: 1,
@ -196,16 +293,16 @@ export default {
if (index === 1) {
this.logParams.serviceStatus = "APPLY";
}
this.orderSn ? (this.logParams.orderSn = this.orderSn) : "";
this.orderList = [];
this.getAfterSaleLogList();
}
uni.stopPullDownRefresh();
},
/**
* 获取订单列表
*/
getOrderList(index) {
getOrderList() {
uni.showLoading({
title: "加载中",
mask: true,
@ -245,7 +342,7 @@ export default {
});
}
this.orderList = [];
this.getOrderList(this.current);
this.searchOrderList(this.current);
uni.hideLoading();
},

View File

@ -1,187 +1,188 @@
import Request from "@/lib/request/index.js";
import { refreshTokenFn } from "@/api/login.js";
import storage from "@/utils/storage.js";
import { md5 } from "@/utils/md5.js";
import Foundation from "@/utils/Foundation.js";
import api from "@/config/api.js";
import uuid from "@/utils/uuid.modified.js";
function cleanStorage() {
uni.showToast({
title: "你的登录状态已过期,请重新登录",
icon: "none",
duration: 1500,
});
if (uni.showLoading()) {
uni.hideLoading();
}
storage.setHasLogin(false);
storage.setAccessToken("");
storage.setRefreshToken("");
console.log("清空token");
storage.setUuid("");
storage.setUserInfo({});
// 防抖处理跳转
// #ifdef MP-WEIXIN
uni.navigateTo({
url: "/pages/passport/wechatMPLogin",
});
// #endif
// #ifndef MP-WEIXIN
uni.navigateTo({
url: "/pages/passport/login",
});
// #endif
}
let http = new Request();
http.setConfig((config) => {
// 没有uuid创建
if (!storage.getUuid()) {
storage.setUuid(uuid.v1());
}
/* 设置全局配置 */
config.baseURL = api.buyer;
config.header = {
...config.header,
};
config.validateStatus = (statusCode) => {
// 不论什么状态,统一在正确中处理
return true;
};
return config;
});
http.interceptors.request.use(
(config) => {
/* 请求之前拦截器。可以使用async await 做异步操作 */
let accessToken = storage.getAccessToken();
if (accessToken) {
const nonce = Foundation.randomString(6);
const timestamp = parseInt(new Date().getTime() / 1000);
const sign = md5(nonce + timestamp + accessToken);
const _params = {
nonce,
timestamp,
sign,
};
let params = config.params || {};
params = { ...params, ..._params };
config.params = params;
config.header.accessToken = accessToken;
}
config.header = {
...config.header,
uuid: storage.getUuid() || uuid.v1(),
};
return config;
},
(config) => {
return Promise.reject(config);
}
);
// 是否正在刷新的标记
let isRefreshing = false;
//重试队列
let requests = [];
// 必须使用异步函数,注意
http.interceptors.response.use(
async (response) => {
/* 请求之后拦截器。可以使用async await 做异步操作 */
// token存在并且token过期
if (isRefreshing && response.statusCode === 403) {
cleanStorage();
isRefreshing = false;
}
let token = storage.getAccessToken();
if (
(token && response.statusCode === 403) ||
response.data.status === 403
) {
if (!isRefreshing) {
isRefreshing = true;
//调用刷新token的接口
return refreshTokenFn(storage.getRefreshToken())
.then((res) => {
let { accessToken, refreshToken } = res.data.result;
storage.setAccessToken(accessToken);
storage.setRefreshToken(refreshToken);
response.header.accessToken = `${accessToken}`;
// token 刷新后将数组的方法重新执行
requests.forEach((cb) => cb(accessToken));
requests = []; // 重新请求完清空
return http.request(response.config);
})
.catch((err) => {
cleanStorage();
return Promise.reject(err);
})
.finally(() => {
isRefreshing = false;
});
} else {
// 返回未执行 resolve 的 Promise
return new Promise((resolve) => {
// 用函数形式将 resolve 存入,等待刷新后再执行
requests.push((token) => {
response.header.accessToken = `${token}`;
resolve(http.request(response.config));
});
});
}
// 如果当前返回没登录
} else if (
(!token && response.statusCode === 403) ||
response.data.code === 403
) {
cleanStorage();
// 如果当前状态码为正常但是success为不正常时
} else if (
(response.statusCode == 200 && !response.data.success) ||
response.statusCode == 400
) {
if (response.data.message) {
uni.showToast({
title: response.data.message,
icon: "none",
duration: 1500,
});
}
}
return response;
},
(error) => {
return error;
}
);
export { http };
export const Method = {
GET: "GET",
POST: "POST",
PUT: "PUT",
DELETE: "DELETE",
};
import Request from "@/lib/request/index.js";
import { refreshTokenFn } from "@/api/login.js";
import storage from "@/utils/storage.js";
import { md5 } from "@/utils/md5.js";
import Foundation from "@/utils/Foundation.js";
import api from "@/config/api.js";
import uuid from "@/utils/uuid.modified.js";
let isNavigateTo = false
function cleanStorage() {
uni.showToast({
title: "你的登录状态已过期,请重新登录",
icon: "none",
duration: 1500,
});
if (uni.showLoading()) {
uni.hideLoading();
}
storage.setHasLogin(false);
storage.setAccessToken("");
storage.setRefreshToken("");
console.log("清空token");
storage.setUuid("");
storage.setUserInfo({});
if(!isNavigateTo){
isNavigateTo= true
// 防抖处理跳转
// #ifdef MP-WEIXIN
uni.navigateTo({
url: "/pages/passport/wechatMPLogin",
});
// #endif
// #ifndef MP-WEIXIN
uni.navigateTo({
url: "/pages/passport/login",
});
// #endif
}
}
let http = new Request();
http.setConfig((config) => {
// 没有uuid创建
if (!storage.getUuid()) {
storage.setUuid(uuid.v1());
}
/* 设置全局配置 */
config.baseURL = api.buyer;
config.header = {
...config.header,
};
config.validateStatus = (statusCode) => {
// 不论什么状态,统一在正确中处理
return true;
};
return config;
});
http.interceptors.request.use(
(config) => {
/* 请求之前拦截器。可以使用async await 做异步操作 */
let accessToken = storage.getAccessToken();
if (accessToken) {
const nonce = Foundation.randomString(6);
const timestamp = parseInt(new Date().getTime() / 1000);
const sign = md5(nonce + timestamp + accessToken);
const _params = {
nonce,
timestamp,
sign,
};
let params = config.params || {};
params = { ...params, ..._params };
config.params = params;
config.header.accessToken = accessToken;
}
config.header = {
...config.header,
uuid: storage.getUuid() || uuid.v1(),
};
return config;
},
(config) => {
return Promise.reject(config);
}
);
// 是否正在刷新的标记
let isRefreshing = false;
//重试队列
let requests = [];
// 必须使用异步函数,注意
http.interceptors.response.use(
async (response) => {
isNavigateTo = false
/* 请求之后拦截器。可以使用async await 做异步操作 */
// token存在并且token过期
if (isRefreshing && response.statusCode === 403) {
cleanStorage();
isRefreshing = false;
}
let token = storage.getAccessToken();
if (
(token && response.statusCode === 403) ||
response.data.status === 403
) {
if (!isRefreshing) {
isRefreshing = true;
//调用刷新token的接口
return refreshTokenFn(storage.getRefreshToken())
.then((res) => {
let { accessToken, refreshToken } = res.data.result;
storage.setAccessToken(accessToken);
storage.setRefreshToken(refreshToken);
response.header.accessToken = `${accessToken}`;
// token 刷新后将数组的方法重新执行
requests.forEach((cb) => cb(accessToken));
requests = []; // 重新请求完清空
return http.request(response.config);
})
.catch((err) => {
cleanStorage();
return Promise.reject(err);
})
.finally(() => {
isRefreshing = false;
});
} else {
// 返回未执行 resolve 的 Promise
return new Promise((resolve) => {
// 用函数形式将 resolve 存入,等待刷新后再执行
requests.push((token) => {
response.header.accessToken = `${token}`;
resolve(http.request(response.config));
});
});
}
// 如果当前返回没登录
} else if (
(!token && response.statusCode === 403) ||
response.data.code === 403
) {
cleanStorage();
// 如果当前状态码为正常但是success为不正常时
} else if (
(response.statusCode == 200 && !response.data.success) ||
response.statusCode == 400
) {
if (response.data.message) {
uni.showToast({
title: response.data.message,
icon: "none",
duration: 1500,
});
}
}
return response;
},
(error) => {
return error;
}
);
export { http };
export const Method = {
GET: "GET",
POST: "POST",
PUT: "PUT",
DELETE: "DELETE",
};

View File

@ -92,11 +92,11 @@ export default {
removeRefreshToken() {
uni.removeStorageSync(REFRESH_TOKEN);
},
// 写入刷新token
setAfterSaleData(val) {
uni.setStorageSync(AFTERSALE_DATA, val);
},
// 获取刷新token
getAfterSaleData() {
return uni.getStorageSync(AFTERSALE_DATA);
},