国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

微信小程序發送短信驗證碼完整實例

來源:懂視網 責編:小采 時間:2020-11-27 22:02:19
文檔

微信小程序發送短信驗證碼完整實例

微信小程序發送短信驗證碼完整實例:微信小程序注冊完整實例,發送短信驗證碼,帶60秒倒計時功能,無需服務器端。效果圖: 代碼: index.wxml <!--index.wxml--> <view class=container> <view class='row'> <input placeholder
推薦度:
導讀微信小程序發送短信驗證碼完整實例:微信小程序注冊完整實例,發送短信驗證碼,帶60秒倒計時功能,無需服務器端。效果圖: 代碼: index.wxml <!--index.wxml--> <view class=container> <view class='row'> <input placeholder

微信小程序注冊完整實例,發送短信驗證碼,帶60秒倒計時功能,無需服務器端。效果圖:

代碼:

index.wxml

<!--index.wxml-->
<view class="container">
 <view class='row'>
 <input placeholder='請輸入姓名' bindinput='bindNameInput'/> 
 </view>
 
 <view class='row'>
 <input placeholder='請輸入手機號' bindinput='bindPhoneInput'/> 
 </view>
 <view class='row'>
 <input placeholder='請輸驗證碼' bindinput='bindCodeInput' style='width:70%;'/> 
 <button class='codeBtn' bindtap='getCode' hidden='{{hidden}}' disabled='{{btnDisabled}}'>{{btnValue}}</button>
 </view>
 <view>
 <button class='save' bindtap='save' >保存</button>
 </view>
 
</view>

index.js

//index.js
var zhenzisms = require('../../utils/zhenzisms.js');
//獲取應用實例
const app = getApp();
 
Page({
 data: {
 hidden: true,
 btnValue:'',
 btnDisabled:false,
 name: '',
 phone: '',
 code: '',
 second: 60
 },
 onLoad: function () {
 
 },
 //姓名輸入
 bindNameInput(e) {
 this.setData({
 name: e.detail.value
 })
 },
 //手機號輸入
 bindPhoneInput(e) {
 console.log(e.detail.value);
 var val = e.detail.value;
 this.setData({
 phone: val
 })
 if(val != ''){
 this.setData({
 hidden: false,
 btnValue: '獲取驗證碼'
 })
 }else{
 this.setData({
 hidden: true
 })
 }
 },
 //驗證碼輸入
 bindCodeInput(e) {
 this.setData({
 code: e.detail.value
 })
 },
 //獲取短信驗證碼
 getCode(e) {
 console.log('獲取驗證碼');
 var that = this;
 zhenzisms.client.init('https://sms_developer.zhenzikj.com', 'appId', 'appSecret');
 zhenzisms.client.send(function (res) {
 if(res.data.code == 0){
 that.timer();
 return ;
 }
 wx.showToast({
 title: res.data.data,
 icon: 'none',
 duration: 2000
 })
 }, '15801636347', '驗證碼為:3322');
 
 },
 timer: function () {
 let promise = new Promise((resolve, reject) => {
 let setTimer = setInterval(
 () => {
 var second = this.data.second - 1;
 this.setData({
 second: second,
 btnValue: second+'秒',
 btnDisabled: true
 })
 if (this.data.second <= 0) {
 this.setData({
 second: 60,
 btnValue: '獲取驗證碼',
 btnDisabled: false
 })
 resolve(setTimer)
 }
 }
 , 1000)
 })
 promise.then((setTimer) => {
 clearInterval(setTimer)
 })
 },
 //保存
 save(e) {
 console.log('姓名: ' + this.data.name);
 console.log('手機號: ' + this.data.phone);
 console.log('驗證碼: ' + this.data.code);
 
 //省略提交過程
 }
})

index.wxss

/**index.wxss**/
page{
 height: 100%;
 width: 100%;
 background: linear-gradient(#5681d7, #486ec3);
 display: flex;
 flex-direction: column;
}
.container{
 display: flex;
 flex-direction: column;
 justify-content: space-around;
 width: 90%;
 margin: 50rpx auto;
}
 
.row{
 position: relative;
 height: 80rpx;
 width: 100%;
 border-radius: 10rpx;
 background: #fff;
 margin-bottom: 20rpx;
 padding-left: 20rpx;
 box-sizing: border-box;
}
.row input{
 width: 100%;
 height:100%;
}
.codeBtn{
 position: absolute;
 right: 0;
 top: 0;
 color: #bbb;
 width: 30%;
 font-size: 26rpx;
 height: 80rpx;
 line-height: 80rpx;
}
.subBtn{
 width: 200rpx;
 height: 80rpx;
 background: #fff;
 color: #000;
 border-radius: 50rpx;
 line-height: 80rpx;
}

完整下載: 下載

詳情參考: http://smsow.zhenzikj.com/doc/sdk.html

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

微信小程序發送短信驗證碼完整實例

微信小程序發送短信驗證碼完整實例:微信小程序注冊完整實例,發送短信驗證碼,帶60秒倒計時功能,無需服務器端。效果圖: 代碼: index.wxml <!--index.wxml--> <view class=container> <view class='row'> <input placeholder
推薦度:
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 国产成人精品视频 | 亚洲精品国产综合一线久久 | 日韩手机视频 | 一区二区三区免费电影 | 久久婷婷色一区二区三区 | 中文字幕美日韩在线高清 | 日韩欧美爱爱 | 国内精品视频免费观看 | 一边摸一边叫床一边爽 | 亚洲日本激情综合在线观看 | 久久久成人网 | 国产精品高清一区二区三区 | 国产网站在线免费观看 | 黄视频网站在线看 | 亚欧美综合 | 亚洲 欧美 日韩 综合 | 国产精品特级毛片一区二区三区 | 国产精品久久久久久久毛片 | 欧美我不卡 | 欧美日韩精品在线播放 | 欧美在线视频一区二区三区 | 国产视频1区 | 欧美高清在线视频一区二区 | 日韩精品免费一区二区 | 91aaa在线观看 | 国产a免费视频 | 欧美日韩网 | 欧美色另类 | 一级大毛片 | 91精品导航| 亚洲欧美日韩在线一区 | 欧美啊v| 好看的电影网站亚洲一区 | h免费视频| 欧美精品在线播放 | 日韩精品免费看 | 国产在线精品一区二区高清不卡 | 国产线视频精品免费观看视频 | 国产中文在线 | 国产精品一区在线播放 | 五月天婷婷综合 |