This article shares the specific code for the WeChat applet to send SMS verification code countdown for your reference. The specific content is as follows Rendering WXML File <view class="container"> <view class="userinfo"> <image class="userinfo-avatar" src="../../images/timg.jpg" mode="cover"></image> <text class="userinfo-nickname">What</text> </view> <view class="wrap"> <view class="tel"> <input type="number" bindinput="bindTelInput" maxlength="11" placeholder="Please enter your phone number" placeholder-style="color:#C3C6C4;"/> </view> <view class="ver-code"> <view class="code"> <input type="number" bindinput="bindCodeInput" maxlength="6" placeholder="Please enter the verification code" placeholder-style="color:#C3C6C4;"/> </view> <view class="getCode" bindtap="getCode" wx:if="{{countDownNum == 60 || countDownNum == -1}}"> <button type="primary" plain="true">Get verification code</button> </view> <view class="getCode" wx:else> <button type="primary" plain="true">Re-acquire after {{countDownNum}}s</button> </view> </view> </view> <view class="btn-login" bindtap="login">Login</view> </view> JS file //Get the application instance const app = getApp() Page({ /** * Initial data of the page */ data: { phone: null, // Phone number code: null, // Phone verification code countDownNum: 60, // Countdown initial value }, /** * Life cycle function--listen for page loading*/ onLoad: function (options) { }, /** * Life cycle function--monitor page display*/ onShow: function () { }, /** * Life cycle function - listen for the completion of the initial rendering of the page*/ onReady: function () { }, /** * User clicks on the upper right corner to share*/ onShareAppMessage: function () { }, // Input phone number bindTelInput: function (e) { this.setData({ phone: e.detail.value }) }, // Input verification code bindCodeInput: function (e) { this.setData({ code: e.detail.value }) }, // Send mobile verification codegetCode: function () { if (!!this.data.phone) { if (!!(/^1[34578]\d{9}$/.test(this.data.phone))) { wx.showToast({ title: "Sent successfully", icon: "none", duration: 1500 }) this.countDown() } else { wx.showToast({ title: "Please enter a valid mobile phone number", icon: "none", duration: 1500 }) } } else { wx.showToast({ title: "Please enter your mobile number", icon: "none", duration: 1500 }) } }, /** * Verification code countdown*/ countDown: function () { var _this = this var countDownNum = _this.data.countDownNum // Get the countdown initial value var timer = setInterval(function () { countDownNum -= 1 _this.setData({ countDownNum: countDownNum }) if (countDownNum <= -1) { clearInterval(timer) // Unpin the code that the setInterval function will execute_this.setData({ countDownNum: 60 }) } }, 1000) }, // Mobile phone verification code login: function () { if (this.data.phone) { if (!!(/^1[34578]\d{9}$/.test(this.data.phone))) { if (this.data.code) { wx.showToast({ title: "Login successful", icon: "none", duration: 1500 }) } else { wx.showToast({ title: "Please enter the verification code", icon: "none", duration: 1500 }) } } else { wx.showToast({ title: "Please enter a valid mobile phone number", icon: "none", duration: 1500 }) } } else { wx.showToast({ title: "Please enter your mobile number", icon: "none", duration: 1500 }) } } }) WXSS File .userinfo { height: 240rpx; margin: 40rpx auto 0; display: flex; flex-direction: column; align-items: center; } .userinfo .userinfo-avatar { width: 140rpx; height: 140rpx; margin: 20rpx; border-radius: 50%; border: 1rpx solid #dad5d5; } .userinfo .userinfo-nickname { color: #aaa; } .wrap { width: 630rpx; font-size: 32rpx; margin: 80rpx auto 120rpx; } .wrap .tel { width: 100%; height: 68rpx; border-bottom: 1rpx solid #DDE3EC; margin-bottom: 60rpx; display: flex; flex-direction: column; justify-content: flex-start; } .wrap .ver-code { width: 100%; height: 68rpx; border-bottom: 1rpx solid #DDE3EC; display: flex; justify-content: space-between; } .wrap .ver-code .code { } .wrap .ver-code .getCode { min-width: 190rpx; height: 40rpx; } .wrap .ver-code .getCode button { width: 100%; height: 100%; font-size: 28rpx; font-weight: normal; line-height: 40rpx; background: #fff; color: #ffaa7f; border: none; padding: 0; margin: 0; } .btn-login { width: 588rpx; height: 88rpx; background: #ffaa7f; border-radius: 10rpx; text-align: center; line-height: 88rpx; font-size: 36rpx; font-weight: 500; color: #fff; margin: 0 auto; } .clickClass { background: #ea986c; } The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: The difference and usage of datetime and timestamp in MySQL
>>: Solution to the problem that the docker container cannot be stopped
JavaScript can do a lot of great things. This art...
Table of contents A JSON is built on two structur...
The MySQL query result row field splicing can be ...
There are many servers that can host static websi...
About derived tables When the main query contains...
As the company's influence grows and its prod...
How to modify the mysql table partitioning progra...
Table of contents Summarize <template> <...
Table of contents 1. Introduction to docker-maven...
1. Concept They are all attributes of Element, in...
1. Installation Tip: There is currently no offici...
There are two tables, and the records in table A ...
Background of the problem The server monitoring s...
Solution to 1449 and 1045 exceptions when connect...
Add inline styles to the required links: Copy code...