Преглед изворни кода

fix(frontend): globalData.currentChildId 替换为 uni.getStorageSync('currentChildId'),修复孩子视角切换数据失效

liaoxg пре 3 месеци
родитељ
комит
8ddabfc78a

+ 1 - 1
cfc-frontend/pages/health/gut-index.vue

@@ -136,7 +136,7 @@ export default {
     },
     goToMyReport: function() {
       var self = this
-      var childId = getApp().globalData.currentChildId || uni.getStorageSync('currentChildId')
+      var childId = uni.getStorageSync('currentChildId')
       if (!childId) {
         var userId = uni.getStorageSync('userId')
         childId = userId

+ 3 - 6
cfc-frontend/pages/mind-detail/emotion-checkin.vue

@@ -298,8 +298,7 @@ export default {
   },
 
   onLoad() {
-    const app = getApp()
-    this.currentChildId = app.globalData.currentChildId || null
+    this.currentChildId = uni.getStorageSync('currentChildId') || null
     this.loadStats()
   },
 
@@ -317,8 +316,7 @@ export default {
 
   methods: {
     loadStats() {
-      const app = getApp()
-      const childId = app.globalData.currentChildId
+      const childId = uni.getStorageSync('currentChildId')
       if (!childId) return
       uni.request({
         url: config.API_BASE_URL + '/api/mind/checkin/stats',
@@ -671,8 +669,7 @@ export default {
       if (!this.canSubmit || this.submitting) return
       this.submitting = true
 
-      const app = getApp()
-      const childId = app.globalData.currentChildId
+      const childId = uni.getStorageSync('currentChildId')
 
       const doSubmit = (mediaUrl) => {
         uni.request({

+ 2 - 4
cfc-frontend/pages/mind-detail/emotion-trend.vue

@@ -255,15 +255,13 @@ export default {
   },
 
   onLoad() {
-    const app = getApp()
-    this.currentChildId = app.globalData.currentChildId || null
+    this.currentChildId = uni.getStorageSync('currentChildId') || null
     this.loadData()
   },
 
   methods: {
     loadData() {
-      const app = getApp()
-      const childId = app.globalData.currentChildId
+      const childId = uni.getStorageSync('currentChildId')
       if (!childId) return
 
       uni.request({

+ 1 - 2
cfc-frontend/pages/mind-detail/screening.vue

@@ -192,8 +192,7 @@ export default {
         if (this.answers[i] === -1) { uni.showToast({ title: '请回答所有问题', icon: 'none' }); this.currentStep = i; return }
       }
       this.submitting = true
-      const app = getApp()
-      const childId = app.globalData.currentChildId
+      const childId = uni.getStorageSync('currentChildId')
       uni.request({
         url: config.API_BASE_URL + '/api/mind/screening/submit',
         method: 'POST',

+ 1 - 2
cfc-frontend/pages/mind-detail/traditional-mirror.vue

@@ -146,8 +146,7 @@ export default {
   methods: {
     loadData() {
       var self = this
-      var app = getApp()
-      var memberId = this.$mp.query.memberId || app.globalData.currentChildId
+      var memberId = this.$mp.query.memberId || uni.getStorageSync('currentChildId')
       if (!memberId) {
         // Try to get from storage
         memberId = uni.getStorageSync('currentChildId')

+ 2 - 4
cfc-frontend/pages/mind/emotion-checkin.vue

@@ -294,8 +294,7 @@ export default {
 
   methods: {
     loadStats() {
-      const app = getApp()
-      const childId = app.globalData.currentChildId
+      const childId = uni.getStorageSync('currentChildId')
       if (!childId) return
       uni.request({
         url: config.API_BASE_URL + '/api/mind/checkin/stats',
@@ -484,8 +483,7 @@ export default {
       if (!this.canSubmit || this.submitting) return
       this.submitting = true
 
-      const app = getApp()
-      const childId = app.globalData.currentChildId
+      const childId = uni.getStorageSync('currentChildId')
 
       const doSubmit = (photoUrl) => {
         uni.request({

+ 1 - 2
cfc-frontend/pages/mind/emotion-trend.vue

@@ -251,8 +251,7 @@ export default {
 
   methods: {
     loadData() {
-      const app = getApp()
-      const childId = app.globalData.currentChildId
+      const childId = uni.getStorageSync('currentChildId')
       if (!childId) return
 
       uni.request({

+ 1 - 2
cfc-frontend/pages/mind/screening.vue

@@ -250,8 +250,7 @@ export default {
 
       this.submitting = true
 
-      const app = getApp()
-      const childId = app.globalData.currentChildId
+      const childId = uni.getStorageSync('currentChildId')
 
       uni.request({
         url: config.API_BASE_URL + '/api/mind/screening/submit',

+ 1 - 2
cfc-frontend/pages/mind/traditional-mirror.vue

@@ -146,8 +146,7 @@ export default {
   methods: {
     loadData() {
       var self = this
-      var app = getApp()
-      var memberId = this.$mp.query.memberId || app.globalData.currentChildId
+      var memberId = this.$mp.query.memberId || uni.getStorageSync('currentChildId')
       if (!memberId) {
         // Try to get from storage
         memberId = uni.getStorageSync('currentChildId')