Commit b09f2bb6 authored by lihui's avatar lihui

feat: mearge lihui+chenglong

parents 23651259 d69677f3
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"dependencies": { "dependencies": {
"axios": "^0.21.1", "axios": "^0.21.1",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"dayjs": "^1.10.6",
"element-plus": "^1.0.2-beta.44", "element-plus": "^1.0.2-beta.44",
"form-data": "^4.0.0", "form-data": "^4.0.0",
"json-bigint": "^1.0.0", "json-bigint": "^1.0.0",
......
...@@ -32,3 +32,50 @@ exports.pindanGoods = async ctx => { ...@@ -32,3 +32,50 @@ exports.pindanGoods = async ctx => {
}; };
ctx.body = await req(ctx, opts); ctx.body = await req(ctx, opts);
}; };
// 获取活动过列表
exports.getActivityList = async ctx => {
const url = `${ACTIVITY_URI}/marketing/background/marketing_list`;
const opts = {
url,
method: "GET"
};
ctx.body = await req(ctx, opts);
};
// 修改商品
exports.editGoodsDetail = async ctx => {
const url = `${ACTIVITY_URI}/goods/background/edit_goods`;
const opts = {
url,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
// 关闭/开启 活动
exports.updateActivity = async ctx => {
const url = `${ACTIVITY_URI}/marketing/background/update_marketing`;
const opts = {
url,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
console.log(ctx.body);
};
// 查看活动订单
exports.checkActivityDetail = async ctx => {
const url = `${ACTIVITY_URI}/marketing/background/marketing_info`;
const opts = {
url,
method: "POST",
json: true,
body: ctx.request.body
};
ctx.body = await req(ctx, opts);
};
...@@ -62,6 +62,11 @@ router.post(`${API_VERSION}/merchant/lifeinner/life_info`, life.get_life_info) ...@@ -62,6 +62,11 @@ router.post(`${API_VERSION}/merchant/lifeinner/life_info`, life.get_life_info)
router.get(`${API_VERSION}/merchant/lifeinner/life_list`, life.get_life_list) router.get(`${API_VERSION}/merchant/lifeinner/life_list`, life.get_life_list)
//用户 //用户
router.post(`${API_VERSION}/merchant/authority/get_user_info`, user.getUser_detail) router.post(`${API_VERSION}/merchant/authority/get_user_info`, user.getUser_detail)
// 后台运营管理
router.get(`${API_VERSION}/marketing/background/marketing_list`, activity.getActivityList)
router.post(`${API_VERSION}/goods/background/edit_goods`, activity.editGoodsDetail)
router.post(`${API_VERSION}/marketing/background/update_marketing`, activity.updateActivity)
router.post(`${API_VERSION}/marketing/background/marketing_info`, activity.checkActivityDetail)
//活动管理 //活动管理
router.get(`${API_VERSION}/goods/background/ota_list`, activity.getBusinessList); router.get(`${API_VERSION}/goods/background/ota_list`, activity.getBusinessList);
......
<template> <template>
<div> <div class="app-wrapper">
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
<keep-alive v-if="$route.meta.keepAlive"> <keep-alive v-if="$route.meta.keepAlive">
<component :is="Component"> </component> <component :is="Component"> </component>
...@@ -10,24 +10,27 @@ ...@@ -10,24 +10,27 @@
</template> </template>
<script> <script>
import { fetchCurrentUser } from './service/user'; import { fetchCurrentUser } from "./service/user";
import { redirectToLogin } from './utils/util'; import { redirectToLogin } from "./utils/util";
export default { export default {
async mounted () { async mounted() {
console.log("master debug 2 !!!!!!") console.log("master debug 2 !!!!!!");
if (this.$store.state.permissions && this.$store.state.userInfo) return if (this.$store.state.permissions && this.$store.state.userInfo) return;
const { status, user } = await fetchCurrentUser(); const { status, user } = await fetchCurrentUser();
if (status === 'success') { if (status === "success") {
this.$store.commit('updateUserInfo', user); this.$store.commit("updateUserInfo", user);
this.$store.dispatch('updateUserPermission', { email: user.email }) this.$store.dispatch("updateUserPermission", { email: user.email });
} else { } else {
redirectToLogin(); redirectToLogin();
} }
}, }
}; };
</script> </script>
<style lang="less" src="./global.less"></style> <style lang="less" src="./global.less"></style>
<style lang="less" scoped>
.app-wrapper {
height: 100%;
}
</style>
<template> <template>
<div class="wrapper"> <div
class="wrapper"
v-loading="pageLoading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)"
>
<div class="activityDetail"> <div class="activityDetail">
<header class="header"> <div class="my-header">
<h3> <h3>
本周六四月三日 洞鞋子 周日就可以常抓这是给 请仔细阅读下面的文字 本周六四月三日 洞鞋子 周日就可以常抓这是给 请仔细阅读下面的文字
关注中澳提示 关注中澳提示
</h3> </h3>
<p class="endTime">距结束 22:77:88</p> <p class="endTime">距结束 22:77:88</p>
</header> </div>
<section class="content"> <section class="content">
<el-card class="activityGoods box-card"> <el-card class="activityGoods box-card">
<p class="title">拼单商品</p> <p class="title">拼单商品</p>
<div> <div>
<el-image class="activityImage" <el-image
class="activityImage"
style="width: 100px; height: 100px" style="width: 100px; height: 100px"
:src="url" :src="url"
:fit="fit" fit="fit"
></el-image> ></el-image>
<el-image class="activityImage" <el-image
class="activityImage"
style="width: 100px; height: 100px" style="width: 100px; height: 100px"
:src="url" :src="url"
:fit="fit" fit="fit"
></el-image> ></el-image>
</div> </div>
</el-card> </el-card>
...@@ -31,18 +39,24 @@ ...@@ -31,18 +39,24 @@
布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息
布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息 布拉布拉 布拉布拉这是一大片介绍信息 布拉布拉这是一大片介绍信息 布拉布拉
</p> </p>
<el-image class="activityImage" <el-image
class="activityImage"
style="width: 500px; height: 400px" style="width: 500px; height: 400px"
:src="url" :src="url"
:fit="fit" fit="fit"
></el-image> ></el-image>
</el-card> </el-card>
<el-card class="activities box-card"> <el-card class="activities box-card">
<div v-for="(item,index) in activityDetailList" :key="index" class="activityItem"> <div
<el-image class="activityImage" v-for="(item, index) in activityDetailList"
:key="index"
class="activityItem"
>
<el-image
class="activityImage"
style="width: 100px; height: 100px" style="width: 100px; height: 100px"
:src="url" :src="url"
:fit="fit" fit="fit"
></el-image> ></el-image>
<div class="itemIntroduce"> <div class="itemIntroduce">
<p>f发布写干洗 戏内除菌 消毒 数遍洗干净</p> <p>f发布写干洗 戏内除菌 消毒 数遍洗干净</p>
...@@ -63,21 +77,43 @@ ...@@ -63,21 +77,43 @@
</template> </template>
<script> <script>
import ActivityService from "@/service/Activity/index";
import { ElMessage } from "element-plus";
export default { export default {
components: {}, components: {},
props: {}, props: {},
data() { data() {
return { return {
fits: ["fill", "contain", "cover", "none", "scale-down"], // 图片属性 pageLoading: false,
url: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg", activityDetailInfo: {},
activityDetailList:[1,2,3] url:
"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
activityDetailList: [1, 2, 3]
}; };
}, },
watch: {}, watch: {},
computed: {}, computed: {},
methods: {}, methods: {
created() {}, async checkActivityDetail() {
mounted() {}, try {
this.pageLoading = true;
let data = await ActivityService.checkActivityDetail({
marketing_id: this.$route.query.marketing_id,
marketing_type: this.$route.query.marketing_type
});
console.log(data.result);
this.pageLoading = false;
} catch {
this.pageLoading = false;
ElMessage.error("加载失败");
}
}
},
created() {
this.checkActivityDetail();
},
mounted() {}
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
...@@ -87,41 +123,38 @@ export default { ...@@ -87,41 +123,38 @@ export default {
padding: 45px 10px 0; padding: 45px 10px 0;
.activityDetail { .activityDetail {
width: 500px; width: 500px;
.header { .my-header {
.endTime { .endTime {
margin: 5px 0; margin: 5px 0;
font-size: 15px; font-size: 15px;
color: red; color: red;
} }
} }
.content{ .content {
.box-card{ .box-card {
margin: 10px 0; margin: 10px 0;
} }
.activityGoods{ .activityGoods {
.title{ .activityImage {
}
.activityImage{
margin: 10px 10px 0 0; margin: 10px 10px 0 0;
} }
} }
.activityIntroduce{ .activityIntroduce {
padding: 5px 0; padding: 5px 0;
.introduceText{ .introduceText {
margin-bottom: 20px; margin-bottom: 20px;
} }
} }
.activities{ .activities {
.activityItem{ .activityItem {
display: flex; display: flex;
margin:15px 0; margin: 15px 0;
.itemIntroduce{ .itemIntroduce {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-around; justify-content: space-around;
margin-left: 10px; margin-left: 10px;
>p{ > p {
width: 200px; width: 200px;
} }
} }
......
<template> <template>
<div> <div
<el-card class="header"> class="manage-wrapper"
<el-form ref="form" :model="activity" inline label-width="80px"> v-loading="tableLoading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)"
>
<el-form
ref="form"
:model="activity"
inline
label-width="80px"
class="form-wrapper"
>
<!-- 表单控件 -->
<div class="formitem-wrapper">
<el-form-item label="活动名称"> <el-form-item label="活动名称">
<el-input v-model="activity.activityName"></el-input> <el-input v-model="activity.activityName"></el-input>
</el-form-item> </el-form-item>
...@@ -16,11 +29,18 @@ ...@@ -16,11 +29,18 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item style="margin-left: 50px"> <el-form-item style="margin-left: 50px">
<el-button type="primary">搜索</el-button> <el-button type="primary" @click="getActivityList">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="goReleaseProduc"
>发布拼单</el-button
>
</el-form-item> </el-form-item>
<el-button type="primary" @click="goReleaseProduc">发布拼单</el-button> </div>
<!-- 列表 --> <!-- 列表 -->
<el-table :data="manageList" border style="width: 100%"> <div class="table-wrapper">
<el-table :data="tableActivityList" border style="width: 100%">
<el-table-column <el-table-column
align="center" align="center"
prop="activiteId" prop="activiteId"
...@@ -32,9 +52,18 @@ ...@@ -32,9 +52,18 @@
align="center" align="center"
prop="activiteHead" prop="activiteHead"
label="活动标题" label="活动标题"
@header-click="handleHeadline"
width="width" width="width"
> >
<template #default="scope">
<div @click="handleHeadline(scope.row)" class="activityTitle">
<div>
{{ scope.row.activiteHead }}
</div>
<div class="activityPrice">
{{ ` ¥ ${scope.row.minPrice}~¥${scope.row.maxPrice} ` }}
</div>
</div>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
...@@ -42,17 +71,6 @@ ...@@ -42,17 +71,6 @@
label="活动状态" label="活动状态"
width="width" width="width"
> >
<template #default="scope">
<span>
{{
scope.row.online_status == 2
? "进行中"
: scope.row.online_status == 1
? "未开始"
: "已结束"
}}
</span>
</template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
align="center" align="center"
...@@ -96,91 +114,270 @@ ...@@ -96,91 +114,270 @@
width="width" width="width"
> >
</el-table-column> </el-table-column>
<el-table-column align="center" prop="prop" label="操作" width="250"> <el-table-column align="center" prop="scope" label="操作" width="250">
<template #default="scope"> <template #default="scope">
<div class="button-one">
<el-button <el-button
type="primary" type="primary"
size="small" size="small"
@click="handleModify(scope.row)" @click="handleModify(scope.row)"
>修改</el-button> >修改</el-button
<el-popconfirm title="确定要结束本次拼单吗?"> >
<el-popconfirm
title="确定要结束本次拼单吗?"
@confirm="updateActivity"
>
<template #reference> <template #reference>
<el-button <el-button
v-show="scope.row.status === 1"
type="primary" type="primary"
size="small" size="small"
@click="handleEnd(scope.row)" @click="handleEnd(scope.row)"
>结束</el-button> >结束</el-button
>
</template> </template>
</el-popconfirm> </el-popconfirm>
<el-popconfirm title="确定要开启本次拼单吗?"> <el-popconfirm
title="确定要开启本次拼单吗?"
@confirm="updateActivity"
>
<template #reference> <template #reference>
<el-button <el-button
v-show="scope.row.status === 2 || scope.row.status === 3"
type="primary" type="primary"
size="small" size="small"
@click="handleStart(scope.row)" @click="handleStart(scope.row)"
>开始</el-button> >开始</el-button
>
</template> </template>
</el-popconfirm> </el-popconfirm>
</div>
<el-button <el-button
class="checkButton"
type="primary" type="primary"
size="small" size="small"
@click="handleLook(scope.row)" @click="handleLook(scope.row)"
>查看订单</el-button> >查看订单</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</div>
<!-- 分页 -->
<div class="pagination-wrapper">
<el-pagination
background
layout="prev, pager, next"
:total="pageCount"
:page-size="10"
@current-change="handleCurrentChange"
>
</el-pagination>
</div>
</el-form> </el-form>
</el-card>
</div> </div>
</template> </template>
<script> <script>
import { ElMessage } from "element-plus";
import ActivityService from "@/service/Activity/index";
import dayJs from "dayjs";
export default { export default {
name: "Manage", name: "Manage",
data() { data() {
return { return {
activity: { activity: {
activityName: "", activityName: "",
online_status: [], online_status: ""
},
pageCount: 0, // 总条数
currentPage: 1, //当前页码
pageSize: 10, // 每页条数
storeQuery: {}, // 存储开始 结束 参数
tableActivityList: [],
tableLoading: false,
options: [
{ value: "", label: "全部" },
{ value: "1", label: "未开始" },
{ value: "2", label: "进行中" },
{ value: "3", label: "已结束" }
]
};
},
methods: {
/* API */
// 获取商品列表
async getActivityList() {
let params = {
marketing_name: this.activity.activityName,
activity_status: this.activity.online_status, //1 未开始,2进行中,3已结束 空值 全部
marketing_type: 4, //1分销 2团购 3秒杀 4团餐 默认传4
// marketing_id: "",
page: this.currentPage,
page_size: this.pageSize
};
try {
this.tableLoading = true;
let data = await ActivityService.getActivityList(params);
this.filterTableActiveList(data.result);
this.pageCount = data.count;
this.tableLoading = false;
} catch {
this.tableLoading = false;
ElMessage.error("加载失败");
}
},
/* API */
// 结束 开始
async updateActivity() {
try {
this.tableLoading = true;
let data = await ActivityService.updateActivity(this.storeQuery);
if (data.code === 0) {
await this.getActivityList();
} else {
this.tableLoading = false;
ElMessage.error(data.reason);
}
} catch {
this.tableLoading = false;
}
}, },
manageList: [
{ /* API */
activiteId: "413315", // 修改
activiteHead: "生活圈7月29午饭", /* API */
activiteStatus: "进行中", // 查看订单
orderNumber: "345",
// 数据转换成tableData格式
filterTableActiveList(tableData) {
this.tableActivityList = tableData.map(item => {
let activityStatusText = "";
let dateNow = dayJs();
if (dateNow.diff(dayJs(item.start_time)) < 0) {
// 开始时间大于当前时间 return 未开始
activityStatusText = "未开始";
} else if (dayJs(item.end_time).diff(dayJs(item.start_time)) > 0) {
// 结束时间大于开始时间 return 进行中
activityStatusText = "进行中";
} else if (dateNow.diff(dayJs(item.end_time)) > 0) {
// 当前时间大于结束时间 return 已结束
activityStatusText = "已结束";
}
return {
activiteId: item.marketing_id,
activiteHead: item.marketing_name,
activiteStatus: activityStatusText,
status: item.online_status,
minPrice: item.min_price,
maxPrice: item.max_price,
marketing_type: 4,
orderNumber: 33,
soldGoods: "", soldGoods: "",
pay: "", pay: "",
discounts: "", discounts: "",
refund: "", refund: "",
realized: "4000", realized: "4000"
},
],
options: [
{ value: "0", label: "未开始" },
{ value: "1", label: "进行中" },
{ value: "2", label: "已结束" },
],
}; };
});
}, },
methods: {
// 更改页数
handleCurrentChange(val) {
this.currentPage = val;
this.getActivityList();
},
// 点击活动标题 // 点击活动标题
handleHeadline() {}, async handleHeadline(val) {
console.log(val);
this.$router.push({
name: "ActivityDetail",
query: {
marketing_id: val.activiteId,
marketing_type: val.marketing_type
}
});
},
// 发布拼单 // 发布拼单
goReleaseProduc() { goReleaseProduc() {
this.$router.push('/op/activity/releaseProduc') this.$router.push("/op/activity/releaseProduc");
}, },
// 修改 // 修改
handleModify() {}, handleModify(val) {
this.$router.push({
path: "/op/activity/releaseProduc",
query: {
marketing_id: val.activiteId,
marketing_type: val.marketing_type
}
});
},
// 结束 // 结束
handleEnd() {}, handleEnd(val) {
this.storeQuery = {
marketing_id: val.activiteId,
online_status: 2 // 1 启用 2 关闭
};
},
// 开始 // 开始
handleStart() {}, handleStart(val) {
this.storeQuery = {
marketing_id: val.activiteId,
online_status: 1 // 1 启用 2 关闭
};
},
// 查看详情 // 查看详情
handleLook() {}, handleLook() {}
}, },
created(){ created() {
this.getActivityList();
} }
}; };
</script> </script>
<style lang="less" src="./index.less" scope></style> <style lang="less" src="./index.less" scope></style>
<style lang="less" scoped>
.manage-wrapper {
height: 100%;
}
.header {
height: 100%;
}
.form-wrapper {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
.el-card__body {
height: 100%;
}
.formitem-wrapper {
height: 100px;
display: flex;
align-items: flex-end;
}
.table-wrapper {
flex: 1;
overflow-y: scroll;
}
.pagination-wrapper {
width: 100%;
height: 100px;
bottom: 20px;
display: flex;
justify-content: center;
align-items: center;
}
}
.checkButton {
margin-top: 5px;
}
.activityTitle {
cursor: pointer;
}
.activityPrice {
color: red;
}
</style>
/** /**
* 活动管理 * 活动管理
*/ */
const activityRouters = [ const activityRouters = [
{ {
path: "/op/activity", path: "/op/activity",
redirect: "/op/activity/manage" redirect: "/op/activity/manage"
...@@ -9,29 +9,36 @@ ...@@ -9,29 +9,36 @@
{ {
path: "/op/activity/manage", path: "/op/activity/manage",
name: "ManageList", name: "ManageList",
component: () => import(/* webpackChunkName: "activity" */ "@/pages/Activity/Manage") component: () =>
import(/* webpackChunkName: "activity" */ "@/pages/Activity/Manage")
}, },
// 发布拼单 // 发布拼单
{ {
path: "/op/activity/releaseProduc", path: "/op/activity/releaseProduc",
name: "releaseProduc", name: "releaseProduc",
component: () => import(/* webpackChunkName: "activity" */ "@/pages/Activity/releaseProduc") component: () =>
import(
/* webpackChunkName: "activity" */ "@/pages/Activity/releaseProduc"
)
}, },
// 标题详情 // 标题详情
{ {
path:"/op/activity/activityDetail", path: "/op/activity/activityDetail",
name:"ActivityDetail", name: "ActivityDetail",
component: () => import(/* webpackChunkName: "activity" */ "@/pages/Activity/ActivityDetail") component: () =>
import(
/* webpackChunkName: "activity" */ "@/pages/Activity/ActivityDetail"
)
}, },
{ {
path: "/op/activity/releaseProduc/spellOrderSet", path: "/op/activity/releaseProduc/spellOrderSet",
name: "spellOrderSet", name: "spellOrderSet",
component: () => import(/* webpackChunkName: "activity" */ "@/pages/Activity/releaseProduc/components/spellOrderSet") component: () =>
}, import(
/* webpackChunkName: "activity" */ "@/pages/Activity/releaseProduc/components/spellOrderSet"
]; )
}
export default activityRouters; ];
export default activityRouters;
...@@ -2,7 +2,7 @@ import axios from "@/utils/request"; ...@@ -2,7 +2,7 @@ import axios from "@/utils/request";
// 获取商家列表 // 获取商家列表
export async function getBusinessList(params) { export async function getBusinessList(params) {
const res = await axios.get("/api/v1/goods/background/ota_list",{ const res = await axios.get("/api/v1/goods/background/ota_list", {
params params
}); });
return res; return res;
...@@ -10,17 +10,54 @@ export async function getBusinessList(params) { ...@@ -10,17 +10,54 @@ export async function getBusinessList(params) {
// 添加商品 // 添加商品
export async function addGoods(params) { export async function addGoods(params) {
const res = await axios.post( const res = await axios.post("/api/v1/goods/background/add_goods", params);
"/api/v1/goods/background/add_goods",
params
);
return res; return res;
} }
// 商品库列表 // 商品库列表
export async function pindanGoods(params) { export async function pindanGoods(params) {
const res = await axios.get("/api/v1/goods/background/pindan_goods",{ const res = await axios.get("/api/v1/goods/background/pindan_goods", {
params params
}); });
return res; return res;
} }
class ActivityService {
// 获取活动列表
static async getActivityList(params) {
const res = await axios.get("/api/v1/marketing/background/marketing_list", {
params
});
return res;
}
// 修改商品
static async editGoodsDetail(query) {
const res = await axios.post("/api/v1/goods/background/edit_goods", {
...query
});
return res;
}
// 关闭/开启 活动
static async updateActivity(query) {
const res = await axios.post(
"/api/v1/marketing/background/update_marketing",
{
...query
}
);
return res;
}
// 查看活动订单
static async checkActivityDetail(query) {
const res = await axios.post(
"/api/v1/marketing/background/marketing_info",
{
...query
}
);
return res;
}
}
export default ActivityService;
import axios from "axios"; import axios from "axios";
import store from "@/store" import store from "@/store";
import { v1 as uuidv1 } from 'uuid'; import { v1 as uuidv1 } from "uuid";
// import jsonBig from 'json-bigint' // import jsonBig from 'json-bigint'
// import { ElMessage } from "element-plus"; // import { ElMessage } from "element-plus";
...@@ -32,17 +32,16 @@ export const defaultConfig = { ...@@ -32,17 +32,16 @@ export const defaultConfig = {
*/ */
const getDefaultParams = () => { const getDefaultParams = () => {
return { return {
'op_cur_user': store.state.userInfo && store.state.userInfo.email, op_cur_user: store.state.userInfo && store.state.userInfo.email,
'reqid': uuidv1().replace(/-/g, '') reqid: uuidv1().replace(/-/g, "")
};
}
}; };
const getDefaultHeaders = (config) => { const getDefaultHeaders = config => {
const { method } = config; const { method } = config;
if (method.toLowerCase() === 'post') { if (method.toLowerCase() === "post") {
return { return {
"Content-Type": "application/json" "Content-Type": "application/json"
} };
} }
}; };
...@@ -56,7 +55,7 @@ const instance = axios.create(defaultConfig); ...@@ -56,7 +55,7 @@ const instance = axios.create(defaultConfig);
* axios instance interceptors * axios instance interceptors
*/ */
instance.interceptors.request.use( instance.interceptors.request.use(
function (config) { function(config) {
// network error // network error
if (navigator.onLine !== undefined && navigator.onLine === false) { if (navigator.onLine !== undefined && navigator.onLine === false) {
return Promise.reject({ message: "网络未链接", code: -1 }); return Promise.reject({ message: "网络未链接", code: -1 });
...@@ -65,7 +64,7 @@ instance.interceptors.request.use( ...@@ -65,7 +64,7 @@ instance.interceptors.request.use(
/** /**
* merge headers * merge headers
*/ */
config.headers = { ...getDefaultHeaders(config), ...config.headers } config.headers = { ...getDefaultHeaders(config), ...config.headers };
/** /**
* merge params * merge params
...@@ -74,7 +73,7 @@ instance.interceptors.request.use( ...@@ -74,7 +73,7 @@ instance.interceptors.request.use(
return config; return config;
}, },
function (error) { function(error) {
// handle error // handle error
return Promise.reject(error); return Promise.reject(error);
} }
...@@ -84,7 +83,7 @@ instance.interceptors.request.use( ...@@ -84,7 +83,7 @@ instance.interceptors.request.use(
* axios response instance * axios response instance
*/ */
instance.interceptors.response.use( instance.interceptors.response.use(
function (response) { function(response) {
const { data = {} } = response; const { data = {} } = response;
// const code = data.code ?? -1; // const code = data.code ?? -1;
// if (code !== 0) { // if (code !== 0) {
...@@ -106,8 +105,7 @@ instance.interceptors.response.use( ...@@ -106,8 +105,7 @@ instance.interceptors.response.use(
// return data; // return data;
// } // }
return data; return data;
}
},
// function (error) { // function (error) {
// if (!(error.code && error.code === -1)) error.message = "接口请求错误"; // if (!(error.code && error.code === -1)) error.message = "接口请求错误";
// showErrorMessage(error.message); // showErrorMessage(error.message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment