提交 97dc3950 authored 作者: 曹末's avatar 曹末

password问题 switch问题

上级 501ebf20
...@@ -9,7 +9,8 @@ Page({ ...@@ -9,7 +9,8 @@ Page({
*/ */
data: { data: {
username: "", username: "",
password: "" password: "",
showPassword: false
}, },
login() { login() {
if (this.data.username.trim() === "") { if (this.data.username.trim() === "") {
...@@ -41,59 +42,9 @@ Page({ ...@@ -41,59 +42,9 @@ Page({
} }
}) })
}, },
/** iconClick() {
* 生命周期函数--监听页面加载 this.setData({
*/ showPassword: !this.data.showPassword
onLoad(options) { })
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
} }
}) })
\ No newline at end of file
<view> <view>
<t-input label="账号" model:value="{{username}}" /> <t-input label="账号" model:value="{{username}}" />
<t-input label="密码" type="password" model:value="{{password}}" suffixIcon="{{ { name: 'browse-off', ariaLabel: '密码' } }}" /> <t-input label="密码" type="{{showPassword?'text':'password'}}" model:value="{{password}}">
<t-icon slot="suffix-icon" name="{{showPassword?'browse':'browse-off'}}" ariaLabel="密码" bind:click="iconClick"></t-icon>
</t-input>
<t-button theme="primary" size="large" block t-class="external-class" bind:tap="login">登录</t-button> <t-button theme="primary" size="large" block t-class="external-class" bind:tap="login">登录</t-button>
</view> </view>
\ No newline at end of file
...@@ -13,7 +13,8 @@ Page({ ...@@ -13,7 +13,8 @@ Page({
password: "", password: "",
remark: "", remark: "",
isAdmin: false, isAdmin: false,
isModify: false isModify: false,
showPassword: false
}, },
/** /**
...@@ -62,5 +63,15 @@ Page({ ...@@ -62,5 +63,15 @@ Page({
}).then(res => { }).then(res => {
wx.navigateBack() wx.navigateBack()
}) })
},
iconClick() {
this.setData({
showPassword: !this.data.showPassword
})
},
switchChange(e) {
this.setData({
isAdmin: e.detail.value
})
} }
}) })
\ No newline at end of file
<view> <view>
<t-input label="账号" model:value="{{label}}"></t-input> <t-input label="账号" model:value="{{label}}"></t-input>
<t-input wx:if="{{!isModify}}" label="密码" model:value="{{password}}" type="password"></t-input> <t-input wx:if="{{!isModify}}" label="密码" type="{{showPassword?'text':'password'}}" model:value="{{password}}">
<t-icon slot="suffix-icon" name="{{showPassword?'browse':'browse-off'}}" ariaLabel="密码" bind:click="iconClick"></t-icon>
</t-input>
<t-input label="备注" model:value="{{remark}}"></t-input> <t-input label="备注" model:value="{{remark}}"></t-input>
<t-cell title="管理员" bordered="{{false}}"> <t-cell title="管理员" bordered="{{false}}">
<t-switch model:value="{{isAdmin}}" slot="note" /> <t-switch value="{{isAdmin}}" slot="note" bind:change="switchChange"/>
</t-cell> </t-cell>
<t-button style="margin-top: 64rpx;" theme="primary" size="large" block t-class="external-class" bind:tap="handleClick">{{isModify?"更新":"新建"}}</t-button> <t-button style="margin-top: 64rpx;" theme="primary" size="large" block t-class="external-class" bind:tap="handleClick">{{isModify?"更新":"新建"}}</t-button>
</view> </view>
\ No newline at end of file
...@@ -50,7 +50,9 @@ Page({ ...@@ -50,7 +50,9 @@ Page({
}) })
}, },
logout() { logout() {
ActionSheet.show(basicListOption) if (this.data.username && this.data.username !== "") {
ActionSheet.show(basicListOption)
}
} }
}); });
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
<t-action-sheet id="t-action-sheet" usingCustomNavbar bind:selected="handleSelected" /> <t-action-sheet id="t-action-sheet" usingCustomNavbar bind:selected="handleSelected" />
<view class="top_bg" /> <view class="top_bg" />
<view class="main_content"> <view class="main_content">
<view class="userinfo_container"> <view class="userinfo_container" style="width:100%" bind:tap="logout">
<image class="avatar" src="../../images/icons/avatar.png" mode="widthFix" /> <image class="avatar" src="../../images/icons/avatar.png" mode="widthFix" />
<block wx:if="{{ username==='' }}"> <block wx:if="{{ username==='' }}">
<view class="username" bind:tap="toLogin">请点击登录</view> <view class="username" bind:tap="toLogin">请点击登录</view>
</block> </block>
<block wx:else> <block wx:else>
<view class="username" bind:tap="logout">{{ username }}</view> <view class="username">{{ username }}</view>
</block> </block>
</view> </view>
<view class="settings_container"> <view class="settings_container">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论