123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <template>
- <view class="ezy-login-page">
- <view class="ezy-login-wrap">
- <view class="login-body-box">
- <view class="login-title-img"></view>
- <view class="yzm-show">验证码已发送至:{{loginData.phoneNumber}}</view>
- <view class="phone-input-box">
- <input class="phone-input" type="text" v-model="loginData.yzmNumber" placeholder="请输入验证码" maxlength="6"
- @input="clearYzmInput" />
- <view class="close-btn" v-if="loginData.clearYzmIcon" @click="clearYzm"></view>
- </view>
- <view class="login-btn login-btn-disabled" @click="loginBtn" :class="loginData.yzmStatus"></view>
- <text class="cxfs-btn" @click="startCountdown"
- :class="{ 'cxfs-btn-disabled': loginData.isDisabled}">{{loginData.buttonText}}</text>
- <text class="login-text" @click="goIndex">无法收到验证码</text>
- <text class="login-text">客服电话:400-052-2130</text>
- </view>
- </view>
- <sliderDialog ref="sliderDialogRef"></sliderDialog>
- </view>
- </template>
- <script setup>
- import {ref,reactive} from "vue"
- import {onLoad,onReady} from '@dcloudio/uni-app';
- import request from "@/utils/request.js"
- import {login,sendCode} from "@/api/login.js"
- import sliderDialog from './sliderDialog.vue'
- const loginData = reactive({
- phoneNumber: null,
- yzmNumber: null,
- clearYzmIcon: false,
- yzmStatus: '',
- timeLeft: 60, // 初始倒计时时间(秒)
- intervalId: null, // 定时器ID
- isDisabled: false, // 按钮是否禁用
- buttonText: '重新发送', // 按钮文本
- })
- const sliderData = reactive({})
-
- const sliderDialogRef = ref(null);
- onLoad((options) => {
- loginInit(options);
- startCountdown();
- getYzmBtn();
- })
- onReady((options) => {
- console.log(sliderDialogRef.value,'sliderDialogRef.value');
- sliderDialogRef.value.sliderShow();
- })
- const loginInit = (options) => {
- loginData.phoneNumber = options.telNum;
- }
- const getYzmBtn = () => {
- let req = {
- appkey: "FFFF0N00000000007EC0",
- phone: "18640920672",
- scene: "nc_message_h5',",
- sessionid: sliderData.sessionId,
- sig: sliderData.sig,
- token: sliderData.token,
- }
- sendCode(req).then(res => {
- })
- }
- const loginBtn = () => {
- let req = {
- tel: "1",
- code: '1'
- }
- login(req).then(res => {
- if (res.code == 0) {
- let obj = JSON.stringify(res.data)
- console.log(obj)
- uni.setStorage({
- key: 'Mta-Auth',
- data: obj // 假设 this.userInputValue 是用户输入的数据
- });
- uni.navigateTo({
- url: `/pages/study/index?gradeId=${obj.orgId}&termId=${obj.userId}&text='测试111'`
- })
- }
- })
- // uni.navigateTo({
- // url: `/pages/study/index?gradeId=${options.grade}&termId=${options.term}&text=${text1}${text2}`
- // })
- }
- const clearYzmInput = (event) => {
- if (event.detail.value.length > 0) {
- loginData.clearYzmIcon = true;
- } else {
- loginData.clearYzmIcon = false;
- }
- }
- const clearYzm = () => {
- loginData.yzmNumber = '';
- loginData.clearYzmIcon = false;
- }
- const startCountdown = () => {
- loginData.isDisabled = true;
- loginData.buttonText = `重新发送(${loginData.timeLeft}S)`;
- // 清除之前的定时器(如果有)
- if (loginData.intervalId) {
- clearInterval(loginData.intervalId);
- }
- // 设置新的定时器
- loginData.intervalId = setInterval(() => {
- loginData.timeLeft--;
- if (loginData.timeLeft <= 0) {
- clearInterval(loginData.intervalId);
- loginData.timeLeft = 60; // 重置倒计时
- loginData.isDisabled = false;
- loginData.buttonText = '重新发送';
- } else {
- loginData.buttonText = `重新发送(${loginData.timeLeft}S)`;
- }
- }, 1000);
- }
-
- const goIndex = () => {
- uni.navigateTo({
- url: `/pages/login/index?data=`+JSON.stringify(sliderData)
- })
- }
- </script>
|