微信小程序自定義用戶登錄彈窗
更新時間:2022年06月29日 17:13:46 作者:kleinBlue.
這篇文章主要為大家詳細介紹了微信小程序自定義用戶登錄彈窗,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了微信小程序自定義用戶登錄彈窗的具體代碼,供大家參考,具體內(nèi)容如下


view
<button ? class="btn" bindtap="powerDrawer" data-statu="open">立即進入</button>
<!--mask:彈出框-->
<view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if="{{showModalStatus}}"></view>
<!--content-->
<!--使用animation屬性指定需要執(zhí)行的動畫-->
<view animation="{{animationData}}" class="drawer_box" wx:if="{{showModalStatus}}">
?<!--drawer content-->
?<view class="drawer_title">請?zhí)顚?lt;/view>
?<view class="drawer_content">
?<!-- denglu ?-->
? ? <view class='top_line'></view>
? ? <view class='name'>姓名</view>
? ? <input class='btn' ?type="text" placeholder='請輸入答題人姓名' maxlength='12'value="" bindinput ="userNameInput" ></input>
? ? <view class='line'></view>
? ? <view class='call'>手機號</view>
? ? <input class='btn' type="text" placeholder='請輸入手機號' maxlength='11 'value="" bindinput ="mobileInput" ></input>
? ? <view class='line'></view>
?</view>
?<button class='btn_ok' type="submit" bindtap='btnclick' >快速進入</button>
?<view class="btn_ok" bindtap="powerDrawer" data-statu="close">取消</view>
</view>css
/*css*/
?.drawer_screen {
? width: 100%;
? height: 100%;
? position: fixed;
? top: 0;
? left: 0;
? z-index: 1000;
? background: #000;
? opacity: 0.75;
? overflow: hidden;
?}
?.drawer_box {
? width: 650rpx;
? overflow: hidden;
? position: fixed;
? top: 50%;
? left: 0;
? z-index: 1001;
? background: #FAFAFA;
? margin: -150px 50rpx 0 50rpx;
? border-radius: 15px;
?}
??
?.drawer_title{
? padding:15px;
? font: 20px "microsoft yahei";
? text-align: center;
? font-size: 30rpx;
?}
?.drawer_content {
? height: 170px;
? overflow-y: scroll; /*超出父盒子高度可滾動*/
?}
?.btn_ok{
? padding: 10px;
? font: 30rpx "microsoft yahei";
? text-align: center;
? border-top: 1px solid #E8E8EA;
? color: #3CC51F;
?}
?.top{
? ?padding-top:8px;
?}
?.bottom {
? ?padding-bottom:8px;
?}
?.title {
? ?height: 30px;
? ?line-height: 30px;
? ?width: 160rpx;
? ?text-align: center;
? ?display: inline-block;
? ?font: 300 28rpx/30px "microsoft yahei";
?}
??
?.input_base {
? ?border: 2rpx solid #ccc;
? ?padding-left: 10rpx;
? ?margin-right: 50rpx;
?}
?.input_h30{
? ?height: 30px;
? ?line-height: 30px;
?}
?.input_h60{
? ?height: 60px;
?}
?.input_view{
? ?font: 12px "microsoft yahei";
? ?background: #E8E8EA;
? ?color:#000;
? ?line-height: 30px;
?}
??
?input {
? ?font: 12px "microsoft yahei";
? ?background: #E8E8EA;
? ?color:#000 ;
?}
?radio{
? ?margin-right: 20px;
?}
?.grid { display: -webkit-box; display: box; }
?.col-0 {-webkit-box-flex:0;box-flex:0;}
?.col-1 {-webkit-box-flex:1;box-flex:1;}
?.fl { float: left;}
?.fr { float: right;}
.name{
? text-align: center;
? font-size: 30rpx;
? width: 90%;
? margin: auto;
? margin-top: 30rpx;?
}
.btn{
? text-align: center;
? font-size: 30rpx;
? height: 60rpx;
? width: 90%;
? margin: auto;
? margin-top: 20rpx;
? background-color: #FAFAFA;
? border-bottom: 1rpx solid #999999;
}
.call{
? font-size: 30rpx;
? text-align: center;
? width: 90%;
? margin: auto;
? margin-top: 45rpx;
}js
?//自定義彈框
? powerDrawer: function (e) {
? ? // wx.removeStorageSync('xingming')
? ? // wx.removeStorageSync('phone')
? ? var currentStatu = e.currentTarget.dataset.statu;
? ? this.util(currentStatu)
? ?},
? ?util: function(currentStatu){
? ? /* 動畫部分 */
? ? // 第1步:創(chuàng)建動畫實例
? ? var animation = wx.createAnimation({
? ? ?duration: 200, //動畫時長
? ? ?timingFunction: "linear", //線性
? ? ?delay: 0 //0則不延遲
? ? }); ?
? ? // 第2步:這個動畫實例賦給當前的動畫實例
? ? this.animation = animation;
? ? // 第3步:執(zhí)行第一組動畫
? ? animation.opacity(0).rotateX(-100).step();
? ? // 第4步:導出動畫對象賦給數(shù)據(jù)對象儲存
? ? this.setData({
? ? ?animationData: animation.export()
? ? })
? ? // 第5步:設置定時器到指定時候后,執(zhí)行第二組動畫
? ? setTimeout(function () {
? ? ?// 執(zhí)行第二組動畫
? ? ?animation.opacity(1).rotateX(0).step();
? ? ?// 給數(shù)據(jù)對象儲存的第一組動畫,更替為執(zhí)行完第二組動畫的動畫對象
? ? ?this.setData({
? ? ? animationData: animation
? ? ?}) ?
? ? ?//關閉
? ? ?if (currentStatu == "close") {
? ? ? this.setData(
? ? ? ?{
? ? ? ? showModalStatus: false
? ? ? ?}
? ? ? );
? ? ?}
? ? }.bind(this), 200)
? ? // 顯示
? ? if (currentStatu == "open") {
? ? ?this.setData(
? ? ? {
? ? ? ?showModalStatus: true
? ? ? }
? ? ?);
? ? }
? ?},
?//登錄
? ?userNameInput: function (e) {
? ? this.setData({
? ? ? userName: e.detail.value
? ? })
? },
? mobileInput: function (e) {
? ? this.setData({
? ? ? mobile: e.detail.value
? ? })
? },
? btnclick:function(){
? ? var userName = this.data.userName;
? ? var mobile = this.data.mobile;
? ? var flag = true;
? ? var phonetel = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
? ? var name = /^[u4E00-u9FA5]+$/;
? ? if (userName == '') {
? ? ? wx.showToast({
? ? ? ? title: '請輸入用戶名',
? ? ? ? icon: 'none',
? ? ? ? duration: 2000,
? ? ? ? mask: true
? ? ? })
? ? ? flag = false;
? ? } else if (mobile == '') {
? ? ? wx.showToast({
? ? ? ? icon: 'none',
? ? ? ? duration: 2000,
? ? ? ? title: '手機號不能為空',
? ? ? })
? ? ? flag = false;
? ? }?
? ? else if (mobile.length != 11) {
? ? ? wx.showToast({
? ? ? ? title: '手機號長度有誤!',
? ? ? ? icon: 'none',
? ? ? ? duration: 2000,
? ? ? })
? ? ? flag = false;
? ? }
? ? var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
? ? if (!myreg.test(mobile)) {
? ? ? wx.showToast({
? ? ? ? title: '請輸入正確信息!',
? ? ? ? icon: 'none',
? ? ? ? duration: 2000,
? ? ? })
? ? ? flag = false;
? ? }
? ? if(flag==true){
? ? ? // console.log(this.data.userName)
? ? ? // console.log(this.data.mobile)
? ? ? wx.setStorageSync('xingming',this.data.userName)
? ? ? wx.setStorageSync('phone',this.data.mobile)
? ? ? ?wx.navigateTo({
? ? ? ? ?url: '/pages/wenda/wenda',
? ? ? ?})
? ? }
? },以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
使用CSS3的scale實現(xiàn)網(wǎng)頁整體縮放
QQ郵箱的網(wǎng)頁整體縮放效果,原來實現(xiàn)方法如此簡單,下面有個實現(xiàn)示例,大家可以參考下2014-03-03
html+css+js實現(xiàn)簡易版ChatGPT聊天機器人
OpenAI的一款聊天機器人模型ChatGPT爆火,本篇文章用一百行html+css+js代碼給大家制作一款簡易的聊天機器人。2023-02-02
詳解如何通過JavaScript實現(xiàn)函數(shù)重載
這篇文章主要為大家詳細介紹了如何通過JavaScript實現(xiàn)函數(shù)重載,文中的示例代碼講解詳細,對我們學習JavaScript有一定的幫助,感興趣的可以了解一下2023-01-01
一文詳解preact的高性能狀態(tài)管理Signals
這篇文章主要介紹了一文詳解preact的高性能狀態(tài)管理Signals,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,感興趣的朋友可以參考一下2022-09-09
bootstrap weebox 支持ajax的模態(tài)彈出框
本篇介紹的bootstrap weebox(支持ajax的模態(tài)彈出框),歷經(jīng)多次修改,目前版本已經(jīng)穩(wěn)定,整合了bootstrap的響應式,界面簡單,功能卻無比豐富,支持ajax、圖片預覽等等2017-02-02

