微信小程序如何驗(yàn)證用戶輸入信息

2023-03-07    分類: 網(wǎng)站建設(shè)

近期遇到一個(gè)小程序需要驗(yàn)證用戶輸入核驗(yàn)碼進(jìn)行下一步,覺(jué)得挺有意思的。

小程序開發(fā)

頁(yè)面效果圖如下:
如圖:需要用戶輸入核驗(yàn)碼,或者點(diǎn)擊右邊的照相圖標(biāo)選擇二維碼圖片進(jìn)行上傳,然后點(diǎn)擊提交進(jìn)行驗(yàn)證,驗(yàn)證成功即進(jìn)入下一步驟,驗(yàn)證失敗則給出相應(yīng)提示:

用戶未輸入時(shí)提示:

小程序開發(fā)

用戶輸入錯(cuò)誤時(shí):
提示核驗(yàn)碼無(wú)效,并且出現(xiàn)下面的購(gòu)買鏈接。
頁(yè)面結(jié)構(gòu)wxml如下:
<view class="container">
<form bindsubmit="check_code">
<view class="box">
<view class="input_con">
<view class="input">
<input type="text" class="weui-input" value="{{code}}" name="code" placeholder-style='color:#999;' placeholder='請(qǐng)輸入你的唯一核驗(yàn)碼' ></input>
</view>
<view bindtap='scan_code' class="img">
<image src='/images/ico_camera.png'></image>
</view>
</view>
<view class="tips">
* 亦可通過(guò)相冊(cè)上傳核驗(yàn)二維碼進(jìn)行核驗(yàn)。
</view>
<view class="tips">
注意: 本次核驗(yàn)后,核驗(yàn)碼不要丟失或告知他人,后期仍將會(huì)用到。
</view>
<view class="btn">
<button type="primary" bindtap='share' form-type="submit">點(diǎn)擊提交</button>
</view>
<view class="msg">
{{msg}}
</view>
</view>
<view class="other hide{{showView?'':'show'}}">
<view class='shoping' bindtap='shoping'>
<image src='/images/ico_buy.png'></image> 點(diǎn)擊購(gòu)買
</view>
<view class='tips'>* 如您暫未購(gòu)買產(chǎn)品,可現(xiàn)在進(jìn)行購(gòu)買并使用</view>
</view>
</form>
</view>
頁(yè)面樣式wxss如下:
page{
background: #fefefe;
}
.container {
padding-top: 54rpx;
}
.box{
width:650rpx;
margin:20rpx auto 0;
}
.input_con{
width: 100%;
border-bottom: 1rpx solid #dedcdf;
display: flex;
margin-bottom: 18rpx;
}
.input_con .input{
border: none;
width:560rpx;
}
.input_con .input input{
width: 100%;
height: 88rpx;
border: none;
padding-left: 40rpx;
box-sizing: border-box;
font-size: 28rpx;
}
.input_con .img{
margin-left:18rpx;
margin-top: 24rpx;
}
.input_con .img image{
width:48rpx;
height:40rpx;
}
.tips{
width: 570rpx;
font-size: 18rpx;
line-height: 42rpx;
color: #999;
box-sizing: border-box;
margin: auto;
}
.btn{
margin-top: 84rpx;
}
.btn button{
width: 544rpx;
height: 85rpx;
border-radius: 42rpx;
background-image: linear-gradient(0deg, #0c9ff3 0%,#22e7e4 100%);
box-shadow: 0 5rpx 0 5rpx rgba(76,218,204,.25);
font-size: 32rpx;
color: #fff;
}
.input_con .msg{
margin-top:10rpx;
}
.other{
width: 544rpx;
margin: 360rpx auto 0;
}
.hide{
display: none;
}
.show{
display: block;
}
.other .shoping{
width: 100%;
height: 85rpx;
border-radius: 42rpx;
background-image: linear-gradient(0deg, #f98a1e 0%,#f4bc33 100%);
box-shadow: 0 5rpx 0 5rpx rgba(218,163,76,.25);
display: flex;
justify-content: center;
align-items: center;
font-size: 32rpx;
color: #fff;
}
.other .shoping image{
width: 50rpx;
height: 40rpx;
margin-right: 15rpx;
}
.other .tips{
font-size: 18rpx;
color: #999;
text-align: center;
line-height: 1;
margin-top: 32rpx;
}
頁(yè)面js如下:

小程序代碼

下面是核驗(yàn)碼的驗(yàn)證

小程序代碼

下面是二維碼的驗(yàn)證:
到此上述功能就實(shí)現(xiàn)了。

分享名稱:微信小程序如何驗(yàn)證用戶輸入信息
本文來(lái)源:http://www.bm7419.com/news22/242272.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、品牌網(wǎng)站建設(shè)、企業(yè)網(wǎng)站制作、營(yíng)銷型網(wǎng)站建設(shè)、小程序開發(fā)品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

小程序開發(fā)