store-management-app/src/App.vue
2024-10-24 15:26:16 +08:00

97 lines
2.8 KiB
Vue

<script>
import { onLoad } from "@dcloudio/uni-app";
import { pbDetail } from "@/api/login.js";
import useToast from "@/hooks/toast/useToast.js";
import { ref, reactive } from "vue";
const { showMessage } = useToast();
const state = reactive({
id: "",
pid: "",
});
const loading = ref(false);
export default {
onLaunch: function () {},
onShow: function () {
console.log("2222222");
// const token = window?.plus?.storage.getItem("token");
// uni.setStorageSync("token", token);
// console.log("App Show", uni.getStorageSync("token"));
const params = new URLSearchParams(window.location.search); //属性包含当前 URL 的查询字符串部分
state.id = params.get("id");
state.pid = params.get("pid");
console.log(state);
const paintingDetail = async () => {
loading.value = true;
console.log("state", state);
const res = await pbDetail({
id: state.id,
pid: state.pid,
});
if (res.status === 0) {
console.log("成功拉1");
state.boxRelBucketStatus = res.data.boxRelBucketStatus;
console.log("boxRelBucketStatus", state.boxRelBucketStatus);
if (res.data.pbStatus == 1) {
console.log("成功拉2");
uni.navigateTo({
url: "/pages/index/index?id=" + state.id + "&pid=" + state.pid,
success: () => {
loading.value = false;
},
fail: () => {
loading.value = false;
showMessage({ type: "default", message: "跳转失败" });
},
});
} else {
if (
res.data.boxRelBucketStatus == 3 &&
res.data.locateAddress == "公司内"
) {
uni.navigateTo({
url: "/pages/painting/index?id=" + state.id + "&pid=" + state.pid,
success: () => {
loading.value = false;
},
fail: () => {
loading.value = false;
showMessage({ type: "default", message: "跳转失败" });
},
});
} else {
uni.setStorageSync("data", res.data);
console.log();
uni.navigateTo({
url:
"/pages/detail/index?id=" +
state.id +
"&pid=" +
state.pid +
"&boxRelBucketStatus=" +
state.boxRelBucketStatus,
success: () => {
loading.value = false;
},
fail: () => {
loading.value = false;
showMessage({ type: "default", message: "跳转失败" });
},
});
}
}
}
};
paintingDetail();
},
onHide: function () {
console.log("App Hide");
},
};
</script>
<style>
/*每个页面公共css */
</style>