123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- <template>
- <view class="top">
- <view class="back-btn cuIcon-back" @click="navBack"></view>
- <!-- 文字 -->
- <view class="top_one">请输入验证码</view>
- <view class="top_two">验证码已发送到<text class="text">{{phone}}</text></view>
- <!-- 六个显示框 -->
- <view class="top_three">
- <view :class="[ !inputList[0]||inputList.length>0 ? 'inb' : '' ]" class="input">
- <text>{{inputList[0]}}</text>
- <view v-if="!inputList[0]" class="fours"></view>
- </view>
- <view :class="[ inputList[0] && !inputList[1]||inputList.length>1 ? 'inb' : '' ]" class="input">
- <text>{{inputList[1]}}</text>
- <view v-if="inputList[0] && !inputList[1]" class="fours"></view>
- </view>
- <view :class="[ inputList[1] && !inputList[2]||inputList.length>2 ? 'inb' : '' ]" class="input">
- <text>{{inputList[2]}}</text>
- <view v-if="inputList[1] && !inputList[2]" class="fours"></view>
- </view>
- <view :class="[ inputList[2] && !inputList[3]||inputList.length>3 ? 'inb' : '' ]" class="input">
- <text>{{inputList[3]}}</text>
- <view v-if="inputList[2] && !inputList[3]" class="fours"></view>
- </view>
- <view :class="[ inputList[3] && !inputList[4]||inputList.length>4 ? 'inb' : '' ]" class="input">
- <text>{{inputList[4]}}</text>
- <view v-if="inputList[3] && !inputList[4]" class="fours"></view>
- </view>
- <view :class="[ inputList[4] && !inputList[5]||inputList.length>5 ? 'inb' : '' ]" class="input">
- <text>{{inputList[5]}}</text>
- <view v-if="inputList[4] && !inputList[5]" class="fours"></view>
- </view>
- </view>
- <!-- 隐藏的input -->
- <view class="top_four">
- <input type="number" class="input_show" maxlength="6" @input='submit' v-model="inputList" focus="true"/>
- </view>
- <!-- 重新获取 -->
- <view class="top_five" @click='regain' :class="!status ? 'active' : '' "><text v-if="!status">重新发送</text><text v-if="status">{{count_down}}秒后重新发送</text></view>
- </view>
- </template>
- <script>
- import helper from '@/common/helper.js';
- export default {
- data() {
- return {
- // 电话
- phone:'',
- // 跟隐藏input绑定的数组
- inputList:[],
- //计时器
- count_down:60,
- status:false
- }
- },
- onLoad(options){
- console.log("options",options.phone)
- this.phone=options.phone
- console.log("phone:",this.phone);
- if(this.phone){
- this.regain()
- }else{
- uni.showToast({
- title: '请输入正确的手机号',
- icon:'none',
- duration: 2000
- })
- }
- },
- methods: {
- navBack() {
- uni.navigateBack();
- },
-
- liangxinLogin(){
- const that = this
- var userInfoTmp = uni.getStorageSync("userInfo")
- console.log('userInfoTmp',userInfoTmp)
- that.$socket.login(userInfoTmp.phone, "123456", null, res=>{
- console.log('粮信登录',res)
- if (res.success) {
- that.$socket.showLoginDialog = false
- // 缓存用户
- that.userData = res.response.data
- console.log('userData',that.userData)
- that.$u.vuex("userData", that.userData);
- // 缓存通讯录
- that.$socket.listGuests(that.userData.user.operId, res => {
- // #ifdef APP-PLUS
- createFSQL(that.userData.user.operId).then();
- let contact = res.response.data;
- contact.forEach(c=>{
- c.members.forEach(m=>{
- m.name = c.name;
- addFSQL(m, that.userData.user.operId).then();
- })
- })
- // #endif
- that.$u.vuex('firendItem', res.response.data)
- });
-
- // 缓存消息列表
- that.$socket.queryOnlineMessage(that.userData.user.operId,q =>{
- let data = q.response.data;
- for(var i in data){
- initData(data[i].groupMsg.list, data[i].groupInfo.chatId);
- }
- })
-
- // 缓存链接
- that.$socket.getLinks(that.userData.user.operId, res=>{
- that.$u.vuex('linkItem',res.response.data)
- });
-
-
- // // 跳转到消息列表
- // that.$u.route({
- // url: 'pages/home/home',
- // type: 'switchTab'
- // });
- } else {
- uni.showModal({
- title:res.reason + ",请稍后再试",
- showCancel:false
- })
- }
- });
- },
- regain(){
-
- console.log("regain",this.phone);
- this.status=true
- // console.log(e)150500
- // 设定一个定时器 1000是1秒的意思
- var interval = setInterval(() =>{
- --this.count_down
- },1000)
- if(this.count_down == 0){
- this.status=false
- }
- // 设定一个定时器 60000就是六十秒
- setTimeout(() =>{
- this.status=false
- clearInterval(interval)//括号里面的名字要与setInterval定义的相同
- },60000)
- this.$api.doRequest('get','/commonUser/sendVerifyCode',{phone:this.phone}).then(res => {
- // 获得数据
- if(res.statusCode!=200){
- uni.showToast({
- title: res.data.message,
- icon:'none',
- duration: 2000
- })
- }
- console.log(res);
- })
- .catch(res => {
- uni.showToast({
- title: res.errMsg,
- icon:'none',
- duration: 2000
- })
- });
- },
- submit(e){
- if(e.detail.value.length==6){
- var that=this
- uni.showLoading({
- title: '登录中',
- mask:true
- })
- this.$api.doRequest('get','/commonUser/loginVerifyCode',{phone:this.phone,verifyCode:this.inputList,cid:this.clientId}).then(res => {
- if(res.data.code==200){
- this.$api.doRequest('post','/commonUser/api/loginQuickly',{mobilePhone: this.phone,
- veriCode: "123456",}).then(res1 => {
- if(res1.data.code==200){
- uni.setStorageSync('pcUserInfo', res1.data.data)
- helper.getListByUserId()
- }
- else{
- that.$api.doRequest('post','/commonUser/api/loginQuickly',{mobilePhone: '14444444444',
- veriCode: "123456",}).then(res2 => {
- uni.setStorageSync('pcUserInfo', res2.data.data)
- helper.getListByUserId()
- })
- }
- })
- uni.setStorageSync('userInfo', res.data.data)
- helper.getListByUserId()
- that.$store.commit('login', res.data.data)
- // that.liangxinLogin()
- uni.switchTab({
- url: '/pages/sale/information'
- });
- uni.hideLoading()
- }else{
- uni.hideLoading()
- uni.showToast({
- title: res.data.message,
- icon:'none',
- duration: 2000
- })
- }
- })
- .catch(res => {
- uni.showToast({
- title: res.data.message,
- icon:'none',
- duration: 2000
- })
- });
- }
- }
-
- }
- }
- </script>1
- <style>
- .top{
- padding-top: 85px;
- position: relative;
- width: 100vw;
- height: 100vh;
- overflow: hidden;
- background: url('~@/static/img/login/bg.png');
- background-size:100%;}
- .back-btn {
- position: absolute;
- left: 40upx;
- z-index: 9999;
- padding-top: var(--status-bar-height);
- top: 40upx;
- font-size: 40upx;
- color: $font-color-dark;
- }
- /* 文字 */
- .top_one{width: 90%; height: 90rpx; line-height: 90rpx; font-size: 44rpx; margin: auto; font-weight: bold;}
- .top_two{width: 90%; height: 40rpx; line-height: 40rpx; font-size: 24rpx; margin: auto; color: #545454;}
- .text{font-weight: bold;}
-
- /* 六个显示框容器 */
- .top_three{width: 80%; height: 200rpx; margin: auto;
- display: flex; align-items: center; justify-content: center;
- }
- /* 六个框显示框 */
- .input{width: 14%; height: 80rpx; background-color: #F5F5F5; margin-right: 12rpx;
- text-align: center; line-height: 80rpx; font-size: 50rpx;
- border-radius:3px;
- color:#181818;
- }
- /* 模拟的焦点 */
- .inb{
- background:#FFFFFF;
- box-shadow: 0px 9px 10px 4px rgba(0, 0, 0, 0.07);
- }
- .fours{width: 5rpx; height: 40rpx; margin: auto; background-color: #000000;
- margin-top: 20rpx; animation: show .8s linear infinite;
- }
- /* 模拟焦点动画 更改animation以更改动画样式*/
- @keyframes show{
- from{background-color: #000000;}
- to{background-color: #ffffff;}
- }
- /* 隐藏的inpit容器 */
- .top_four{width: 80%; height: 100rpx; margin: auto; margin-top: -140rpx;}
- .input_show{width: 100%; height: 100rpx; border-bottom: 2rpx solid #000000; margin: auto;
- opacity: 0;background-color: #c6c6c6;
- }
- /* 重新获取 */
- .top_five{width: 100%; height: 60rpx; margin-top: 180rpx; text-align: center; line-height: 60rpx;
- color: #959595;
- }
- /* 定时器结束的字体样式 */
- .active{color: #22C572;}
- .button{width: 80%; height: 100rpx; line-height: 100rpx; background-color: #5473E8; border-radius: 60rpx;
-
- }
- </style>
|