From ea2fb93a0dfcde8f5b66825b20f9d9b835a28acc Mon Sep 17 00:00:00 2001
From: MrShi <1878285526@qq.com>
Date: 星期五, 22 五月 2026 10:54:09 +0800
Subject: [PATCH] 提交

---
 small-program/shop/pages/login/login.vue |  126 +++++++++++++++++++++++------------------
 1 files changed, 71 insertions(+), 55 deletions(-)

diff --git a/small-program/shop/pages/login/login.vue b/small-program/shop/pages/login/login.vue
index dcd8401..481dda0 100644
--- a/small-program/shop/pages/login/login.vue
+++ b/small-program/shop/pages/login/login.vue
@@ -9,19 +9,16 @@
 		<view class="form-wrap">
 			<view class="input-row">
 				<u-icon name="account" size="30" color="#B8B8B8"></u-icon>
-				<input v-model="form.account" class="input-field" type="text" placeholder="璇疯緭鍏ヨ处鍙�" placeholder-style="color: #999999;" />
+				<input v-model="form.telephone" class="input-field" type="text" placeholder="璇疯緭鍏ヨ处鍙�" placeholder-style="color: #999999;" />
 			</view>
 			<view class="input-divider"></view>
 
 			<view class="input-row password-row">
 				<u-icon name="lock" size="30" color="#B8B8B8"></u-icon>
-				<input v-model="form.password" class="input-field" password type="text" placeholder="璇疯緭鍏ュ瘑鐮�" placeholder-style="color: #999999;" />
-			</view>
-			<view class="input-divider"></view>
-
-			<view class="input-row password-row">
-				<u-icon name="phone" size="30" color="#B8B8B8"></u-icon>
-				<input v-model="form.telephone" class="input-field" type="number" maxlength="11" placeholder="璇疯緭鍏ユ墜鏈哄彿" placeholder-style="color: #999999;" />
+				<input v-model="form.password" class="input-field" :password="!showPassword" placeholder="璇疯緭鍏ュ瘑鐮�" placeholder-style="color: #999999;" />
+				<view class="password-toggle" @click="showPassword = !showPassword">
+					<u-icon :name="showPassword ? 'eye' : 'eye-off'" size="20" color="#B8B8B8"></u-icon>
+				</view>
 			</view>
 			<view class="input-divider"></view>
 		</view>
@@ -32,9 +29,9 @@
 			<image class="agree-icon" :src="agreed ? '/static/icon/ic_accept_sel@2x.png' : '/static/icon/ic_accept@2x.png'" mode="aspectFit" @tap="agreed = !agreed"></image>
 			<view class="agreement-text-wrap">
 				<text class="agreement-text">鎴戝凡闃呰骞跺悓鎰�</text>
-				<text class="agreement-link" @click="goToService">銆婄敤鎴锋湇鍔″崗璁��</text>
+				<text class="agreement-link" @click="goToService(2)">銆婇棬搴楁湇鍔″崗璁��</text>
 				<text class="agreement-text">鍙�</text>
-				<text class="agreement-link" @click="goToPrivacy">銆婄敤鎴烽殣绉佹斂绛栥��</text>
+				<text class="agreement-link" @click="goToService(3)">銆婇棬搴楅殣绉佹斂绛栥��</text>
 			</view>
 		</view>
 	</view>
@@ -45,28 +42,57 @@
 
 	export default {
 		computed: {
-			...mapState(['openid'])
+			...mapState(['openid', 'userInfo','userType'])
 		},
 		data() {
 			return {
 				agreed: false,
+				showPassword: false,
 				form: {
-					account: '',
-					password: '',
-					telephone: ''
+					telephone: '',
+					password: ''
 				}
 			}
 		},
-		methods: {
-			async handleLogin() {
-				if (!this.agreed) {
-					uni.showToast({
-						title: '璇峰厛闃呰骞跺悓鎰忓崗璁�',
-						icon: 'none'
-					})
-					return
+		onLoad() {
+			// 闈欓粯鐧诲綍
+			if (this.userInfo.bindShopId) {
+				uni.showLoading({
+					title:'鐧诲綍涓�...'
+				})
+				try{
+					console.log(this.userType,"============================================")
+					this.$u.api.shopSilentLogin({})
+						.then( res => {
+							if (res.code === 200 && res.data) {
+								this.$store.commit('setUserType', 1)
+								this.$store.commit('setShopToken', res.data.token)
+								// 鑾峰彇闂ㄥ簵淇℃伅
+								this.$u.api.getShopInfo({}).then( shopInfoRes => {
+									if (shopInfoRes.code === 200) {
+										this.$store.commit('setShopInfo', shopInfoRes.data)
+									}
+									uni.hideLoading();
+									// setTimeout(() => {
+										uni.navigateTo({
+											url: '/shop/pages/store-home/store-home'
+										});
+									// }, 1000)
+								})
+							}
+							uni.hideLoading()
+						})
+				}catch(e){
+					uni.hideLoading()
 				}
-				if (!this.form.account) {
+				setTimeout(() => {
+					uni.hideLoading()
+				}, 10000)
+			}
+		},
+		methods: {
+			handleLogin() {
+				if (!this.form.telephone) {
 					uni.showToast({
 						title: '璇疯緭鍏ヨ处鍙�',
 						icon: 'none'
@@ -80,54 +106,40 @@
 					})
 					return
 				}
-				if (!this.form.telephone) {
+				if (!this.agreed) {
 					uni.showToast({
-						title: '璇疯緭鍏ユ墜鏈哄彿',
+						title: '璇峰厛闃呰骞跺悓鎰忓崗璁�',
 						icon: 'none'
 					})
 					return
 				}
-				uni.showLoading({ title: '鐧诲綍涓�...', mask: true })
-				try {
-					const res = await this.$u.api.shopLogin({
-						openid: this.openid,
-						password: this.form.password,
-						telephone: this.form.telephone
-					})
-					uni.hideLoading()
+				this.$u.api.shopLogin({
+					openid: this.openid,
+					password: this.form.password,
+					telephone: this.form.telephone
+				}).then(async res => {
 					if (res.code === 200) {
 						this.$store.commit('setUserType', 1)
 						this.$store.commit('setShopToken', res.data.token)
+						// 鑾峰彇闂ㄥ簵淇℃伅
+						const shopInfoRes = await this.$u.api.getShopInfo({})
+						if (shopInfoRes.code === 200) {
+							this.$store.commit('setShopInfo', shopInfoRes.data)
+						}
 						uni.showToast({ title: '鐧诲綍鎴愬姛', icon: 'success' })
 						setTimeout(() => {
-							uni.switchTab({
-								url: '/pages/shop-index/shop-index'
-							})
+							uni.reLaunch({
+								url: '/shop/pages/store-home/store-home'
+							});
 						}, 1500)
-					} else {
-						uni.showToast({
-							title: res.msg || '鐧诲綍澶辫触',
-							icon: 'none'
-						})
 					}
-				} catch (err) {
-					uni.hideLoading()
-					uni.showToast({
-						title: '鐧诲綍澶辫触',
-						icon: 'none'
-					})
-				}
-			},
-			goToService() {
-				uni.navigateTo({
-					url: '/pages/rich-text/rich-text?type=userAgreement'
 				})
 			},
-			goToPrivacy() {
+			goToService(type) {
 				uni.navigateTo({
-					url: '/pages/rich-text/rich-text?type=privacyPolicy'
+					url: '/pages/rich-text/rich-text?type='+type
 				})
-			}
+			} 
 		}
 	}
 </script>
@@ -172,6 +184,10 @@
 	.password-row {
 		margin-top: 18rpx;
 	}
+	
+	.password-toggle {
+		padding: 10rpx;
+	}
 
 	.input-field {
 		flex: 1;

--
Gitblit v1.9.3