|
|
@@ -168,6 +168,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
onLoad() {
|
|
|
+ var role = this.getUserRole()
|
|
|
+ if (role !== 'parent') {
|
|
|
+ uni.showToast({ title: '仅家长可管理挑战', icon: 'none' })
|
|
|
+ setTimeout(function() { uni.navigateBack() }, 1000)
|
|
|
+ return
|
|
|
+ }
|
|
|
this.loadFamilyId()
|
|
|
this.loadData()
|
|
|
this.loadTemplates()
|
|
|
@@ -178,6 +184,10 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ getUserRole: function() {
|
|
|
+ // store state 顶层有 role 字段(见 store/index.js:15)
|
|
|
+ return this.$store && this.$store.state ? this.$store.state.role : ''
|
|
|
+ },
|
|
|
loadFamilyId: function() {
|
|
|
var self = this
|
|
|
try {
|