From 2c86a8bd60deed0dd0e044bad6fb83f75d19a332 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 26 十月 2025 15:05:50 +0800
Subject: [PATCH] Merge branch 'feature-task'
---
app/pages/login.vue | 331 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 331 insertions(+), 0 deletions(-)
diff --git a/app/pages/login.vue b/app/pages/login.vue
new file mode 100644
index 0000000..4aef7f9
--- /dev/null
+++ b/app/pages/login.vue
@@ -0,0 +1,331 @@
+<template>
+ <scroll-view class="normal-login-container" scroll-y="true">
+ <view class="logo-content align-center justify-center flex">
+ <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
+ </image>
+ <text class="title">姘戣埅璋冨害绯荤粺</text>
+ </view>
+ <view class="login-form-content">
+ <view class="input-item flex align-center">
+ <view class="iconfont icon-user icon"></view>
+ <input v-model="loginForm.username" class="input" type="text" placeholder="璇疯緭鍏ヨ处鍙�" maxlength="30" />
+ </view>
+ <view class="input-item flex align-center">
+ <view class="iconfont icon-password icon"></view>
+ <input v-model="loginForm.password" type="password" class="input" placeholder="璇疯緭鍏ュ瘑鐮�" maxlength="20" />
+ </view>
+ <view class="input-item flex align-center captcha-container" v-if="captchaEnabled">
+ <view class="iconfont icon-code icon"></view>
+ <input v-model="loginForm.code" type="number" class="input" placeholder="璇疯緭鍏ラ獙璇佺爜" maxlength="4" />
+ <view class="login-code">
+ <image :src="codeUrl" @click="getCode" class="login-code-img" mode="aspectFit"></image>
+ </view>
+ </view>
+ <view class="action-btn">
+ <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">鐧诲綍</button>
+ </view>
+ <view class="wechat-login" @click="handleWechatLogin">
+ <view class="wechat-btn">
+ <image class="wechat-icon" src="/static/icons/profile.png"></image>
+ <text class="wechat-text">寰俊涓�閿櫥褰�</text>
+ </view>
+ </view>
+
+ <view class="xieyi text-center">
+ <text class="text-grey1">鐧诲綍鍗充唬琛ㄥ悓鎰�</text>
+ <text @click.stop="handleUserAgrement" class="text-blue agreement-link">銆婄敤鎴峰崗璁��</text>
+ <text class="text-grey1">鍜�</text>
+ <text @click.stop="handlePrivacy" class="text-blue agreement-link">銆婇殣绉佸崗璁��</text>
+ </view>
+ </view>
+ </scroll-view>
+</template>
+
+<script>
+ import { getCodeImg } from '@/api/login'
+
+ export default {
+ data() {
+ return {
+ codeUrl: "",
+ captchaEnabled: true,
+ // 鐢ㄦ埛娉ㄥ唽寮�鍏�
+ register: false,
+ globalConfig: getApp().globalData.config,
+ loginForm: {
+ username: "",
+ password: "",
+ code: "",
+ uuid: ''
+ }
+ }
+ },
+ created() {
+ this.getCode()
+ },
+ methods: {
+ // 鐢ㄦ埛娉ㄥ唽
+ handleUserRegister() {
+ this.$tab.redirectTo(`/pages/register`)
+ },
+ // 闅愮鍗忚
+ handlePrivacy() {
+ this.$tab.navigateTo('/pages/mine/privacy-policy/index')
+ },
+ // 鐢ㄦ埛鍗忚
+ handleUserAgrement() {
+ this.$tab.navigateTo('/pages/mine/user-agreement/index')
+ },
+ // 鑾峰彇鍥惧舰楠岃瘉鐮�
+ getCode() {
+ getCodeImg().then(res => {
+ this.captchaEnabled = res.captchaEnabled === undefined ? true : res.captchaEnabled
+ if (this.captchaEnabled) {
+ this.codeUrl = 'data:image/gif;base64,' + res.img
+ this.loginForm.uuid = res.uuid
+ }
+ })
+ },
+ // 鐧诲綍鏂规硶
+ async handleLogin() {
+ if (this.loginForm.username === "") {
+ this.$modal.msgError("璇疯緭鍏ユ偍鐨勮处鍙�")
+ } else if (this.loginForm.password === "") {
+ this.$modal.msgError("璇疯緭鍏ユ偍鐨勫瘑鐮�")
+ } else if (this.loginForm.code === "" && this.captchaEnabled) {
+ this.$modal.msgError("璇疯緭鍏ラ獙璇佺爜")
+ } else {
+ this.$modal.loading("鐧诲綍涓紝璇疯�愬績绛夊緟...")
+ this.pwdLogin()
+ }
+ },
+ // 寰俊鐧诲綍鏂规硶
+ async handleWechatLogin() {
+ // #ifdef MP-WEIXIN
+ // 寰俊灏忕▼搴忕櫥褰�
+ uni.login({
+ provider: 'weixin',
+ success: (loginRes) => {
+ console.log('寰俊鐧诲綍鎴愬姛', loginRes);
+ // 鑾峰彇鐢ㄦ埛淇℃伅
+ uni.getUserInfo({
+ provider: 'weixin',
+ success: (infoRes) => {
+ console.log('鐢ㄦ埛淇℃伅鑾峰彇鎴愬姛', infoRes);
+ // 璺宠浆鍒板井淇$櫥褰曠‘璁ら〉闈�
+ this.$tab.navigateTo(`/pages/login/wechat?userInfo=${encodeURIComponent(JSON.stringify(infoRes.userInfo))}`);
+ },
+ fail: (error) => {
+ console.error('鑾峰彇鐢ㄦ埛淇℃伅澶辫触', error);
+ this.$modal.msgError("鑾峰彇寰俊鐢ㄦ埛淇℃伅澶辫触");
+ }
+ });
+ },
+ fail: (error) => {
+ console.error('寰俊鐧诲綍澶辫触', error);
+ this.$modal.msgError("寰俊鐧诲綍澶辫触");
+ }
+ });
+ // #endif
+
+ // #ifndef MP-WEIXIN
+ // H5鎴栧叾浠栧钩鍙版彁绀�
+ this.$modal.msgError("璇峰湪寰俊瀹㈡埛绔腑浣跨敤寰俊鐧诲綍鍔熻兘");
+ // #endif
+ },
+ // 瀵嗙爜鐧诲綍
+ async pwdLogin() {
+ this.$store.dispatch('Login', this.loginForm).then(() => {
+ this.$modal.closeLoading()
+ this.loginSuccess()
+ }).catch(() => {
+ if (this.captchaEnabled) {
+ this.getCode()
+ }
+ })
+ },
+ // 鐧诲綍鎴愬姛鍚庯紝澶勭悊鍑芥暟
+ loginSuccess(result) {
+ // 璁剧疆鐢ㄦ埛淇℃伅
+ this.$store.dispatch('GetInfo').then(res => {
+ this.$tab.reLaunch('/pages/index')
+ })
+ }
+ }
+ }
+</script>
+
+<style lang="scss">
+ page {
+ background-color: #ffffff;
+ }
+
+ .normal-login-container {
+ width: 100%;
+ min-height: 100vh;
+ // 闅愯棌婊氬姩鏉′絾淇濇寔婊氬姩鍔熻兘
+ ::-webkit-scrollbar {
+ display: none;
+ width: 0 !important;
+ height: 0 !important;
+ background: transparent;
+ }
+
+ // Firefox婊氬姩鏉¢殣钘�
+ * {
+ scrollbar-width: none; /* Firefox */
+ }
+
+ // IE/Edge婊氬姩鏉¢殣钘�
+ * {
+ -ms-overflow-style: none; /* IE 10+ */
+ }
+
+ .logo-content {
+ width: 100%;
+ font-size: 21px;
+ text-align: center;
+ padding-top: 15%;
+
+ image {
+ border-radius: 4px;
+ }
+
+ .title {
+ margin-left: 10px;
+ }
+ }
+
+ .login-form-content {
+ text-align: center;
+ margin: 20px auto;
+ margin-top: 15%;
+ width: 80%;
+
+ .input-item {
+ margin: 20px auto;
+ background-color: #f5f6f7;
+ height: 45px;
+ border-radius: 20px;
+
+ .icon {
+ font-size: 38rpx;
+ margin-left: 10px;
+ }
+
+ .input {
+ margin-left: 20rpx;
+ width: 100%;
+ height: 45px;
+ background: none;
+ }
+ }
+
+ .captcha-container {
+ width: 100%;
+ margin: 20px auto;
+ background-color: #f5f6f7;
+ height: 45px;
+ border-radius: 20px;
+ padding-right: 10rpx;
+ box-sizing: border-box;
+
+ .icon {
+ font-size: 38rpx;
+ margin-left: 10px;
+ }
+
+ .input {
+ margin-left: 20rpx;
+ width: 60%;
+ height: 45px;
+ background: none;
+ }
+
+ .login-code {
+ width: 30%;
+ height: 45px;
+ margin-left: 10rpx;
+ border-left: 1px solid #e0e0e0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+
+ .login-code-img {
+ max-width: 100%;
+ max-height: 45px;
+ object-fit: contain;
+ cursor: pointer;
+ }
+ }
+ }
+
+ .action-btn {
+ margin: 40rpx 0;
+
+ .login-btn {
+ height: 90rpx;
+ font-size: 32rpx;
+ }
+ }
+
+ .wechat-login {
+ margin: 20rpx 0;
+
+ .wechat-btn {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background-color: #07c160;
+ height: 90rpx;
+ border-radius: 20px;
+
+ .wechat-icon {
+ width: 40rpx;
+ height: 40rpx;
+ margin-right: 10rpx;
+ }
+
+ .wechat-text {
+ color: white;
+ font-size: 32rpx;
+ }
+ }
+ }
+
+ .reg {
+ margin: 20rpx 0;
+
+ .text-grey1 {
+ color: #888;
+ }
+
+ .text-blue {
+ margin: 0 10rpx;
+ color: #007AFF;
+ }
+ }
+
+ .xieyi {
+ margin: 50rpx 0 30rpx 0;
+ padding: 20rpx 0;
+ line-height: 2;
+
+ .text-grey1 {
+ color: #888;
+ font-size: 24rpx;
+ }
+
+ .agreement-link {
+ color: #007AFF;
+ font-size: 24rpx;
+ padding: 10rpx 8rpx;
+ margin: 0 5rpx;
+ display: inline-block;
+ position: relative;
+ z-index: 10;
+ }
+ }
+ }
+ }
+</style>
\ No newline at end of file
--
Gitblit v1.9.1