xugenyuan

fix |> 空串解析json报错

Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
... ... @@ -13,6 +13,7 @@ import { BusinessError } from '@kit.BasicServicesKit';
import { BottomNavigationComponent } from './view/BottomNavigationComponent';
import LaunchDataModel from './viewModel/LaunchDataModel';
import { LaunchPageModel } from './viewModel/LaunchPageModel';
import { JSON } from '@kit.ArkTS';
const TAG = 'MainPage';
... ... @@ -46,14 +47,19 @@ struct MainPage {
LogoutViewModel.clearLoginInfo()
})
let GrayManage = new GrayManageModel()
let dataModelStr : string = SPHelper.default.getSync(SpConstants.APP_MOURNS_INFO_DATA_MODEL,'') as string
let dataModel : LaunchDataModel = JSON.parse(dataModelStr)
// console.log(dataModelStr)
try {
if (dataModelStr && dataModelStr.length > 0) {
let dataModel : LaunchDataModel = JSON.parse(dataModelStr) as LaunchDataModel
// 处理国殇模式数据
let mourns: mournsInfoModel = dataModel.mourns as mournsInfoModel
let GrayManage = new GrayManageModel()
GrayManage.setMourning(mourns)
}
AppStorage.setOrCreate('GrayManage', GrayManage)
} catch (e) {
Logger.error(TAG, `Unexpected Text in JSON ??` + JSON.stringify(e) +" " + dataModelStr);
}
}
pageTransition() {
... ...