From 552ec6b7d8ccc56c379da195fc6c9c74312b1070 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期五, 22 五月 2026 17:57:46 +0800
Subject: [PATCH] OA部分查询条件变更
---
src/pages/login.vue | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 159 insertions(+), 10 deletions(-)
diff --git a/src/pages/login.vue b/src/pages/login.vue
index f717c26..2d96046 100644
--- a/src/pages/login.vue
+++ b/src/pages/login.vue
@@ -22,6 +22,21 @@
clearable
type="password"></up-input>
</view>
+ <!-- <view class="input-item flex align-center"
+ v-if="factoryList.length > 0">
+ <up-input prefixIcon="home"
+ placeholder="璇烽�夋嫨宸ュ巶"
+ border="bottom"
+ readonly
+ @click="showFactorySelect = true"
+ v-model="selectedFactoryName"
+ clearable></up-input>
+ <up-action-sheet :show="showFactorySelect"
+ :actions="factoryList"
+ title="璇烽�夋嫨宸ュ巶"
+ @close="showFactorySelect = false"
+ @select="handleFactorySelect"></up-action-sheet>
+ </view> -->
<view>
<button @click="handleLogin"
class="login-btn cu-btn block bg-blue lg round">鐧诲綍</button>
@@ -37,6 +52,9 @@
</up-checkbox>
</view>
</view>
+ <view class="version-wrap">
+ <text class="version-text">鐗堟湰鍙凤細{{ versionName }}</text>
+ </view>
</template>
<script setup>
@@ -48,22 +66,36 @@
icon: "none",
});
};
- import { userLoginFacotryList, updateClientId } from "@/api/login";
+ import {
+ userLoginFacotryList,
+ updateClientId,
+ getNoticeCount,
+ } from "@/api/login";
import { ref, onMounted } from "vue";
import useUserStore from "@/store/modules/user";
import { getWxCode } from "@/utils/geek";
import { wxLogin } from "@/api/oauth";
import { setToken } from "@/utils/auth";
import View from "@/pages/procurementManagement/procurementLedger/view.vue";
+ import config from "@/config";
const userStore = useUserStore();
const useWxLogin = ref(false); // 鏄惁浣跨敤寰俊鐧诲綍
const rememberPassword = ref(false); // 璁颁綇瀵嗙爜
+ const versionName = ref(config?.appInfo?.version || "1.0.0");
const loginForm = ref({
userName: "",
password: "",
- currentFatoryName: "",
+ factoryId: "",
});
const factoryList = ref([]); // 鍏徃鍒楄〃
+ const showFactorySelect = ref(false);
+ const selectedFactoryName = ref("");
+
+ const handleFactorySelect = e => {
+ loginForm.value.factoryId = e.id;
+ selectedFactoryName.value = e.name;
+ showFactorySelect.value = false;
+ };
// 淇濆瓨瀵嗙爜鍒版湰鍦板瓨鍌�
function savePassword() {
@@ -118,17 +150,28 @@
id: item.deptId,
name: item.deptName,
}));
+ // 濡傛灉鍙湁涓�涓伐鍘傦紝榛樿閫変腑
+ if (factoryList.value.length === 1) {
+ loginForm.value.factoryId = factoryList.value[0].id;
+ selectedFactoryName.value = factoryList.value[0].name;
+ }
} else {
// 濡傛灉res.data涓嶆槸鏁扮粍锛岃缃负绌烘暟缁�
factoryList.value = [];
+ loginForm.value.factoryId = "";
+ selectedFactoryName.value = "";
}
})
.catch(error => {
showToast("鑾峰彇鍏徃鍒楄〃澶辫触:", error);
factoryList.value = [];
+ loginForm.value.factoryId = "";
+ selectedFactoryName.value = "";
});
} else {
factoryList.value = [];
+ loginForm.value.factoryId = "";
+ selectedFactoryName.value = "";
}
}
@@ -137,6 +180,8 @@
showToast("璇疯緭鍏ユ偍鐨勮处鍙�");
} else if (loginForm.value.password === "") {
showToast("璇疯緭鍏ユ偍鐨勫瘑鐮�");
+ } else if (factoryList.value.length > 0 && loginForm.value.factoryId === "") {
+ showToast("璇烽�夋嫨宸ュ巶");
} else {
showToast("鐧诲綍涓紝璇疯�愬績绛夊緟...");
pwdLogin();
@@ -160,18 +205,55 @@
function loginSuccess(result) {
// 璁剧疆鐢ㄦ埛淇℃伅
userStore.getInfo().then(res => {
+ const userId = res.user.userId;
// 鑾峰彇璺敱鏉冮檺
- userStore.getRouters().then(() => {
- console.log("璺敱鏉冮檺鑾峰彇鎴愬姛");
- }).catch(error => {
- console.error("鑾峰彇璺敱鏉冮檺澶辫触:", error);
- });
+ userStore
+ .getRouters()
+ .then(() => {
+ console.log("璺敱鏉冮檺鑾峰彇鎴愬姛");
+ })
+ .catch(error => {
+ console.error("鑾峰彇璺敱鏉冮檺澶辫触:", error);
+ });
// 鐧诲綍鎴愬姛鍚庯紝灏嗗鎴风鎺ㄩ�佹爣璇嗗彂閫佸埌鏈嶅姟鍣�
sendClientIdToServer();
- uni.switchTab({
- url: "/pages/index",
- });
+ // 鍚姩瀹氭椂鑾峰彇鏈娑堟伅鏁伴噺鐨勫畾鏃跺櫒
+ startNoticeCountTimer(userId);
+ uni.switchTab({ url: "/pages/index" });
});
+ }
+
+ // 鍚姩瀹氭椂鑾峰彇鏈娑堟伅鏁伴噺鐨勫畾鏃跺櫒
+ function startNoticeCountTimer(userId) {
+ // 绔嬪嵆鑾峰彇涓�娆℃湭璇绘秷鎭暟閲�
+ updateNoticeCount(userId);
+ // 璁剧疆瀹氭椂鍣紝姣�30绉掕幏鍙栦竴娆�
+ setInterval(() => {
+ updateNoticeCount(userId);
+ }, 30000);
+ }
+
+ // 鏇存柊鏈娑堟伅鏁伴噺
+ function updateNoticeCount(userId) {
+ getNoticeCount(userId)
+ .then(res => {
+ const count = res.data || 0;
+ console.log("鏈娑堟伅鏁伴噺:", count);
+ // 鏇存柊tabbar鐨勮鏍�
+ if (count > 0) {
+ uni.setTabBarBadge({
+ index: 2, // 娑堟伅鏍囩椤电殑绱㈠紩
+ text: count.toString(),
+ });
+ } else {
+ uni.removeTabBarBadge({
+ index: 2,
+ });
+ }
+ })
+ .catch(error => {
+ console.error("鑾峰彇鏈娑堟伅鏁伴噺澶辫触:", error);
+ });
}
// 灏嗗鎴风鎺ㄩ�佹爣璇嗗彂閫佸埌鏈嶅姟鍣�
@@ -202,6 +284,62 @@
}
// 椤甸潰鍔犺浇鏃舵鏌ユ槸鍚︽湁淇濆瓨鐨勫瘑鐮�
onMounted(() => {
+ console.log("[login-version] 寮�濮嬭幏鍙栫櫥褰曢〉鐗堟湰锛岄粯璁ゅ��:", versionName.value);
+ // #ifdef MP-WEIXIN
+ try {
+ const accountInfo = uni.getAccountInfoSync();
+ if (accountInfo?.miniProgram?.version) {
+ versionName.value = accountInfo.miniProgram.version;
+ console.log(
+ "[login-version] 褰撳墠鐜=MP-WEIXIN锛岀増鏈�=",
+ versionName.value
+ );
+ }
+ } catch (e) {
+ // 鑾峰彇澶辫触鏃朵娇鐢ㄩ粯璁ゅ��
+ console.log("[login-version] MP-WEIXIN 鑾峰彇鐗堟湰澶辫触:", e);
+ }
+ // #endif
+
+ // #ifdef APP-PLUS
+ try {
+ // #ifdef APP-PLUS
+ // @ts-ignore
+ if (plus?.runtime?.getProperty) {
+ // @ts-ignore
+ const appid = plus.runtime.appid;
+ // @ts-ignore
+ plus.runtime.getProperty(appid, info => {
+ const v = info?.version || info?.versionName || "";
+ if (v) {
+ versionName.value = String(v);
+ console.log(
+ "[login-version] 褰撳墠鐜=APP-PLUS锛岀増鏈�=",
+ versionName.value
+ );
+ } else {
+ console.log(
+ "[login-version] APP-PLUS 鑾峰彇鍒扮殑鐗堟湰瀛楁涓虹┖锛屼娇鐢ㄩ粯璁ゅ��:",
+ versionName.value
+ );
+ }
+ console.log("[login-version] 鏈�缁堢増鏈彿:", versionName.value);
+ });
+ } else {
+ console.log(
+ "[login-version] APP-PLUS 鐜涓嬬己灏� getProperty锛屼娇鐢ㄩ粯璁ゅ��:",
+ versionName.value
+ );
+ console.log("[login-version] 鏈�缁堢増鏈彿:", versionName.value);
+ }
+ // #endif
+ } catch (e) {
+ // 鑾峰彇澶辫触鏃朵娇鐢ㄩ粯璁ゅ��
+ console.log("[login-version] APP-PLUS 鑾峰彇鐗堟湰澶辫触:", e);
+ console.log("[login-version] 鏈�缁堢増鏈彿:", versionName.value);
+ }
+ // #endif
+
loadPassword();
getUserLoginFacotryList();
});
@@ -305,4 +443,15 @@
}
}
}
+
+ .version-wrap {
+ width: 100%;
+ text-align: center;
+ margin-top: 20px;
+ }
+
+ .version-text {
+ font-size: 12px;
+ color: #999;
+ }
</style>
--
Gitblit v1.9.3