Bläddra i källkod

'登录页面'

贾宇博 1 månad sedan
förälder
incheckning
b5b819127e

+ 41 - 42
pages/login.vue

@@ -2,7 +2,7 @@
 	<view class="normal-login-container">
 		<view class="logo-content align-center justify-center flex">
 			<!-- <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix" /> -->
-			 <image :src="imagePath" mode="aspectFit" style="width: 100rpx;height: 100rpx;"></image>
+			<image :src="imagePath" mode="aspectFit" style="width: 100rpx;height: 100rpx;"></image>
 			<text class="title">乐融融</text>
 		</view>
 		<!-- <view class="login-form-content">
@@ -19,9 +19,9 @@
         <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
       </view>
     </view> -->
-	<view>
-		
-	</view>
+		<view>
+
+		</view>
 
 		<up-popup :show="show" mode="bottom" @close="close" @open="open">
 			<view class="popup-content">
@@ -62,8 +62,8 @@
 	// const globalConfig = getApp().globalData.config; // 注意:getApp()是特定于小程序的方法
 	const register = ref(false); // 用户注册开关
 	const loginForm = reactive({
-		username: "admin",
-		password: "admin123",
+		username: "",
+		password: "",
 		code: "",
 		uuid: ''
 	});
@@ -118,39 +118,38 @@
 
 	// 登录方法
 	const handleLogin = async () => {
-			uni.showLoading({
-				title: "登录中,请耐心等待..."
-			}); // 使用uni-app的loading方法替代$modal.loading
-			// 获取服务商信息
-			uni.getProvider({
-				service: "oauth",
-				success: (res) => {
-					console.log(res);
-				}
-			});
-			
-			// 获取code
-			uni.login({
-				provider: 'weixin',
-				success: (res) => {
-					loginForm.code = res.code;
-					// 获取用户信息
-					uni.getUserInfo({
-						success: (res) => {
-							console.log("用户信息", res);
-						}
-					});
-					
-					pwdLogin();
-	
-					uni.hideLoading()
-				},
-			});
-		};
-	
+		uni.showLoading({
+			title: "登录中,请耐心等待..."
+		}); // 使用uni-app的loading方法替代$modal.loading
+		// 获取服务商信息
+		uni.getProvider({
+			service: "oauth",
+			success: (res) => {
+				console.log(res);
+			}
+		});
+
+		// 获取code
+		uni.login({
+			provider: 'weixin',
+			success: (res) => {
+				loginForm.code = res.code;
+				// 获取用户信息
+				uni.getUserInfo({
+					success: (res) => {
+						console.log("用户信息", res);
+					}
+				});
+
+				pwdLogin();
+
+				uni.hideLoading()
+			},
+		});
+	};
+
 	// 密码登录
 	const pwdLogin = async () => {
-		console.log('>>>>>>>234568');
 		if (!store) {
 			console.error("Store is not defined");
 			return;
@@ -160,20 +159,20 @@
 			loginSuccess();
 		})
 	};
-	
+
 
 	// 登录成功后,处理函数
 	const loginSuccess = () => {
-		// 设置用户信息
 		store.dispatch('GetInfo').then(() => {
-			router.replace('/pages/index');
+			uni.switchTab({// 跳转 tabBar 中的页面
+				url: '/pages/index'
+			});
+
 		});
 	};
 
-
 	// 页面加载时获取验证码
 	onMounted(() => {
-		// getCode();
 		open();
 	});
 </script>

+ 234 - 231
pages/mine.vue

@@ -1,49 +1,46 @@
 <template>
-  <view class="mine-container" :style="{height: `${windowHeight}px`}">
-    <!--顶部个人信息栏-->
-    <view class="header-section">
-      <view class="flex padding justify-between">
-        <view class="flex align-center">
-          <view v-if="!avatar" class="cu-avatar xl round bg-white">
-            <view class="iconfont icon-people text-gray icon"></view>
-          </view>
-          <image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round" mode="widthFix">
-          </image>
-          <view v-if="!name" @click="handleToLogin" class="login-tip">
-            点击登录
-          </view>
-          <view v-if="name" @click="handleToInfo" class="user-info">
-            <view class="u_title">
-              用户名:{{ name }}
-            </view>
-          </view>
-        </view>
-        <view @click="handleToInfo" class="flex align-center">
-          <text>个人信息</text>
-          <view class="iconfont icon-right"></view>
-        </view>
-      </view>
-    </view>
-
-    <view class="content-section">
-     <view class="Wrapper-grid">
-     				   <up-grid :border="false" col="4" @click="handleGridClick">
-     				     <up-grid-item 
-     				       v-for="(item, index) in serviceList" 
-     				       :key="index"
-     				       :custom-style="{ padding: '20rpx' }"
-     				     >
-     				       <!-- 图标 -->
-     				       <image :src="item.icon" class="service-img" mode="aspectFit" />
-     				       
-     				       <!-- 文本 -->
-     				       <text class="grid-text">{{ item.name }}</text>
-     				     </up-grid-item>
-     				   </up-grid>
-     				   			
-     				   <up-toast ref="uToastRef" />
-     </view>
-<!-- 
+	<view class="mine-container" :style="{height: `${windowHeight}px`}">
+		<!--顶部个人信息栏-->
+		<view class="header-section">
+			<view class="flex padding justify-between">
+				<view class="flex align-center">
+					<view v-if="!avatar" class="cu-avatar xl round bg-white">
+						<view class="iconfont icon-people text-gray icon"></view>
+					</view>
+					<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round"
+						mode="widthFix">
+					</image>
+					<view v-if="!name" @click="handleToLogin" class="login-tip">
+						点击登录
+					</view>
+					<view v-if="name" @click="handleToInfo" class="user-info">
+						<view class="u_title">
+							用户名:{{ name }}
+						</view>
+					</view>
+				</view>
+				<view @click="handleToInfo" class="flex align-center">
+					<image :src="imagePath" mode="aspectFit" style="width: 50rpx;height: 50rpx;"></image>
+				</view>
+			</view>
+		</view>
+
+		<view class="content-section">
+			<view class="Wrapper-grid">
+				<up-grid :border="false" col="4" @click="handleGridClick">
+					<up-grid-item v-for="(item, index) in serviceList" :key="index"
+						:custom-style="{ padding: '20rpx' }">
+						<!-- 图标 -->
+						<image :src="item.icon" class="service-img" mode="aspectFit" />
+
+						<!-- 文本 -->
+						<text class="grid-text">{{ item.name }}</text>
+					</up-grid-item>
+				</up-grid>
+
+				<up-toast ref="uToastRef" />
+			</view>
+			<!-- 
       <view class="menu-list">
         <view class="list-cell list-cell-arrow" @click="handleToEditInfo">
           <view class="menu-item-box">
@@ -70,9 +67,9 @@
           </view>
         </view>
       </view> -->
-    </view>
-  </view>
-  <!-- <view>
+		</view>
+	</view>
+	<!-- <view>
 	  <uni-popup ref="popup" type="dialog">
 	    <uni-popup-dialog type="info" cancelText="关闭" confirmText="退出"
 	                      title="通知" content="确定注销并退出系统吗" 
@@ -84,193 +81,199 @@
 </template>
 
 <script setup>
-  import storage from '@/utils/storage'
-  import store from '@/store'
-  import { ref } from "vue";
-  import config from '@/config.js'
-  const name=store.state.user.name;
-  const version= config.appInfo.version;
-  const avatar=ref(store.state.user.avatar);
-  const windowHeight=ref(uni.getSystemInfoSync().windowHeight - 50);
-  const popup = ref(null);
-  
-  uni.$on('refresh', () => {
-      avatar.value=store.state.user.avatar;
-  }) 
-  
-  
-  const serviceList = ref([
-  	{
-  		icon: '/static/my/待付款.png',
-  		name: '待付款'
-  	},
-  	{
-  		icon: '/static/my/待服务.png',
-  		name: '待服务'
-  	},
-  	{
-  		icon: '/static/my/已完成.png',
-  		name: '已完成'
-  	},
-  	{
-  		icon: '/static/my/评论.png',
-  		name: '评论'
-  	},
-  	{
-  		icon: '/static/my/钱包.png',
-  		name: '钱包'
-  	},
-  	{
-  		icon: '/static/my/浏览记录.png',
-  		name: '浏览记录'
-  	},
-	{
-		icon: '/static/my/收藏.png',
-		name: '收藏'
-	},
-	{
-		icon: '/static/my/客服.png',
-		name: '帮助与客服'
-	},
-  ]);
-  
-  function handleToInfo() {
-	  uni.navigateTo({
-	  	url: '/pages_mine/pages/info/index'
-	  });
-  };
- 
-
-  function handleToAvatar() {
-	  uni.navigateTo({
-	  	url: '/pages_mine/pages/avatar/index'
-	  });
-  };
-  function handleLogout() {
-	  popup.value.open();
-  };
-  function dialogConfirm() {
-  	//console.log('----------------点击确认------------')
-	store.dispatch('LogOut').then(() => {
+	import storage from '@/utils/storage'
+	import store from '@/store'
+	import {
+		ref
+	} from "vue";
+	import config from '@/config.js'
+	const name = store.state.user.name;
+	const version = config.appInfo.version;
+	const avatar = ref(store.state.user.avatar);
+	const windowHeight = ref(uni.getSystemInfoSync().windowHeight - 50);
+	const popup = ref(null);
+	const imagePath = '/static/设置.png';
+
+	uni.$on('refresh', () => {
+		avatar.value = store.state.user.avatar;
+	})
+
+
+	const serviceList = ref([{
+			icon: '/static/my/待付款.png',
+			name: '待付款'
+		},
+		{
+			icon: '/static/my/待服务.png',
+			name: '待服务'
+		},
+		{
+			icon: '/static/my/已完成.png',
+			name: '已完成'
+		},
+		{
+			icon: '/static/my/评论.png',
+			name: '评论'
+		},
+		{
+			icon: '/static/my/钱包.png',
+			name: '钱包'
+		},
+		{
+			icon: '/static/my/浏览记录.png',
+			name: '浏览记录'
+		},
+		{
+			icon: '/static/my/收藏.png',
+			name: '收藏'
+		},
+		{
+			icon: '/static/my/客服.png',
+			name: '帮助与客服'
+		},
+	]);
+
+	function handleToInfo() {
+		uni.navigateTo({
+			url: '/pages_mine/pages/info/index'
+		});
+	};
+
+
+	function handleToAvatar() {
+		uni.navigateTo({
+			url: '/pages_mine/pages/avatar/index'
+		});
+	};
+
+	function handleLogout() {
+		popup.value.open();
+	};
+
+	function dialogConfirm() {
+		//console.log('----------------点击确认------------')
+		store.dispatch('LogOut').then(() => {
 			uni.reLaunch({
 				url: '/pages/login'
 			});
-	})
-  };
-  function dialogClose() {
-  	//console.log('点击关闭')
-  };
-  function handleHelp() {
-	  uni.navigateTo({
-	  	url: '/pages_mine/pages/help/index'
-	  });
-  };
-  function handleAbout() {
-	  uni.navigateTo({
-	  	url: '/pages_mine/pages/about/index'
-	  });
-  };
-  function handleJiaoLiuQun() {
-	  uni.showToast({
-	    title: 'QQ群:133713780',
-	    mask: false,
-		icon:"none",
-	    duration: 1000
-	  });
-  };
-  function handleBuilding() {
-	  uni.showToast({
-	    title: '模块建设中~',
-	    mask: false,
-		icon:"none",
-	    duration: 1000
-	  });
-  }
-  
+		})
+	};
+
+	function dialogClose() {
+		//console.log('点击关闭')
+	};
+
+	function handleHelp() {
+		uni.navigateTo({
+			url: '/pages_mine/pages/help/index'
+		});
+	};
+
+	function handleAbout() {
+		uni.navigateTo({
+			url: '/pages_mine/pages/about/index'
+		});
+	};
+
+	function handleJiaoLiuQun() {
+		uni.showToast({
+			title: 'QQ群:133713780',
+			mask: false,
+			icon: "none",
+			duration: 1000
+		});
+	};
+
+	function handleBuilding() {
+		uni.showToast({
+			title: '模块建设中~',
+			mask: false,
+			icon: "none",
+			duration: 1000
+		});
+	}
 </script>
 
 <style lang="scss">
+	page {
+		background-color: #f5f6f7;
+	}
+
+	.mine-container {
+		width: 100%;
+		height: 100%;
+
+
+		.header-section {
+			padding: 15px 15px 45px 15px;
+			background-color: #3c96f3;
+			color: white;
+
+			.login-tip {
+				font-size: 18px;
+				margin-left: 10px;
+			}
+
+			.cu-avatar {
+				border: 2px solid #eaeaea;
+
+				.icon {
+					font-size: 40px;
+				}
+			}
+
+			.user-info {
+				margin-left: 15px;
+
+				.u_title {
+					font-size: 18px;
+					line-height: 30px;
+				}
+			}
+		}
+
+		.content-section {
+			position: relative;
+			top: -50px;
+
+			.mine-actions {
+				margin: 15px 15px;
+				padding: 20px 0px;
+				border-radius: 8px;
+				background-color: white;
+
+				.action-item {
+					.icon {
+						font-size: 28px;
+					}
+
+					.text {
+						display: block;
+						font-size: 13px;
+						margin: 8px 0px;
+					}
+				}
+			}
+		}
+	}
+
+
+	.Wrapper-grid {
+		margin-top: 120rpx;
+	}
+
+	/* 图标样式 */
+	.service-img {
+		width: 60rpx;
+		height: 60rpx;
+		margin-bottom: 10rpx;
+	}
 
-  page {
-    background-color: #f5f6f7;
-  }
-
-  .mine-container {
-    width: 100%;
-    height: 100%;
-
-
-    .header-section {
-      padding: 15px 15px 45px 15px;
-      background-color: #3c96f3;
-      color: white;
-
-      .login-tip {
-        font-size: 18px;
-        margin-left: 10px;
-      }
-
-      .cu-avatar {
-        border: 2px solid #eaeaea;
-
-        .icon {
-          font-size: 40px;
-        }
-      }
-
-      .user-info {
-        margin-left: 15px;
-
-        .u_title {
-          font-size: 18px;
-          line-height: 30px;
-        }
-      }
-    }
-
-    .content-section {
-      position: relative;
-      top: -50px;
-
-      .mine-actions {
-        margin: 15px 15px;
-        padding: 20px 0px;
-        border-radius: 8px;
-        background-color: white;
-
-        .action-item {
-          .icon {
-            font-size: 28px;
-          }
-
-          .text {
-            display: block;
-            font-size: 13px;
-            margin: 8px 0px;
-          }
-        }
-      }
-    }
-  }
-  
-  
-  .Wrapper-grid{
-  	margin-top: 120rpx;
-  }
-  
-  /* 图标样式 */
-  .service-img {
-    width: 60rpx;
-    height: 60rpx;
-    margin-bottom: 10rpx;
-  }
-  
-  /* 文本样式 */
-  .grid-text {
-    font-size: 24rpx;
-    color: #333;
-    text-align: center;
-    margin-top: 10rpx;
-  }
-  
-</style>
+	/* 文本样式 */
+	.grid-text {
+		font-size: 24rpx;
+		color: #333;
+		text-align: center;
+		margin-top: 10rpx;
+	}
+</style>

BIN
static/设置.png


+ 0 - 2
store/modules/user.ts

@@ -41,14 +41,12 @@ const user: Module<UserState, UserState> = {
   actions: {
     // 登录
     Login({ commit }, userInfo: UserForm) {
-		console.log('>>>>進來了', userInfo);
       const username = userInfo.username
       const password = userInfo.password
       const code = userInfo.code
       const uuid = userInfo.uuid
       return new Promise((resolve, reject) => {
         login(username, password, code, uuid).then((res: any) => {
-			// console.log(login(),'接口调用了')
           setToken(res.token)
           commit('SET_TOKEN', res.token)
           resolve(res)

+ 6 - 4
unpackage/dist/dev/mp-weixin/pages/login.js

@@ -29,8 +29,8 @@ const _sfc_main = {
     const imagePath = "/static/logo.png";
     common_vendor.ref(false);
     const loginForm = common_vendor.reactive({
-      username: "admin",
-      password: "admin123",
+      username: "",
+      password: "",
       code: "",
       uuid: ""
     });
@@ -75,7 +75,6 @@ const _sfc_main = {
       });
     };
     const pwdLogin = async () => {
-      console.log(">>>>>>>234568");
       if (!store_index.store) {
         console.error("Store is not defined");
         return;
@@ -86,7 +85,10 @@ const _sfc_main = {
     };
     const loginSuccess = () => {
       store_index.store.dispatch("GetInfo").then(() => {
-        router.replace("/pages/index");
+        common_vendor.index.switchTab({
+          // 跳转 tabBar 中的页面
+          url: "/pages/index"
+        });
       });
     };
     common_vendor.onMounted(() => {

+ 9 - 7
unpackage/dist/dev/mp-weixin/pages/mine.js

@@ -30,6 +30,7 @@ const _sfc_main = {
     const avatar = common_vendor.ref(store_index.store.state.user.avatar);
     const windowHeight = common_vendor.ref(common_vendor.index.getSystemInfoSync().windowHeight - 50);
     common_vendor.ref(null);
+    const imagePath = "/static/设置.png";
     common_vendor.index.$on("refresh", () => {
       avatar.value = store_index.store.state.user.avatar;
     });
@@ -95,8 +96,9 @@ const _sfc_main = {
         h: common_vendor.t(common_vendor.unref(name)),
         i: common_vendor.o(handleToInfo)
       } : {}, {
-        j: common_vendor.o(handleToInfo),
-        k: common_vendor.f(serviceList.value, (item, index, i0) => {
+        j: imagePath,
+        k: common_vendor.o(handleToInfo),
+        l: common_vendor.f(serviceList.value, (item, index, i0) => {
           return {
             a: item.icon,
             b: common_vendor.t(item.name),
@@ -104,18 +106,18 @@ const _sfc_main = {
             d: "645199aa-1-" + i0 + ",645199aa-0"
           };
         }),
-        l: common_vendor.p({
+        m: common_vendor.p({
           ["custom-style"]: {
             padding: "20rpx"
           }
         }),
-        m: common_vendor.o(_ctx.handleGridClick),
-        n: common_vendor.p({
+        n: common_vendor.o(_ctx.handleGridClick),
+        o: common_vendor.p({
           border: false,
           col: "4"
         }),
-        o: common_vendor.sr("uToastRef", "645199aa-2"),
-        p: `${windowHeight.value}px`
+        p: common_vendor.sr("uToastRef", "645199aa-2"),
+        q: `${windowHeight.value}px`
       });
     };
   }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1 - 1
unpackage/dist/dev/mp-weixin/pages/mine.wxml


BIN
unpackage/dist/dev/mp-weixin/static/设置.png


+ 0 - 1
unpackage/dist/dev/mp-weixin/store/modules/user.js

@@ -37,7 +37,6 @@ const user = {
   actions: {
     // 登录
     Login({ commit }, userInfo) {
-      console.log(">>>>進來了", userInfo);
       const username = userInfo.username;
       const password = userInfo.password;
       const code = userInfo.code;