update: 细节优化

This commit is contained in:
admin 2024-06-04 09:50:18 +08:00
parent 4b4c39ae5a
commit 87bd3b0544
15 changed files with 182 additions and 66 deletions

View File

@ -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");

View File

@ -49,7 +49,6 @@ const props = defineProps<{
}>();
const emit = defineEmits(["handleDialog", "changeProduct"]);
const handleClose = () => {
debugger
emit("handleDialog", false);
};

View File

@ -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',
}

View File

@ -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") {

View File

@ -565,7 +565,21 @@ 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>

View File

@ -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;

View File

@ -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];
}
}
});
}

View File

@ -643,6 +643,8 @@ const updateOrder = () => {
icon: "success",
});
//
if (scaleStatus.value === ScaleStatus.ToBeShipmentPay) {
uni.navigateBack({
delta: 1,
success: (res) => {
@ -653,6 +655,12 @@ const updateOrder = () => {
},
});
}
if (scaleStatus.value === ScaleStatus.ShipmentPaid) {
uni.redirectTo({
url: "/pagesShipment/shipmentSettlement?scaleStatus=4", //
});
}
}
});
};

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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}`, //
});
};

View File

@ -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,
});
};

View File

@ -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
};
},
{

View File

@ -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,8 +18,13 @@ const obj = {
options.timeout = 10000;
// 拼接完整路径
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;
}
}
// 请求头标识
// 1.小程序唯一标识
// 'source-client' 'miniapp'
@ -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",