123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- <template>
- <view class="normal-login-container">
- <view class="logo-content align-center justify-center flex">
- <image :src="login_top" mode="widthFix" class="width100" style="margin-top: -80upx;"></image>
- </view>
- <!-- 账号密码框 -->
- <view class="login-form-content">
- <text style="color: #98AEAF;">账号</text>
- <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>
- <text style="color: #98AEAF;">密码</text>
- <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="login-form-content2">
- <button @click="handleLogin" class="login-btn cu-btn block lg">确认绑定</button>
- <button @click="goregister" class="sign-btn cu-btn block lg">前往注册</button>
- </view>
- </view>
- <!-- <view class="xieyi text-center">
- <text class="text-grey1">登录即代表同意</text>
- <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
- <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
- </view> -->
- </view>
- </template>
- <script>
- // #ifdef H5
- import Verify from '@/pagesA/components/verifition/Verify';
- // #endif
- import config from '@/config'
- const baseUrlImg = config.baseUrlImg
- export default {
- name: 'Login',
- components: {
- // #ifdef H5
- Verify
- // #endif
- },
- data() {
- return {
- description: `${baseUrlImg}/login/description.png`, //登录页面顶部装饰图
- login_top: `${baseUrlImg}/login/login_top.png`,
- //登录页面顶部
- captchaEnabled: true, // 验证码开关 TODO 芋艿:需要抽到配置里
- canIUseGetUserProfile: false, // 用来判断用哪个登录
- globalConfig: getApp().globalData.config,
- userInfo: '',
- loginForm: {
- username: '',
- password: '',
- socialCode: '',
- socialType: 34,
- socialState: '9b2ffbc1-7425-4155-9894-9d5c08541d62'
- }
- };
- },
- onLoad(option) {
- this.loginForm.socialCode = option.socialCode
- },
- methods: {
- //前往注册
- goregister() {
- uni.navigateTo({
- url: `/pages/sign/sign?socialCode=${this.loginForm.socialCode}`
- })
- },
- // 登录方法
- async handleLogin(params) {
- if (this.loginForm.username === '') {
- this.$modal.msgError('请输入您的账号');
- } else if (this.loginForm.password === '') {
- this.$modal.msgError('请输入您的密码');
- } else {
- // 显示验证码
- // if (this.captchaEnabled) {
- // this.$refs.verify.show()
- // } else { // 直接登录
- await this.pwdLogin({});
- // }
- }
- },
- // 密码登录
- async pwdLogin(captchaParams) {
- this.$modal.loading('登录中,请耐心等待...');
- // 执行登录
- this.loginForm.captchaVerification = captchaParams.captchaVerification;
- this.$store.dispatch('Login', this.loginForm).then(() => {
- // uni.setStorageSync('token', res.data.data.token);
- this.$modal.closeLoading();
- this.loginSuccess();
- });
- },
- // 登录成功后,处理函数
- loginSuccess(result) {
- this.$store.dispatch('loadDictDatas');
- // 设置用户信息
- this.$store.dispatch('GetInfo').then(res => {
- this.$tab.reLaunch('/pages/index');
- // this.$tab.reLaunch('/pages/work/index');
- });
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background-color: #ffffff;
- }
- .normal-login-container {
- width: 100%;
- .logo-content {
- width: 100%;
- font-size: 21px;
- text-align: center;
- image {
- border-radius: 4px;
- }
- .title {
- margin-left: 10px;
- }
- }
- .login-form-content {
- text-align: left;
- margin: 20px auto;
- margin-top: 10%;
- width: 80%;
- .input-item {
- margin: 15px auto;
- background-color: #f5f9f7;
- height: 45px;
- border-radius: 20px;
- .icon {
- font-size: 38rpx;
- margin-left: 10px;
- color: #999;
- }
- .input {
- width: 100%;
- font-size: 14px;
- line-height: 20px;
- text-align: left;
- padding-left: 15px;
- }
- }
- .login-btn,
- .sign-btn {
- margin-top: 30px;
- height: 90upx;
- border-radius: 356upx;
- background-color: #4cb2b6;
- color: #ffffff;
- box-shadow: 0px 2upx 6upx 0px rgba(123, 123, 123, 0.3);
- }
- .sign-btn {
- color: #4cb2b6;
- background-color: #f5f9f7;
- }
- .xieyi {
- color: #333;
- margin-top: 20px;
- }
- }
- .easyinput {
- width: 100%;
- }
- }
- // 登录按钮
- .login-form-content2 {
- text-align: center;
- margin: 20px auto;
- margin-top: 0%;
- width: 75%;
- .wx_login {
- height: 100upx;
- width: 450upx;
- // font-size: 16px;
- // padding-top: 2px;
- // background-color: #f5f7f9;
- // color: #728f90;
- // border-radius: 356upx;
- // box-shadow: 0px 2upx 6upx 0px rgba(123, 123, 123, 0.3);
- }
- .or {
- font-size: 20upx;
- margin: 20upx;
- color: #98aeaf;
- }
- }
- .login-code-img {
- height: 45px;
- }
- .wx_icon {
- position: relative;
- margin-top: 27%;
- margin-left: 42%;
- }
- </style>
|