合并分支

master
lemon橪 2021-06-22 18:11:41 +08:00
commit b566a2fd4f
3 changed files with 118 additions and 75 deletions

View File

@ -1,27 +1,27 @@
// import Vue from 'vue';
import axios from "axios";
import https from "https";
import { Message, Spin, Modal } from "view-design";
import Storage from "./storage";
import config from "@/config";
import router from "../router/index.js";
import store from "../vuex/store";
import { handleRefreshToken } from "@/api/index";
const qs = require("qs");
import axios from 'axios';
import https from 'https';
import { Message, Spin, Modal } from 'view-design';
import Storage from './storage';
import config from '@/config';
import router from '../router/index.js';
import store from '../vuex/store';
import { handleRefreshToken } from '@/api/index';
const qs = require('qs');
export const buyerUrl =
process.env.NODE_ENV === "development"
process.env.NODE_ENV === 'development'
? config.api_dev.buyer
: config.api_prod.buyer;
export const commonUrl =
process.env.NODE_ENV === "development"
process.env.NODE_ENV === 'development'
? config.api_dev.common
: config.api_prod.common;
export const managerUrl =
process.env.NODE_ENV === "development"
process.env.NODE_ENV === 'development'
? config.api_dev.manager
: config.api_prod.manager;
export const sellerUrl =
process.env.NODE_ENV === "development"
process.env.NODE_ENV === 'development'
? config.api_dev.seller
: config.api_prod.seller;
// 创建axios实例
@ -35,7 +35,7 @@ const service = axios.create({
}),
paramsSerializer: params =>
qs.stringify(params, {
arrayFormat: "repeat"
arrayFormat: 'repeat'
})
});
@ -44,15 +44,15 @@ service.interceptors.request.use(
config => {
const { loading } = config;
// 如果是put/post请求用qs.stringify序列化参数
const isPutPost = config.method === "put" || config.method === "post";
const isJson = config.headers["Content-Type"] === "application/json";
const isFile = config.headers["Content-Type"] === "multipart/form-data";
const isPutPost = config.method === 'put' || config.method === 'post';
const isJson = config.headers['Content-Type'] === 'application/json';
const isFile = config.headers['Content-Type'] === 'multipart/form-data';
if (isPutPost && isJson) {
config.data = JSON.stringify(config.data);
}
if (isPutPost && !isFile && !isJson) {
config.data = qs.stringify(config.data, {
arrayFormat: "repeat"
arrayFormat: 'repeat'
});
}
/** 配置全屏加载 */
@ -60,16 +60,16 @@ service.interceptors.request.use(
config.loading = Spin.show();
}
const uuid = Storage.getItem("uuid");
config.headers["uuid"] = uuid;
const uuid = Storage.getItem('uuid');
config.headers['uuid'] = uuid;
// 获取访问Token
let accessToken = Storage.getItem("accessToken");
let accessToken = Storage.getItem('accessToken');
if (accessToken && config.needToken) {
config.headers["accessToken"] = accessToken;
config.headers['accessToken'] = accessToken;
// 解析当前token时间
let jwtData = JSON.parse(
decodeURIComponent(escape(window.atob(accessToken.split(".")[1])))
decodeURIComponent(escape(window.atob(accessToken.split('.')[1].replace(/-/g, '+').replace(/_/g, '/'))))
);
if (jwtData.exp < Math.round(new Date() / 1000)) {
refresh()
@ -85,31 +85,31 @@ service.interceptors.request.use(
async function refresh () {
const getTokenRes = await refreshToken();
if (getTokenRes === "success") {
if (getTokenRes === 'success') {
// 刷新token
if (isRefreshToken === 1) {
error.response.config.headers.accessToken = Storage.getItem(
"accessToken"
'accessToken'
);
return service(error.response.config);
} else {
router.go(0);
}
} else {
Storage.removeItem("accessToken");
Storage.removeItem("refreshToken");
Storage.removeItem("userInfo");
Storage.setItem("cartNum", 0);
store.commit("SET_CARTNUM", 0);
console.log("1111");
Storage.removeItem('accessToken');
Storage.removeItem('refreshToken');
Storage.removeItem('userInfo');
Storage.setItem('cartNum', 0);
store.commit('SET_CARTNUM', 0);
console.log('1111');
Modal.confirm({
title: "请登录",
content: "<p>请登录后执行此操作</p>",
okText: "立即登录",
cancelText: "继续浏览",
title: '请登录',
content: '<p>请登录后执行此操作</p>',
okText: '立即登录',
cancelText: '继续浏览',
onOk: () => {
router.push({
path: "/login",
path: '/login',
query: {
rePath: router.history.current.path,
query: JSON.stringify(router.history.current.query)
@ -146,9 +146,9 @@ service.interceptors.response.use(
} else {
if (error.message) {
let _message =
error.code === "ECONNABORTED"
? "连接超时,请稍候再试!"
: "网络错误,请稍后再试!";
error.code === 'ECONNABORTED'
? '连接超时,请稍候再试!'
: '网络错误,请稍后再试!';
Message.error(errorData.message || _message);
}
}
@ -171,10 +171,10 @@ const closeLoading = target => {
};
export const Method = {
GET: "get",
POST: "post",
PUT: "put",
DELETE: "delete"
GET: 'get',
POST: 'post',
PUT: 'put',
DELETE: 'delete'
};
export default function request (options) {
@ -192,13 +192,13 @@ function getTokenDebounce() {
return function () {
if (!lock) {
lock = true;
let oldRefreshToken = Storage.getItem("refreshToken");
let oldRefreshToken = Storage.getItem('refreshToken');
handleRefreshToken(oldRefreshToken)
.then(res => {
if (res.success) {
let { accessToken, refreshToken } = res.result;
Storage.setItem("accessToken", accessToken);
Storage.setItem("refreshToken", refreshToken);
Storage.setItem('accessToken', accessToken);
Storage.setItem('refreshToken', refreshToken);
success = true;
lock = false;
@ -220,9 +220,9 @@ function getTokenDebounce() {
if (!lock) {
clearInterval(timer);
if (success) {
resolve("success");
resolve('success');
} else {
resolve("fail");
resolve('fail');
}
}
}, 500); // 轮询时间间隔

View File

@ -38,6 +38,12 @@
<Option value="DOWN">下架</Option>
</Select>
</Form-item>
<Form-item label="商品类型" prop="status">
<Select v-model="searchForm.goodsType" placeholder="请选择" clearable style="width: 200px">
<Option value="PHYSICAL_GOODS">实物商品</Option>
<Option value="VIRTUAL_GOODS">虚拟商品</Option>
</Select>
</Form-item>
<Button @click="handleSearch" class="search-btn" type="primary" icon="ios-search" >搜索</Button>
</Form>
</Row>
@ -174,6 +180,20 @@ export default {
);
},
},
{
title: "商品类型",
key: "goodsType",
width: 130,
render: (h, params) => {
if (params.row.goodsType === 'PHYSICAL_GOODS') {
return h("div", "实物商品");
} else if (params.row.goodsType === 'VIRTUAL_GOODS') {
return h("div", "虚拟商品");
} else {
return h("div", "电子卡券");
}
},
},
{
title: "状态",
key: "marketEnable",

View File

@ -12,6 +12,12 @@
<Option value="UPPER">上架</Option>
</Select>
</Form-item>
<Form-item label="商品类型" prop="status">
<Select v-model="searchForm.goodsType" placeholder="请选择" clearable style="width: 200px">
<Option value="PHYSICAL_GOODS">实物商品</Option>
<Option value="VIRTUAL_GOODS">虚拟商品</Option>
</Select>
</Form-item>
<Form-item label="商品编号" prop="sn">
<Input type="text" v-model="searchForm.sn" placeholder="商品编号" clearable style="width: 200px"/>
</Form-item>
@ -49,7 +55,8 @@
</div>
<Poptip trigger="hover" title="扫码在手机中查看" transfer>
<div slot="content">
<vue-qr :text="wapLinkTo(row.id,row.skuId)" :margin="0" colorDark="#000" colorLight="#fff" :size="150"></vue-qr>
<vue-qr :text="wapLinkTo(row.id,row.skuId)" :margin="0" colorDark="#000" colorLight="#fff"
:size="150"></vue-qr>
</div>
<img src="../../../assets/qrcode.svg" class="hover-pointer" width="20" height="20" alt="">
</Poptip>
@ -60,7 +67,8 @@
</Table>
<Row type="flex" justify="end" class="page">
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" size="small"
<Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage"
@on-page-size-change="changePageSize" :page-size-opts="[10, 20, 50]" size="small"
show-total show-elevator show-sizer></Page>
</Row>
</Card>
@ -78,7 +86,8 @@
<Modal title="批量设置运费模板" v-model="shipTemplateModal" :mask-closable="false" :width="500">
<Form ref="shipTemplateForm" :model="shipTemplateForm" :label-width="120">
<FormItem class="form-item-view-el" label="运费" prop="freightPayer">
<RadioGroup type="button" button-style="solid" @on-change="logisticsTemplateUndertakerChange" v-model="shipTemplateForm.freightPayer">
<RadioGroup type="button" button-style="solid" @on-change="logisticsTemplateUndertakerChange"
v-model="shipTemplateForm.freightPayer">
<Radio label="STORE">
<span>卖家承担运费</span>
</Radio>
@ -245,6 +254,20 @@ export default {
);
},
},
{
title: "商品类型",
key: "goodsType",
width: 130,
render: (h, params) => {
if (params.row.goodsType === 'PHYSICAL_GOODS') {
return h("div", "实物商品");
} else if (params.row.goodsType === 'VIRTUAL_GOODS') {
return h("div", "虚拟商品");
} else {
return h("div", "电子卡券");
}
},
},
{
title: "商品价格",
key: "price",