微信小程序自定義用戶登錄彈窗
更新時間:2022年06月29日 17:13:46 作者:kleinBlue.
這篇文章主要為大家詳細(xì)介紹了微信小程序自定義用戶登錄彈窗,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了微信小程序自定義用戶登錄彈窗的具體代碼,供大家參考,具體內(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步:這個動畫實例賦給當(dāng)前的動畫實例 ? ? this.animation = animation; ? ? // 第3步:執(zhí)行第一組動畫 ? ? animation.opacity(0).rotateX(-100).step(); ? ? // 第4步:導(dǎo)出動畫對象賦給數(shù)據(jù)對象儲存 ? ? this.setData({ ? ? ?animationData: animation.export() ? ? }) ? ? // 第5步:設(shè)置定時器到指定時候后,執(zhí)行第二組動畫 ? ? setTimeout(function () { ? ? ?// 執(zhí)行第二組動畫 ? ? ?animation.opacity(1).rotateX(0).step(); ? ? ?// 給數(shù)據(jù)對象儲存的第一組動畫,更替為執(zhí)行完第二組動畫的動畫對象 ? ? ?this.setData({ ? ? ? animationData: animation ? ? ?}) ? ? ? ?//關(guān)閉 ? ? ?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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
VSCode Webview中實現(xiàn)點擊下載圖片的基本流程
這篇文章主要介紹了VSCode Webview中如何實現(xiàn)點擊下載圖片,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-04-04微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用方法
這篇文章主要介紹了微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05詳解webpack中的hash、chunkhash、contenthash區(qū)別
這篇文章主要介紹了詳解webpack中的hash、chunkhash、contenthash區(qū)別,詳細(xì)的介紹了hash、chunkhash、contenthash的用法和區(qū)別,有興趣的可以了解一下2018-01-01JavaScript中的動態(tài)?import()用法示例解析
這篇文章主要為大家介紹了JavaScript中的動態(tài)import()用法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-04-04javascript addBookmark 加入收藏 多瀏覽器兼容
不錯的加入收藏代碼,加入了對一些常見瀏覽器的判斷,更好的體現(xiàn)用戶體驗,兼容了ie,firefox.2009-08-08