小程序登录逻辑跑通;登陆密码MD5存储;小程序首页添加调试输出
This commit is contained in:
@@ -4,6 +4,24 @@
|
||||
<view style="display: block; padding-left: 30px; padding-top: 12px;">
|
||||
<text>欢迎你,{{ displayUsername }}!</text>
|
||||
</view>
|
||||
|
||||
<view style="display: block;" v-if="isVisitor">
|
||||
<view style="display: flex;text-align: center;margin-top: 20px;">
|
||||
<view style="width: 25%;">
|
||||
<image src="../../image/icon/code.png" style="width: 40px;height: 40px;" @tap='goCode'></image>
|
||||
<view>进出码</view>
|
||||
</view>
|
||||
<view style="width: 25%;">
|
||||
<image src="../../image/icon/feedback.png" style="width: 40px;height: 40px;" bindtap='goFeedback'></image>
|
||||
<view>反馈查看</view>
|
||||
</view>
|
||||
<view style="width: 25%;">
|
||||
<image src="../../image/icon/apply.png" style="width: 40px;height: 40px;" bindtap='goApply'></image>
|
||||
<view>申请记录</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="display: block;" v-if="isUser">
|
||||
<view style="display: flex;text-align: center;margin-top: 20px;">
|
||||
<view style="width: 25%;">
|
||||
@@ -39,6 +57,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="display: block;" v-if="isAdmin">
|
||||
<view style="display: flex;text-align: center;margin-top: 20px;">
|
||||
<view style="width: 25%;">
|
||||
@@ -76,28 +95,39 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="debugMode">
|
||||
<button @tap='debugCleanCache'>清除缓存</button>
|
||||
<text decode="nbsp">{{ debugText }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Taro from '@tarojs/taro'
|
||||
import { eventCenter, getCurrentInstance } from '@tarojs/taro'
|
||||
import ENUM from '../../utils/const.js'
|
||||
|
||||
import './index.css'
|
||||
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
userInfo: null,
|
||||
displayUsername: "",
|
||||
isVisitor: false,
|
||||
isUser: false,
|
||||
isAdmin: false,
|
||||
debugMode: Taro.getApp().globalData.debugMode,
|
||||
debugText: "",
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
eventCenter.once(getCurrentInstance().router.onShow, () => {
|
||||
console.log('onShow')
|
||||
console.log("ENUM", ENUM)
|
||||
console.log("debugMode", this.debugMode)
|
||||
|
||||
this.userInfo = Taro.getStorageSync("userInfo");
|
||||
this.displayUsername = this.userInfo?.username ?? "请登录";
|
||||
if (!this.userInfo) {
|
||||
@@ -106,8 +136,30 @@ export default {
|
||||
url: '/pages/index/login'
|
||||
})
|
||||
} else {
|
||||
this.isUser = this.userInfo.userType == "user";
|
||||
this.isAdmin = this.userInfo.userType == "admin";
|
||||
const role = ENUM.user.role;
|
||||
this.isVisitor = [
|
||||
role.VISITOR,
|
||||
].includes(this.userInfo.role);
|
||||
this.isUser = [
|
||||
role.RESIDENTS_OWNER,
|
||||
role.RESIDENTS_MEMBER,
|
||||
role.RESIDENTS_TENENT,
|
||||
].includes(this.userInfo.role);
|
||||
this.isAdmin = [
|
||||
role.ADMIN,
|
||||
role.STAFF,
|
||||
].includes(this.userInfo.role);
|
||||
console.log(
|
||||
"isVisitor", this.isVisitor,
|
||||
"isUser", this.isUser,
|
||||
"isAdmin", this.isAdmin
|
||||
)
|
||||
this.debugText = JSON.stringify({
|
||||
"isVisitor": this.isVisitor,
|
||||
"isUser": this.isUser,
|
||||
"isAdmin": this.isAdmin,
|
||||
"userInfo": this.userInfo
|
||||
}, null, 4).replace(/[ ]/g, ' ')
|
||||
}
|
||||
})
|
||||
},
|
||||
@@ -119,6 +171,19 @@ export default {
|
||||
Taro.switchTab({
|
||||
url: '/pages/residents/code'
|
||||
})
|
||||
},
|
||||
debugCleanCache() {
|
||||
Taro.clearStorage({
|
||||
success: function () {
|
||||
Taro.showToast({
|
||||
title: "成功",
|
||||
icon: 'success'
|
||||
})
|
||||
Taro.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user