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">
|
||||
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
||||
const isFirstLaunch = ref(true);
|
||||
// const isFirstLaunch = ref(true);
|
||||
|
||||
onLaunch(() => {
|
||||
console.log("App Launch");
|
||||
// 当应用启动时,检查是否已显示过启动页
|
||||
if (Boolean(uni.getStorageSync("hasLaunched"))) {
|
||||
// 如果已显示过,不再显示启动页
|
||||
isFirstLaunch.value = false;
|
||||
console.log("不再显示启动页");
|
||||
} else {
|
||||
// 如果未显示过,标记为已显示,并保存到存储
|
||||
uni.setStorageSync("hasLaunched", true);
|
||||
uni.redirectTo({ url: "pagesLaunch/index" });
|
||||
}
|
||||
// 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('******* 执行啦')
|
||||
// }
|
||||
});
|
||||
onShow(() => {
|
||||
console.log("App Show");
|
||||
|
|
|
@ -49,7 +49,6 @@ const props = defineProps<{
|
|||
}>();
|
||||
const emit = defineEmits(["handleDialog", "changeProduct"]);
|
||||
const handleClose = () => {
|
||||
debugger
|
||||
emit("handleDialog", false);
|
||||
};
|
||||
|
||||
|
|
|
@ -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://ifanda.52zaisheng.cn/prod',
|
||||
VITE_APP_BASE_URL: 'http://cloud.52zaisheng.cn',
|
||||
appid: 'wx9251d74fe0e87028',
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ const test = {
|
|||
}
|
||||
|
||||
const production = {
|
||||
VITE_APP_BASE_URL: 'https://ifanda.52zaisheng.cn/prod',
|
||||
VITE_APP_BASE_URL: 'http://cloud.52zaisheng.cn',
|
||||
appid: 'wx9251d74fe0e87028',
|
||||
}
|
||||
|
||||
|
|
|
@ -496,7 +496,6 @@ 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") {
|
||||
|
|
|
@ -565,7 +565,21 @@ onMounted(() => {
|
|||
// #endif
|
||||
});
|
||||
onShow(() => {
|
||||
init();
|
||||
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>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<NavBar :count="0" :title="'登陆'"></NavBar>
|
||||
<NavBar :count="0" :title="'登录'"></NavBar>
|
||||
<LoginLayout>
|
||||
<template #form-box>
|
||||
<u-form
|
||||
|
@ -9,6 +9,23 @@
|
|||
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"
|
||||
|
@ -19,10 +36,11 @@
|
|||
'border-color':
|
||||
currentFocus === 'userName' ? '#00dcee !important' : '',
|
||||
}"
|
||||
border="none"
|
||||
type="number"
|
||||
@focus="handleFocus('userName')"
|
||||
@change="(e:any) => {handleInput(e, 'userName')}"
|
||||
@clear="handleClear({key: 'userName'})"
|
||||
@clear="handleClear({ key: 'userName' })"
|
||||
>
|
||||
</u-input>
|
||||
</u-form-item>
|
||||
|
@ -37,10 +55,11 @@
|
|||
'border-color':
|
||||
currentFocus === 'password' ? '#00dcee !important' : '',
|
||||
}"
|
||||
border="none"
|
||||
@focus="handleFocus('password')"
|
||||
clearable
|
||||
@change="(e:any) => {handleInput(e, 'password')}"
|
||||
@clear="handleClear({key: 'password'})"
|
||||
@clear="handleClear({ key: 'password' })"
|
||||
>
|
||||
<template #suffix>
|
||||
<image
|
||||
|
@ -109,6 +128,15 @@
|
|||
</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">
|
||||
|
@ -116,8 +144,7 @@ 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(() => {
|
||||
|
@ -130,6 +157,7 @@ const model1 = reactive({
|
|||
userInfo: {
|
||||
userName: "",
|
||||
password: "",
|
||||
dpName: "",
|
||||
},
|
||||
});
|
||||
// 控制focus 边框样式
|
||||
|
@ -143,6 +171,12 @@ const checkGroup = reactive({
|
|||
});
|
||||
|
||||
const rules = ref({
|
||||
"userInfo.dpName": {
|
||||
type: "string",
|
||||
required: true,
|
||||
message: "请选择基地名称",
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
"userInfo.userName": {
|
||||
type: "string",
|
||||
required: true,
|
||||
|
@ -206,7 +240,7 @@ const submit = () => {
|
|||
ProfileApi.loginByAccount(model1.userInfo).then((res: any) => {
|
||||
if (res.code === 200) {
|
||||
store.setProfile(res.data);
|
||||
uni.navigateTo({
|
||||
uni.reLaunch({
|
||||
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>
|
||||
|
||||
<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;
|
||||
|
|
|
@ -368,7 +368,7 @@ const handleOk = () => {
|
|||
ReceiveApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
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"];
|
||||
}
|
||||
} else {
|
||||
if (item.enName === 'buckleMiscellaneous') {
|
||||
if (item.enName === "buckleMiscellaneous") {
|
||||
if (state.order[item.enName as string]) {
|
||||
item.num = state.order[item.enName as string];
|
||||
} else {
|
||||
item.num = 0
|
||||
item.num = 0;
|
||||
}
|
||||
} else {
|
||||
item.num = state.order[item.enName as string];
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -643,15 +643,23 @@ const updateOrder = () => {
|
|||
icon: "success",
|
||||
});
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
success: (res) => {
|
||||
uni.$emit("shipmentReviewUrlParams", {
|
||||
id: model1.order.id,
|
||||
scaleStatusBtnType: model1.scaleStatusBtnType,
|
||||
});
|
||||
},
|
||||
});
|
||||
// 根据不同的状态进入返回不同的页面
|
||||
if (scaleStatus.value === ScaleStatus.ToBeShipmentPay) {
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
success: (res) => {
|
||||
uni.$emit("shipmentReviewUrlParams", {
|
||||
id: model1.order.id,
|
||||
scaleStatusBtnType: model1.scaleStatusBtnType,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
if (scaleStatus.value === ScaleStatus.ShipmentPaid) {
|
||||
uni.redirectTo({
|
||||
url: "/pagesShipment/shipmentSettlement?scaleStatus=4", // 要跳转到的页面路径
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -418,7 +418,6 @@ const updateOrder = () => {
|
|||
// else if (state.scaleStatus === ScaleStatus.ToBeGrossWeight) {
|
||||
// status = ScaleStatus.ToBeShipmentReview;
|
||||
// }
|
||||
debugger
|
||||
let status = 0;
|
||||
if (state.scaleStatus === ScaleStatus.ToBeShipment) {
|
||||
status = ScaleStatus.ToBeGrossWeight;
|
||||
|
|
|
@ -80,7 +80,6 @@ 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) {
|
||||
|
|
|
@ -539,7 +539,9 @@ const handleOk = () => {
|
|||
ShipmentApi.deleteOrder({ ids: [deleteId.value] }).then((res) => {
|
||||
if (res.code === 200) {
|
||||
uni.navigateTo({
|
||||
url: "/pagesShipment/shipmentSettlement?scaleStatus=2", // 要跳转到的页面路径
|
||||
url:
|
||||
"/pagesShipment/shipmentSettlement?scaleStatus=" +
|
||||
state.scaleStatus, // 要跳转到的页面路径
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -591,22 +593,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) => {
|
||||
onLoad((option:any) => {
|
||||
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;
|
||||
|
|
|
@ -171,9 +171,8 @@ 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}`, // 要跳转到的页面路径
|
||||
url: "/pagesShipment/review/index?id=" + id + `&scaleStatusBtnType=${type}&scaleStatus=${scaleStatus}`, // 要跳转到的页面路径
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// 存放路径: 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;
|
||||
|
@ -250,3 +252,13 @@ export const forgetPwd = (data: any) => {
|
|||
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>({
|
||||
token: '',
|
||||
token: "",
|
||||
userInfo: {
|
||||
userName: "",
|
||||
factoryName: "",
|
||||
},
|
||||
menusList:[],
|
||||
menusNameList: []
|
||||
menusList: [],
|
||||
menusNameList: [],
|
||||
childPath: '/test/sh0001'
|
||||
});
|
||||
|
||||
// 保存会员信息,登录时使用
|
||||
const setProfile = (val: any) => {
|
||||
profile.value = val;
|
||||
profile.value = {...profile.value, ...val};
|
||||
profile.value.menusNameList = _.pluck(val.menusList, "name");
|
||||
};
|
||||
|
||||
const setChildPath= (v: string) => {
|
||||
profile.value.childPath = v
|
||||
}
|
||||
|
||||
|
||||
// 清理会员信息,退出时使用
|
||||
const clearProfile = () => {
|
||||
// profile.value = undefined
|
||||
profile.value = {
|
||||
token: "",
|
||||
userInfo: {
|
||||
userName: "",
|
||||
factoryName: "",
|
||||
},
|
||||
menusList: [],
|
||||
menusNameList: [],
|
||||
childPath: ''
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
// 记得 return
|
||||
return {
|
||||
profile,
|
||||
setProfile,
|
||||
clearProfile,
|
||||
setChildPath,
|
||||
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,8 @@ let baseUrl = "";
|
|||
(process.env as any).config = ENV_CONFIG;
|
||||
// #endif
|
||||
|
||||
baseUrl = (process.env as any).config[(process.env as any).NODE_ENV]
|
||||
.VITE_APP_BASE_URL;
|
||||
|
||||
const store = useMemberStore(pinia);
|
||||
baseUrl = (process.env as any).config[(process.env as any).NODE_ENV].VITE_APP_BASE_URL;
|
||||
|
||||
const obj = {
|
||||
// 拦截前触发
|
||||
|
@ -20,7 +18,12 @@ const obj = {
|
|||
options.timeout = 10000;
|
||||
// 拼接完整路径
|
||||
if (!options.url.startsWith("http")) {
|
||||
options.url = baseUrl + options.url;
|
||||
if ('/prod/gateway/api/db/getDbInfo' !== options.url) {
|
||||
options.url = baseUrl + store.profile.childPath + options.url;
|
||||
} else {
|
||||
options.url = baseUrl + options.url;
|
||||
}
|
||||
|
||||
}
|
||||
// 请求头标识
|
||||
// 1.小程序唯一标识
|
||||
|
@ -79,20 +82,23 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
|||
},
|
||||
fail(err) {
|
||||
console.log(err);
|
||||
resolve(err as any)
|
||||
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: any = JSON.parse(json1);
|
||||
console.log(res1);
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
if (
|
||||
res1.code === 1001 ||
|
||||
|
@ -109,12 +115,12 @@ export const http = <T>(options: UniApp.RequestOptions) => {
|
|||
url: "/pagesLogin/login/index",
|
||||
});
|
||||
return;
|
||||
}else if ((res1 as any).code === 10001) {
|
||||
} else if ((res1 as any).code === 10001) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: (res1 as Data<T>).message || "请求失败",
|
||||
});
|
||||
return
|
||||
return;
|
||||
} else if ((res1 as any).code === 5001) {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
|
|
Loading…
Reference in New Issue