fix
13404089107
2025-07-28 2e90f57e7d28d6a949247ef39b487d3e75b56683
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<template>
  <view class="content">
    <view class="title">已发送至手机</view>
    <view class="phone">{{phone}}</view>
    <view class="retry" @click="getCode">重新发送 <text v-if="s">({{s}})</text></view>
    <u-code-input :maxlength="4" v-model="code" size="115rpx" color="#000000" fontSize="65rpx" @finish="finish"></u-code-input>
 
  </view>
</template>
 
<script>
  import {
    mapState,
    mapMutations
  } from 'vuex'
  export default {
    data() {
      return {
        code:"",
        phone:"",
        s:0
      };
    },
    onLoad(o) {
      this.phone = o.phone
      this.getCode()
    },
    methods:{
      ...mapMutations(['setUserInfo']),
      getCode(){
        if(this.s >= 1){
          return
        }
        this.$apis.login.getCode({phone:this.phone,type:1}).then(res=>{
          this.$toast(res.msg)
          this.s = 90
          let timer = setInterval(()=>{
            if(this.s <= 1){
              clearInterval(timer)
            }
            this.s--
          },1000)
        })
      },
      finish(ev){
        if(ev.length != 4){
          return
        }
        uni.login({
          provider:"weixin",
          success: (e) => {
            const code = e.code
            this.$apis.login.loginPhone({phone:this.phone,smsCode:ev,type:1,code:code}).then(res=>{
              this.$toast('登录成功')
              this.setUserInfo(res.data)
              uni.reLaunch({
                url:"/pages/index/index/index"
              })
            })
          }
        })
        
      }
    }
  }
</script>
 
<style lang="scss">
.content{
  display: flex;
  flex-direction: column;
  align-items: center;
  .title{
    font-size: 23rpx;
    color: rgba(0, 0, 0, .4);
    line-height: 33rpx;
    margin-top: 86rpx;
  }
  .phone{
    font-weight: 700;
    font-size: 46rpx;
    color: #000000;
    line-height: 50rpx;
    margin-top: 17rpx;
  }
  .retry{
    font-size: 23rpx;
    color: rgba(0, 0, 0, .6);
    line-height: 33rpx;
    margin-top: 23rpx;
    margin-bottom: 42rpx;
  }
}
</style>