123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410 |
- <template>
- <view>
-
- <view class="main">
- <view class="close" @click="goBack">
- <u-icon name="close" size="32" color="#101010"></u-icon>
- </view>
- <view class="logo">
- <img src="../../assets/img/logo.png" alt="">
- </view>
- <view class="name">
- 荆州市地方铁路有限公司
- </view>
- <view class="login">
- <view class="login-box">
- <view :class="['tel',telHighlight==true?'highlight':'']" >
- <view class="icon">
- <u-icon name="account-fill" size="40"></u-icon>
- </view>
- <view class="line">
- </view>
- <view class="tips">
- <u-input type="number"
- @focus="handleTelFocus" @blur="handleTelBlur"
- v-model="form.phone" placeholder="请填写系统预留手机号码" />
- </view>
- </view>
- <view :class="['pwd',pwdHighlight==true?'highlight':'']">
- <view class="icon">
- <u-icon name="chat-fill" size="40"></u-icon>
- </view>
- <view class="line">
- </view>
- <view class="tips">
- <view class="input">
- <u-input type="number" v-model="form.code"
- @focus="handlePwdFocus" @blur="handlePwdBlur"
- placeholder="请输入验证码" />
- </view>
- <view class="verification-code" @click="getCode" >{{codeTips}}</view>
- <u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start">
- </u-verification-code>
- </view>
- </view>
- </view>
- </view>
-
- <view class="btn">
- <button
- :class="{
- 'login-btn':!(form.phone&&form.code)
- }" type="primary"
- @click="finish"
-
- >登录</button>
-
- </view>
- </view>
-
- </view>
- </template>
- <script>
- import * as API from '@/apis/pagejs/user.js'
- import {
- checkPhone
- } from '@/apis/utils'
- export default {
- data() {
- return {
- form: {
- name: '',
-
- phone: '',
- code: '',
- },
- codeTips: '',
- isSendMsgIng: false,
- sendMsgSecond: 60 * 2,
- customStyle: {
- background: '#1677ff'
- },
- telHighlight:false,
- pwdHighlight:false
- }
- },
- onLoad(op) {
-
- // this.message = op.message;
- // this.backUrl = op.back;
- if (op.phone) {
- this.form.phone = op.phone;
- }
-
- },
- onReady() {
- this.query()
-
- },
- methods: {
- // 帐号框聚焦失焦
- handleTelFocus(){
- this.telHighlight=true
- },
- handleTelBlur(){
- this.telHighlight=false
- },
- // 密码框聚焦失焦
- handlePwdFocus(){
- this.pwdHighlight=true
- },
- handlePwdBlur(){
- this.pwdHighlight=false
- },
- goBack(){
- uni.redirectTo({
- url: '/'
- })
- },codeChange(text) {
- this.codeTips = text;
- },
- //倒计时
-
- end() {
- this.sendMsgSecond = 2 * 60;
- this.isSendMsgIng = false;
- },
- finish() {
-
- if (!this.carhelp.getOpenId()) {
- // uni.showToast({
- // title: "请使用“微信”访问本系统登录"
- // })
- // return
- }
- if (!this.form.phone) {
- uni.showToast({
- title: "请输入手机号"
- })
- return
- }
- if (!this.form.code) {
- uni.showToast({
- title: "请输入验证码"
- })
- return
- }
-
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- var headImg = "";
- var userInfo = this.carhelp.get("xpgj_wx_user_info")
- if (userInfo) {
-
- headImg = userInfo.headimgurl;
- }
-
-
- API.validateCode({
- verifyCode: this.form.code,
- telephone: this.form.phone,
- openId: this.carhelp.getOpenId(),
- headImg: headImg
- }).then((response) => {
- this.loginset(response)
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- start() {
- if (!this.isSendMsgIng) {
-
-
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.getVerifyCode(this.form.phone).then((response) => {
-
-
- uni.hideLoading();
- this.carhelp.set("getvcodetime", new Date().getTime());
-
- if (!"") {
- //倒计时
- uni.showToast({
- title: "发送成功"
- })
- } else {
- uni.showToast({
- title: "您的验证码已经发送[5分钟有效],请勿重复点击"
- })
- }
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
-
-
- }
- },
- // 获取验证码
- getCode() {
- if (this.$refs.uCode.canGetCode) {
-
- } else {
-
- uni.showToast({
- title: '倒计时结束后再发送',
- icon: "none"
- })
- return
- }
-
- var checkPhoneResult = checkPhone(this.form.phone);
-
- if (checkPhoneResult !== true) {
- uni.showToast({
- title: checkPhoneResult,
-
- })
- return;
- }
- this.$refs.uCode.start();
- },
- loginset(response){
- var token = response ? response.data.token : '';
- this.carhelp.setToken(token);
- this.carhelp.setPersonInfo(response.data.regUser);
- this.carhelp.setPersonInfoPlus(response.data)
- //this.gotoUrl("pages/user/index")
- uni.redirectTo({
- url: '/'
- })
- },
- query(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
-
- API.findByOpenId({
- noerror:true,
- 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();
- }
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- page {
- background: url("../../assets/img/bgc.png");
- }
-
- .main {
- width: 100%;
- padding-top:240rpx;
- position: relative;
- .close{
- position: absolute;
- top: 24rpx;
- left: 24rpx;
- }
- .logo {
- display: flex;
- justify-content: center;
- }
- .name {
- color: rgba(16, 16, 16, 1);
- font-size: 40rDDpx;
- text-align: center;
- font-weight: bold;
- margin-top: 8rpx;
- }
- }
- .login-box {
- margin-top: 160rpx;
- .tel {
- /deep/.u-input {
- width: 400rpx;
- }
- }
- .line{
- width: 2rpx;
- height: 40rpx;
- background-color: #C1CCDF;
- position: absolute;
- top: 20rpx;
- left: 70rpx;
- }
- .tel,
- .pwd {
- position: relative;
- display: flex;
- width: 74.4%;
- height: 80rpx;
- line-height: 80rpx;
- color: rgba(183, 172, 172, 1);
- margin: auto;
- margin-bottom: 36rpx;
- border: 1px solid rgba(193, 204, 223, 1);
-
- border-radius: 8px;
- /deep/.u-input__input{
- font-size: 32rpx;
- }
- .icon {
- width: 14%;
- text-align: center;
- color: #B0B8C8;
- img {
- vertical-align: middle;
- }
- }
- .tips {
- text-indent: 16rpx;
- padding-right: 16rpx;
- display: flex;
- justify-content: space-between;
- /deep/uni-input {
- height: 80rpx !important;
- line-height: 80rpx !important;
- }
- .input {
- width: 50%;
- }
- }
- // 验证码
- .verification-code {
- color: #1F4A99;
- line-height: 80rpx;
- }
- }
- .highlight {
- border: 1px solid rgba(31, 74, 153, 1);
- box-shadow: 0px 0px 8rpx 0px rgba(0, 90, 217, 50);
- /deep/.u-input__input{
- color: rgba(0, 90, 217, 1);
- }
- .icon{
- color: #1F4A99;
- }
- .line{
- background-color: #005AD9;
- }
- }
- }
- .btn{
- width: 100%;
- margin-top: 120rpx;
-
- uni-button{
- margin:0 96rpx;
- height: 80rpx;
- border-radius: 8px;
- background-color: rgba(31, 74, 153, 1);
- color: rgba(255, 255, 255, 1);
- font-size: 16px;
- }
- }
- </style>
|