From a94f1b73dce878f7102081aae0d796c233a4699f Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期二, 20 五月 2025 16:04:49 +0800
Subject: [PATCH] 绑定班次

---
 pages/login/index.vue |  127 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 126 insertions(+), 1 deletions(-)

diff --git a/pages/login/index.vue b/pages/login/index.vue
index de2efe3..67148bb 100644
--- a/pages/login/index.vue
+++ b/pages/login/index.vue
@@ -64,6 +64,18 @@
 				</view>
 			</uni-popup>
 			<!-- 鐗堟湰鍗囩骇寮圭獥缁撴潫 -->
+			<uni-popup ref="refClassDialog" type="dialog">
+				<uni-popup-dialog mode="info" :title="$t('page.bind_classes')" @confirm="dialogClassConfirm">
+					<view class="popup-class">
+						<view class="popup-class-item" :style="{color:item.text == selectedClasses ? '#27A6E1' :''}"
+							v-for="(item,index) in classesLst" :key="index" @click="clickSelectClass(item)">
+							<view class="ico"><uni-icons v-if="item.text == selectedClasses" type="checkmarkempty"
+									:color="item.text == selectedClasses ? '#27A6E1' :''" size="24"></uni-icons></view>
+							{{item.text}}
+						</view>
+					</view>
+				</uni-popup-dialog>
+			</uni-popup>
 		</view>
 		<!-- <button @click="onClickWms">鐧诲綍wms</button>
 		<view class="webview">
@@ -87,7 +99,9 @@
 		getApkVersionInfo
 	} from "@/api/index.js"
 	import buttonClickMixin from '@/mixins/button-click.js';
-
+	import {
+		dictGetInfo
+	} from "@/api/mobox.js"
 	import utils from "@/js/utils.js"
 	export default {
 		mixins: [buttonClickMixin],
@@ -105,6 +119,8 @@
 				downloadUrl: "", //瀹夊崜app涓嬭浇閾炬帴
 				percentage: 0, //涓嬭浇杩涘害
 				showBtns: true,
+				selectedClasses: "",
+				classesLst: [],
 			}
 		},
 		onShow() {
@@ -305,6 +321,7 @@
 				// }, 3000)
 				// }, 3000)
 			},
+
 			rememberPwd(e) { //璁颁綇瀵嗙爜
 				console.log(e.target);
 				utils.session.setValue('account', '');
@@ -388,10 +405,22 @@
 						pwd: this.userPwd
 					}
 					hideLoading()
+					const bindInfo = utils.session.getValue('bind_classes')
+					app.globalData.bindClasses = bindInfo?.checked || false
+					if (app.globalData.bindClasses) {
+						this.selectedClasses = bindInfo?.classes || ""
+						await this.loadClassesList()
+						if (this.classesLst.length > 0) {
+							this.$refs.refClassDialog.open()
 
+						}
+						return
+					}
 					uni.navigateTo({
 						url: '../index/index?args=9999999999'
 					})
+
+
 
 				} catch (ex) {
 					hideLoading()
@@ -413,6 +442,82 @@
 				plus.runtime.openURL(otherAppSchemeURL, function(error) {
 					console.error('鎵撳紑搴旂敤澶辫触: ', error);
 				}, "uni.TeatApp");
+			},
+			async loadClassesList() {
+				try {
+					var $this = this;
+					var dataInfo = {
+						dict_id: "",
+						dict_name: "WMS_CLASSES"
+					};
+					const res = await dictGetInfo(dataInfo)
+					var list = [];
+					(res.dict_item_list || []).forEach((item) => {
+						list.push({
+							text: item.value ? item.value : item.name,
+							value: item.name,
+						});
+					});
+
+					if (list.length == 0) {
+						uni.showModal({
+							title: this.translate("get_classes_fail"),
+							content: this.translate("page.please_login_after_admin_add_classes"),
+							showCancel: false,
+							confirmText: this.translateSys('close')
+						});
+						this.selectedClasses = ""
+					} else {
+						if (this.selectedClasses) {
+							const curIndex = list.findIndex((a) => {
+								return a.text == this.selectedClasses
+							})
+							if (curIndex < 0) {
+								this.selectedClasses = list[0].text
+							}
+						} else {
+							this.selectedClasses = list[0].text
+						}
+					}
+					this.classesLst = list
+
+
+				} catch (ex) {
+					let exStr = JSON.stringify(ex)
+					if (exStr == "{}")
+						exStr = ex
+					let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
+					uni.showModal({
+						title: this.translate("get_classes_fail"),
+						content: tip,
+						showCancel: false,
+						confirmText: this.translateSys('close')
+					});
+					
+					this.selectedClasses = ""
+					this.classesLst = []
+					// {
+					// 	text: "娴嬭瘯",
+					// 	value: "test"
+					// }, {
+					// 	text: "娴嬭瘯3",
+					// 	value: "test3"
+					// }
+				}
+			},
+			dialogClassConfirm() {
+
+				utils.session.setValue('bind_classes', {
+					checked: true,
+					classes: this.selectedClasses
+				})
+				getApp().globalData.classes = this.selectedClasses
+				uni.navigateTo({
+					url: '../index/index?args=9999999999'
+				})
+			},
+			clickSelectClass(item) {
+				this.selectedClasses = item.text
 			},
 			translate(t) {
 				if (typeof this.$t == "function") return this.$t(`page.${t}`)
@@ -597,5 +702,25 @@
 			border: none;
 			color: #fff;
 		}
+
+		.popup-class {
+			display: flex;
+			flex-direction: column;
+			width: 100%;
+
+			.popup-class-item {
+				padding: 20rpx 0;
+				border-bottom: 1px solid #eee;
+				display: flex;
+				flex-direction: row;
+
+				.ico {
+					width: 20px;
+					margin: 0 20rpx;
+
+				}
+			}
+
+		}
 	}
 </style>
\ No newline at end of file

--
Gitblit v1.9.1