首页功能按钮使用v-for渲染;完善调试输出(可以手动修改用户role)
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
<template>
|
||||
<view v-if="debugMode">
|
||||
<button @tap='debugCleanCache'>清除缓存</button>
|
||||
<button type="warn" size="mini" @tap='debugCleanCache'>清除缓存</button>
|
||||
<view style="border: 3px solid black;">
|
||||
<input v-model="userRole" style="border: 1px solid grey; display: inline-block; width: 40%;" />
|
||||
<button style="width: 50%;" type="primary" size="mini" @tap='updateUserRole'>更新role ({{ userGroup }})</button>
|
||||
</view>
|
||||
<textarea maxlength="-1" disabled="true" auto-height="true" style="width: 100%" :value="debugText"></textarea>
|
||||
</view>
|
||||
</template>
|
||||
@@ -9,22 +13,33 @@
|
||||
import Taro from '@tarojs/taro'
|
||||
import { eventCenter, getCurrentInstance } from '@tarojs/taro'
|
||||
|
||||
import ENUM from '../utils/const'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userRole: -1,
|
||||
debugMode: Taro.getApp().globalData.debugMode,
|
||||
debugText: "",
|
||||
}
|
||||
},
|
||||
props: {
|
||||
params: Object,
|
||||
userGroup: String
|
||||
},
|
||||
mounted() {
|
||||
eventCenter.once(getCurrentInstance().router.onShow, () => {
|
||||
this.userRole = Taro.getStorageSync("userInfo").role;
|
||||
|
||||
const res = Taro.getStorageInfoSync()
|
||||
let storage = {};
|
||||
res.keys.forEach(key => storage[key] = Taro.getStorageSync(key))
|
||||
this.debugText = JSON.stringify({
|
||||
TARO_ENV: process.env.TARO_ENV,
|
||||
globalData: Taro.getApp().globalData,
|
||||
params: this.params,
|
||||
storage: storage,
|
||||
ENUM: ENUM,
|
||||
// storageInfo: {
|
||||
// keys: res.keys,
|
||||
// currentSize: res.currentSize,
|
||||
@@ -46,6 +61,14 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
updateUserRole() {
|
||||
let userInfo = Taro.getStorageSync("userInfo");
|
||||
userInfo.role = this.userRole;
|
||||
Taro.setStorageSync("userInfo", userInfo);
|
||||
Taro.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user