From 6c497f71f5441633099fc7a7896da8e8c7835f05 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 09 三月 2026 15:46:37 +0800
Subject: [PATCH] 公司app 1.商机管理添加字段
---
src/pages/login.vue | 108 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 94 insertions(+), 14 deletions(-)
diff --git a/src/pages/login.vue b/src/pages/login.vue
index ace9551..7c97065 100644
--- a/src/pages/login.vue
+++ b/src/pages/login.vue
@@ -7,7 +7,7 @@
<view class="input-item flex align-center">
<up-input prefixIcon="account" placeholder="璇疯緭鍏ヨ处鍙�" border="bottom"
@blur="getUserLoginFacotryList"
- maxlength="30" v-model="loginForm.username" clearable></up-input>
+ maxlength="30" v-model="loginForm.userName" clearable></up-input>
</view>
<view class="input-item flex align-center">
<up-input prefixIcon="lock" placeholder="璇疯緭鍏ュ瘑鐮�" border="bottom" maxlength="20" v-model="loginForm.password" clearable type="password"></up-input>
@@ -19,6 +19,7 @@
title="璇烽�夋嫨鍏徃"
:options="factoryList"
valueKey="id"
+ style="width: 100%;"
labelKey="name">
</up-picker-data>
</view>
@@ -41,18 +42,30 @@
</template>
<script setup>
-import modal from '@/plugins/modal'
-import { userLoginFacotryList} from '@/api/login'
+import {modal} from "@/plugins";
+
+const showToast = (message) => {
+ uni.showToast({
+ title: message,
+ icon: 'none'
+ })
+}
+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";
const userStore = useUserStore()
const useWxLogin = ref(false); // 鏄惁浣跨敤寰俊鐧诲綍
const rememberPassword = ref(false); // 璁颁綇瀵嗙爜
const loginForm = ref({
- username: "",
+ userName: "",
password: "",
factoryId: "",
currentFatoryName: "",
@@ -62,7 +75,7 @@
// 淇濆瓨瀵嗙爜鍒版湰鍦板瓨鍌�
function savePassword() {
if (rememberPassword.value) {
- uni.setStorageSync('remembered_username', loginForm.value.username);
+ uni.setStorageSync('remembered_username', loginForm.value.userName);
uni.setStorageSync('remembered_password', loginForm.value.password);
uni.setStorageSync('remember_password', true);
} else {
@@ -80,7 +93,7 @@
const savedUsername = uni.getStorageSync('remembered_username');
const savedPassword = uni.getStorageSync('remembered_password');
if (savedUsername) {
- loginForm.value.username = savedUsername;
+ loginForm.value.userName = savedUsername;
}
if (savedPassword) {
loginForm.value.password = savedPassword;
@@ -101,8 +114,9 @@
}
function getUserLoginFacotryList() {
- if(loginForm.value.username){
- userLoginFacotryList({userName:loginForm.value.username}).then(res => {
+ if(loginForm.value.userName){
+ userLoginFacotryList({userName:loginForm.value.userName}).then(res => {
+ console.log('res',res)
// 妫�鏌es.data鏄惁涓烘暟缁�
if (res.data && Array.isArray(res.data)) {
// 閲嶆柊缁勮鏁版嵁鏍煎紡锛歞eptId鍙樻垚id锛宒eptName鍙樻垚name
@@ -115,7 +129,7 @@
factoryList.value = []
}
}).catch(error => {
- modal.msgError('鑾峰彇鍏徃鍒楄〃澶辫触:', error)
+ showToast('鑾峰彇鍏徃鍒楄〃澶辫触:', error)
factoryList.value = []
})
}else {
@@ -124,14 +138,14 @@
}
async function handleLogin() {
- if (loginForm.value.username === "") {
- modal.msgError("璇疯緭鍏ユ偍鐨勮处鍙�")
+ if (loginForm.value.userName === "") {
+ showToast("璇疯緭鍏ユ偍鐨勮处鍙�")
} else if (loginForm.value.password === "") {
- modal.msgError("璇疯緭鍏ユ偍鐨勫瘑鐮�")
+ showToast("璇疯緭鍏ユ偍鐨勫瘑鐮�")
} else if (loginForm.value.factoryId === "") {
- modal.msgError("璇烽�夋嫨鍏徃")
+ showToast("璇烽�夋嫨鍏徃")
} else {
- modal.loading("鐧诲綍涓紝璇疯�愬績绛夊緟...")
+ showToast("鐧诲綍涓紝璇疯�愬績绛夊緟...")
pwdLogin()
}
};
@@ -148,6 +162,13 @@
};
function loginSuccess(result) {
+ userStore.getInfo().then(res => {
+ const userId = res.user.userId;
+ // 鐧诲綍鎴愬姛鍚庯紝灏嗗鎴风鎺ㄩ�佹爣璇嗗彂閫佸埌鏈嶅姟鍣�
+ sendClientIdToServer();
+ // 鍚姩瀹氭椂鑾峰彇鏈娑堟伅鏁伴噺鐨勫畾鏃跺櫒
+ startNoticeCountTimer(userId);
+ })
// 璁剧疆鐢ㄦ埛淇℃伅
userStore.getInfo().then(res => {
uni.switchTab({
@@ -155,6 +176,65 @@
});
})
}
+// 鍚姩瀹氭椂鑾峰彇鏈娑堟伅鏁伴噺鐨勫畾鏃跺櫒
+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: 1, // 娑堟伅鏍囩椤电殑绱㈠紩
+ text: count.toString(),
+ });
+ } else {
+ uni.removeTabBarBadge({
+ index: 1,
+ });
+ }
+ })
+ .catch(error => {
+ console.error("鑾峰彇鏈娑堟伅鏁伴噺澶辫触:", error);
+ });
+}
+
+// 灏嗗鎴风鎺ㄩ�佹爣璇嗗彂閫佸埌鏈嶅姟鍣�
+function sendClientIdToServer() {
+ // 鑾峰彇鏈湴瀛樺偍鐨勫鎴风鏍囪瘑
+ const clientId = uni.getStorageSync("clientid");
+ if (clientId) {
+ console.log("鐧诲綍鎴愬姛锛屽噯澶囧彂閫佸鎴风鏍囪瘑鍒版湇鍔″櫒:", clientId);
+ // 杩欓噷璋冪敤鍚庣鎺ュ彛鍙戦�佸鎴风鏍囪瘑
+ updateClientId({ cid: clientId })
+ .then(res => {
+ console.log("鏈嶅姟鍣ㄥ搷搴�:", res);
+ if (res.code === 200) {
+ console.log("瀹㈡埛绔爣璇嗗凡鎴愬姛鍙戦�佸埌鏈嶅姟鍣�");
+ } else {
+ console.log("鏈嶅姟鍣ㄨ繑鍥為敊璇�:", res.msg);
+ }
+ })
+ .catch(error => {
+ console.log("鍙戦�佸鎴风鏍囪瘑鍒版湇鍔″櫒澶辫触:", error);
+ });
+ // 绀轰緥锛歛pi.updateClientId({ clientId: clientId });
+ // 鐢变簬娌℃湁鍏蜂綋鐨勬帴鍙o紝杩欓噷鍙墦鍗版棩蹇�
+ console.log("瀹㈡埛绔爣璇嗗凡鍙戦�佸埌鏈嶅姟鍣�");
+ } else {
+ console.log("鏈幏鍙栧埌瀹㈡埛绔帹閫佹爣璇�");
+ }
+}
// 椤甸潰鍔犺浇鏃舵鏌ユ槸鍚︽湁淇濆瓨鐨勫瘑鐮�
onMounted(() => {
loadPassword();
--
Gitblit v1.9.3