微信小程序自定義用戶登錄彈窗
本文實(shí)例為大家分享了微信小程序自定義用戶登錄彈窗的具體代碼,供大家參考,具體內(nèi)容如下
view
<button ? class="btn" bindtap="powerDrawer" data-statu="open">立即進(jìn)入</button> <!--mask:彈出框--> <view class="drawer_screen" bindtap="powerDrawer" data-statu="close" wx:if="{{showModalStatus}}"></view> <!--content--> <!--使用animation屬性指定需要執(zhí)行的動(dòng)畫--> <view animation="{{animationData}}" class="drawer_box" wx:if="{{showModalStatus}}"> ?<!--drawer content--> ?<view class="drawer_title">請(qǐng)?zhí)顚?lt;/view> ?<view class="drawer_content"> ?<!-- denglu ?--> ? ? <view class='top_line'></view> ? ? <view class='name'>姓名</view> ? ? <input class='btn' ?type="text" placeholder='請(qǐng)輸入答題人姓名' maxlength='12'value="" bindinput ="userNameInput" ></input> ? ? <view class='line'></view> ? ? <view class='call'>手機(jī)號(hào)</view> ? ? <input class='btn' type="text" placeholder='請(qǐng)輸入手機(jī)號(hào)' maxlength='11 'value="" bindinput ="mobileInput" ></input> ? ? <view class='line'></view> ?</view> ?<button class='btn_ok' type="submit" bindtap='btnclick' >快速進(jìn)入</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; /*超出父盒子高度可滾動(dòng)*/ ?} ?.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){ ? ? /* 動(dòng)畫部分 */ ? ? // 第1步:創(chuàng)建動(dòng)畫實(shí)例 ? ? var animation = wx.createAnimation({ ? ? ?duration: 200, //動(dòng)畫時(shí)長(zhǎng) ? ? ?timingFunction: "linear", //線性 ? ? ?delay: 0 //0則不延遲 ? ? }); ? ? ? // 第2步:這個(gè)動(dòng)畫實(shí)例賦給當(dāng)前的動(dòng)畫實(shí)例 ? ? this.animation = animation; ? ? // 第3步:執(zhí)行第一組動(dòng)畫 ? ? animation.opacity(0).rotateX(-100).step(); ? ? // 第4步:導(dǎo)出動(dòng)畫對(duì)象賦給數(shù)據(jù)對(duì)象儲(chǔ)存 ? ? this.setData({ ? ? ?animationData: animation.export() ? ? }) ? ? // 第5步:設(shè)置定時(shí)器到指定時(shí)候后,執(zhí)行第二組動(dòng)畫 ? ? setTimeout(function () { ? ? ?// 執(zhí)行第二組動(dòng)畫 ? ? ?animation.opacity(1).rotateX(0).step(); ? ? ?// 給數(shù)據(jù)對(duì)象儲(chǔ)存的第一組動(dòng)畫,更替為執(zhí)行完第二組動(dòng)畫的動(dòng)畫對(duì)象 ? ? ?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: '請(qǐng)輸入用戶名', ? ? ? ? icon: 'none', ? ? ? ? duration: 2000, ? ? ? ? mask: true ? ? ? }) ? ? ? flag = false; ? ? } else if (mobile == '') { ? ? ? wx.showToast({ ? ? ? ? icon: 'none', ? ? ? ? duration: 2000, ? ? ? ? title: '手機(jī)號(hào)不能為空', ? ? ? }) ? ? ? flag = false; ? ? }? ? ? else if (mobile.length != 11) { ? ? ? wx.showToast({ ? ? ? ? title: '手機(jī)號(hào)長(zhǎng)度有誤!', ? ? ? ? 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: '請(qǐng)輸入正確信息!', ? ? ? ? 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', ? ? ? ?}) ? ? } ? },
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
VSCode Webview中實(shí)現(xiàn)點(diǎn)擊下載圖片的基本流程
這篇文章主要介紹了VSCode Webview中如何實(shí)現(xiàn)點(diǎn)擊下載圖片,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-04-04微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用方法
這篇文章主要介紹了微信小程序Page中data數(shù)據(jù)操作和函數(shù)調(diào)用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(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深拷貝與淺拷貝實(shí)現(xiàn)詳解
深拷貝和淺拷貝是面試中經(jīng)常出現(xiàn)的,主要考察對(duì)基本類型和引用類型的理解深度,這篇文章主要給大家介紹了關(guān)于js深拷貝和淺拷貝的相關(guān)資料,需要的朋友可以參考下2022-11-11高性能JavaScript模板引擎實(shí)現(xiàn)原理詳解
這篇文章主要介紹了JavaScript模板引擎實(shí)現(xiàn)原理詳解,本文著重講解artTemplate模板的實(shí)現(xiàn)原理,它采用預(yù)編譯方式讓性能有了質(zhì)的飛躍,是其它知名模板引擎的25、32 倍,需要的朋友可以參考下2015-02-02JavaScript中的動(dòng)態(tài)?import()用法示例解析
這篇文章主要為大家介紹了JavaScript中的動(dòng)態(tài)import()用法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-04-04javascript addBookmark 加入收藏 多瀏覽器兼容
不錯(cuò)的加入收藏代碼,加入了對(duì)一些常見瀏覽器的判斷,更好的體現(xiàn)用戶體驗(yàn),兼容了ie,firefox.2009-08-08