|
@@ -1,101 +1,167 @@
|
|
|
<template>
|
|
|
- <view>
|
|
|
- <view class="l-topbox">
|
|
|
- <text>欢迎登录</text>
|
|
|
- </view>
|
|
|
- <view class="box">
|
|
|
+ <view>
|
|
|
+ <view class="remain">
|
|
|
+ <h1>欢迎回来</h1>
|
|
|
+ <view class="wel">请登录您的账号</view>
|
|
|
+ </view>
|
|
|
+ <view class="form">
|
|
|
+ <u-form :model="form" ref="uForm" label-width="100px" label-position="top">
|
|
|
+ <u-form-item label="手机号" prop="phone">
|
|
|
+ <view class="form-input">
|
|
|
+ <u-input v-model="form.phone" type="number" border="surround" maxlength='11'
|
|
|
+ placeholder='请输入手机号码' :clearable='false' />
|
|
|
+ </view>
|
|
|
+ </u-form-item>
|
|
|
+ <u-form-item label="密码" prop="password">
|
|
|
+ <view class="form-input">
|
|
|
+ <u-input v-model="form.password" type="password" placeholder='请输入密码' :clearable='false' />
|
|
|
+ </view>
|
|
|
+ </u-form-item>
|
|
|
+ </u-form>
|
|
|
+ <view style="font-size: 13px;">忘记密码?</view>
|
|
|
+ <view class="btn">
|
|
|
+ <view style="margin-bottom: 10px;">
|
|
|
+ <u-radio-group v-model="value" :wrap="true">
|
|
|
+ <u-radio :label="radioLabel"></u-radio>
|
|
|
+ </u-radio-group>
|
|
|
+ </view>
|
|
|
+ <view>
|
|
|
+ <u-button type="error" shape="circle" text="登录" @click="submit()"></u-button>
|
|
|
+ </view>
|
|
|
+ <view class="tip" @click="toRegister()">还没有账号?马上注册</view>
|
|
|
+ </view>
|
|
|
|
|
|
- <view class="item">
|
|
|
- <view class="l">手机号:</view>
|
|
|
- <view class="r">
|
|
|
- <u-input v-model="form.key" placeholder="请输入手机号"/>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="item">
|
|
|
- <view class="l">密码:</view>
|
|
|
- <view class="r">
|
|
|
- <u-input v-model="form.password" placeholder="请输入密码" type="password"/>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="common-btn" @click="loginFn">确认登录</view>
|
|
|
- </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-export default {
|
|
|
- data() {
|
|
|
- return {
|
|
|
- sliderVerifyFLag: false, //滑块验证
|
|
|
- form: {
|
|
|
- key: '',
|
|
|
- password: ''
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
- methods: {
|
|
|
- loginFn() {
|
|
|
- if (!this.form.key) {
|
|
|
- this.$common.toast('请输入登录名');
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!this.form.password) {
|
|
|
- this.$common.toast('请输入密码');
|
|
|
- return;
|
|
|
- }
|
|
|
- let openid = uni.getStorageSync('openid');
|
|
|
- if (!openid) {
|
|
|
- openid = uni.getStorageSync('login_openid');
|
|
|
- }
|
|
|
- this.form.openid = openid
|
|
|
- this.$api.doLogin(this.form).then(resp => {
|
|
|
- let data = resp.data;
|
|
|
-
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ sliderVerifyFLag: false, //滑块验证
|
|
|
+ form: {
|
|
|
+ phone: '',
|
|
|
+ password: ''
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ phone: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入手机号',
|
|
|
+ trigger: 'blur,change'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // 自定义验证函数,见上说明
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ // 上面有说,返回true表示校验通过,返回false表示不通过
|
|
|
+ // uni.$u.test.mobile()就是返回true或者false的
|
|
|
+ return uni.$u.test.mobile(value);
|
|
|
+ },
|
|
|
+ message: '手机号码不正确',
|
|
|
+ // 触发器可以同时用blur和change
|
|
|
+ trigger: ['change', 'blur'],
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ password: [{
|
|
|
+ required: true,
|
|
|
+ message: '请输入密码',
|
|
|
+ trigger: 'blur,change'
|
|
|
+ }]
|
|
|
+ },
|
|
|
+ radioLabel: "登录同意《用户协议》和《隐私政策》",
|
|
|
+ value: '',
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onReady() {
|
|
|
+ this.$refs.uForm.setRules(this.rules);
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ loginFn() {
|
|
|
+ if (!this.form.key) {
|
|
|
+ this.$common.toast('请输入登录名');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.form.password) {
|
|
|
+ this.$common.toast('请输入密码');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let openid = uni.getStorageSync('openid');
|
|
|
+ if (!openid) {
|
|
|
+ openid = uni.getStorageSync('login_openid');
|
|
|
+ }
|
|
|
+ this.form.openid = openid
|
|
|
+ this.$api.doLogin(this.form).then(resp => {
|
|
|
+ let data = resp.data;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+
|
|
|
+ this.$refs.uForm.validate().then(res => {
|
|
|
+ this.$api.doLogin(this.form).then(resp => {
|
|
|
+ console.log(resp)
|
|
|
+ let data = resp.data;
|
|
|
+ if(resp.code==200){
|
|
|
+ let data = resp.data;
|
|
|
+ uni.$u.toast('登录成功,欢迎你'+data.appUser.name)
|
|
|
+ localStorage.setItem('token',data.tokenInfo.tokenValue)
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/login/chooseRole'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch(errors => {
|
|
|
+ uni.$u.toast('校验失败')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ radioChange() {
|
|
|
+ console.log("1111")
|
|
|
+ },
|
|
|
+ toRegister() {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/pages/login/register'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
-page {
|
|
|
- background-color: #fff;
|
|
|
-}
|
|
|
+ page {
|
|
|
+ background-color: #fff;
|
|
|
+ padding: 30px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .remain {
|
|
|
+ margin: 40px 50px 0;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+
|
|
|
+ .wel {
|
|
|
+ margin-top: 10px;
|
|
|
+ }
|
|
|
|
|
|
-.l-topbox {
|
|
|
- //background-color: #0080ff;
|
|
|
- height: 400rpx;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- //border-radius: 0 0 30rpx 30rpx;
|
|
|
- margin-bottom: 50rpx;
|
|
|
- background-image: url(../../static/login-bg.png);
|
|
|
- background-size: 100% 100%;
|
|
|
+ .form {
|
|
|
+ // margin: 0 30px;
|
|
|
+ height: 200px;
|
|
|
+ // display: flex;
|
|
|
+ // align-items: center;
|
|
|
+ // justify-content: center;
|
|
|
+ }
|
|
|
|
|
|
- text {
|
|
|
- font-size: 50rpx;
|
|
|
- font-weight: bold;
|
|
|
- color: #fff;
|
|
|
- }
|
|
|
-}
|
|
|
+ .form-input {
|
|
|
+ width: 100%;
|
|
|
+ background-color: #E8E8E8;
|
|
|
+ border-radius: 5px;
|
|
|
+ margin-top: 5px;
|
|
|
+ }
|
|
|
|
|
|
-@import '@/common/common.scss';
|
|
|
-.box {
|
|
|
- box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.05);
|
|
|
- background-color: #fff;
|
|
|
- box-sizing: border-box;
|
|
|
- margin: 60rpx;
|
|
|
- margin-top: -150rpx;
|
|
|
- width: auto;
|
|
|
- border-radius: 10rpx;
|
|
|
-}
|
|
|
+ .btn {
|
|
|
+ margin: 25px 10px;
|
|
|
+ }
|
|
|
|
|
|
-.common-btn {
|
|
|
- margin: 100rpx 60rpx;
|
|
|
- width: auto;
|
|
|
- height: 98rpx;
|
|
|
- box-shadow: 0 30rpx 30rpx -15rpx rgba(0, 128, 255, 0.2);
|
|
|
-}
|
|
|
-</style>
|
|
|
+ .tip {
|
|
|
+ margin-top: 30px;
|
|
|
+ text-align: center;
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+</style>
|