update: 细节优化
This commit is contained in:
parent
4b4c39ae5a
commit
87bd3b0544
26
src/App.vue
26
src/App.vue
|
@ -1,19 +1,21 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
||||||
const isFirstLaunch = ref(true);
|
// const isFirstLaunch = ref(true);
|
||||||
|
|
||||||
onLaunch(() => {
|
onLaunch(() => {
|
||||||
console.log("App Launch");
|
// console.log(Boolean(uni.getStorageSync("hasLaunched")))
|
||||||
// 当应用启动时,检查是否已显示过启动页
|
// // 当应用启动时,检查是否已显示过启动页
|
||||||
if (Boolean(uni.getStorageSync("hasLaunched"))) {
|
// if (Boolean(uni.getStorageSync("hasLaunched"))) {
|
||||||
// 如果已显示过,不再显示启动页
|
// // 如果已显示过,不再显示启动页
|
||||||
isFirstLaunch.value = false;
|
// isFirstLaunch.value = false;
|
||||||
console.log("不再显示启动页");
|
// console.log("不再显示启动页");
|
||||||
} else {
|
// } else {
|
||||||
// 如果未显示过,标记为已显示,并保存到存储
|
|
||||||
uni.setStorageSync("hasLaunched", true);
|
// // 如果未显示过,标记为已显示,并保存到存储
|
||||||
uni.redirectTo({ url: "pagesLaunch/index" });
|
// uni.redirectTo({ url: "pagesLaunch/index" });
|
||||||
}
|
// uni.setStorageSync("hasLaunched", true);
|
||||||
|
// console.log('******* 执行啦')
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
console.log("App Show");
|
console.log("App Show");
|
||||||
|
|
|
@ -49,7 +49,6 @@ const props = defineProps<{
|
||||||
}>();
|
}>();
|
||||||
const emit = defineEmits(["handleDialog", "changeProduct"]);
|
const emit = defineEmits(["handleDialog", "changeProduct"]);
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
debugger
|
|
||||||
emit("handleDialog", false);
|
emit("handleDialog", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ const development = {
|
||||||
// VITE_APP_BASE_URL: 'http://47.100.31.83:8081',
|
// VITE_APP_BASE_URL: 'http://47.100.31.83:8081',
|
||||||
// VITE_APP_BASE_URL: 'https://47.100.31.83:8081',
|
// VITE_APP_BASE_URL: 'https://47.100.31.83:8081',
|
||||||
// appid: '',
|
// appid: '',
|
||||||
VITE_APP_BASE_URL: 'https://ifanda.52zaisheng.cn/prod',
|
VITE_APP_BASE_URL: 'http://cloud.52zaisheng.cn',
|
||||||
appid: 'wx9251d74fe0e87028',
|
appid: 'wx9251d74fe0e87028',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ const test = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const production = {
|
const production = {
|
||||||
VITE_APP_BASE_URL: 'https://ifanda.52zaisheng.cn/prod',
|
VITE_APP_BASE_URL: 'http://cloud.52zaisheng.cn',
|
||||||
appid: 'wx9251d74fe0e87028',
|
appid: 'wx9251d74fe0e87028',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -496,7 +496,6 @@ const handleUpload = () => {
|
||||||
const handleSelect = (key: string, v: any) => {
|
const handleSelect = (key: string, v: any) => {
|
||||||
contrlModalParams[key].isShow = false;
|
contrlModalParams[key].isShow = false;
|
||||||
if (key === "user") {
|
if (key === "user") {
|
||||||
debugger;
|
|
||||||
model1.order.userName = v.name;
|
model1.order.userName = v.name;
|
||||||
model1.order.userId = v.id;
|
model1.order.userId = v.id;
|
||||||
} else if (key === "product") {
|
} else if (key === "product") {
|
||||||
|
|
|
@ -565,7 +565,21 @@ onMounted(() => {
|
||||||
// #endif
|
// #endif
|
||||||
});
|
});
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
|
if (store.profile?.token) {
|
||||||
init();
|
init();
|
||||||
|
} else {
|
||||||
|
// 当应用启动时,检查是否已显示过启动页
|
||||||
|
if (Boolean(uni.getStorageSync("hasLaunched"))) {
|
||||||
|
// 如果已显示过,不再显示启动页
|
||||||
|
uni.reLaunch({
|
||||||
|
url: "/pagesLogin/login/index",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 如果未显示过,标记为已显示,并保存到存储
|
||||||
|
uni.setStorageSync("hasLaunched", true);
|
||||||
|
uni.reLaunch({ url: "/pagesLaunch/index" });
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<NavBar :count="0" :title="'登陆'"></NavBar>
|
<NavBar :count="0" :title="'登录'"></NavBar>
|
||||||
<LoginLayout>
|
<LoginLayout>
|
||||||
<template #form-box>
|
<template #form-box>
|
||||||
<u-form
|
<u-form
|
||||||
|
@ -9,6 +9,23 @@
|
||||||
ref="loginForm"
|
ref="loginForm"
|
||||||
:labelWidth="0"
|
:labelWidth="0"
|
||||||
>
|
>
|
||||||
|
<u-form-item prop="userInfo.dpName" @click="state.isShow = true">
|
||||||
|
<u-input
|
||||||
|
v-model="model1.userInfo.dpName"
|
||||||
|
:placeholder="`请选择基地名称`"
|
||||||
|
clearable
|
||||||
|
:customStyle="{}"
|
||||||
|
border="none"
|
||||||
|
:disabledColor="''"
|
||||||
|
:disabled="true"
|
||||||
|
>
|
||||||
|
<!-- @change="(e:any) => {handleInput(e, item)}"
|
||||||
|
@clear="handleClear(item)" -->
|
||||||
|
</u-input>
|
||||||
|
<template #right>
|
||||||
|
<u-icon name="arrow-right" color="#dadbde"></u-icon>
|
||||||
|
</template>
|
||||||
|
</u-form-item>
|
||||||
<u-form-item prop="userInfo.userName">
|
<u-form-item prop="userInfo.userName">
|
||||||
<u-input
|
<u-input
|
||||||
v-model="model1.userInfo.userName"
|
v-model="model1.userInfo.userName"
|
||||||
|
@ -19,10 +36,11 @@
|
||||||
'border-color':
|
'border-color':
|
||||||
currentFocus === 'userName' ? '#00dcee !important' : '',
|
currentFocus === 'userName' ? '#00dcee !important' : '',
|
||||||
}"
|
}"
|
||||||
|
border="none"
|
||||||
type="number"
|
type="number"
|
||||||
@focus="handleFocus('userName')"
|
@focus="handleFocus('userName')"
|
||||||
@change="(e:any) => {handleInput(e, 'userName')}"
|
@change="(e:any) => {handleInput(e, 'userName')}"
|
||||||
@clear="handleClear({key: 'userName'})"
|
@clear="handleClear({ key: 'userName' })"
|
||||||
>
|
>
|
||||||
</u-input>
|
</u-input>
|
||||||
</u-form-item>
|
</u-form-item>
|
||||||
|
@ -37,10 +55,11 @@
|
||||||
'border-color':
|
'border-color':
|
||||||
currentFocus === 'password' ? '#00dcee !important' : '',
|
currentFocus === 'password' ? '#00dcee !important' : '',
|
||||||
}"
|
}"
|
||||||
|
border="none"
|
||||||
@focus="handleFocus('password')"
|
@focus="handleFocus('password')"
|
||||||
clearable
|
clearable
|
||||||
@change="(e:any) => {handleInput(e, 'password')}"
|
@change="(e:any) => {handleInput(e, 'password')}"
|
||||||
@clear="handleClear({key: 'password'})"
|
@clear="handleClear({ key: 'password' })"
|
||||||
>
|
>
|
||||||
<template #suffix>
|
<template #suffix>
|
||||||
<image
|
<image
|
||||||
|
@ -109,6 +128,15 @@
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</LoginLayout>
|
</LoginLayout>
|
||||||
|
|
||||||
|
<u-action-sheet
|
||||||
|
:actions="state.dpList"
|
||||||
|
:title="'基地名称'"
|
||||||
|
:show="state.isShow"
|
||||||
|
@select="(v: any) => handleSelect(v)"
|
||||||
|
@close="state.isShow = false"
|
||||||
|
:closeOnClickAction="true"
|
||||||
|
></u-action-sheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
@ -116,8 +144,7 @@ import { ProfileApi } from "@/services/index";
|
||||||
import LoginLayout from "./components/loginLayout.vue";
|
import LoginLayout from "./components/loginLayout.vue";
|
||||||
import { useMemberStore } from "@/store/index";
|
import { useMemberStore } from "@/store/index";
|
||||||
import valid from "@/utils/validate";
|
import valid from "@/utils/validate";
|
||||||
import pinia from '@/store'
|
import pinia from "@/store";
|
||||||
|
|
||||||
|
|
||||||
const handleClear = (item: any) => {
|
const handleClear = (item: any) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -130,6 +157,7 @@ const model1 = reactive({
|
||||||
userInfo: {
|
userInfo: {
|
||||||
userName: "",
|
userName: "",
|
||||||
password: "",
|
password: "",
|
||||||
|
dpName: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// 控制focus 边框样式
|
// 控制focus 边框样式
|
||||||
|
@ -143,6 +171,12 @@ const checkGroup = reactive({
|
||||||
});
|
});
|
||||||
|
|
||||||
const rules = ref({
|
const rules = ref({
|
||||||
|
"userInfo.dpName": {
|
||||||
|
type: "string",
|
||||||
|
required: true,
|
||||||
|
message: "请选择基地名称",
|
||||||
|
trigger: ["blur", "change"],
|
||||||
|
},
|
||||||
"userInfo.userName": {
|
"userInfo.userName": {
|
||||||
type: "string",
|
type: "string",
|
||||||
required: true,
|
required: true,
|
||||||
|
@ -206,7 +240,7 @@ const submit = () => {
|
||||||
ProfileApi.loginByAccount(model1.userInfo).then((res: any) => {
|
ProfileApi.loginByAccount(model1.userInfo).then((res: any) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
store.setProfile(res.data);
|
store.setProfile(res.data);
|
||||||
uni.navigateTo({
|
uni.reLaunch({
|
||||||
url: "/pagesHome/index", // 要跳转到的页面路径
|
url: "/pagesHome/index", // 要跳转到的页面路径
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -258,9 +292,36 @@ const openDoc = (item: string) => {
|
||||||
// },
|
// },
|
||||||
// });
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSelect = (v: any) => {
|
||||||
|
state.isShow = false;
|
||||||
|
state.dpObj = v;
|
||||||
|
model1.userInfo.dpName = v.name;
|
||||||
|
console.log(v.dbIp)
|
||||||
|
store.setChildPath(v.dbIp)
|
||||||
|
};
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
dpList: [],
|
||||||
|
isShow: false,
|
||||||
|
dpObj: {},
|
||||||
|
});
|
||||||
|
// 获取基地信息
|
||||||
|
ProfileApi.getDbInfo({}).then((res) => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
state.dpList = res.data.map((item: any) => {
|
||||||
|
return { name: item.dbName, ...item };
|
||||||
|
});
|
||||||
|
console.log(state.dpList);
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
::v-deep .u-form-item__body__right__content {
|
||||||
|
border-radius: 100px;
|
||||||
|
border: 1px solid #dadbde;
|
||||||
|
}
|
||||||
.custom-icon {
|
.custom-icon {
|
||||||
width: 37.18rpx;
|
width: 37.18rpx;
|
||||||
height: 18.59rpx;
|
height: 18.59rpx;
|
||||||
|
|
|
@ -368,7 +368,7 @@ const handleOk = () => {
|
||||||
ReceiveApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
ReceiveApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pagesReceive/payReview?scaleStatus=2", // 要跳转到的页面路径
|
url: "/pagesReceive/payReview?scaleStatus=" + state.scaleStatus, // 要跳转到的页面路径
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -436,16 +436,15 @@ onLoad((option) => {
|
||||||
state.order[item.enName] = state.order["totalPrice"];
|
state.order[item.enName] = state.order["totalPrice"];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (item.enName === 'buckleMiscellaneous') {
|
if (item.enName === "buckleMiscellaneous") {
|
||||||
if (state.order[item.enName as string]) {
|
if (state.order[item.enName as string]) {
|
||||||
item.num = state.order[item.enName as string];
|
item.num = state.order[item.enName as string];
|
||||||
} else {
|
} else {
|
||||||
item.num = 0
|
item.num = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
item.num = state.order[item.enName as string];
|
item.num = state.order[item.enName as string];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -643,6 +643,8 @@ const updateOrder = () => {
|
||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 根据不同的状态进入返回不同的页面
|
||||||
|
if (scaleStatus.value === ScaleStatus.ToBeShipmentPay) {
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta: 1,
|
delta: 1,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
@ -653,6 +655,12 @@ const updateOrder = () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (scaleStatus.value === ScaleStatus.ShipmentPaid) {
|
||||||
|
uni.redirectTo({
|
||||||
|
url: "/pagesShipment/shipmentSettlement?scaleStatus=4", // 要跳转到的页面路径
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -418,7 +418,6 @@ const updateOrder = () => {
|
||||||
// else if (state.scaleStatus === ScaleStatus.ToBeGrossWeight) {
|
// else if (state.scaleStatus === ScaleStatus.ToBeGrossWeight) {
|
||||||
// status = ScaleStatus.ToBeShipmentReview;
|
// status = ScaleStatus.ToBeShipmentReview;
|
||||||
// }
|
// }
|
||||||
debugger
|
|
||||||
let status = 0;
|
let status = 0;
|
||||||
if (state.scaleStatus === ScaleStatus.ToBeShipment) {
|
if (state.scaleStatus === ScaleStatus.ToBeShipment) {
|
||||||
status = ScaleStatus.ToBeGrossWeight;
|
status = ScaleStatus.ToBeGrossWeight;
|
||||||
|
|
|
@ -80,7 +80,6 @@ const handleScenePhoto = (imagesId: number) => {
|
||||||
};
|
};
|
||||||
const pricingDetail = (id: string) => {
|
const pricingDetail = (id: string) => {
|
||||||
// 待过皮的时候 编辑前先查询当前状态 若是待过皮,则可继续编辑 否则提示该数据已处理 刷新当前页面
|
// 待过皮的时候 编辑前先查询当前状态 若是待过皮,则可继续编辑 否则提示该数据已处理 刷新当前页面
|
||||||
debugger
|
|
||||||
ShipmentApi.getDetailById({ id: id }).then((res: any) => {
|
ShipmentApi.getDetailById({ id: id }).then((res: any) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
if (res.data.scaleStatus > 1) {
|
if (res.data.scaleStatus > 1) {
|
||||||
|
|
|
@ -539,7 +539,9 @@ const handleOk = () => {
|
||||||
ShipmentApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
ShipmentApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pagesShipment/shipmentSettlement?scaleStatus=2", // 要跳转到的页面路径
|
url:
|
||||||
|
"/pagesShipment/shipmentSettlement?scaleStatus=" +
|
||||||
|
state.scaleStatus, // 要跳转到的页面路径
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -591,22 +593,22 @@ const handlePrint = () => {
|
||||||
DeviceApi.print({
|
DeviceApi.print({
|
||||||
id: state.order.id,
|
id: state.order.id,
|
||||||
orderType: OrderType.Shipment,
|
orderType: OrderType.Shipment,
|
||||||
userId: state.order.deviceId
|
userId: state.order.deviceId,
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "打印成功",
|
title: "打印成功",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
onLoad((option) => {
|
onLoad((option:any) => {
|
||||||
state.order.id = (option as any).id;
|
state.order.id = (option as any).id;
|
||||||
state.scaleStatusBtnType = parseInt((option as any).scaleStatusBtnType);
|
state.scaleStatusBtnType = parseInt((option as any).scaleStatusBtnType);
|
||||||
|
state.scaleStatus = parseInt(option.scaleStatus);
|
||||||
uni.$on("shipmentReviewUrlParams", (data) => {
|
uni.$on("shipmentReviewUrlParams", (data) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
state.order.id = data.id;
|
state.order.id = data.id;
|
||||||
|
|
|
@ -171,9 +171,8 @@ const handleReview = (id: string, scaleStatus: number) => {
|
||||||
} else if (scaleStatus === 4) {
|
} else if (scaleStatus === 4) {
|
||||||
type = ScaleStatusBtnType.ShipmentPay;
|
type = ScaleStatusBtnType.ShipmentPay;
|
||||||
}
|
}
|
||||||
console.log("**************", type);
|
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pagesShipment/review/index?id=" + id + `&scaleStatusBtnType=${type}`, // 要跳转到的页面路径
|
url: "/pagesShipment/review/index?id=" + id + `&scaleStatusBtnType=${type}&scaleStatus=${scaleStatus}`, // 要跳转到的页面路径
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
// 存放路径: src/services/home.ts
|
// 存放路径: src/services/home.ts
|
||||||
|
// import { useMemberStore } from "@/store/modules/member";
|
||||||
|
// import pinia from "@/store";
|
||||||
|
// const store = useMemberStore(pinia);
|
||||||
import type { User } from "@/types/user";
|
import type { User } from "@/types/user";
|
||||||
import { http } from "@/utils/http";
|
import { http } from "@/utils/http";
|
||||||
|
// console.log(store.profile.childPath)
|
||||||
// 登陆
|
// 登陆
|
||||||
export const loginByAccount = (data: {
|
export const loginByAccount = (data: {
|
||||||
userName: string;
|
userName: string;
|
||||||
|
@ -250,3 +252,13 @@ export const forgetPwd = (data: any) => {
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 获取基地信息
|
||||||
|
export const getDbInfo = (data: any) => {
|
||||||
|
return http<User>({
|
||||||
|
method: "POST",
|
||||||
|
url: "/prod/gateway/api/db/getDbInfo",
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,31 +8,48 @@ export const useMemberStore = defineStore(
|
||||||
() => {
|
() => {
|
||||||
// 会员信息
|
// 会员信息
|
||||||
const profile = ref<LoginResult>({
|
const profile = ref<LoginResult>({
|
||||||
token: '',
|
token: "",
|
||||||
userInfo: {
|
userInfo: {
|
||||||
userName: "",
|
userName: "",
|
||||||
factoryName: "",
|
factoryName: "",
|
||||||
},
|
},
|
||||||
menusList:[],
|
menusList: [],
|
||||||
menusNameList: []
|
menusNameList: [],
|
||||||
|
childPath: '/test/sh0001'
|
||||||
});
|
});
|
||||||
|
|
||||||
// 保存会员信息,登录时使用
|
// 保存会员信息,登录时使用
|
||||||
const setProfile = (val: any) => {
|
const setProfile = (val: any) => {
|
||||||
profile.value = val;
|
profile.value = {...profile.value, ...val};
|
||||||
profile.value.menusNameList = _.pluck(val.menusList, "name");
|
profile.value.menusNameList = _.pluck(val.menusList, "name");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setChildPath= (v: string) => {
|
||||||
|
profile.value.childPath = v
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 清理会员信息,退出时使用
|
// 清理会员信息,退出时使用
|
||||||
const clearProfile = () => {
|
const clearProfile = () => {
|
||||||
// profile.value = undefined
|
profile.value = {
|
||||||
|
token: "",
|
||||||
|
userInfo: {
|
||||||
|
userName: "",
|
||||||
|
factoryName: "",
|
||||||
|
},
|
||||||
|
menusList: [],
|
||||||
|
menusNameList: [],
|
||||||
|
childPath: ''
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 记得 return
|
// 记得 return
|
||||||
return {
|
return {
|
||||||
profile,
|
profile,
|
||||||
setProfile,
|
setProfile,
|
||||||
clearProfile,
|
setChildPath,
|
||||||
|
clearProfile
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { useMemberStore } from "@/store/modules/member";
|
import { useMemberStore } from "@/store/modules/member";
|
||||||
import ENV_CONFIG from "../config/env";
|
import ENV_CONFIG from "../config/env";
|
||||||
import pinia from '@/store'
|
import pinia from "@/store";
|
||||||
|
|
||||||
// 基础地址
|
// 基础地址
|
||||||
let baseUrl = "";
|
let baseUrl = "";
|
||||||
|
@ -8,10 +8,8 @@ let baseUrl = "";
|
||||||
(process.env as any).config = ENV_CONFIG;
|
(process.env as any).config = ENV_CONFIG;
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
baseUrl = (process.env as any).config[(process.env as any).NODE_ENV]
|
|
||||||
.VITE_APP_BASE_URL;
|
|
||||||
|
|
||||||
const store = useMemberStore(pinia);
|
const store = useMemberStore(pinia);
|
||||||
|
baseUrl = (process.env as any).config[(process.env as any).NODE_ENV].VITE_APP_BASE_URL;
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
// 拦截前触发
|
// 拦截前触发
|
||||||
|
@ -20,8 +18,13 @@ const obj = {
|
||||||
options.timeout = 10000;
|
options.timeout = 10000;
|
||||||
// 拼接完整路径
|
// 拼接完整路径
|
||||||
if (!options.url.startsWith("http")) {
|
if (!options.url.startsWith("http")) {
|
||||||
|
if ('/prod/gateway/api/db/getDbInfo' !== options.url) {
|
||||||
|
options.url = baseUrl + store.profile.childPath + options.url;
|
||||||
|
} else {
|
||||||
options.url = baseUrl + options.url;
|
options.url = baseUrl + options.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// 请求头标识
|
// 请求头标识
|
||||||
// 1.小程序唯一标识
|
// 1.小程序唯一标识
|
||||||
// 'source-client': 'miniapp'
|
// 'source-client': 'miniapp'
|
||||||
|
@ -79,20 +82,23 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
resolve(err as any)
|
resolve(err as any);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
uni.request({
|
uni.request({
|
||||||
...options,
|
...options,
|
||||||
dataType:'string', //1.先将dataType设置为string
|
dataType: "string", //1.先将dataType设置为string
|
||||||
success(res) {
|
success(res) {
|
||||||
var json=(res.data as any).replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2')
|
var json = (res.data as any).replace(
|
||||||
|
/:s*([0-9]{15,})s*(,?)/g,
|
||||||
|
': "$1" $2'
|
||||||
|
);
|
||||||
//2.根据后端返回的数据调用一次或者两次replace替换
|
//2.根据后端返回的数据调用一次或者两次replace替换
|
||||||
var json1=json.replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2')
|
var json1 = json.replace(/:s*([0-9]{15,})s*(,?)/g, ': "$1" $2');
|
||||||
//3.手动转换回json数据即可
|
//3.手动转换回json数据即可
|
||||||
let res1:any = JSON.parse(json1);
|
let res1: any = JSON.parse(json1);
|
||||||
console.log(res1)
|
console.log(res1);
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
if (
|
if (
|
||||||
res1.code === 1001 ||
|
res1.code === 1001 ||
|
||||||
|
@ -109,12 +115,12 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
||||||
url: "/pagesLogin/login/index",
|
url: "/pagesLogin/login/index",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}else if ((res1 as any).code === 10001) {
|
} else if ((res1 as any).code === 10001) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
title: (res1 as Data<T>).message || "请求失败",
|
title: (res1 as Data<T>).message || "请求失败",
|
||||||
});
|
});
|
||||||
return
|
return;
|
||||||
} else if ((res1 as any).code === 5001) {
|
} else if ((res1 as any).code === 5001) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
icon: "none",
|
icon: "none",
|
||||||
|
|
Loading…
Reference in New Issue