Compare commits
No commits in common. "447d9ab591c3635acbaae8c8f891515e1d3b84de" and "f433f725cd42428f6437f303ade0f1a89a386fd1" have entirely different histories.
447d9ab591
...
f433f725cd
26
src/App.vue
26
src/App.vue
|
@ -1,21 +1,19 @@
|
|||
<script setup lang="ts">
|
||||
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
||||
// const isFirstLaunch = ref(true);
|
||||
const isFirstLaunch = ref(true);
|
||||
|
||||
onLaunch(() => {
|
||||
// console.log(Boolean(uni.getStorageSync("hasLaunched")))
|
||||
// // 当应用启动时,检查是否已显示过启动页
|
||||
// if (Boolean(uni.getStorageSync("hasLaunched"))) {
|
||||
// // 如果已显示过,不再显示启动页
|
||||
// isFirstLaunch.value = false;
|
||||
// console.log("不再显示启动页");
|
||||
// } else {
|
||||
|
||||
// // 如果未显示过,标记为已显示,并保存到存储
|
||||
// uni.redirectTo({ url: "pagesLaunch/index" });
|
||||
// uni.setStorageSync("hasLaunched", true);
|
||||
// console.log('******* 执行啦')
|
||||
// }
|
||||
console.log("App Launch");
|
||||
// 当应用启动时,检查是否已显示过启动页
|
||||
if (Boolean(uni.getStorageSync("hasLaunched"))) {
|
||||
// 如果已显示过,不再显示启动页
|
||||
isFirstLaunch.value = false;
|
||||
console.log("不再显示启动页");
|
||||
} else {
|
||||
// 如果未显示过,标记为已显示,并保存到存储
|
||||
uni.setStorageSync("hasLaunched", true);
|
||||
uni.redirectTo({ url: "pagesLaunch/index" });
|
||||
}
|
||||
});
|
||||
onShow(() => {
|
||||
console.log("App Show");
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
<view
|
||||
>{{ state.type === "1" ? "应付" : "应收" }}金额:<text class="num"
|
||||
>¥{{
|
||||
state.type === "1"
|
||||
? formatMoney(item.balanceTotalPrice)
|
||||
: formatMoney(item.totalPrice)
|
||||
state.type === "1" ? formatMoney(item.balanceTotalPrice) : formatMoney(item.totalPrice)
|
||||
}}</text
|
||||
></view
|
||||
>
|
||||
|
@ -87,25 +85,22 @@ const getList = (v?: boolean) => {
|
|||
ReceiveApi.getOrderPage(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
pageList.isLoading = false;
|
||||
pageList.list = pageList.list.concat(
|
||||
res.data.list.map((item: any) => {
|
||||
(pageList as any).list = (res.data.list as any).map((item: any) => {
|
||||
return { ...item, isChecked: false };
|
||||
})
|
||||
);
|
||||
});
|
||||
pageList.total = (res.data as any).total;
|
||||
|
||||
}
|
||||
});
|
||||
} else if (state.type === "2") {
|
||||
ShipmentApi.getOrderPage(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
pageList.isLoading = false;
|
||||
|
||||
pageList.list = pageList.list.concat(
|
||||
res.data.list.map((item: any) => {
|
||||
(pageList as any).list = (res.data.list as any).map((item: any) => {
|
||||
return { ...item, isChecked: false };
|
||||
})
|
||||
);
|
||||
});
|
||||
pageList.total = (res.data as any).total;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -79,10 +79,13 @@ const handleSelect = (item: any) => {
|
|||
};
|
||||
const getList = () => {
|
||||
if (props.isShipment) {
|
||||
|
||||
GoodsApi.getChildrenList().then((res) => {
|
||||
if (res.code === 200) {
|
||||
if (res.code === 200) {
|
||||
state.list = res.data;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ReceiveProductApi.getAllReProducts().then((res) => {
|
||||
|
|
|
@ -49,6 +49,7 @@ const props = defineProps<{
|
|||
}>();
|
||||
const emit = defineEmits(["handleDialog", "changeProduct"]);
|
||||
const handleClose = () => {
|
||||
debugger
|
||||
emit("handleDialog", false);
|
||||
};
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ const gridList2 = reactive([
|
|||
]);
|
||||
const handleScenePhoto = (id: string) => {
|
||||
uni.navigateTo({
|
||||
url: "/pagesScenePhoto/index?orderType=2&imagesType=1&id=" + id, // 要跳转到的页面路径
|
||||
url: "/pagesScenePhoto/index?orderType=1&imagesType=1&id=" + id, // 要跳转到的页面路径
|
||||
});
|
||||
};
|
||||
const state = reactive<any>({
|
||||
|
|
|
@ -19,8 +19,8 @@ const props = withDefaults(
|
|||
}
|
||||
);
|
||||
const navbarRect = reactive({
|
||||
height: 42,
|
||||
top: 48,
|
||||
height: 32,
|
||||
top: 28,
|
||||
safeHeight: 500,
|
||||
});
|
||||
const getSafeHeight = () => {
|
||||
|
|
|
@ -67,8 +67,8 @@ const props = withDefaults(
|
|||
);
|
||||
|
||||
const navbarRect = reactive({
|
||||
height: 42,
|
||||
top: 48,
|
||||
height: 32,
|
||||
top: 28,
|
||||
msgCount: 10,
|
||||
});
|
||||
onMounted(() => {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
const navbarRect = reactive({
|
||||
height: 42,
|
||||
top: 48,
|
||||
height: 32,
|
||||
top: 28,
|
||||
msgCount: 10,
|
||||
});
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const development = {
|
|||
// VITE_APP_BASE_URL: 'http://47.100.31.83:8081',
|
||||
// VITE_APP_BASE_URL: 'https://47.100.31.83:8081',
|
||||
// appid: '',
|
||||
VITE_APP_BASE_URL: 'https://cloud.52zaisheng.cn',
|
||||
VITE_APP_BASE_URL: 'https://ifanda.52zaisheng.cn/prod',
|
||||
appid: 'wx9251d74fe0e87028',
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ const test = {
|
|||
}
|
||||
|
||||
const production = {
|
||||
VITE_APP_BASE_URL: 'https://cloud.52zaisheng.cn',
|
||||
VITE_APP_BASE_URL: 'https://ifanda.52zaisheng.cn/prod',
|
||||
appid: 'wx9251d74fe0e87028',
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,11 @@
|
|||
"appid" : "__UNI__898003A",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : 100,
|
||||
"versionCode" : "100",
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
"compatible" : {
|
||||
"ignoreVersion" : true
|
||||
},
|
||||
"ignoreVersion": false,
|
||||
"usingComponents" : true,
|
||||
"nvueStyleCompiler" : "uni-app",
|
||||
"compilerVersion" : 3,
|
||||
|
|
|
@ -83,10 +83,8 @@ const handleInput = (e: any, item: any) => {
|
|||
icon: "none",
|
||||
});
|
||||
}
|
||||
const minPrice = parseFloat(model1.formData.minPrice)
|
||||
const maxPrice = parseFloat(model1.formData.maxPrice)
|
||||
if (item.key === "maxPrice") {
|
||||
if (minPrice > maxPrice) {
|
||||
if (model1.formData.minPrice > model1.formData.maxPrice) {
|
||||
uni.showToast({
|
||||
title: `${item.name}应小于${model1.formData.maxPrice}`,
|
||||
icon: "none",
|
||||
|
@ -95,10 +93,10 @@ const handleInput = (e: any, item: any) => {
|
|||
}
|
||||
}
|
||||
if (item.key === "commonPrice") {
|
||||
if (minPrice > -1 && maxPrice > -1) {
|
||||
if (model1.formData.minPrice > -1 && model1.formData.maxPrice > -1) {
|
||||
if (
|
||||
!(temp >= minPrice &&
|
||||
temp <= maxPrice)
|
||||
temp < model1.formData.minPrice ||
|
||||
temp > model1.formData.maxPrice
|
||||
) {
|
||||
uni.showToast({
|
||||
title: `${item.name}应在${model1.formData.minPrice}-${model1.formData.maxPrice}之间`,
|
||||
|
@ -255,20 +253,16 @@ const check = () => {
|
|||
};
|
||||
|
||||
const save = () => {
|
||||
const minPrice = parseFloat(model1.formData.minPrice)
|
||||
const maxPrice = parseFloat(model1.formData.maxPrice)
|
||||
if (minPrice > maxPrice) {
|
||||
if (model1.formData.minPrice > model1.formData.maxPrice) {
|
||||
uni.showToast({
|
||||
title: `最低价应小于${model1.formData.maxPrice}`,
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (minPrice > -1 &&maxPrice > -1) {
|
||||
|
||||
if (model1.formData.minPrice > -1 && model1.formData.maxPrice > -1) {
|
||||
const temp = model1.formData.commonPrice;
|
||||
if (!(temp >= minPrice && temp <= maxPrice)) {
|
||||
if (temp < model1.formData.minPrice || temp > model1.formData.maxPrice) {
|
||||
uni.showToast({
|
||||
title: `常用价格应在${model1.formData.minPrice}-${model1.formData.maxPrice}之间`,
|
||||
icon: "none",
|
||||
|
@ -276,6 +270,7 @@ const save = () => {
|
|||
return;
|
||||
}
|
||||
}
|
||||
console.log(model1.formData);
|
||||
check().then((res) => {
|
||||
if (res) {
|
||||
startSave();
|
||||
|
|
|
@ -65,7 +65,7 @@ const handleModal = (v: boolean, id: number) => {
|
|||
deleteId.value = id;
|
||||
};
|
||||
const handleOk = () => {
|
||||
deleteCustomer({ id: deleteId.value });
|
||||
deleteCustomer({id: deleteId.value})
|
||||
};
|
||||
const state = reactive<any>({
|
||||
name: "",
|
||||
|
@ -125,16 +125,16 @@ const getList = (v?: boolean) => {
|
|||
params.supplierTypeId = state.supplierTypeId;
|
||||
}
|
||||
pageList.isLoading = true;
|
||||
CustomerApi.getCustomUserPage(params).then((res: any) => {
|
||||
CustomerApi.getCustomUserPage(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
pageList.isLoading = false;
|
||||
pageList.list = pageList.list = pageList.list.concat(res.data.list);
|
||||
pageList.total = res.data.total;
|
||||
(pageList as any).list = (res.data as any).list;
|
||||
pageList.total = (res.data as any).total;
|
||||
}
|
||||
});
|
||||
};
|
||||
onShow(() => {
|
||||
resetPageList();
|
||||
resetPageList()
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
<u-swipe-action-item
|
||||
:options="options1"
|
||||
v-for="(item, index) in pageList.list"
|
||||
:disabled="[1].indexOf(item.paymentType) === -1"
|
||||
:key="index"
|
||||
@click="handleItem(item)"
|
||||
>
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
<u-swipe-action-item
|
||||
:options="options1"
|
||||
v-for="(item, index) in pageList.list"
|
||||
:disabled="[2,3].indexOf(item.paymentType) === -1"
|
||||
:key="index"
|
||||
@click="handleItem(item)"
|
||||
>
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
<view class="type">{{ item.productName }}</view>
|
||||
<view class="flex-box">
|
||||
<text>定价人:{{ item.pricingUserName }}</text>
|
||||
<!-- 过毛时间 -->
|
||||
<text>过磅时间:{{ item.grossTime }}</text>
|
||||
<text>过磅时间:{{ item.tareTime }}</text>
|
||||
</view>
|
||||
|
||||
<view class="more">
|
||||
|
|
|
@ -496,6 +496,7 @@ const handleUpload = () => {
|
|||
const handleSelect = (key: string, v: any) => {
|
||||
contrlModalParams[key].isShow = false;
|
||||
if (key === "user") {
|
||||
debugger;
|
||||
model1.order.userName = v.name;
|
||||
model1.order.userId = v.id;
|
||||
} else if (key === "product") {
|
||||
|
|
|
@ -25,20 +25,16 @@
|
|||
:isLoading="pageList.isLoading"
|
||||
>
|
||||
<view class="box">
|
||||
<block v-for="(item, index) in pageList.list" :key="index">
|
||||
<view v-if="item.roleName !== '超级管理员'">
|
||||
<view v-for="(item, index) in pageList.list" :key="index">
|
||||
<view>
|
||||
<view>{{ item.roleName }}</view>
|
||||
</view>
|
||||
<view class="op-box">
|
||||
<view class="btn" @click="edit(item)"> 编辑 </view>
|
||||
<view class="btn" @click="handleModal(true, item.id)">
|
||||
删除
|
||||
<view class="btn" @click="handleModal(true, item.id)"> 删除 </view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</page-view>
|
||||
</view>
|
||||
|
||||
|
@ -64,7 +60,7 @@ const handleModal = (v: boolean, id: number) => {
|
|||
deleteId.value = id;
|
||||
};
|
||||
const handleOk = () => {
|
||||
deleteRole({ id: deleteId.value });
|
||||
deleteRole({id: deleteId.value})
|
||||
};
|
||||
|
||||
const state = reactive<any>({
|
||||
|
@ -72,7 +68,7 @@ const state = reactive<any>({
|
|||
});
|
||||
const pageList: PageResult<{
|
||||
roleName: string;
|
||||
id: number;
|
||||
id: number
|
||||
}> = reactive({
|
||||
noMoreData: false,
|
||||
total: 0,
|
||||
|
@ -102,13 +98,13 @@ const edit = (item: any) => {
|
|||
const deleteRole = (item: any) => {
|
||||
ProfileApi.updateRole({ isDeleted: true, id: item.id }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
resetPageList();
|
||||
resetPageList()
|
||||
getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleSearch = () => {
|
||||
resetPageList();
|
||||
resetPageList()
|
||||
getList();
|
||||
};
|
||||
const getList = (v?: boolean) => {
|
||||
|
@ -125,15 +121,17 @@ const getList = (v?: boolean) => {
|
|||
};
|
||||
pageList.isLoading = true;
|
||||
ProfileApi.getRoleList(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
if (res.code === 200) {
|
||||
pageList.isLoading = false;
|
||||
(pageList as any).list = res.data as any;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onShow(() => {
|
||||
resetPageList();
|
||||
resetPageList()
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -171,7 +171,7 @@ const gridList1 = reactive([
|
|||
]);
|
||||
const handleScenePhoto = (id: string) => {
|
||||
uni.navigateTo({
|
||||
url: "/pagesScenePhoto/index?orderType=2&imagesType=1&id=" + id, // 要跳转到的页面路径
|
||||
url: "/pagesScenePhoto/index?orderType=1&imagesType=1&id=" + id, // 要跳转到的页面路径
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@ const gridList1 = reactive([
|
|||
]);
|
||||
const handleScenePhoto = (id: string) => {
|
||||
uni.navigateTo({
|
||||
url: "/pagesScenePhoto/index?orderType=2&imagesType=1&id=" + id, // 要跳转到的页面路径
|
||||
url: "/pagesScenePhoto/index?orderType=1&imagesType=1&id=" + id, // 要跳转到的页面路径
|
||||
});
|
||||
};
|
||||
const getScaleStatus = (type: number) => {
|
||||
|
|
|
@ -71,7 +71,7 @@ const handleModal = (v: boolean, id: number) => {
|
|||
deleteId.value = id;
|
||||
};
|
||||
const handleOk = () => {
|
||||
deleteStockCard({ id: deleteId.value });
|
||||
deleteStockCard({id: deleteId.value})
|
||||
};
|
||||
|
||||
const state = reactive<any>({
|
||||
|
@ -131,18 +131,17 @@ const getList = (v?: boolean) => {
|
|||
if (state.supplierTypeId > -1) {
|
||||
params.supplierTypeId = state.supplierTypeId;
|
||||
}
|
||||
pageList.isLoading = true;
|
||||
StockCardApi.getStockCardList(params).then((res: any) => {
|
||||
StockCardApi.getStockCardList(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
pageList.isLoading = false;
|
||||
pageList.list = pageList.list = pageList.list.concat(res.data.list);
|
||||
pageList.total = res.data.total;
|
||||
if (res.code === 200) {
|
||||
(pageList as any).list = (res.data as any).list;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onShow(() => {
|
||||
resetPageList();
|
||||
resetPageList()
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -169,8 +169,8 @@ import pinia from "@/store";
|
|||
|
||||
const store = useMemberStore(pinia);
|
||||
const navbarRect = reactive({
|
||||
height: 42,
|
||||
top: 48,
|
||||
height: 32,
|
||||
top: 28,
|
||||
safeHeight: 500,
|
||||
});
|
||||
|
||||
|
@ -393,7 +393,7 @@ const appList = reactive([
|
|||
},
|
||||
},
|
||||
{
|
||||
icon: "11.png",
|
||||
icon: "09.png",
|
||||
title: "收货产品",
|
||||
fn: () => {
|
||||
uni.navigateTo({
|
||||
|
@ -411,7 +411,7 @@ const appList = reactive([
|
|||
},
|
||||
},
|
||||
{
|
||||
icon: "09.png",
|
||||
icon: "11.png",
|
||||
title: "出货产品",
|
||||
fn: () => {
|
||||
uni.navigateTo({
|
||||
|
@ -565,21 +565,7 @@ onMounted(() => {
|
|||
// #endif
|
||||
});
|
||||
onShow(() => {
|
||||
if (store.profile?.token) {
|
||||
init();
|
||||
} else {
|
||||
// 当应用启动时,检查是否已显示过启动页
|
||||
if (Boolean(uni.getStorageSync("hasLaunched"))) {
|
||||
// 如果已显示过,不再显示启动页
|
||||
uni.reLaunch({
|
||||
url: "/pagesLogin/login/index",
|
||||
});
|
||||
} else {
|
||||
// 如果未显示过,标记为已显示,并保存到存储
|
||||
uni.setStorageSync("hasLaunched", true);
|
||||
uni.reLaunch({ url: "/pagesLaunch/index" });
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -670,7 +656,7 @@ onShow(() => {
|
|||
// display: flex;
|
||||
// align-items: center;
|
||||
position: relative;
|
||||
// top: 50%;
|
||||
top: 50%;
|
||||
// transform: translateY(-50%);
|
||||
.num {
|
||||
font-size: 32rpx;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<NavBar :count="0" :title="'登录'"></NavBar>
|
||||
<NavBar :count="0" :title="'登陆'"></NavBar>
|
||||
<LoginLayout>
|
||||
<template #form-box>
|
||||
<u-form
|
||||
|
@ -9,23 +9,6 @@
|
|||
ref="loginForm"
|
||||
: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-input
|
||||
v-model="model1.userInfo.userName"
|
||||
|
@ -36,7 +19,6 @@
|
|||
'border-color':
|
||||
currentFocus === 'userName' ? '#00dcee !important' : '',
|
||||
}"
|
||||
border="none"
|
||||
type="number"
|
||||
@focus="handleFocus('userName')"
|
||||
@change="(e:any) => {handleInput(e, 'userName')}"
|
||||
|
@ -55,7 +37,6 @@
|
|||
'border-color':
|
||||
currentFocus === 'password' ? '#00dcee !important' : '',
|
||||
}"
|
||||
border="none"
|
||||
@focus="handleFocus('password')"
|
||||
clearable
|
||||
@change="(e:any) => {handleInput(e, 'password')}"
|
||||
|
@ -128,15 +109,6 @@
|
|||
</view>
|
||||
</template>
|
||||
</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>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
@ -144,7 +116,8 @@ import { ProfileApi } from "@/services/index";
|
|||
import LoginLayout from "./components/loginLayout.vue";
|
||||
import { useMemberStore } from "@/store/index";
|
||||
import valid from "@/utils/validate";
|
||||
import pinia from "@/store";
|
||||
import pinia from '@/store'
|
||||
|
||||
|
||||
const handleClear = (item: any) => {
|
||||
setTimeout(() => {
|
||||
|
@ -157,7 +130,6 @@ const model1 = reactive({
|
|||
userInfo: {
|
||||
userName: "",
|
||||
password: "",
|
||||
dpName: "",
|
||||
},
|
||||
});
|
||||
// 控制focus 边框样式
|
||||
|
@ -171,12 +143,6 @@ const checkGroup = reactive({
|
|||
});
|
||||
|
||||
const rules = ref({
|
||||
"userInfo.dpName": {
|
||||
type: "string",
|
||||
required: true,
|
||||
message: "请选择基地名称",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
"userInfo.userName": {
|
||||
type: "string",
|
||||
required: true,
|
||||
|
@ -240,7 +206,7 @@ const submit = () => {
|
|||
ProfileApi.loginByAccount(model1.userInfo).then((res: any) => {
|
||||
if (res.code === 200) {
|
||||
store.setProfile(res.data);
|
||||
uni.reLaunch({
|
||||
uni.navigateTo({
|
||||
url: "/pagesHome/index", // 要跳转到的页面路径
|
||||
});
|
||||
}
|
||||
|
@ -292,36 +258,9 @@ 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 };
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .u-form-item__body__right__content {
|
||||
border-radius: 100px;
|
||||
border: 1px solid #dadbde;
|
||||
}
|
||||
.custom-icon {
|
||||
width: 37.18rpx;
|
||||
height: 18.59rpx;
|
||||
|
|
|
@ -551,15 +551,10 @@ watch(
|
|||
}
|
||||
}
|
||||
model1.order.totalPrice =
|
||||
Math.round(
|
||||
(model1.order.price || 0) * (model1.order.netWeight || 0) * 100
|
||||
) / 100;
|
||||
|
||||
(model1.order.price || 0) * (model1.order.netWeight || 0);
|
||||
// 货款金额默认=预估总价,当系统自动算出预估总价时,值需同步
|
||||
if (<number>model1.order.balanceTotalPrice <= 0) {
|
||||
model1.order.balanceTotalPrice = model1.order.totalPrice;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// SupplierApi.getSupplierUserList({}).then((res) => {
|
||||
|
@ -567,16 +562,16 @@ watch(
|
|||
// contrlModalParams.userSelect.list = res.data;
|
||||
// }
|
||||
// });
|
||||
// ReceiveProductApi.getAllReProducts().then((res) => {
|
||||
// if (res.code === 200) {
|
||||
// contrlModalParams.productSelect.list = _.map(
|
||||
// res.data as any,
|
||||
// function (item: any) {
|
||||
// return { name: item.reProductsName, ...item };
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// });
|
||||
ReceiveProductApi.getAllReProducts().then((res) => {
|
||||
if (res.code === 200) {
|
||||
contrlModalParams.productSelect.list = _.map(
|
||||
res.data as any,
|
||||
function (item: any) {
|
||||
return { name: item.reProductsName, ...item };
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
const handleSelect = (key: string, v: any) => {
|
||||
contrlModalParams[key].isShow = false;
|
||||
if (key === "userSelect") {
|
||||
|
@ -595,6 +590,7 @@ const handleBack = () => {
|
|||
// const files = ref<FileObj[]>([]);
|
||||
const filesRef = ref();
|
||||
const handleUpload = () => {
|
||||
// console.log(event.tempFilePaths)
|
||||
return filesRef.value[0].filesList.map((item: any, index: number) => {
|
||||
if (item.fileID) {
|
||||
return;
|
||||
|
@ -625,6 +621,7 @@ const handleUpload = () => {
|
|||
*
|
||||
*/
|
||||
const handleDelete = (e: any) => {
|
||||
console.log(model1.order.fileLists);
|
||||
if (e.tempFile.fileID) {
|
||||
PictureApi.deleteById({ id: e.tempFile.fileID }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
|
@ -706,14 +703,9 @@ const save = () => {
|
|||
};
|
||||
const startSave = () => {
|
||||
Promise.all(handleUpload()).then((res) => {
|
||||
console.log("***** 所有文件已经上传成功", res);
|
||||
if (res.filter((item) => item).length > 0) {
|
||||
PictureApi.addListAnnex({ annexPos: res.filter((item) => item) }).then(
|
||||
(res1) => {
|
||||
console.log(
|
||||
"***** 关联的内容是",
|
||||
res.filter((item) => item)
|
||||
);
|
||||
if (res1.code === 200) {
|
||||
console.log("*** 资源文件更新成功");
|
||||
}
|
||||
|
@ -732,8 +724,6 @@ const updateOrder = () => {
|
|||
零皮重 scaleState = 2 带审核
|
||||
*/
|
||||
// 若是补单数据 则不做此判断
|
||||
// 到待审核状态不用关心补单的逻辑
|
||||
if (<number>model1.order.scaleStatus < 2) {
|
||||
if (!model1.order.repairFlag) {
|
||||
if (model1.order.weighingMethod === 0) {
|
||||
model1.order.scaleStatus = 1;
|
||||
|
@ -741,7 +731,6 @@ const updateOrder = () => {
|
|||
model1.order.scaleStatus = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
/**
|
||||
|
@ -813,7 +802,7 @@ onLoad((option) => {
|
|||
});
|
||||
PictureApi.getAnnex({
|
||||
businessId: model1.order.id.toString(),
|
||||
orderType: OrderType.Receive,
|
||||
orderType: 1,
|
||||
imagesType: ImagesType.NORMARL,
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
|
@ -823,7 +812,7 @@ onLoad((option) => {
|
|||
}
|
||||
|
||||
uni.$on("pricingParams", (data) => {
|
||||
model1.order.userName = data.name;
|
||||
model1.order.userName = data.name
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -210,7 +210,6 @@ const resetPageList = () => {
|
|||
};
|
||||
const currentTab = ref(2);
|
||||
const handleTab = (item: any) => {
|
||||
state.isAll = false;
|
||||
currentTab.value = item.key;
|
||||
resetPageList();
|
||||
getList();
|
||||
|
@ -289,14 +288,12 @@ const getList = (v?: boolean) => {
|
|||
pageNumber: pageList.pageNum,
|
||||
scaleStatus: currentTab.value,
|
||||
userName: keyword.value
|
||||
}).then((res:any) => {
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
pageList.isLoading = false;
|
||||
pageList.list = pageList.list.concat(
|
||||
res.data.list.map((item: any) => {
|
||||
(pageList as any).list = (res.data.list as any).map((item: any) => {
|
||||
return { ...item, isChecked: false };
|
||||
})
|
||||
);
|
||||
});
|
||||
pageList.total = (res.data as any).total;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -151,7 +151,6 @@ const getList = (v?: boolean) => {
|
|||
const handleOk = () => {
|
||||
ReceiveApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
resetPageList();
|
||||
getList();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -299,9 +299,7 @@ const handleScenePhoto = (id: any) => {
|
|||
};
|
||||
// 审核暂不支付 // 更新状态为3
|
||||
const handleReviewNoPay = () => {
|
||||
ReceiveApi.updateOrderIn({
|
||||
orderInPos: [{ ...state.order, scaleStatus: 3 }],
|
||||
}).then((res) => {
|
||||
ReceiveApi.updateOne({ ...state.order, scaleStatus: 3 }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.redirectTo({
|
||||
url: "/pagesReceive/payReview?scaleStatus=3", // 要跳转到的页面路径
|
||||
|
@ -368,7 +366,7 @@ const handleOk = () => {
|
|||
ReceiveApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.redirectTo({
|
||||
url: "/pagesReceive/payReview?scaleStatus=" + state.scaleStatus, // 要跳转到的页面路径
|
||||
url: "/pagesReceive/payReview?scaleStatus=2", // 要跳转到的页面路径
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -397,12 +395,12 @@ const handlePrint = () => {
|
|||
DeviceApi.print({
|
||||
id: state.order.id,
|
||||
orderType: OrderType.Receive,
|
||||
userId: state.order.deviceId,
|
||||
userId: state.order.deviceId
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: "打印成功",
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -436,15 +434,7 @@ onLoad((option) => {
|
|||
state.order[item.enName] = state.order["totalPrice"];
|
||||
}
|
||||
} else {
|
||||
if (item.enName === "buckleMiscellaneous") {
|
||||
if (state.order[item.enName as string]) {
|
||||
item.num = state.order[item.enName as string];
|
||||
} else {
|
||||
item.num = 0;
|
||||
}
|
||||
} else {
|
||||
item.num = state.order[item.enName as string];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -113,14 +113,7 @@ const handleClear = (item: any) => {
|
|||
};
|
||||
const isShowFormItem = (item: any) => {
|
||||
if (model1.scaleStatusBtnType === ScaleStatusBtnType.ShipmentPay) {
|
||||
if (
|
||||
model1.order.deliveryMethod === 1 &&
|
||||
["freight", "incidentals"].indexOf(item.key) > -1
|
||||
) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return (
|
||||
item.key !== "paymentMethodName" &&
|
||||
|
@ -643,8 +636,6 @@ const updateOrder = () => {
|
|||
icon: "success",
|
||||
});
|
||||
|
||||
// 根据不同的状态进入返回不同的页面
|
||||
if (scaleStatus.value === ScaleStatus.ToBeShipmentPay) {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
success: (res) => {
|
||||
|
@ -655,12 +646,6 @@ const updateOrder = () => {
|
|||
},
|
||||
});
|
||||
}
|
||||
if (scaleStatus.value === ScaleStatus.ShipmentPaid) {
|
||||
uni.redirectTo({
|
||||
url: "/pagesShipment/shipmentSettlement?scaleStatus=4", // 要跳转到的页面路径
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -418,6 +418,7 @@ const updateOrder = () => {
|
|||
// else if (state.scaleStatus === ScaleStatus.ToBeGrossWeight) {
|
||||
// status = ScaleStatus.ToBeShipmentReview;
|
||||
// }
|
||||
debugger
|
||||
let status = 0;
|
||||
if (state.scaleStatus === ScaleStatus.ToBeShipment) {
|
||||
status = ScaleStatus.ToBeGrossWeight;
|
||||
|
|
|
@ -80,6 +80,7 @@ const handleScenePhoto = (imagesId: number) => {
|
|||
};
|
||||
const pricingDetail = (id: string) => {
|
||||
// 待过皮的时候 编辑前先查询当前状态 若是待过皮,则可继续编辑 否则提示该数据已处理 刷新当前页面
|
||||
debugger
|
||||
ShipmentApi.getDetailById({ id: id }).then((res: any) => {
|
||||
if (res.code === 200) {
|
||||
if (res.data.scaleStatus > 1) {
|
||||
|
@ -119,9 +120,9 @@ const getList = (v?: boolean) => {
|
|||
});
|
||||
};
|
||||
const handleOk = () => {
|
||||
console.log(deleteId.value);
|
||||
ShipmentApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
resetPageList();
|
||||
getList();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -539,9 +539,7 @@ const handleOk = () => {
|
|||
ShipmentApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.navigateTo({
|
||||
url:
|
||||
"/pagesShipment/shipmentSettlement?scaleStatus=" +
|
||||
state.scaleStatus, // 要跳转到的页面路径
|
||||
url: "/pagesShipment/shipmentSettlement?scaleStatus=2", // 要跳转到的页面路径
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -593,22 +591,22 @@ const handlePrint = () => {
|
|||
DeviceApi.print({
|
||||
id: state.order.id,
|
||||
orderType: OrderType.Shipment,
|
||||
userId: state.order.deviceId,
|
||||
userId: state.order.deviceId
|
||||
}).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.showToast({
|
||||
title: "打印成功",
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
onShow(() => {
|
||||
init();
|
||||
});
|
||||
onLoad((option:any) => {
|
||||
onLoad((option) => {
|
||||
state.order.id = (option as any).id;
|
||||
state.scaleStatusBtnType = parseInt((option as any).scaleStatusBtnType);
|
||||
state.scaleStatus = parseInt(option.scaleStatus);
|
||||
|
||||
uni.$on("shipmentReviewUrlParams", (data) => {
|
||||
console.log(data);
|
||||
state.order.id = data.id;
|
||||
|
|
|
@ -37,12 +37,7 @@
|
|||
"
|
||||
:noMoreData="pageList.noMoreData"
|
||||
:list="pageList.list"
|
||||
:height="
|
||||
ScaleStatus.ShipmentPaid === currentTab ||
|
||||
ScaleStatus.ToBeShipmentReview === currentTab
|
||||
? 160
|
||||
: 240
|
||||
"
|
||||
:height="ScaleStatus.ShipmentPaid === currentTab ? 160 : 240"
|
||||
:isLoading="pageList.isLoading"
|
||||
>
|
||||
<block v-for="(item, index) in pageList.list" :key="index">
|
||||
|
@ -50,6 +45,7 @@
|
|||
<view style="min-width: 20px"
|
||||
><checkbox
|
||||
v-if="
|
||||
ScaleStatus.ToBeShipmentReview === currentTab ||
|
||||
ScaleStatus.ToBeShipmentPay === currentTab
|
||||
"
|
||||
:color="'#00D2E3'"
|
||||
|
@ -106,7 +102,10 @@
|
|||
</block>
|
||||
</page-view>
|
||||
</view>
|
||||
<view class="btn-box" v-if="currentTab === 3 && pageList.list.length > 0">
|
||||
<view
|
||||
class="btn-box"
|
||||
v-if="(currentTab === 2 || currentTab === 3) && pageList.list.length > 0"
|
||||
>
|
||||
<u-button
|
||||
text="全选/取消"
|
||||
color="#fff"
|
||||
|
@ -115,21 +114,10 @@
|
|||
></u-button>
|
||||
<u-button
|
||||
type="primary"
|
||||
:text="`批量支付`"
|
||||
@click="handleReviewOrPay()"
|
||||
:text="`${currentTab === 2 ? '批量审核' : '批量支付'}`"
|
||||
@click="handleReviewOrPay(currentTab)"
|
||||
></u-button>
|
||||
</view>
|
||||
|
||||
<block>
|
||||
<u-action-sheet
|
||||
:actions="contrlModalParams.select.list"
|
||||
:title="contrlModalParams.select.title"
|
||||
:show="contrlModalParams.select.isShow"
|
||||
@select="(v: any) => handleSelect1('select', v)"
|
||||
@close="contrlModalParams.select.isShow = false"
|
||||
:closeOnClickAction="true"
|
||||
></u-action-sheet>
|
||||
</block>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ShipmentApi } from "@/services/index";
|
||||
|
@ -137,43 +125,6 @@ import { ScaleStatus, ScaleStatusBtnType } from "@/utils/enum";
|
|||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import PageView from "@/components/PageView/index.vue";
|
||||
import type { ComType } from "@/types/global";
|
||||
|
||||
const contrlModalParams = reactive<ComType>({
|
||||
select: {
|
||||
isShow: false,
|
||||
title: "标题",
|
||||
list: [
|
||||
{
|
||||
name: "微信",
|
||||
key: 3,
|
||||
},
|
||||
{
|
||||
name: "现金",
|
||||
key: 1,
|
||||
},
|
||||
{
|
||||
name: "支付宝",
|
||||
key: 4,
|
||||
},
|
||||
{
|
||||
name: "转账",
|
||||
key: 2,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const payState = reactive({
|
||||
paymentMethodName: "",
|
||||
paymentMethod: "",
|
||||
});
|
||||
const handleSelect1 = (key: string, v: any) => {
|
||||
contrlModalParams.select.isShow = false;
|
||||
payState.paymentMethodName = v.name;
|
||||
payState.paymentMethod = v.key;
|
||||
updateStatus(ScaleStatus.ShipmentPaid);
|
||||
};
|
||||
// scaleStatus
|
||||
const pageList: PageResult<Shipment> = reactive({
|
||||
isLoading: false,
|
||||
|
@ -207,7 +158,6 @@ const tabList = reactive([
|
|||
]);
|
||||
const currentTab = ref(2);
|
||||
const handleTab = (item: any) => {
|
||||
state.isAll = false;
|
||||
currentTab.value = item.key;
|
||||
resetPageList();
|
||||
getList();
|
||||
|
@ -221,35 +171,26 @@ const handleReview = (id: string, scaleStatus: number) => {
|
|||
} else if (scaleStatus === 4) {
|
||||
type = ScaleStatusBtnType.ShipmentPay;
|
||||
}
|
||||
console.log("**************", type);
|
||||
uni.navigateTo({
|
||||
url:
|
||||
"/pagesShipment/review/index?id=" +
|
||||
id +
|
||||
`&scaleStatusBtnType=${type}&scaleStatus=${scaleStatus}`, // 要跳转到的页面路径
|
||||
url: "/pagesShipment/review/index?id=" + id + `&scaleStatusBtnType=${type}`, // 要跳转到的页面路径
|
||||
});
|
||||
};
|
||||
|
||||
const handleReviewOrPay = () => {
|
||||
const list = pageList.list
|
||||
.filter((item) => item.isChecked)
|
||||
if (list.length === 0) {
|
||||
uni.showToast({ icon: "none", title: "请至少选择一个出货单" });
|
||||
return;
|
||||
}
|
||||
const handleReviewOrPay = (status: number) => {
|
||||
// 批量审核
|
||||
if (ScaleStatus.ToBeShipmentReview === status) {
|
||||
updateStatus(ScaleStatus.ToBeShipmentPay);
|
||||
} else if (ScaleStatus.ToBeShipmentPay === status) {
|
||||
// 批量支付
|
||||
contrlModalParams.select.isShow = true;
|
||||
contrlModalParams.select.title = "结算方式";
|
||||
updateStatus(ScaleStatus.ShipmentPaid);
|
||||
}
|
||||
};
|
||||
const updateStatus = (status: number) => {
|
||||
const list = pageList.list
|
||||
.filter((item) => item.isChecked)
|
||||
.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
scaleStatus: status,
|
||||
paymentMethodName: payState.paymentMethodName,
|
||||
paymentMethod: payState.paymentMethod,
|
||||
};
|
||||
return { ...item, scaleStatus: status };
|
||||
});
|
||||
if (list.length === 0) {
|
||||
uni.showToast({ icon: "none", title: "请至少选择一个出货单" });
|
||||
|
@ -302,8 +243,8 @@ const getList = (v?: boolean) => {
|
|||
// (pageList as any).list = (res.data.list as any).map((item: any) => {
|
||||
// return { ...item, isChecked: false };
|
||||
// });
|
||||
pageList.list = pageList.list.concat(
|
||||
res.data.list.map((item: any) => {
|
||||
(pageList as any).list = (pageList as any).list.concat(
|
||||
(res.data.list as any).map((item: any) => {
|
||||
return { ...item, isChecked: false };
|
||||
})
|
||||
);
|
||||
|
@ -312,7 +253,7 @@ const getList = (v?: boolean) => {
|
|||
});
|
||||
};
|
||||
onShow(() => {
|
||||
resetPageList();
|
||||
resetPageList()
|
||||
getList();
|
||||
});
|
||||
onLoad((option) => {
|
||||
|
|
|
@ -98,7 +98,7 @@ const handleModal = (v: boolean, id: number) => {
|
|||
};
|
||||
const handleScenePhoto = (id: any) => {
|
||||
uni.navigateTo({
|
||||
url: `/pagesScenePhoto/index?orderType=2&id=${id}&imagesType=1`, // 要跳转到的页面路径
|
||||
url: `/pagesScenePhoto/index?orderType=1&id=${id}&imagesType=1`, // 要跳转到的页面路径
|
||||
});
|
||||
};
|
||||
const pricingDetail = (id: string) => {
|
||||
|
@ -145,7 +145,6 @@ const handleOk = () => {
|
|||
console.log(deleteId.value);
|
||||
ShipmentApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
resetPageList();
|
||||
getList();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
// 存放路径: 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 { http } from "@/utils/http";
|
||||
// console.log(store.profile.childPath)
|
||||
|
||||
// 登陆
|
||||
export const loginByAccount = (data: {
|
||||
userName: string;
|
||||
|
@ -252,13 +250,3 @@ export const forgetPwd = (data: any) => {
|
|||
data,
|
||||
});
|
||||
};
|
||||
|
||||
// 获取基地信息
|
||||
export const getDbInfo = (data: any) => {
|
||||
return http<User>({
|
||||
method: "POST",
|
||||
url: "/prod/gateway/api/db/getDbInfo",
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -8,55 +8,31 @@ export const useMemberStore = defineStore(
|
|||
() => {
|
||||
// 会员信息
|
||||
const profile = ref<LoginResult>({
|
||||
token: "",
|
||||
token: '',
|
||||
userInfo: {
|
||||
userName: "",
|
||||
factoryName: "",
|
||||
},
|
||||
menusList:[],
|
||||
menusNameList: [],
|
||||
childPath: '/test/sh0001',
|
||||
err: null
|
||||
menusNameList: []
|
||||
});
|
||||
|
||||
// 保存会员信息,登录时使用
|
||||
const setProfile = (val: any) => {
|
||||
profile.value = {...profile.value, ...val};
|
||||
profile.value = val;
|
||||
profile.value.menusNameList = _.pluck(val.menusList, "name");
|
||||
};
|
||||
|
||||
const setChildPath= (v: string) => {
|
||||
profile.value.childPath = v
|
||||
}
|
||||
|
||||
const setErr= (v: any) => {
|
||||
profile.value.err = v
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 清理会员信息,退出时使用
|
||||
const clearProfile = () => {
|
||||
profile.value = {
|
||||
token: "",
|
||||
userInfo: {
|
||||
userName: "",
|
||||
factoryName: "",
|
||||
},
|
||||
menusList: [],
|
||||
menusNameList: [],
|
||||
childPath: ''
|
||||
};
|
||||
|
||||
// profile.value = undefined
|
||||
};
|
||||
|
||||
// 记得 return
|
||||
return {
|
||||
profile,
|
||||
setProfile,
|
||||
setChildPath,
|
||||
setErr,
|
||||
clearProfile
|
||||
clearProfile,
|
||||
};
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useMemberStore } from "@/store/modules/member";
|
||||
import ENV_CONFIG from "../config/env";
|
||||
import pinia from "@/store";
|
||||
import pinia from '@/store'
|
||||
|
||||
// 基础地址
|
||||
let baseUrl = "";
|
||||
|
@ -8,10 +8,11 @@ let baseUrl = "";
|
|||
(process.env as any).config = ENV_CONFIG;
|
||||
// #endif
|
||||
|
||||
const store = useMemberStore(pinia);
|
||||
baseUrl = (process.env as any).config[(process.env as any).NODE_ENV]
|
||||
.VITE_APP_BASE_URL;
|
||||
|
||||
const store = useMemberStore(pinia);
|
||||
|
||||
const obj = {
|
||||
// 拦截前触发
|
||||
invoke(options: UniApp.RequestOptions) {
|
||||
|
@ -19,12 +20,8 @@ const obj = {
|
|||
options.timeout = 10000;
|
||||
// 拼接完整路径
|
||||
if (!options.url.startsWith("http")) {
|
||||
if (options.url.indexOf("/prod/gateway/api/db/getDbInfo") === -1) {
|
||||
options.url = baseUrl + store.profile.childPath + options.url;
|
||||
} else {
|
||||
options.url = baseUrl + options.url;
|
||||
}
|
||||
}
|
||||
// 请求头标识
|
||||
// 1.小程序唯一标识
|
||||
// 'source-client': 'miniapp'
|
||||
|
@ -56,13 +53,8 @@ interface Data<T> {
|
|||
*/
|
||||
export const http = <T>(options: UniApp.RequestOptions) => {
|
||||
return new Promise<Data<T>>((resolve, reject) => {
|
||||
console.log(options);
|
||||
if ((options as any).header?.type === "UPLOAD") {
|
||||
// 压缩图片
|
||||
uni.compressImage({
|
||||
src: (options as any).data.path,
|
||||
quality: 80, // 压缩质量
|
||||
success: (compressRes) => {
|
||||
const compressedTempFilePath = compressRes.tempFilePath;
|
||||
uni.uploadFile({
|
||||
header: {
|
||||
"x-userToken": store.profile?.token,
|
||||
|
@ -70,14 +62,13 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
|||
"Content-Type": "multipart/form-data",
|
||||
// #endif
|
||||
},
|
||||
timeout: 1800000,
|
||||
url: baseUrl + store.profile.childPath + options.url,//仅为示例,非真实的接口地址
|
||||
url: baseUrl + options.url, //仅为示例,非真实的接口地址
|
||||
fileType: "image",
|
||||
// #ifdef H5
|
||||
files: (options as any).data.files,
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
filePath: compressedTempFilePath,
|
||||
filePath: (options as any).data.path,
|
||||
// #endif
|
||||
name: "file",
|
||||
formData: {
|
||||
|
@ -87,80 +78,25 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
|||
resolve(JSON.parse(res.data) as Data<T>);
|
||||
},
|
||||
fail(err) {
|
||||
console.log("上传失败了", err);
|
||||
resolve(err as any);
|
||||
console.log(err);
|
||||
resolve(err as any)
|
||||
},
|
||||
});
|
||||
|
||||
// 上传图片
|
||||
// uni.uploadFile({
|
||||
// url: 'https://your-api-upload-endpoint.com/upload', // 你的上传接口
|
||||
// filePath: compressedTempFilePath,
|
||||
// name: 'file',
|
||||
// formData: {
|
||||
// 'user': 'test'
|
||||
// },
|
||||
// success: (uploadFileRes) => {
|
||||
// console.log('upload success:', uploadFileRes);
|
||||
// },
|
||||
// fail: (uploadFileErr) => {
|
||||
// console.error('upload fail:', uploadFileErr);
|
||||
// }
|
||||
// });
|
||||
},
|
||||
fail: (compressErr) => {
|
||||
console.error("compress fail:", compressErr);
|
||||
},
|
||||
});
|
||||
|
||||
// uni.uploadFile({
|
||||
// header: {
|
||||
// "x-userToken": store.profile?.token,
|
||||
// // #ifdef H5
|
||||
// "Content-Type": "multipart/form-data",
|
||||
// // #endif
|
||||
// },
|
||||
// timeout: 1800000,
|
||||
// url: baseUrl + store.profile.childPath + options.url,//仅为示例,非真实的接口地址
|
||||
// fileType: "image",
|
||||
// // #ifdef H5
|
||||
// files: (options as any).data.files,
|
||||
// // #endif
|
||||
// // #ifdef MP-WEIXIN
|
||||
// filePath: (options as any).data.path,
|
||||
// // #endif
|
||||
// name: "file",
|
||||
// formData: {
|
||||
// file: (options as any).data.files,
|
||||
// }, // HTTP 请求中其他额外的 form data
|
||||
// success: (res) => {
|
||||
// resolve(JSON.parse(res.data) as Data<T>);
|
||||
// },
|
||||
// fail(err) {
|
||||
// console.log("上传失败了", err);
|
||||
// resolve(err as any);
|
||||
// },
|
||||
// });
|
||||
} else {
|
||||
uni.request({
|
||||
...options,
|
||||
dataType: "string", //1.先将dataType设置为string
|
||||
dataType:'string', //1.先将dataType设置为string
|
||||
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替换
|
||||
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数据即可
|
||||
let res1: any = JSON.parse(json1);
|
||||
console.log(res1);
|
||||
let res1 = JSON.parse(json1);
|
||||
console.log(res1)
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
if (
|
||||
res1.code === 1001 ||
|
||||
res1.code === 1002 ||
|
||||
res1.code === 1003 ||
|
||||
res1.code === 1004
|
||||
(res1 as any).code === 1001 ||
|
||||
(res1 as any).code === 1002
|
||||
) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
|
@ -176,7 +112,7 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
|||
icon: "none",
|
||||
title: (res1 as Data<T>).message || "请求失败",
|
||||
});
|
||||
return;
|
||||
return
|
||||
} else if ((res1 as any).code === 5001) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
|
@ -195,7 +131,6 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
|||
fail(err) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
// title: JSON.stringify(err),
|
||||
title: "网络错误,请检查网络",
|
||||
});
|
||||
reject(err);
|
||||
|
|
|
@ -259,4 +259,3 @@ export function getScaleStatus(type: number, value: number) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue