feat(store): 添加上传接口后台配置字段

fix(axios): 更新开发环境测试session值
fix(public-list-item): 修复location为0时的显示问题
fix(edit): 修复location为0时的显示问题并优化上传逻辑

refactor(main): 优化代码格式并添加上传配置初始化
This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-07-24 15:33:05 +08:00
parent 8462981904
commit 7743571aca
13 changed files with 101 additions and 91 deletions

View File

@@ -33,7 +33,7 @@
<!-- {{ data.rentalduration == 0 ? '不限' : -->
<!-- listData['rentalduration'][data.rentalduration] }} -->
</div>
<div class="address-text dis-f al-item" v-if="item['location']">
<div class="address-text dis-f al-item" v-if="item['location'] && item['location'] !== '0'">
<template v-if="Array.isArray(item['location'])">
<template v-for="(it, i) in item['location']" :key="i">
<div class="address-item flexacenter" v-if="it">

View File

@@ -1,7 +1,7 @@
import { createApp } from "vue"
import App from "./App.vue"
import router from "./router"
import store from "./store"
import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
// import ElementPlus from 'element-plus'
// import { ElButton, ElInput } from 'element-plus'
@@ -28,110 +28,113 @@ import {
ElProgress,
ElScrollbar,
// 其他需要的组件
} from "element-plus"
} from "element-plus";
import "element-plus/theme-chalk/index.css"
import "element-plus/dist/index.css"
import "element-plus/theme-chalk/index.css"
import locale from "element-plus/lib/locale/lang/zh-cn"
import "element-plus/theme-chalk/index.css";
import "element-plus/dist/index.css";
import "element-plus/theme-chalk/index.css";
import locale from "element-plus/lib/locale/lang/zh-cn";
import zhCn from "element-plus/dist/locale/zh-cn.mjs"
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
import lazyPlugin from "vue3-lazyload"
import lazyPlugin from "vue3-lazyload";
// import zhCn from 'element-plus/lib/locale/lang/zh-cn'
import api from "./utils/api"
import api from "./utils/api";
//引入封装Axios请求
import Axios from "@/utils/axios"
import Axios from "@/utils/axios";
const app = createApp(App)
const app = createApp(App);
app.use(ElButton)
app.use(ElInput)
app.use(ElSelect)
app.use(ElOption)
app.use(ElLoading)
app.use(ElCheckbox)
app.use(ElCheckboxGroup)
app.use(ElCarousel)
app.use(ElCarouselItem)
app.use(ElBadge)
app.use(ElDropdown)
app.use(ElPopover)
app.use(ElButton);
app.use(ElInput);
app.use(ElSelect);
app.use(ElOption);
app.use(ElLoading);
app.use(ElCheckbox);
app.use(ElCheckboxGroup);
app.use(ElCarousel);
app.use(ElCarouselItem);
app.use(ElBadge);
app.use(ElDropdown);
app.use(ElPopover);
app.use(ElDatePicker, {
locale: zhCn,
})
app.use(ElSkeleton)
app.use(ElSkeletonItem)
app.use(ElMessage)
app.use(ElBreadcrumb)
app.use(ElAffix)
app.use(ElProgress)
});
app.use(ElSkeleton);
app.use(ElSkeletonItem);
app.use(ElMessage);
app.use(ElBreadcrumb);
app.use(ElAffix);
app.use(ElProgress);
app.use(ElConfigProvider)
app.use(ElScrollbar)
app.use(ElConfigProvider);
app.use(ElScrollbar);
app.use(lazyPlugin)
app.use(lazyPlugin);
app.use(store).use(router).use(Axios)
app.use(store).use(router).use(Axios);
api.index()
.then(res => {
const data = res.data
.then((res) => {
const data = res.data;
// const url = import("@/assets/homeImage/informationO.png")
store.state.seachTypeData = data.combination
store.state.indexData = data
store.state.ListSelectBtn = data.recommendedTab
store.state.user = data.user
store.state.nav = data.nav
store.state.wechat = data.wechat
store.state.apartment = data.config.apartment
store.state.schoolList = data.schoolList
store.state.advData = data.adv
store.state.typeKey = data.config.type
store.state.locationKey = data.config.location
console.log("data", data);
store.state.seachTypeData = data.combination;
store.state.indexData = data;
store.state.ListSelectBtn = data.recommendedTab;
store.state.user = data.user;
store.state.nav = data.nav;
store.state.wechat = data.wechat;
store.state.apartment = data.config.apartment;
store.state.schoolList = data.schoolList;
store.state.advData = data.adv;
store.state.typeKey = data.config.type;
store.state.locationKey = data.config.location;
// 将 location 转换为对象 好用于级联选择器
const location = data.config.location || {}
const type = data.config.type || {}
const location = data.config.location || {};
const type = data.config.type || {};
store.state.locationObj = optimalValue(location)
store.state.typeObj = optimalValue(type)
store.state.locationObj = optimalValue(location);
store.state.typeObj = optimalValue(type);
store.state.brandKey = optimalValueArray(data.config.apartment.brand || [])
store.state.roomTypeKey = optimalValueArray(data.config.apartment.roomtype || [])
store.state.roomlistingsKey = optimalValueArray(data.config.apartment.roomlistings || [])
store.state.brandKey = optimalValueArray(data.config.apartment.brand || []);
store.state.roomTypeKey = optimalValueArray(data.config.apartment.roomtype || []);
store.state.roomlistingsKey = optimalValueArray(data.config.apartment.roomlistings || []);
store.state.upload = data.upload || {};
})
.finally(() => {
app.mount("#app")
})
app.mount("#app");
});
// 优化值 1 1.1 1.2 类似的值
const optimalValue = data => {
let obj = {}
const optimalValue = (data) => {
let obj = {};
for (const key in data) {
const [parentKey, childKey] = key.split(".")
const [parentKey, childKey] = key.split(".");
if (!childKey) {
obj[parentKey] = {
name: data[key],
children: {},
}
};
} else {
if (!obj[parentKey].children) obj[parentKey].children = {}
obj[parentKey].children[key] = data[key]
if (!obj[parentKey].children) obj[parentKey].children = {};
obj[parentKey].children[key] = data[key];
}
}
return obj || {}
}
return obj || {};
};
// 优化值 数组 转对象
const optimalValueArray = data => {
let obj = {}
data.forEach(item => {
obj[item.id] = item.name
})
return obj
}
const optimalValueArray = (data) => {
let obj = {};
data.forEach((item) => {
obj[item.id] = item.name;
});
return obj;
};

View File

@@ -33,6 +33,9 @@ export default createStore({
userInfoWin: {},
realname: 1, // 是否已经实名
upload: {}, // 上传 接口后台配置
},
getters: {},
mutations: {

View File

@@ -20,7 +20,7 @@ axios.interceptors.request.use(
if (config.url != "/tenement/pc/api/user/operation" && !noMask) showFullScreenLoading()
// 开发时登录用的,可以直接替换小程序的 authorization
if (process.env.NODE_ENV !== "production") {
const miucms_session = "nlwy6wa5rqr6csaic4u6aqb08bjmqqbg";
const miucms_session = "z5Qz9m995zGmhmq95hpsQ9PeQm90HhHVCcCmUhm5";
document.cookie = "miucms_session=" + miucms_session;
config["headers"]["authorization"] = miucms_session;
}

View File

@@ -314,10 +314,10 @@
<el-popover v-model:visible="areaPopState" placement="bottom" :width="640" :show-arrow="false" trigger="click" popper-style="padding:0; border-radius:16px !important;" :disabled="verified == 1">
<template #reference>
<div ref="location" class="modeOne-item flexacenter" :class="{ disabled: verified == 1 }" style="width: 640px">
<div class="modeOne-text flexacenter" v-if="info['location']">
{{ locationData[Math.floor(info.location)].name }}
<div class="modeOne-text flexacenter" v-if="info['location'] && info['location'] !== '0'">
{{ locationData[Math.floor(info.location)]?.name }}
<img class="form-arrows form-arrows-disabled" src="@/assets/img/edit/thin-arrow-disabled.svg" />
{{ locationData[Math.floor(info.location)].data[info.location] }}
{{ locationData[Math.floor(info.location)]?.data[info.location] }}
</div>
<div class="modeOne-text flexacenter" style="color: #aaaaaa" v-else>请选择</div>
<img class="arrows-icon" src="@/assets/img/edit/arrows.svg" />
@@ -934,7 +934,7 @@ export default {
if (info["floor"]) info["floor"] = Number(info["floor"]);
if (info["rentalduration"]) info["rentalduration"] = Number(info["rentalduration"]);
}
this.fieldinfo = fieldinfo;
this.typeData = typeData;
this.locationData = locationData;
@@ -954,6 +954,7 @@ export default {
});
}
});
this.info = info;
this.verified = data.verified;
@@ -1077,7 +1078,6 @@ export default {
const formData = new FormData();
formData.append("files", file); // 将文件添加到 formData 中
formData.append("data", this.uploadData); // 添加额外的数据参数 data: uploadData
// this.$post("/tenement/pc/api/publish/uploadweixinqrcode",
this.$axios
.post(
"https://oss.gter.net/upload/qrcode",
@@ -1149,16 +1149,20 @@ export default {
this.uploadVideo(type, target);
},
// 上传视频
// 上传视频 和 图片
uploadVideo(type, target) {
let config = this.$store.state.upload;
console.log("config",config);
const formData = new FormData();
formData.append("files", target); // 文件数据
formData.append(config.requestName, target); // 文件数据
formData.append("name", target.name); // 文件名
formData.append("type", type); // 文件名
formData.append("data", this.uploadData); // 文件名
formData.append("data", config.params.data); // 文件名
// this.$axios.post('/tenement/pc/api/publish/upload', formData).then(res => {
this.$axios
.post("https://oss.gter.net/upload", formData)
.post(config.url, formData)
.then((res) => {
res = res["data"];