123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- <template>
- <view>
- <view class="remain">
- <h1>账号登录</h1>
- </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: 20rpx;font-size: 28rpx;">
- <u-checkbox-group v-model="value" :wrap="true">
- <u-checkbox name="1"></u-checkbox>登录同意<text class="blue-class">《用户协议》</text>和<text
- class="blue-class">《隐私政策》</text>
- </u-checkbox-group>
- </view>
- <view>
- <u-button type="error" shape="circle" text="登录" @click="submit()"></u-button>
- </view>
- <view class="tip" @click="toRegister()">还没有账号?马上<text class="register_btn blue-class">注册</text></view>
- </view>
- </view>
- </view>
- </template>
- <script>
- 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: ["1"],
- }
- },
- onReady() {
- this.$refs.uForm.setRules(this.rules);
- },
- methods: {
- submit() {
- this.$refs.uForm.validate().then(res => {
- let value = this.value;
- if (value.length == 0) {
- this.$common.toast('请先同意协议');
- return;
- }
- this.$api.doLogin(this.form).then(resp => {
- if (resp.code == 200) {
- let data = resp.data;
- uni.setStorageSync('token', data.tokenInfo.tokenValue);
- uni.setStorageSync('info',data.appUser)
- this.$common.toBar('/pages/index/index')
- }
- })
- }).catch(errors => {
- uni.$u.toast('校验失败')
- })
- },
- toRegister() {
- this.$common.to('/pages/login/chooseRole')
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #fff;
- padding: 30px;
- }
- .remain {
- margin: 30rpx 150rpx 0;
- text-align: center;
- }
- .wel {
- margin-top: 10px;
- }
- .form {
- // margin: 0 30px;
- height: 200px;
- // display: flex;
- // align-items: center;
- // justify-content: center;
- }
- .form-input {
- width: 100%;
- background-color: #f5f5f5;
- margin-top: 10rpx;
- border-radius: 20rpx;
- border: none;
- }
- .btn {
- margin: 25px 10px;
- }
- .tip {
- margin-top: 30px;
- text-align: center;
- font-size: 14px;
- }
- .blue-class {
- color: #55aaff;
- cursor: pointer;
- }
- .register_btn {
- text-decoration: underline;
- margin-left: 0.5em;
- }
- </style>
|