login的一小些代码

This commit is contained in:
Xu Chang 2022-04-25 20:40:49 +08:00
parent 0abc8f0f9a
commit c36b804d50
2 changed files with 17 additions and 9 deletions

View File

@ -9,8 +9,9 @@ OakPage({
level: 1,
},
isList: true,
formData: (tokenList) => {
if (tokenList.length > 0) {
formData: (tokenList, features) => {
const tokenValue = features.token.getToken();
if (tokenValue) {
return {
loggedIn: true,
};
@ -20,12 +21,14 @@ OakPage({
}
},
}, {
properties: {
depth: Number,
},
methods: {
async onLoginClicked(options: WechatMiniprogram.Touch) {
const code = await wx.login();
console.log(code);
},
onReturnClicked() {
wx.navigateBack();
}
}
});

View File

@ -1,8 +1,13 @@
<!-- index.wxml -->
<view class="page-body">
<view class="g-form" style="flex: 1" wx:for="{{arealist}}" wx:key="index">
<view class="g-form-item" data-id="{{item.id}}" bindtap="onItemClicked">
<text>{{item.name}}</text>
<block wx:if={{loggedIn}}>
<view class="g-cell">
<button class="g-btn g-btn-fullWidth" size="default" bindtap="onLoginClicked">登录</button>
</view>
</view>
</block>
<block wx:else>
<view class="g-cell">
<button class="g-btn g-btn-fullWidth" size="default" bindtap="onReturnClicked">返回</button>
</view>
</block>
</view>