123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <template>
- <view>
- <view class="login-logo">
- <u-image width="120rpx" height="120rpx" src="../../static/img/logo.png" border-radius="20"></u-image>
- <h3>停车场管理端</h3>
- </view>
- <view class="login-form">
- <u-form :model="form" ref="uForm">
- <view class="login-form-row">
- <u-icon name="account-fill" color="#b0b8c8" size="40"></u-icon>
- <u-line color="#c3c9d3" length="30" direction="col" margin="20rpx"/>
- <u-form-item label="" prop="phone" :border-bottom="false">
- <u-input v-model="form.phone" placeholder="请输入手机号" type="number" maxlength="11"/>
- </u-form-item>
- </view>
- <view class="login-form-row">
- <u-icon name="more-circle-fill" color="#b0b8c8" size="40"></u-icon>
- <u-line color="#c3c9d3" length="30" direction="col" margin="20rpx"/>
- <u-form-item label="" prop="code" :border-bottom="false">
- <u-input v-model="form.code" placeholder="请输入验证码" type="number"/>
- </u-form-item>
- </view>
- <view class="login-code" >
- <span @click="getCode" >{{codeTips}}</span>
- </view>
- </u-form>
- <u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start" keep-running>
- </u-verification-code>
- <u-button :disabled="!(form.phone&&form.code)" style="margin-top: 30px;" type="primary" @click="finish">登录</u-button>
- </view>
- </view>
- </template>
- <script>
- import * as API from '@/apis/login.js'
- import app from '@/utils/app.js'
- export default {
- data() {
- return {
- form: {
- name: '',
- intro: '',
-
- phone: '',
- code: '',
- },
- backUrl: "",
- message: "",
- codeTips: '',
- isSendMsgIng: false,
- sendMsgSecond: 60 * 2
-
- }
- },
- onLoad(op) {
-
- //登录过直接进入主页
- let settting=app.getSetting();
- if(settting&&settting.user_id){
- uni.switchTab({
- url: '../index/index'
- })
- }
-
- this.message = op.message;
- this.backUrl = op.back;
- if (op.phone) {
- this.form.phone = op.phone;
- }
-
- },
- methods: {
-
- codeChange(text) {
- this.codeTips = text;
- },
- //倒计时
-
- end() {
- this.sendMsgSecond = 2 * 60;
- this.isSendMsgIng = false;
- },
- finish() {
-
- uni.showLoading({
- title: "登录中",
- mask: true
- })
-
- //登录请求,后台校验验证码
- API.checkLogin({
- verifyCode: this.form.code,
- phoneNum: this.form.phone
- }).then((response) => {
- uni.hideLoading();
- if(!response.success){
- uni.showToast({
- title: response.msg||' 登录失败',
- icon: "none"
- })
-
- return;
- }
- //console.log(response.data);
- app.addSetting(response.data);
- uni.switchTab({
- url: '../index/index'
- })
-
- }).catch(error => {
- //console.log(error)
- uni.hideLoading();
-
- })
-
- },
- start() {
- let _this=this;
- if (!this.isSendMsgIng) {
- API.getVerifyCode(this.form.phone).then((response) => {
- if(!response.success){
- uni.showToast({
- title:response.msg||'验证码发送失败',
- icon:'error'
- });
- _this.$refs.uCode.reset();
- return;
- }
- uni.showToast({
- title:'验证码已发送'
- })
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
-
-
-
- }
- },
- // 获取验证码
- getCode() {
-
-
- if(!this.$refs.uCode.canGetCode){
- uni.showToast({
- title: '倒计时结束后再发送',
- icon: "none"
- })
- return
- }
-
- var checkPhoneResult = API.checkPhone(this.form.phone);
-
- if (checkPhoneResult !== true) {
- uni.showToast({
- title: checkPhoneResult,
- icon:'none'
-
- })
- return;
- }
- this.$refs.uCode.start();
- },
-
- /* query(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
-
- API.findByOpenId({
-
- openId: this.carhelp.getOpenId(),
-
- }).then((response) => {
- this.loginset(response)
-
-
- }).catch(error => {
- uni.hideLoading();
- // if (!this.carhelp.getOpenId()) {
- // uni.showToast({
- // title: "请使用“微信”访问本系统登录"
- // })
- // return
- // }
- var time = this.carhelp.get("getvcodetime");
- if (time) {
- //this.$refs.uCode.start();
- var nowtime = new Date().getTime()
- var differ = (nowtime - time) / 1000
- if (differ < 2 * 60) {
- this.sendMsgSecond = 2 * 60 - parseInt(differ)
- this.isSendMsgIng = true;
- this.$refs.uCode.start();
- }
- }
- })
- } */
- },
- onReady() {
- //this.query()
-
- }
- }
- </script>
- <style>
- page{
- background: url(../../static/img/bgbg.png) no-repeat;
- background-size: 100%;
- }
- </style>
- <style lang="scss" scoped>
- .login-logo{
- display: flex;
- flex-direction: column;
- align-items: center;
- padding-top: 20%;
- h3{
- margin:15px 0;
- }
- }
-
- /deep/.u-form-item{
- padding: 0;
- flex: 1;
- }
- .login-form{
- width: 80%;
- margin:50px auto 0;
- }
- .login-form-row{
- height: 80rpx;
- border: 1rpx solid #c7d1e2;
- background-color: #fff;
- border-radius: 20rpx;
- display: flex;
- align-items: center;
- padding: 4rpx 20rpx;
- margin-bottom: 30rpx;
- }
- .login-code{
- text-align: right;
- span{
- color:#005AD9;
- }
- }
- .login-btn{
- background-color: #cdd7e8;
- border-color:#cdd7e8 ;
- color:#fff;
- margin-top: 30px;
- }
- </style>
|