This commit is contained in:
qiaopengfei 2024-07-25 11:13:30 +08:00
parent 8fca5e55b3
commit 74bc0df089
18 changed files with 2589 additions and 1183 deletions

View File

@ -1,10 +1,10 @@
VITE_MODE = 'development'
VITE_APP_BASE_API = 'http://d1-api.erp.xtkj99.com:88'
VITE_APP_BASE_API = 'https://122.228.26.226:12025'
# VITE_APP_BASE_API = 'https://pre-api.aiguoerp.com'
# VITE_APP_BASE_API = 'http://localhost:80'
VITE_APP_BASE_SITE = 'http://localhost:80'
VITE_APP_BASE_URL = 'http://192.168.2.5:9986'
VITE_APP_BASE_URL = 'http://d1-api.erp.xtkj99.com:88'

View File

@ -88,7 +88,7 @@ onMounted(() => {
overflow: hidden;
}
.routeview {
height: calc(100vh - 38px);
height: calc(100vh - 40px);
overflow-y: auto;
&::-webkit-scrollbar {
display: none;

View File

@ -0,0 +1,41 @@
import request from '@axioshooks'
// 获取商品分类
export function getGoodsType(data) {
return request({
url: 'xy_openapi/publish/getGoodsType',
method: 'post',
data
})
}
//获取商品属性
export function getGoodsInfo(data) {
return request({
url: 'xy_openapi/publish/getGoodsInfo',
method: 'get',
data
})
}
//获取闲鱼店铺
export function getshopInfo(data) {
return request({
url: 'xy_openapi/publish/shop/info',
method: 'get',
data
})
}
//上传图片
export function uploadImage(data) {
return request({
url: 'xy_openapi/publish/uploadImage',
method: 'file',
data
})
}
//获取发货地
export function region(data) {
return request({
url: 'xy_openapi/region',
method: 'get',
data
})
}

View File

@ -16,10 +16,10 @@ export function login(data) {
})
}
/*获取阿里云签名*/
export function get_oss_sign_aliyun(data){
export function get_oss_sign_aliyun(data) {
return request({
url:'base_config/get_oss_sign_aliyun',
method:'post',
url: 'base_config/get_oss_sign_aliyun',
method: 'post',
data
})
}
@ -32,11 +32,11 @@ export function get_user_menu(token) {
})
}
/*获取用户信息*/
export function getInfo(token) {
export function getInfo(data) {
return request({
url: 'menu/get_userinfo',
method: 'post',
params: { token }
url: 'auth/getUserInfo',
method: 'get',
data
})
}
/*判断是否绑定拍机堂账号*/

View File

@ -1,74 +0,0 @@
import request from '@axioshooks';
/* 店铺列表*/
export function xy_shop_list(data) {
return request({
url: 'xy_shop/xy_shop_list',
method: 'post',
data
})
}
//获取授权地址
export function get_auth_address(data) {
return request({
url: 'xy_shop/get_auth_address',
method: 'post',
data
})
}
//授权完的确认是否授权成功
export function affirm_auth_success(data) {
return request({
url: 'xy_shop/affirm_auth_success',
method: 'post',
data
})
}
//创建账号
export function account_config_create(data) {
return request({
url: 'base_config/account_config_create',
method: 'post',
data
})
}
//创建账号新
export function xy_account_config_create(data) {
return request({
url: 'base_config/xy_account_config_create',
method: 'post',
data
})
}
//删除店铺
export function account_config_delete(data) {
return request({
url: 'base_config/account_config_delete',
method: 'post',
data
})
}
// 第三方账号配置编辑||店铺修改
export function account_config_edit(data) {
return request({
url: 'base_config/account_config_edit',
method: 'post',
data
})
}
//获取行政区id
export function get_division_id(data) {
return request({
url: 'xy_shop/get_division_id',
method: 'post',
data
})
}
//获取站点拥有的闲鱼商品业务模式
export function site_business_model(data) {
return request({
url: 'xy_shop/site_business_model',
method: 'post',
data
})
}

40
src/api/xyshop.js Normal file
View File

@ -0,0 +1,40 @@
import request from '@axioshooks';
//创建闲鱼店铺
export function save_shop(data) {
return request({
url: 'xy_openapi/auth/save_shop',
method: 'post',
data
})
}
//编辑闲鱼店铺
export function update_shop(data) {
return request({
url: 'xy_openapi/auth/update_shop',
method: 'post',
data
})
}
//删除闲鱼店铺
export function delById(data) {
return request({
url: `xy_openapi/auth/delById/${data}`,
method: 'delete',
})
}
//查询店铺列表
export function list_shop(data) {
return request({
url: 'xy_openapi/auth/list_shop',
method: 'get',
data
})
}
//上传图片
export function upload(data) {
return request({
url: 'xy_openapi/upload',
method: 'file',
data
})
}

View File

@ -97,7 +97,7 @@ const onNavTo=(path)=>{
.breadcrumbbox{
color: #000;
flex:1;
height:100%;
height:40px;
width:100%;
&::-webkit-scrollbar{
display: none;

View File

@ -1,207 +1,231 @@
<template>
<header class="headerbox" v-if="showslider">
<Breadcrumb/>
<div class="flex items-center">
<el-popover
placement="bottom"
width="290"
trigger="hover"
v-model="store.infovisible">
<template #reference>
<div
style="font-size:15px;font-weight:bold; cursor: pointer;max-width:156px;white-space: nowrap;text-overflow:ellipsis;overflow:hidden;padding:0 16px;color:#101010;">
<span> {{ userinfo.truename.slice(0,7) }}</span>
<el-icon @click="store.infovisible=!store.infovisible"><CaretTop v-if="store.infovisible"/><CaretBottom v-if="!store.infovisible"/></el-icon>
</div>
</template>
<ul class="infopopverbox">
<li @click.stop="onCopy(userinfo.username)" class="font14 bold">{{userinfo.username}}<img src="@assets/copy.png"/></li>
<li @click.stop="onCopy(userinfo.company_unique_id)" class="font12 "><span class="gay">公司 ID</span><span style="margin-left:10px">{{userinfo.company_unique_id}}</span>
<img src="@assets/copy.png"/>
</li>
</ul>
<!-- <div class="infopopvercenter">
<header class="headerbox" v-if="showslider">
<Breadcrumb />
<div class="flex items-center">
<el-popover
placement="bottom"
width="290"
trigger="hover"
v-model="store.infovisible"
>
<template #reference>
<div
style="
font-size: 15px;
font-weight: bold;
cursor: pointer;
max-width: 156px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
padding: 0 16px;
color: #101010;
"
>
<span> {{ userinfo ? userinfo.nick_name : "退出登录" }}</span>
<el-icon @click="store.infovisible = !store.infovisible"
><CaretTop v-if="store.infovisible" /><CaretBottom
v-if="!store.infovisible"
/></el-icon>
</div>
</template>
<ul class="infopopverbox" v-if="userinfo">
<li @click.stop="onCopy(userinfo.username)" class="font14 bold">
{{ userinfo.username }}<img src="@assets/copy.png" />
</li>
<li @click.stop="onCopy(userinfo.businesses_code)" class="font12">
<span class="gay">公司 ID</span
><span style="margin-left: 10px">{{
userinfo.businesses_code
}}</span>
<img src="@assets/copy.png" />
</li>
</ul>
<!-- <div class="infopopvercenter">
<li @click="purchase()">微信绑定</li>
<li @click="passwordshow=true">修改密码</li>
</div> -->
<div class="outloginbtnbox">
<el-button class="outloginbtn" @click="logout">退出登录</el-button>
</div>
</el-popover>
</div>
</header>
</template>
<div class="outloginbtnbox">
<el-button class="outloginbtn" @click="logout">退出登录</el-button>
</div>
</el-popover>
</div>
</header>
</template>
<script setup>
import Breadcrumb from './Breadcrumb.vue';
import { useRouter } from 'vue-router';
import { ref, watch,reactive,onMounted} from 'vue';
import axioshooks from "@axioshooks";
import {copytext,delAllStorage} from "@services/commont";
import {
CaretTop,
CaretBottom,
} from '@element-plus/icons-vue';
import Breadcrumb from "./Breadcrumb.vue";
import { useRouter } from "vue-router";
import { ref, watch, reactive, onMounted } from "vue";
import { copytext, delAllStorage } from "@services/commont";
import { getInfo } from "@/api/user.js";
const router = useRouter();
const router = useRouter();
const store=reactive({
infovisible:false
});
const infovisible=ref(true);
const showslider=ref(true);
const store = reactive({
infovisible: false,
});
const infovisible = ref(true);
const showslider = ref(true);
watch(router.currentRoute,async(newpath,oldpath)=>{
if(newpath.path=='/qualityreport'){
showslider.value=false;
}else{
showslider.value=true;
watch(router.currentRoute, async (newpath, oldpath) => {
if (newpath.path == "/qualityreport") {
showslider.value = false;
} else {
showslider.value = true;
}
});
onMounted(()=>{
if(router.currentRoute.path=='/qualityreport'){
showslider.value=false;
}else{
showslider.value=true;
onMounted(() => {
if (router.currentRoute.path == "/qualityreport") {
showslider.value = false;
} else {
showslider.value = true;
}
});
const userinfo=ref({username:"",company_unique_id:"",truename:""});
axioshooks({
url:"menu/get_userinfo",
customHandler:(err,e)=>{
if(!err&&e){
if(e.errcode==0){
userinfo.value=e.datas
}
}
}
});
const userinfo = ref({
username: "",
company_unique_id: "",
businesses_code: "",
});
getInfo().then((res) => {
console.log(res, "res++++++++++++++++++++");
if (res.code === "200") {
userinfo.value = res.data;
}
});
// axioshooks({
// url: "menu/get_userinfo",
// customHandler: (err, e) => {
// if (!err && e) {
// if (e.errcode == 0) {
// userinfo.value = e.datas;
// }
// }
// },
// });
const onCopy=(str)=>{
copytext(str);
}
const onCopy = (str) => {
copytext(str);
};
const logout=()=>{
location.href="/";
delAllStorage();
setTimeout(()=>{
location.reload();
},500);
}
</script>
const logout = () => {
location.href = "/";
delAllStorage();
setTimeout(() => {
location.reload();
}, 500);
};
</script>
<style lang="scss" scoped>
.headerbox{
background:#f1f2f5;
padding:0px 12px;
box-sizing: border-box;
display:flex;
align-items:center;
justify-content: space-between;
height:38px;
.headerbox {
background: #f1f2f5;
padding: 0px 12px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
height: 38px;
}
.infopopverbox{
padding:16px;
background:#FAFAFA;
box-sizing:border-box;
li{
display:flex;
align-items:center;
line-height:20px;
box-sizing:border-box;
padding:3px 0;
color:var(--black);
.infopopverbox {
padding: 16px;
background: #fafafa;
box-sizing: border-box;
li {
display: flex;
align-items: center;
line-height: 20px;
box-sizing: border-box;
padding: 3px 0;
color: var(--black);
cursor: pointer;
img{
margin-left:6px;
width:12px;
height:12px;
img {
margin-left: 6px;
width: 12px;
height: 12px;
}
}
.infopopversubbox{
padding:5px 0 0px;
display:flex;
align-items:center;
box-sizing:border-box;
.infopopversubbox {
padding: 5px 0 0px;
display: flex;
align-items: center;
box-sizing: border-box;
}
.btnStyle{
border:1px solid #4091FF;
color:#4091FF;
background:#fff;
border-radius:20px;
height:20px;
font-weight:400;
padding:0px 12px;
box-sizing:border-box;
font-size:12px;
.btnStyle {
border: 1px solid #4091ff;
color: #4091ff;
background: #fff;
border-radius: 20px;
height: 20px;
font-weight: 400;
padding: 0px 12px;
box-sizing: border-box;
font-size: 12px;
cursor: pointer;
}
}
}
.infopopvercenter{
display:flex;
align-items:stretch;
padding:8px 16px;
box-sizing:border-box;
border-bottom:1px solid var(--lightGay);
li{
flex:1;
text-align:center;
.infopopvercenter {
display: flex;
align-items: stretch;
padding: 8px 16px;
box-sizing: border-box;
border-bottom: 1px solid var(--lightGay);
li {
flex: 1;
text-align: center;
position: relative;
color:var(--gay);
font-size:12px;
color: var(--gay);
font-size: 12px;
cursor: pointer;
&:after{
content:"";
&:after {
content: "";
position: absolute;
right:0;
background:var(--lightGay);
height:17px;
width:1px;
right: 0;
background: var(--lightGay);
height: 17px;
width: 1px;
}
&:last-child{
&:after{
content:"";
display:none;
&:last-child {
&:after {
content: "";
display: none;
}
}
}
}
.infopopverbottom{
padding:6px 12px;
box-sizing:border-box;
li{
padding:6px 0;
box-sizing:border-box;
display:flex;
color:var(--gay);
font-size:12px;
.infopopverbottom {
padding: 6px 12px;
box-sizing: border-box;
li {
padding: 6px 0;
box-sizing: border-box;
display: flex;
color: var(--gay);
font-size: 12px;
cursor: pointer;
img{
width:16px;
height:16px;
margin-right:6px;
img {
width: 16px;
height: 16px;
margin-right: 6px;
}
}
}
.outloginbtnbox{
margin-top:60px;
margin-bottom:16px;
padding:0 12px;
box-sizing:border-box;
.outloginbtn{
width:100%;
font-size:12px;
font-weight:400;
color:#6F6D6D;
height:30px;
line-height:0px;
.outloginbtnbox {
margin-top: 60px;
margin-bottom: 16px;
padding: 0 12px;
box-sizing: border-box;
.outloginbtn {
width: 100%;
font-size: 12px;
font-weight: 400;
color: #6f6d6d;
height: 30px;
line-height: 0px;
}
}
</style>

View File

@ -0,0 +1,247 @@
<template>
<div class="text-msg-pic-upload">
<div class="uploadcontainer">
<div v-for="(item, index) in tempFileList" :key="index" class="prewimg">
<img :src="item.base64" />
<div></div>
</div>
<label for="uploadinput" class="inputlabel"> 上传 </label>
<input
type="file"
id="uploadinput"
class="fileinput"
multiple
accept="image/jpeg,image/png,image/gif,image/jpg"
:onChange="onUpload"
/>
</div>
<!-- <el-upload
ref="upload"
id="upload"
list-type="picture-card"
:class="{ display: data.uploadDisabled }"
v-model:file-list="tempFileList"
:multiple="props.multiple"
:auto-upload="props.autoUpload"
:on-exceed="handleExceed"
:on-change="onChange"
accept="jpeg"
:show-file-list="props.limit > 1 || !props.limit"
>
<el-icon v-if="props.limit > 1 || tempFileList.length == 0"
><Plus
/></el-icon>
<img
:src="tempFileList[0].url"
v-if="props.limit == 1 && tempFileList.length > 0"
class="showimg"
/>
<template #file="{ file }">
<div>
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
<span class="el-upload-list__item-actions">
<span
class="el-upload-list__item-preview"
@click="hImgPreview(file)"
>
<el-icon><zoom-in /></el-icon>
</span>
<span
class="el-upload-list__item-delete"
@click="handleRemove(file)"
>
<el-icon><Delete /></el-icon>
</span>
</span>
</div>
</template>
</el-upload> -->
<el-dialog v-model="data.dialogVisible" append-to-body>
<img width="100%" :src="data.dialogImageUrl" alt="" />
</el-dialog>
<!-- <div class="Upload_pictures">
<ul class="el-upload__tip cBBBDBF" style="color: #bbbdbf">
<li>支持PNGJEPG格式 不超过2MB</li>
</ul>
</div> -->
</div>
</template>
<script setup>
import { ref, reactive, watch, computed, onMounted } from "vue";
import { ElMessage } from "element-plus";
import { Delete, Download, Plus, ZoomIn } from "@element-plus/icons-vue";
const $emit = defineEmits(["onSuccessFiles"]);
const props = defineProps({
limitType: {
type: Array,
default: ["jpeg", "jpg", "gif", "png"],
}, //
autoUpload: Boolean,
limit: Number, //
imgList: Array, //
multiple: Boolean, //
});
const data = reactive({
// el-upload使
uploadDisabled: false,
dialogImageUrl: "",
dialogVisible: false,
});
const tempFileList = ref([]);
const onUpload = (e) => {
const ImgList = [];
for (let i = 0; i < e.target.files.length; i++) {
if (isPngImage(e.target.files[i])) {
let file = isPngImage(e.target.files[i]);
const render = new FileReader();
render.onload = (re) => {
ImgList.push({ file: file, base64: re.target.result });
if (e.target.files.length - 1 == i) {
if (!handleExceed(ImgList, tempFileList.value)) return;
tempFileList.value.push(...ImgList);
$emit("onSuccessFiles", tempFileList.value);
}
};
render.readAsDataURL(file);
}
}
};
const isPngImage = (file) => {
if (!file.type.startsWith("image/")) {
console.error("这不是一个图片文件");
return false;
}
const fileName = file.name || "";
const extension = fileName.split(".").pop().toLowerCase();
if (props.limitType.includes(extension)) return file;
};
watch(
props,
(newval) => {
// if (Array.isArray(props.imgList)) {
// console.log(
// props.imgList,
// "props.imgListprops.imgListprops.imgListprops.imgListprops.imgListprops.imgListprops.imgListprops.imgListprops.imgListprops.imgListprops.imgList"
// );
// tempFileList.value = props.imgList||[];
// }
},
{ deep: true, immediate: true }
);
//
const hImgPreview = (file) => {
data.dialogImageUrl = file.url;
data.dialogVisible = true;
};
//
const handleRemove = (file) => {
if (tempFileList.value) {
const list = tempFileList.value.filter((f) => f.url != file.url);
$emit("onSuccessFiles", list);
} else {
$emit("onSuccessFiles", []);
}
return true;
};
const onChange = (file) => {
// if (!file || !file.raw) {
// return;
// }
// let types = props.limitType;
// const isImage = types.find((f) => file.raw.type.includes(f));
// const isLt20M = file.raw.size / 1024 / 1024 < 2;
// if (!isImage && props.limit > 1) {
// ElMessage(
// types.length == 0
// ? " PNG !"
// : " JPGPNG !"
// );
// return false;
// }
// if (!isLt20M) {
// ElMessage(" 2MB!");
// return false;
// }
// isPngImage(file.raw);
// $emit("onSuccessFiles", tempFileList.value);
// return false;
};
//
const handleUpload = (op, filelist) => {};
const handleExceed = (files, fileList) => {
console.log(files.length + fileList.length, "files.length + fileList.length");
if (files.length + fileList.length > props.limit) {
ElMessage(
`当前限制选择 ${props.limit} 个文件,本次选择了 ${
files.length
} 个文件共选择了 ${files.length + fileList.length} 个文件`
);
return false;
}
return true;
};
</script>
<style lang="scss">
.text-msg-pic-upload .el-upload--picture-card,
.text-msg-pic-upload .el-upload-list--picture-card .el-upload-list__item {
width: 62px;
height: 62px;
line-height: 72px;
display: flex;
align-items: center;
justify-content: center;
margin: 0 10px 0 0;
}
.showimg {
width: 60px;
height: 60px;
}
.display .el-upload--picture-card {
display: none;
}
.el-upload-list__item-delete {
margin-left: 10px !important;
}
.inputlabel {
display: flex;
align-items: center;
justify-content: center;
width: 80px;
height: 80px;
border: 1px dashed #e5e5e5;
border-radius: 6px;
&:hover {
border: 1px dashed #409eff;
}
}
.uploadcontainer {
display: flex;
align-items: stretch;
gap: 10px;
}
.fileinput {
display: none;
}
.prewimg {
width: 80px;
height: 80px;
border: 1px solid #e5e5e5;
border-radius: 6px;
display: block;
img {
width: 100%;
height: 100%;
display: block;
}
}
</style>

View File

@ -1,24 +1,23 @@
<template>
<div class="text-msg-pic-upload">
<el-upload
:class="{ display: data.uploadDisabled }"
action=""
list-type="picture-card"
ref="upload"
list-type="picture-card"
:class="{ display: data.uploadDisabled }"
v-model:file-list="tempFileList"
:multiple="props.multiple"
:auto-upload="props.autoUpload"
v-model:file-list="data.tempFileList"
:on-exceed="handleExceed"
:on-success="handleSuccess"
accept="jpg,.jpeg,.png,.JPG,.JPEG"
:on-change="beforeUpload"
:on-change="onChange"
:show-file-list="props.limit > 1 || !props.limit"
accept="image/jpeg,image/png,image/gif,image/jpg"
>
<el-icon v-if="props.limit > 1 || data.tempFileList.length == 0"
<el-icon v-if="props.limit > 1 || tempFileList.length == 0"
><Plus
/></el-icon>
<img
:src="data.tempFileList[0].url"
v-if="props.limit == 1 && data.tempFileList.length > 0"
:src="tempFileList[0].url"
v-if="props.limit == 1 && tempFileList.length > 0"
class="showimg"
/>
<template #file="{ file }">
@ -27,12 +26,11 @@
<span class="el-upload-list__item-actions">
<span
class="el-upload-list__item-preview"
@click="handlePictureCardPreview(file)"
@click="hImgPreview(file)"
>
<el-icon><zoom-in /></el-icon>
</span>
<span
v-if="!data.uploadDisabled"
class="el-upload-list__item-delete"
@click="handleRemove(file)"
>
@ -41,7 +39,6 @@
</span>
</div>
</template>
<div class="el-upload__tip" v-if="props.tipsFlag">{{ props.tips }}</div>
</el-upload>
<el-dialog v-model="data.dialogVisible" append-to-body>
<img width="100%" :src="data.dialogImageUrl" alt="" />
@ -57,54 +54,61 @@
<script setup>
import { ref, reactive, watch, computed } from "vue";
import { ElMessage } from "element-plus";
import { initOss } from "@services/commont";
import { Delete, Download, Plus, ZoomIn } from "@element-plus/icons-vue";
const $emit = defineEmits(["onSuccessFiles"]);
const props = defineProps({
width: String,
limitType: {
type: Array,
default: ["jpeg", "jpg", "gif", "png"],
}, //
autoUpload: Boolean,
limit: Number,
limitType: Array,
disabled: Boolean,
imgList: Array,
tipsFlag: Boolean,
tips: String,
limit: Number, //
imgList: Array, //
multiple: Boolean, //
});
const data = reactive({
// el-upload使
tempFileList: [],
host: "", //
uploadDisabled: false,
dialogImageUrl: "",
dialogVisible: false,
});
const tempFileList = ref([]);
watch(
props,
(newval) => {
console.log(newval, "newval");
if (Array.isArray(props.imgList)) {
console.log(props.imgList, "props.imgList");
data.tempFileList = props.imgList;
tempFileList.value = props.imgList;
}
},
{ deep: true }
{ deep: true, immediate: true }
);
const upText = computed(() => {
computed(() => {
return props.autoUpload ? "上传文件" : "选择文件";
});
const handlePictureCardPreview = (file) => {
//
const hImgPreview = (file) => {
data.dialogImageUrl = file.url;
data.dialogVisible = true;
};
const beforeUpload = (file) => {
//
const handleRemove = (file) => {
if (tempFileList.value) {
const list = tempFileList.value.filter((f) => f.url != file.url);
$emit("onSuccessFiles", list);
} else {
$emit("onSuccessFiles", []);
}
return true;
};
const onChange = (file) => {
if (!file || !file.raw) {
return;
}
// console.log('beforeUpload', file)
let types = props.limitType || ["jpeg", "jpg", "gif", "png"];
let types = props.limitType;
const isImage = types.find((f) => file.raw.type.includes(f));
const isLt20M = file.raw.size / 1024 / 1024 < 2;
@ -120,58 +124,23 @@ const beforeUpload = (file) => {
ElMessage("上传图片大小不能超过 2MB!");
return false;
}
if (props.limit == 1) {
tempFileList.value = [];
}
handleUpload({ file: file });
return false;
};
//
const handleUpload = (op) => {
console.log(op.file, "handleUpload");
initOss(op.file.raw)
.then((link) => {
console.log(link, "link");
let tempFileList = [];
if (props.limit == 1) {
tempFileList = [op.file];
} else {
tempFileList.push(...data.tempFileList, op.file);
}
$emit("onSuccessFiles", link, tempFileList);
})
.catch((err) => {
console.log(err, "err");
$emit("onSuccessFiles", "", []);
});
const handleUpload = (op, filelist) => {
if (props.limit == 1) {
tempFileList.value = [];
setTimeout(() => {
tempFileList.value = [op.file];
}, 100);
}
$emit("onSuccessFiles", op.file);
};
//
const handleSuccess = (response, file, fileList) => {
// this.filterFileFn(fileList)
};
//
const filterFileFn = (fileList) => {
// let filterArr = fileList
// .filter(item => !item.status || item.status !== 'ready') //
// .map(item => {
// let url = item.response ? item.response.url : item.url
// return {
// url: url, // item.url || item.response.url
// name: item.name
// }
// })
// // console.log('fileList', fileList)
// this.$emit('onSuccessFiles', filterArr)
};
//
const handleRemove = (file, fileList) => {
if (data.tempFileList) {
const list = data.tempFileList.filter((f) => f.url != file.url);
$emit("onSuccessFiles", "", list);
} else {
$emit("onSuccessFiles", "", []);
$emit("onSuccessFiles", "", []);
}
return true;
};
const handleExceed = (files, fileList) => {
ElMessage(
`当前限制选择 ${props.limit} 个文件,本次选择了 ${
@ -179,9 +148,6 @@ const handleExceed = (files, fileList) => {
} 个文件共选择了 ${files.length + fileList.length} 个文件`
);
};
const beforeRemove = () => {
// return this.$confirm(` ${file.name}`)
};
</script>
<style lang="scss">
@ -193,6 +159,7 @@ const beforeRemove = () => {
display: flex;
align-items: center;
justify-content: center;
margin: 0 10px 0 0;
}
.showimg {
width: 60px;
@ -201,5 +168,8 @@ const beforeRemove = () => {
.display .el-upload--picture-card {
display: none;
}
.el-upload-list__item-delete {
margin-left: 10px !important;
}
</style>

View File

@ -1,6 +1,6 @@
import axios, * as defaultAxios from 'axios';
import { getStorage, deloneStorage } from "./commont";
import { getStorage, deloneStorage, jsonurldata } from "./commont";
import { ElMessage } from 'element-plus';
@ -37,6 +37,7 @@ let _window = window;
let cancelTokenSource = null;
let lasturl = [];
export default ({
url,
method = 'post',
@ -66,27 +67,44 @@ export default ({
};
let axioshooks = axios.create();
let config = {
headers: Object.assign({}, headers)
};
var axiosfn = {
"delete": (url, paramdata, config) => {
let newurl = url
let str = data && Object.keys(data).length > 0 ? "/" + jsonurldata(data) : ""
newurl = url + str
return axios.delete(newurl, config)
}, "post": axios.post, "get": (url, paramdata, config) => {
let newurl = url
let str = data && Object.keys(data).length > 0 ? "/" + jsonurldata(data) : ""
newurl = url + str
return axios.get(newurl, config)
}, "put": axios.put
}
const token = getStorage('token');
const virtoken = getStorage('virtoken');
const baseApi = import.meta.env.VITE_APP_BASE_API;
let newurl = '';
if (/http/.test(url)) {
newurl = url;
} else {
const baseApi = import.meta.env.VITE_APP_BASE_API;
newurl = baseApi + '/api/' + url;
}
let newtoken = newurl.indexOf(baseApi) > -1 ? "Bearer " + virtoken : token;
let config = {
headers: Object.assign({}, headers, {
token: newtoken
})
};
cancelTokenSource = CancelToken.source();
if (token) {
config = {
headers: Object.assign({}, {
token: token,
token: newtoken,
'Content-Type': 'application/json;'
}, headers),
cancelToken: cancelTokenSource.token,
@ -101,22 +119,17 @@ export default ({
}//添加请求头
}
if (method && method == 'get') {
config.headers = Object.assign({}, {
token: token,
cancelToken: cancelTokenSource.token,
}, headers);
axioshooks = axios.get;
config.headers = Object.assign({}, config.headers || {}, headers);
} else if (method && method == 'file') {
config.headers = Object.assign({}, {
token: token,
config.headers = Object.assign({}, config.headers || {}, {
token: newtoken,
'Content-Type': 'multipart/form-data',
Accept: '*/*',
}, headers);
axioshooks = axios.post;
} else {
axioshooks = axios.post;
}
console.log(config,"config")
axioshooks = axiosfn[method] ? axiosfn[method] : axios.post
// console.log(config,"config")
if (!url || !dispatchEffect()) return;
// ONLY trigger by query
@ -131,9 +144,12 @@ console.log(config,"config")
_Object.values(data).map((d, index) => {
if ((d && d != '') || typeof d == 'number') {
if (Object.keys(data)[index] == 'file') {
params.append('file', d, d.name);
d.map((h)=>{
params.append('file', h, h.name);
})
} else if (Object.keys(data)[index] == 'filekey') {
params.append(d, data[d], data[d].name);
params.append(d, data[d]);
} else {
params.append(Object.keys(data)[index], d);
}
@ -165,10 +181,8 @@ console.log(config,"config")
paramsdata = params;
}
}
axioshooks(newurl, paramsdata, config)
.then(response => {
console.log(response,"response")
if (response.data && response.data.errcode && response.data.errcode == 1002) {
deloneStorage("token");
location.href = "/";
@ -187,7 +201,7 @@ console.log(config,"config")
}
})
.catch(error => {
console.log(error,"error")
// console.log(error,"error")
if (!isCancel(error.message)) {
handler(error.message, error, null);
reject(error.message);

View File

@ -2,23 +2,21 @@ import { ElMessage } from 'element-plus';
import axioshooks from './axioshooks.js';
export async function getFileMenu() {
var filemoduleMap=import.meta.glob(["./../views/**/*.vue","./../views/*.vue"]);
var filemoduleMap = import.meta.glob(["./../views/**/*.vue", "./../views/*.vue"]);
let results=[];
Object.keys(filemoduleMap).map((k,i)=>{
let defaultmenu=filemoduleMap[k];
const matches=k.match(/[^\.\/]+/g).slice(1,-1);
let path="";
console.log(matches,'matches');
matches.map((h)=>{
path+=h+'/';
});
path=path.slice(0,path.length-1);
console.log(path,'path')
let data={path:'/'+path,module:defaultmenu,url:k}
results.push(data);
let results = [];
Object.keys(filemoduleMap).map((k, i) => {
let defaultmenu = filemoduleMap[k];
const matches = k.match(/[^\.\/]+/g).slice(1, -1);
let path = "";
matches.map((h) => {
path += h + '/';
});
return results;
path = path.slice(0, path.length - 1);
let data = { path: '/' + path, module: defaultmenu, url: k }
results.push(data);
});
return results;
}
/**
* 脱敏处理函数
@ -27,318 +25,318 @@ export async function getFileMenu() {
* @return {string} 脱敏后的数据
*/
export function maskData(input, type = 'phone') {
if (typeof input !== 'string') return input
// const { securityEncryption } = session.get('THEME_CONFIG') || {}
// 与服务端商定加解密方式
// input = decrypt(input)
// 只解密不脱敏
if (type === 'custom') return input
// 地址脱敏 中间的数字进行脱敏 明月小区*单元**号楼101
if (type === 'address') return input.replace(/(\d+)(?=\D)/g, match => '*'.repeat(match.length))
let start, end
switch (type) {
case 'email': {
// 邮箱,保留前两位和 "@" 后的所有字符
const [localPart, domain] = input.split('@')
if (localPart.length > 2) {
start = 2
end = domain.length + 1 }
break
}
case 'bankCard': {
// 身份证号或银行卡号,保留前三位和后四位
start = 3
end = 4
break
}
case 'birthdate': {
// 出生日期,隐藏中间四位
if (typeof input !== 'string') return input
// const { securityEncryption } = session.get('THEME_CONFIG') || {}
// 与服务端商定加解密方式
// input = decrypt(input)
// 只解密不脱敏
if (type === 'custom') return input
// 地址脱敏 中间的数字进行脱敏 明月小区*单元**号楼101
if (type === 'address') return input.replace(/(\d+)(?=\D)/g, match => '*'.repeat(match.length))
let start, end
switch (type) {
case 'email': {
// 邮箱,保留前两位和 "@" 后的所有字符
const [localPart, domain] = input.split('@')
if (localPart.length > 2) {
start = 2
end = 2
break
end = domain.length + 1
}
case 'name': {
// 姓名3个字以内隐藏第1个字4-6个字隐藏前2个字大于6个字隐藏第3-6个字
const length = input.length
if (length <= 3) {
start = 0
end = length - 1
} else if (length <= 6) {
start = 0
end = length - 2
} else {
start = 2
end = length - 6
}
break
}
default: // phone 包含手机号和固定电话
// 手机号,保留前三位和后两位,电话号码保留区号和后三位
// telRegExp-固定电话正则 phoneRegExp-手机号正则
let telRegExp=/^(?:(?:\+|00)86)?1\d{10}$/;
if (telRegExp.test(input)) {
let matchRes = input.match(telRegExp);
if(matchRes){
console.log(matchRes,"matchRes")
if(matchRes[1]&&matchRes[1].length){
start = matchRes[1].length
}else{
start = 3
}
if(matchRes[2]&&matchRes[2].length){
end = matchRes[2].length
}else{
end = 2
}
}
} else {
start = 3
end = 2
}
break
}
// 计算被脱敏处理后的字符的长度
let maskLength = input.length - start - end
// 使用正则表达式进行脱敏处理
const reg = new RegExp(`^(.{${start}}).*(.{${end}})$`)
return input.replace(reg, `$1${'*'.repeat(maskLength)}$2`)
case 'bankCard': {
// 身份证号或银行卡号,保留前三位和后四位
start = 3
end = 4
break
}
case 'birthdate': {
// 出生日期,隐藏中间四位
start = 2
end = 2
break
}
case 'name': {
// 姓名3个字以内隐藏第1个字4-6个字隐藏前2个字大于6个字隐藏第3-6个字
const length = input.length
if (length <= 3) {
start = 0
end = length - 1
} else if (length <= 6) {
start = 0
end = length - 2
} else {
start = 2
end = length - 6
}
break
}
default: // phone 包含手机号和固定电话
// 手机号,保留前三位和后两位,电话号码保留区号和后三位
// telRegExp-固定电话正则 phoneRegExp-手机号正则
let telRegExp = /^(?:(?:\+|00)86)?1\d{10}$/;
if (telRegExp.test(input)) {
let matchRes = input.match(telRegExp);
if (matchRes) {
if (matchRes[1] && matchRes[1].length) {
start = matchRes[1].length
} else {
start = 3
}
if (matchRes[2] && matchRes[2].length) {
end = matchRes[2].length
} else {
end = 2
}
}
} else {
start = 3
end = 2
}
}
// 计算被脱敏处理后的字符的长度
let maskLength = input.length - start - end
// 使用正则表达式进行脱敏处理
const reg = new RegExp(`^(.{${start}}).*(.{${end}})$`)
return input.replace(reg, `$1${'*'.repeat(maskLength)}$2`)
}
//获取近几天
export function getDay (number,bool = false) {
let today = new Date();
let day = today.getTime() + 24 * 60 * 60 * 1000 * number;
today.setTime(day);
let val = formatDate(parseInt(today.getTime() / 1000), 'Y-m-d')
if(bool){
val = parseInt(today.getTime() / 1000)
}
export function getDay(number, bool = false) {
let today = new Date();
let day = today.getTime() + 24 * 60 * 60 * 1000 * number;
today.setTime(day);
let val = formatDate(parseInt(today.getTime() / 1000), 'Y-m-d')
if (bool) {
val = parseInt(today.getTime() / 1000)
}
return val
return val
}
export function getMonthFirst (data) {
let date = new Date(data);
date.setDate(1);
let month = parseInt(date.getMonth() + 1);
let day = date.getDate();
if( month < 10) {
month = '0' + month
}
if(day < 10 ) {
day = '0' + day
}
let val = date.getFullYear() + '-' + month +'-' + day
export function getMonthFirst(data) {
let date = new Date(data);
date.setDate(1);
let month = parseInt(date.getMonth() + 1);
let day = date.getDate();
if (month < 10) {
month = '0' + month
}
if (day < 10) {
day = '0' + day
}
let val = date.getFullYear() + '-' + month + '-' + day
return val
return val
}
export function getMonthLast (data) {
let date = new Date(data);
let currentMonth = date.getMonth();
let nextMonth = ++currentMonth;
let nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1);
let oneDay = 24 * 60 * 60 * 1000
let lastTime = new Date(nextMonthFirstDay - oneDay);
let month = parseInt(lastTime.getMonth() + 1);
let day = lastTime.getDate();
if( month < 10) {
month = '0' + month
}
if(day < 10 ) {
day = '0' + day
}
let val = date.getFullYear() + '-' + month +'-' + day
export function getMonthLast(data) {
let date = new Date(data);
let currentMonth = date.getMonth();
let nextMonth = ++currentMonth;
let nextMonthFirstDay = new Date(date.getFullYear(), nextMonth, 1);
let oneDay = 24 * 60 * 60 * 1000
let lastTime = new Date(nextMonthFirstDay - oneDay);
let month = parseInt(lastTime.getMonth() + 1);
let day = lastTime.getDate();
if (month < 10) {
month = '0' + month
}
if (day < 10) {
day = '0' + day
}
let val = date.getFullYear() + '-' + month + '-' + day
return val
return val
}
//格式化时间
export function uuid(){
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
var uuid = s.join("");
return uuid;
export function uuid() {
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
var uuid = s.join("");
return uuid;
}
//获取url上的参数值 e为参数名称
export function getQueryString(e) {
var t = new RegExp("(/\?|&)" + e + "=([^&]*)(&|$)");
var a = window.location.href.substr(1).match(t);
if (a != null) return a[2];
return ""
var t = new RegExp("(/\?|&)" + e + "=([^&]*)(&|$)");
var a = window.location.href.substr(1).match(t);
if (a != null) return a[2];
return ""
}
// 添加本地存储
export function addSessionStorage(key,value) {
console.log(key,value,"9888978787");
try{
sessionStorage.setItem(key,JSON.stringify(value));
}catch(err){
export function addSessionStorage(key, value) {
try {
sessionStorage.setItem(key, JSON.stringify(value));
} catch (err) {
}
}
export function getSessionStorage(key) {
let result=sessionStorage.getItem(key);
try{
result= JSON.parse(result);
}catch(err){
}
return result;
}
}
}
export function getSessionStorage(key) {
let result = sessionStorage.getItem(key);
try {
result = JSON.parse(result);
} catch (err) {
}
return result;
}
export function delSessionStorage(key) {
export function delSessionStorage(key) {
sessionStorage.removeItem(key);
}
// 添加本地存储
export function addStorage(key,value) {
localStorage.setItem(key,JSON.stringify(value));
export function addStorage(key, value) {
localStorage.setItem(key, JSON.stringify(value));
}
// 获取本地存储
export function getStorage(key) {
let result=localStorage.getItem(key);
try{
result= JSON.parse(result);
}catch(err){
}
return result;
let result = localStorage.getItem(key);
try {
result = JSON.parse(result);
} catch (err) {
}
return result;
}
// <Button className={styles.btnDelete} size="small"><Icon type="delete" />删除本地存储指定的值
export function deloneStorage(key) {
localStorage.removeItem(key);
localStorage.removeItem(key);
}
// <Button className={styles.btnDelete} size="small"><Icon type="delete" />删除所有本地存储的值
export function delAllStorage(key) {
return localStorage.clear();
return localStorage.clear();
}
// JSON数据转换 url后的参数格式
export function jsonurldata(datas) {
const dataarray = [];
const datakeys = Array.from(Object.keys(datas));
const datavalue = Array.from(Object.values(datas));
for (let i in datakeys) {
let jsontostring = datakeys[i] + '=' + datavalue[i]
dataarray.push(jsontostring);
}
let outdata = dataarray.join('&');
return outdata;
if (typeof datas !== "object") return datas
const dataarray = [];
const datakeys = Array.from(Object.keys(datas));
const datavalue = Array.from(Object.values(datas));
for (let i in datakeys) {
let jsontostring = datakeys[i] + '=' + datavalue[i]
dataarray.push(jsontostring);
}
let outdata = dataarray.join('&');
return outdata;
}
export function isWeiXin(){
let ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
return true;
}else{
return false;
}
export function isWeiXin() {
let ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return false;
}
}
//把时间戳格式化成标准格式 第一个参数为时间戳,第二个参数为格式例如 Y-m-d h:M:s'
export function formatDate(date, format) {
if(!date){
return ''
if (!date) {
return ''
}
const days = [
'周日',
'周一',
'周二',
'周三',
'周四',
'周五',
'周六'
];
if (typeof date == 'string') {
if (date.length < 13) {
const j = 13 - date.length;
for (let i = 0; i < j; i++) {
date = date + '0';
}
}
const days = [
'周日',
'周一',
'周二',
'周三',
'周四',
'周五',
'周六'
];
if ( typeof date == 'string') {
if (date.length < 13) {
const j = 13 - date.length;
for (let i = 0; i < j; i++) {
date = date + '0';
}
}
date = new Date(Number(date));
}else if (typeof date == 'number'){
if(date<1000000000000){
date=date*1000;
}
date = new Date(date);
} else if (typeof date === 'undefined') {
return '';
}
if (!format) {
format = 'Y-m-d';
date = new Date(Number(date));
} else if (typeof date == 'number') {
if (date < 1000000000000) {
date = date * 1000;
}
date = new Date(date);
} else if (typeof date === 'undefined') {
return '';
}
if (!format) {
format = 'Y-m-d';
}
if (Number(date.getHours()) < 10) {
var hour = '0' + String(date.getHours());
}
else {
var hour = date.getHours();
}
if (Number(date.getMinutes()) < 10) {
var Minute = '0' + String(date.getMinutes());
}
else {
var Minute = date.getMinutes();
}
if (Number(date.getSeconds()) < 10) {
var Seconds = '0' + String(date.getSeconds());
}
else {
var Seconds = date.getSeconds();
}
if (Number((date.getMonth()) + 1) < 10) {
var month = '0' + String(date.getMonth() + 1);
} else {
var month = date.getMonth() + 1;
}
if (Number(date.getDate()) < 10) {
var day = '0' + String(date.getDate());
} else {
var day = date.getDate();
}
if (Number(date.getHours()) < 10) {
var hour = '0' + String(date.getHours());
}
else {
var hour = date.getHours();
}
if (Number(date.getMinutes()) < 10) {
var Minute = '0' + String(date.getMinutes());
}
else {
var Minute = date.getMinutes();
}
if (Number(date.getSeconds()) < 10) {
var Seconds = '0' + String(date.getSeconds());
}
else {
var Seconds = date.getSeconds();
}
if (Number((date.getMonth()) + 1) < 10) {
var month = '0' + String(date.getMonth() + 1);
} else {
var month = date.getMonth() + 1;
}
if (Number(date.getDate()) < 10) {
var day = '0' + String(date.getDate());
} else {
var day = date.getDate();
}
format = format.replace('Y', date.getFullYear())
.replace('m', month)
.replace('d', day)
.replace('h', hour)
.replace('M', Minute)
.replace('D', days[date.getDay()])
.replace('s', Seconds);
return format;
format = format.replace('Y', date.getFullYear())
.replace('m', month)
.replace('d', day)
.replace('h', hour)
.replace('M', Minute)
.replace('D', days[date.getDay()])
.replace('s', Seconds);
return format;
};
// 压缩图片
export function compression(imgsrc, truewidth,trueheight) {
return new Promise((resolve, reject) => {
const canvas = document.createElement('canvas');
const cts = canvas.getContext('2d');
const newimg = new Image();
newimg.src = imgsrc;
newimg.onload = function () {
let _w = newimg.naturalWidth;
let _h = newimg.naturalHeight;
const trueheightarray=[];
if(trueheight){
trueheightarray.push(trueheight);
}else{
let trueheight = _h / _w * truewidth;
trueheightarray.push(trueheight);
}
canvas.width = truewidth;
canvas.height = trueheightarray[0];
cts.drawImage(newimg, 0, 0, _w, _h, 0, 0, truewidth, trueheightarray[0]);
resolve(canvas.toDataURL('images/png',0.8));
}
})
export function compression(imgsrc, truewidth, trueheight) {
return new Promise((resolve, reject) => {
const canvas = document.createElement('canvas');
const cts = canvas.getContext('2d');
const newimg = new Image();
newimg.src = imgsrc;
newimg.onload = function () {
let _w = newimg.naturalWidth;
let _h = newimg.naturalHeight;
const trueheightarray = [];
if (trueheight) {
trueheightarray.push(trueheight);
} else {
let trueheight = _h / _w * truewidth;
trueheightarray.push(trueheight);
}
canvas.width = truewidth;
canvas.height = trueheightarray[0];
cts.drawImage(newimg, 0, 0, _w, _h, 0, 0, truewidth, trueheightarray[0]);
resolve(canvas.toDataURL('images/png', 0.8));
}
})
}
export function isObject(item) {
// 判断参数是否存在且类型为对象且不是数组
// 判断参数是否存在且类型为对象且不是数组
return (item && typeof item === 'object' && !Array.isArray(item));
}
@ -347,131 +345,129 @@ export function isArray(value) {
return Array.isArray(value);
}
export function debunce(fn,delay=1000) {
export function debunce(fn, delay = 1000) {
let timer;
return function(...args){
if(timer){
clearTimeout(timer);
}
timer=setTimeout(()=>{
fn.apply(this,args);
},delay);
return function (...args) {
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
fn.apply(this, args);
}, delay);
}
}
export function copytext(text){
try {
const textToCopy = text;
navigator.clipboard.writeText(textToCopy);
ElMessage({ type: 'success', message: '复制成功' })
} catch (err) {
console.error('无法复制文本: ', err);
ElMessage({ type: 'waning', message: '该浏览器不支持自动复制' })
}
export function copytext(text) {
try {
const textToCopy = text;
navigator.clipboard.writeText(textToCopy);
ElMessage({ type: 'success', message: '复制成功' })
} catch (err) {
console.error('无法复制文本: ', err);
ElMessage({ type: 'waning', message: '该浏览器不支持自动复制' })
}
}
export const initOss=(file)=>{
return new Promise((r,j)=>{
let oss=getSessionStorage("oss");
console.log(oss,"oss");
if(oss){
const key = oss.dir +new Date().getTime()+(99999)*Math.random()+'.png';
if(oss.expire>Number(new Date().getTime().toString().slice(0,10))){
sendoss({ key, file, ... oss });
}else{
delSessionStorage("oss");
getSign();
}
}else{
export const initOss = (file) => {
return new Promise((r, j) => {
let oss = getSessionStorage("oss");
if (oss) {
const key = oss.dir + new Date().getTime() + (99999) * Math.random() + '.png';
if (oss.expire > Number(new Date().getTime().toString().slice(0, 10))) {
sendoss({ key, file, ...oss });
} else {
delSessionStorage("oss");
getSign();
}
function getSign(){
axioshooks({
url:"base_config/get_oss_sign_aliyun_v3",
data:{bussiness_type:"xy_shop_qc_avatar"},
customHandler:(err,res)=>{
if(!err&&res){
if(res.errcode==0){
let oss=Object.assign({},res.datas);
const key = oss.dir +new Date().getTime()+(99999)*Math.random()+'.png';
oss.accessKeyId = res.datas.accessid;
oss.accessKeySecret = res.datas.signature;
addSessionStorage('oss',oss);
sendoss({ key, file, ... oss });
}else{
j();
ElMessage("上传失败:"+res.msg);
}
} else {
getSign();
}
function getSign() {
const baseApi = import.meta.env.VITE_APP_BASE_URL;
axioshooks({
url: baseApi+"/api/base_config/get_oss_sign_aliyun_v3",
data: { bussiness_type: "xy_shop_qc_avatar" },
customHandler: (err, res) => {
if (!err && res) {
if (res.errcode == 0) {
let oss = Object.assign({}, res.datas);
const key = oss.dir + new Date().getTime() + (99999) * Math.random() + '.png';
oss.accessKeyId = res.datas.accessid;
oss.accessKeySecret = res.datas.signature;
addSessionStorage('oss', oss);
sendoss({ key, file, ...oss });
} else {
j();
ElMessage("上传失败:" + res.msg);
}
}
}
}).catch((err)=>{
}
}).catch((err) => {
j();
ElMessage("上传失败");
});
}
}
function sendoss(data){
// OSS 的 POST 请求 URL
const url = 'https://'+data.host;
// 创建一个 FormData 实例
const formData = new FormData();
function sendoss(data) {
// OSS 的 POST 请求 URL
const url = 'https://' + data.host;
// 创建一个 FormData 实例
const formData = new FormData();
// 添加字段到 formData
formData.append('key',data.key);
formData.append('policy', data.policy);
formData.append('OSSAccessKeyId',data.accessid);
formData.append('Signature',data.signature);
formData.append('success_action_status', 201);
formData.append('file', data.file,data.file.name);
// 添加字段到 formData
formData.append('key', data.key);
formData.append('policy', data.policy);
formData.append('OSSAccessKeyId', data.accessid);
formData.append('Signature', data.signature);
formData.append('success_action_status', 201);
formData.append('file', data.file, data.file.name);
let resulturl=url+'/'+data.key;
let resulturl = url + '/' + data.key;
fetch(url, {
method: 'POST', // 或者 'PUT'
body: formData,
}).then((res)=>{
console.log(res,"rrr",resulturl)
if(res.status==201){
r(resulturl);
}else{
ElMessage("上传失败");
j();
}
}).catch((err)=>{
console.log(err.message,"err1")
if(err.message=="Failed to fetch"){
ElMessage("上传失败");
delSessionStorage("oss");
j();
}
});
}
fetch(url, {
method: 'POST', // 或者 'PUT'
body: formData,
}).then((res) => {
if (res.status == 201) {
r(resulturl);
} else {
ElMessage("上传失败");
j();
}
}).catch((err) => {
if (err.message == "Failed to fetch") {
ElMessage("上传失败");
delSessionStorage("oss");
j();
}
});
}
});
}
let commont={
maskData:maskData,
copytext:copytext,
copytext:copytext,
getDay:getDay,
uuid:uuid,
addStorage:addStorage,
getStorage:getStorage,
deloneStorage:deloneStorage,
delAllStorage:delAllStorage,
formatDate:formatDate,
jsonurldata:jsonurldata,
isWeiXin:isWeiXin,
getQueryString:getQueryString,
getMonthLast:getMonthLast,
getMonthFirst:getMonthFirst,
compression:compression,
isObject:isObject,
isArray:isArray,
initOss:initOss
let commont = {
maskData: maskData,
copytext: copytext,
copytext: copytext,
getDay: getDay,
uuid: uuid,
addStorage: addStorage,
getStorage: getStorage,
deloneStorage: deloneStorage,
delAllStorage: delAllStorage,
formatDate: formatDate,
jsonurldata: jsonurldata,
isWeiXin: isWeiXin,
getQueryString: getQueryString,
getMonthLast: getMonthLast,
getMonthFirst: getMonthFirst,
compression: compression,
isObject: isObject,
isArray: isArray,
initOss: initOss
}

View File

@ -126,7 +126,6 @@ import { ElMessage } from "element-plus";
import axioshooks from "@axioshooks";
import { getStorage, addStorage } from "@services/commont";
import { Loading } from "@element-plus/icons-vue";
import Header from "../components/Layout/Header.vue";
const props = defineProps(["callback"]);
const ruleForm = reactive({
@ -158,9 +157,11 @@ const rules = ref({
});
const getCatchImage = () => {
const baseApi = import.meta.env.VITE_APP_BASE_URL;
checkloading.value = true;
axioshooks({
url: "login/get_brand_img_tncode",
url: baseApi + "/api/login/get_brand_img_tncode",
data: { username: ruleForm.username, password: ruleForm.password },
customHandler: (err, e) => {
if (!err && e) {
@ -191,8 +192,9 @@ const onCheckImg = () => {
const find = checkimages?.value?.model?.find(
(f) => f.cate_map_id == checkvalue.value
);
const baseApi = import.meta.env.VITE_APP_BASE_URL;
axioshooks({
url: "login/xy_hosted_login",
url: baseApi + "/api/login/xy_hosted_login",
data: {
username: ruleForm.username,
password: ruleForm.password,
@ -207,9 +209,8 @@ const onCheckImg = () => {
checkimages.value = false;
let token = e.datas.token;
if (e.datas.token) {
const baseApi = import.meta.env.VITE_APP_BASE_URL;
axioshooks({
url: baseApi + "/api/auth/login3rd",
url: "auth/login3rd",
headers: {
loginType: "erpLogin",
token: e.datas.token,
@ -219,7 +220,11 @@ const onCheckImg = () => {
console.log(e, "eee");
if (e.code == "200") {
addStorage("token", token);
addStorage("virtoken", e.data);
// addStorage("virtoken", e.data);
addStorage(
"virtoken",
"9wEUErM0vX7OGuPq7byzZA0KdSMhROI8cCWvQAK5bH8TyOwHhekuHF0vwF9cMg5h92fVFtoZssQv9Oo36CYbZmXjrWa56NWWLNppUGRiTFEHYNzPhn7NYBP7SqvPPI6z"
);
if (props.callback) {
props.callback();
}

View File

@ -0,0 +1,221 @@
<template>
<el-dialog
:title="props.specificationTitle"
v-model="props.specificationDialogVisible"
width="40%"
top="23vh"
:close-on-click-modal="false"
:before-close="specificationClose"
>
<div>
<div style="display: flex; align-items: center; margin-bottom: 10px">
<span style="font-size: 18px; display: flex; align-items: center"
><Warning style="width: 1em; height: 1em; margin-right: 8px" /></span
>最多添加两个商品规格单个规格最多添加50个属性值两个属性时相乘不得超过400个
</div>
<el-form
ref="ruleFormRef"
:model="ruleForm"
label-width="auto"
class="demo-ruleForm"
:rules="rules"
>
<el-form-item prop="name">
<el-input
v-model="ruleForm.name"
style="width: 280px"
placeholder="请输入商品规格字数限制4"
>
<template #suffix>
<el-button
type="primary"
size="small"
@click.stop="submit_specification(ruleFormRef)"
>确定</el-button
>
</template>
</el-input>
</el-form-item>
<div v-for="(item, index) in specification_list" :key="index">
<div
style="
display: flex;
align-items: center;
justify-content: space-between;
"
>
<div>
<el-input
v-if="item.disabled"
class="title"
v-model="item.label"
size="small"
@keydown="item.keydown($event, item, index)"
>
<template #suffix>
<span>{{ `(${item.num})` }}</span>
</template>
</el-input>
<span v-else>{{ item.label }}{{ `(${item.num})` }}</span>
</div>
<div>
<el-button
style="margin-left: 0"
v-for="el in item.buttonGroup"
:key="el.label"
:type="el.type"
text
size="small"
@click="el.handler(item, index)"
>{{ el.label }}</el-button
>
</div>
</div>
<el-input
style="margin: 5px 0"
v-model="item.inputGroup.valueName"
:placeholder="item.inputGroup.placeholder"
@keydown="
item.inputGroup.keydown($event, item.inputGroup.valueName, index)
"
>
</el-input>
<div>
<el-button
style="margin: 2px 5px 2px 0px"
v-for="(el, ind) in item.valueGrop"
:key="ind"
:type="el.type"
round
size="small"
@click="el.delete(item, ind)"
>
{{ el.label }}<el-icon class="el-icon--right"><Delete /></el-icon>
</el-button>
</div>
</div>
</el-form>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="specificationClose">取消</el-button>
<el-button type="primary" @click="submitForm">{{ editText }}</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { ref, defineEmits, defineProps, reactive } from "vue";
import { Warning, Delete } from "@element-plus/icons-vue";
import { ElMessage } from "element-plus";
const $emit = defineEmits(["specificationClose"]);
const props = defineProps({
specificationDialogVisible: {
type: Boolean,
default: false,
},
specificationTitle: {
type: String,
default: "",
},
editText: {
type: String,
default: "确定",
},
specification_arr: {
type: Array,
default: [],
},
});
const ruleFormRef = ref(null);
const ruleForm = reactive({
name: "",
});
const rules = reactive({
name: [
{ min: 1, max: 4, message: "字数限制最多输入4个字符", trigger: "blur" },
],
});
const specification_list = ref(props.specification_arr);
const specification_list_index = ref(0);
const submit_specification = (formEl) => {
formEl.validate((valid) => {
if (!valid || !ruleForm.name) return;
if (specification_list.value.length >= 2)
return ElMessage.warning("超过输入限制!");
specification_list_index.value++;
specification_list.value.push({
label: ruleForm.name,
num: 0,
index: specification_list_index.value,
disabled: false,
keydown: (e, item, index) => {
if (e.key !== "Enter") return;
if (item.label.length <= 4) {
item.disabled = false;
} else {
ElMessage.warning("字数限制4个字符");
}
},
buttonGroup: [
{
type: "primary",
label: "编辑",
handler: (item) => {
item.disabled = true;
},
},
{
type: "danger",
label: "删除",
handler: (item, index) => {
specification_list.value.splice(index, 1);
},
},
],
inputGroup: {
valueName: "",
placeholder: "请输入规格属性,按回车健确认",
keydown: (e, name, index) => {
if (e.key !== "Enter" || !name) return;
if (specification_list.value.length <= 1) {
if (specification_list.value[index].valueGrop.length >= 10) return;
} else {
if (
specification_list.value[0].valueGrop.length *
specification_list.value[1].valueGrop.length >=
100
)
return;
}
specification_list.value[index].valueGrop.push({
type: "danger",
label: specification_list.value[index].inputGroup.valueName,
delete: (item, ind) => {
specification_list.value[index].valueGrop.splice(ind, 1);
},
});
specification_list.value[index].num =
specification_list.value[index].valueGrop.length;
specification_list.value[index].inputGroup.valueName = "";
},
},
valueGrop: [],
});
ruleForm.name = "";
});
};
const submitForm = () => {
$emit("specificationSubmit", specification_list);
specificationClose();
};
const specificationClose = () => {
$emit("specificationClose");
};
</script>
<style scoped lang='scss'>
</style>

File diff suppressed because it is too large Load Diff

View File

@ -59,8 +59,8 @@
<UploadImage
:limit="item.limit"
:imgList="item.fileImgList"
:autoUpload="false"
@onSuccessFiles="item.handler"
:multiple="item.multiple"
@onSuccessFiles="item.onSuccessFiles"
/>
</div>
</el-form-item>
@ -81,7 +81,7 @@
import UploadImage from "@components/Upload/newfileupload.vue";
import { ref, defineEmits, defineProps } from "vue";
const ruleFormRef = ref(null);
const $emit = defineEmits(["submitForm"]);
const $emit = defineEmits(["submitForm", "CreateStoreClose"]);
const props = defineProps({
CreateStoreDialogVisible: {
type: Boolean,
@ -116,6 +116,7 @@ const submitForm = (form) => {
};
const CreateStoreClose = () => {
$emit("CreateStoreClose");
ruleFormRef.value.resetFields();
};
</script>

View File

@ -9,7 +9,7 @@
@click="operation('create')"
>创建闲鱼店铺</el-button
>
<el-button class="btn" size="small" @click="operation()"
<el-button class="btn" size="small" @click="operation('publish')"
>发布商品</el-button
>
</div>
@ -21,20 +21,20 @@
:sm="10"
:md="8"
:lg="6"
:xl="4"
v-for="(item, index) in 88"
:xl="get_win_width"
v-for="(item, index) in store_list"
:key="index"
>
<div class="card">
<div class="card-top">
<div class="top-left">
<div class="block">
<el-avatar shape="square" :size="50" :src="squareUrl" />
<el-avatar shape="square" :size="50" :src="item.lcon" />
</div>
</div>
<div class="top-right">
<div class="info">
<div class="username">账号名称</div>
<!-- <div class="username">{{ item.xyName }}</div> -->
<div>
<el-button
v-for="el in buttonGroup"
@ -49,29 +49,29 @@
</div>
</div>
<el-tag
v-for="el in tags"
:key="el.label"
:type="el.type"
v-for="(el, ind) in item.storeType"
:key="ind"
:type="el"
size="small"
>{{ el.label }}</el-tag
>{{ el == 1 ? "特卖" : el == 2 ? "鱼小铺" : "普通" }}</el-tag
>
</div>
</div>
<el-descriptions :column="1" :size="size" :style="blockMargin">
<el-descriptions-item
v-for="(el, index) in descriptions"
v-for="(el, index) in item.descriptions"
:key="index"
:label="el.label"
:class-name="el.cssName"
:label-class-name="el.cssName"
>kooriookami</el-descriptions-item
>{{ el.value }}</el-descriptions-item
>
</el-descriptions>
</div>
</el-col>
</el-row>
<!-- 空状态 -->
<!-- <el-empty description="暂无数据" class="empty"></el-empty> -->
<!-- <el-empty description="暂无数据" class="empty"></el-empty> -->
</div>
<!-- 弹窗 -->
@ -82,6 +82,7 @@
:ruleForm="CreateStore.ruleForm"
:ruleFormList="CreateStore.ruleFormList"
:rules="CreateStore.rules"
:editText="CreateStore.editText"
@CreateStoreClose="CreateStoreClose"
@submitForm="submitForm"
></CreateStoreDialog>
@ -89,23 +90,42 @@
</template>
<script setup>
import { ref, reactive } from "vue";
import { router } from "@/router.js";
import { ref, reactive, onMounted, watch, computed } from "vue";
import { Delete, Edit, Search, Share, Upload } from "@element-plus/icons-vue";
import CreateStoreDialog from "./CreateStoreDialog/CreateStoreDialog.vue";
import axioshooks from '@services/axioshooks.js'
const tags = ref([
{ type: "primary", label: "Tag 1" },
{ type: "primary", label: "Tag 1" },
{ type: "primary", label: "Tag 1" },
]);
import {
save_shop,
list_shop,
upload,
update_shop,
delById,
} from "@/api/xyshop";
import { useRoute } from "vue-router";
import { ElMessage } from "element-plus";
const route = useRoute();
const CreateStoreDialogVisible = ref(route.query.CreateStoreDialogVisible);
const get_win_width = computed(() => {
const xl = window.innerWidth > 1920 ? 4 : 6;
return xl;
});
const buttonGroup = ref([
{
type: "primary",
label: "编辑",
icon: Edit,
handler: (item) => {
operation("edit", item);
CreateStore.CreateStoreTitle = "编辑店铺";
CreateStore.editText = "编辑";
CreateStore.CreateStoreDialogVisible = true;
CreateStore.ruleForm = {
id: item.id,
xyName: item.xyName,
shopDescr: item.shopDescr,
};
CreateStore.ruleFormList.find(
(e) => e.type == "UploadImage"
).fileImgList = [{ url: item.lcon }];
},
},
{
@ -113,164 +133,138 @@ const buttonGroup = ref([
label: "删除",
icon: Delete,
handler: (item) => {
operation("delete", item);
delById(item.id).then((res) => {
if (res.code == "200") {
get_list_shop();
}
});
},
},
]);
const descriptions = ref([
{ label: "闲鱼号:" },
{ label: "昵称:" },
{ label: "授权:", cssName: "active" },
{ label: "备注:" },
]);
const CreateStore = reactive({
ruleForm: {
class_id: "23",
business_line: [
{
abl_id: "",
customer_id: "",
},
],
account: "",
quality_inspector: "",
contact_name: "",
inspection_signature: "",
inspection_avatar: "",
inspection_position: "",
inspection_positions: [],
xyName: "",
shopDescr: "",
lcon: "",
},
ruleFormList: [
{
type: "el-input",
label: "账号名称",
params: "account",
prop: "account",
label: "店铺名称",
params: "xyName",
prop: "xyName",
clearable: true,
placeholder: "请输入账号名称",
},
{
type: "el-input",
label: "质检师签名",
params: "inspection_signature",
prop: "inspection_signature",
clearable: true,
placeholder: "请输入质检师签名",
},
{
type: "el-input",
label: "质检师职位",
params: "inspection_position",
prop: "inspection_position",
clearable: true,
placeholder: "请输入质检师职位",
placeholder: "请输入店铺名称",
},
{
type: "UploadImage",
label: "质检师头像",
label: "店铺图片",
params: "inspection_avatar",
// prop: "inspection_avatar",
limit: 1,
multiple: true,
fileImgList: [],
handler: (file,filelist) => {
console.log(file,filelist,"file,filelist");
return
CreateStore.ruleFormList.find(
(e) => e.label === "质检师头像"
).fileImgList = files;
CreateStore.ruleForm.inspection_avatar = files;
onSuccessFiles: (files) => {
upload({ file: files.raw }).then((res) => {
if (res.code === "200") {
CreateStore.ruleForm.lcon = res.data;
ElMessage.success("上传成功");
}
});
},
},
{
type: "el-select",
label: "城市",
params: "",
prop: "",
clearable: true,
placeholder: "请选择城市",
options: [],
},
{
type: "el-select",
label: "商品业务模式",
params: "",
prop: "",
clearable: true,
placeholder: "请选择闲鱼商品业务模式",
options: [],
},
{
type: "el-checkbox-group",
label: "保障服务",
params: "inspection_positions",
prop: "",
clearable: true,
placeholder: "请选择保障服务",
options: [
{
label: "闲鱼-是否支持七天无理由",
value: "1",
},
{
label: "闲鱼-是否支持描述不符包邮退",
value: "2",
},
{
label: "闲鱼-是否支持 极速发货-24小时",
value: "3",
},
],
},
{
type: "el-input",
label: "备注",
params: "",
prop: "",
params: "shopDescr",
prop: "shopDescr",
clearable: true,
placeholder: "请输入备注",
},
],
rules: {
account: [{ trigger: "blur", required: true, message: "请输入内容" }],
inspection_signature: [
{ trigger: "change", required: true, message: "请输入质检师签名" },
],
inspection_avatar: [
{
validator: "",
required: true,
message: "请上传质检师头像",
},
],
inspection_position: [
{ trigger: "change", required: true, message: "请输入质检师职位" },
],
account: [{ trigger: "change", required: true, message: "请输入95分账号" }],
contact_name: [
{ trigger: "change", required: true, message: "请输入联系人" },
],
xyName: [{ trigger: "blur", required: true, message: "请输入店铺名称" }],
},
CreateStoreDialogVisible: false,
CreateStoreTitle: "",
editText: "",
});
const operation = (status, item) => {
if (status === "create") {
CreateStore.CreateStoreTitle = "创建店铺";
CreateStore.editText = "授权店铺";
CreateStore.ruleForm = {
xyName: "",
shopDescr: "",
lcon: "",
};
CreateStore.ruleFormList.find((e) => e.type == "UploadImage").fileImgList =
[];
CreateStore.CreateStoreDialogVisible = true;
} else if (status === "edit") {
console.log(status, item, "pkpkpkppkp");
} else {
console.log("删除", item, "pkpkpkppkp");
} else if (status === "publish") {
router.push({
path: "/NewlyBuiltGoods",
});
}
};
const CreateStoreClose = () => {
CreateStore.CreateStoreDialogVisible = false;
};
const submitForm = () => {
console.log(CreateStore.ruleForm.account, "ruleFormruleForm");
if (CreateStore.editText == "授权店铺") {
save_shop(CreateStore.ruleForm).then((res) => {
if (res.code === "200") {
window.open(res.data);
get_list_shop();
CreateStoreClose();
}
});
} else {
update_shop(CreateStore.ruleForm).then((res) => {
if (res.code === "200") {
get_list_shop();
CreateStoreClose();
}
});
}
};
const store_list = ref({});
//
const get_list_shop = () => {
list_shop().then((res) => {
if (res.code === "200") {
store_list.value = res.data;
res.data.forEach((item) => {
item.descriptions = [
{ label: "闲鱼号:", value: item.xyAccount },
{ label: "昵称:", value: item.xyName },
{
label: "授权:",
cssName: "active",
value:
Math.ceil(
(new Date(item.expireTime) - new Date()) / (1000 * 60 * 60 * 24)
) + "天",
},
{ label: "备注:", value: item.shopDescr },
];
});
}
});
};
onMounted(() => {
CreateStore.CreateStoreDialogVisible = route.query.CreateStoreDialogVisible;
get_list_shop();
});
watch(
() => route.query.CreateStoreDialogVisible,
(val) => {
if (val) {
CreateStore.CreateStoreDialogVisible = CreateStoreDialogVisible;
}
}
);
</script>
<style scoped lang='scss'>

View File

@ -50,21 +50,21 @@ export default defineConfig((command, mode) => {
errors: true,
},
host: '0.0.0.0',
proxy: {
[process.env.VUE_APP_BASE_API]: {
//这里是公共部分,在调用接口时后面接不相同的部分
target: process.env.VUE_APP_BASE_API, //修改后台接口地址
changeOrigin: true, //开启跨域
pathRewrite: {
//重命名
["^" + process.env.VUE_APP_BASE_API]: "",
},
},
'^/api': {
target: 'http://dev-erp-api.xtkj99.com:7890',
changeOrigin: true
}
},
// proxy: {
// [process.env.VUE_APP_BASE_API]: {
// //这里是公共部分,在调用接口时后面接不相同的部分
// target: process.env.VUE_APP_BASE_API, //修改后台接口地址
// // changeOrigin: true, //开启跨域
// pathRewrite: {
// //重命名
// ["^" + process.env.VUE_APP_BASE_API]: "",
// },
// },
// '^/api': {
// target: 'http://dev-erp-api.xtkj99.com:7890',
// changeOrigin: true
// }
// },
disableHostCheck: true,
},
resolve: {