123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 |
- <template>
- <view class="phonelogin">
- <u-navbar title-color="#FFFFFF" :custom-back="customBack" :bpay-bottom="false" back-icon-color="#FFFFFF" :background="{background: 'transparent' }" title="手机登录" class="phonelogin-unavbar" />
- <view class="phonelogin-title">
- <view>欢迎您!</view>
- <view>登录退役军人服务移动端</view>
- </view>
- <view class="phonelogin-content">
- <!-- <input class="u-border-bottom" type="number" maxlength="11" v-model="tel" placeholder="请输入手机号" /> -->
- <u-input class="u-border-bottom phonelogin-content-input" v-model="tel" type="number" maxlength="11" placeholder="请输入手机号" />
- <view class="u-text-center u-type-error u-m-t-20" v-if="telError">手机号输入错误</view>
- <button @tap="submit" :style="[inputStyle]" class="phonelogin-content-getcaptcha">获取验证码</button>
- <u-message-input v-if="show" :focus="true" :value="messageCode" @change="change" @finish="finish" mode="bottomLine" :maxlength="codelength" class="phonelogin-content-messageinput"></u-message-input>
- </view>
- <!-- <view class="u-text-center u-type-error" v-if="phoneError">手机号输入错误</view> -->
- <view class="phonelogin-captcha">
- <!-- <text v-if="show&&this.messageDisable==false" @tap="noCaptcha">收不到验证码点这里</text> -->
- <text v-if="messageShow">{{ second }}秒后可重新获取验证码</text>
- </view>
- <view class="phonelogin-pact" :class="messageShow?'phonelogin-msgpact':''">
- <view class="phonelogin-pact-hint u-text-center">
- 进入即代表同意
- <text class="link" @tap="jumpToPage(1)">《用户协议》</text>及
- <text class="link" @tap="jumpToPage(2)">《隐私协议》</text>
- </view>
- </view>
- <u-toast ref="uToast" />
- </view>
- </template>
- <script>
- import getUrlParams from "utils/getUrlParams.js";
- export default {
- data() {
- return {
- tel: '',
- messageCode:'',
- messageShow: false,
- messageDisable: false,
- codelength: 4,
- show: false,
- second:60,
- toastMsg:'',
- toastUrl:'',
- toastType:'',
- accessToken:'',
- userId:'',
- telError:false,
- // messageError:false
- }
- },
- onLoad(page) {},
- onShow() {
- // 判断是否登录 已登录直接跳转首页
- if(this.vuex_hasLogin){
- uni.switchTab({
- url: '../index/index'
- })
- }
- },
- computed: {
- inputStyle() {
- let style = {};
- if(this.tel.length == 11&&this.messageDisable==false&&this.$u.test.mobile(this.tel)) {
- style.color = "#fff";
- style.backgroundColor = '#5295F5';
- this.telError = false;
- // style.backgroundColor = this.$u.color['warning'];
- }else if(this.tel.length==11&&!this.$u.test.mobile(this.tel)){
- this.telError = true;
- }
- return style;
- }
- },
- methods: {
- showToast() {
- this.$refs.uToast.show({
- title: this.toastMsg,
- type: this.toastType,
- url: this.toastUrl
- })
- },
- submit() {
- if(this.$u.test.mobile(this.tel)&&this.messageDisable==false) {
- let that = this;
- this.$u.api.getPhoneLoginCode({mobile:this.tel})
- .then(res =>{
- if(res.code == 200){
- this.messageDisable = true;
- this.messageShow = true;
- this.show = true;
- let interval = setInterval(() => {
- that.second--;
- if (that.second <= 0) {
- that.messageDisable=false
- that.messageShow = false;
- if (that.messageCode.lenth != 4) {
- // this.messageError = true;
- }
- clearInterval(interval);
- that.second=60;
- }
- }, 1000);
- this.accessToken = res.data.accessToken;
- this.$u.vuex('vuex_token', res.data.accessToken);
- this.userId = res.data.userId;
- }else{
- uni.showToast({
- title: res.msg,
- icon:'none',
- duration: 2000
- });
- }
-
- }).catch(err=>{
- this.toastMsg = err.code + ":" + err.msg;
- this.showToast();
- });
- }
- },
- // 收不到验证码选择时的选择
- // noCaptcha() {
- // uni.showActionSheet({
- // itemList: ['重新获取验证码', '接听语音验证码'],
- // success: function(res) {
-
- // },
- // fail: function(res) {
-
- // }
- // });
- // },
- // change事件侦听
- change(value) {
- // console.log('change', value);
- },
- // 输入完验证码最后一位执行
- finish(value) {
- let params = {
- accessToken:this.accessToken,
- userId:this.userId,
- code:value
- };
- this.$u.api.phoneLoginAuth(params)
- .then(res =>{
- if(res.code=='200'){
- // console.log('finish res',res);
- this.$u.vuex('vuex_user', res.data);
- this.$u.vuex('vuex_hasLogin', true);
- this.veteEducCheck();
- // this.wechatLogin()
-
- }else{
- this.toastMsg = res.msg;
- this.showToast();
- }
- }).catch(err=>{
- this.toastMsg = err.msg;
- this.showToast();
- });
- },
- veteEducCheck(){
- this.$u.api.getVeteEducCheck().then(res=>{
- if(res.data!=9){
- this.jumpIndex();
- }else{
- uni.navigateTo({
- url: '/pages/applyEducationCode/applyEducationCode'
- })
- }
- })
- },
- // 跳转到首页
- jumpIndex() {
- let ret = localStorage.getItem('backUrl')
- if (ret && ret.indexOf('phoneLogin') < 0) {
- // 截取url
- const pagesIndex = ret.indexOf('pages')
- let switchTabList = ['/pages/index/index','pages/center/center','pages/mine/mine'];
- if (pagesIndex > (-1)) {
- const pageUrl = ret.slice(pagesIndex)
- if(switchTabList.includes(pageUrl)){
- setTimeout(() => {
- uni.switchTab({
- url: '/' + pageUrl
- })
- }, 100)
- }else{
- setTimeout(() => {
- uni.navigateTo({
- url: '/' + pageUrl
- })
- }, 100)
- }
-
- } else {
- uni.switchTab({
- url: '../index/index'
- })
- }
- } else {
- uni.switchTab({
- url: '../index/index'
- })
- }
- },
- /**
- * 跳转页面
- * */
- jumpToPage(flag){
- uni.navigateTo({
- url: "/pages/inbuild/inbuild",
- // url: "/pages/privacyPolicy/privacyPolicy?termsType=" + flag,
- })
- },
- // tabbar 返回
- customBack() {
- this.$u.route({
- type: 'switchTab',
- url: 'pages/index/index'
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .hide{display: none!important;}
- .phonelogin{
- width: 100%;
- height: 100vh;
- background-image: url(../../static/img/phonelogin-bg-png.png);
- background-repeat: no-repeat;
- background-size: cover;
-
- &-unavbar{
- ::v-deep .u-border-bottom:after {
- border-bottom-width: 0 !important;
- }
- }
-
- &-title{
- padding: 10% 4% 6%;
- font-family: PingFangSC-Light, PingFang SC;
- font-weight: 300;
- color: #FFFFFF;
- line-height: 98rpx;
- letter-spacing: 2rpx;
-
- view:first-child{
- font-size: 70rpx;
- }
-
- view:last-child{
- font-size: 56rpx;
- }
- }
-
- &-content{
- padding: 0 4%;
-
- &-input{
- ::v-deep {
- .uni-input-placeholder {
- text-align: center;
- font-size: 40rpx;
- font-family: PingFangSC-Heavy, PingFang SC;
- color: #FFFFFF !important;
- letter-spacing: 1px;
- line-height: 60rpx;
- opacity: 0.6;
- }
- .uni-input-input{
- text-align: center;
- font-size: 60rpx;
- font-family: PingFangSC-Heavy, PingFang SC;
- font-weight: 800;
- color: #FFFFFF;
- line-height: 83rpx;
- letter-spacing: 1px;
- }
- }
-
- &:after {
- top: 21rpx;
- }
- }
-
- &-getcaptcha{
- margin-top: 10%;
- color: $u-tips-color;
- border: none;
- padding: 14rpx 0;
- background-color: rgba(255, 255, 255, 0.5);
- border-radius: 55rpx;
- font-size: 40rpx;
- font-family: PingFangSC-Medium, PingFang SC;
- font-weight: 500;
- color: #6A5C52;
- line-height: 83rpx;
-
- &::after {
- border: none;
- }
- }
-
- &-messageinput{
- ::v-deep .u-char-item{
- color: #FFFFFF !important;
-
- .u-bottom-line, .u-placeholder-line{
- background: #FFFFFF !important;
- }
- }
- }
- }
-
- &-captcha{
- color: $u-type-warning;
- font-size: 30rpx;
- margin-top: 40rpx;
- text-align: center;
- }
-
- &-pact{
- width: 100%;
-
- &-hint{
- font-size: 28rpx;
- font-family: PingFangSC-Regular, PingFang SC;
- font-weight: 400;
- color: #FFFFFF;
- line-height: 83rpx;
- opacity: 0.7;
- .link {
- color: $u-type-warning;
- }
- }
- }
- }
- </style>
|