1/** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15import common from "../../data/commonData"; 16import dateUtil from "../../utils/DateUtil"; 17import router from "@system.router"; 18import HiLog from "../../utils/HiLog" 19 20const TAG = "QueryReportController"; 21 22let queryReportCtrl; 23 24export default class QueryReportController { 25 // MMS or not 26 isMsm: boolean = true; 27 // Sending Status Description 28 sendStatusDesc: Resource; 29 // Sending Status 30 sendStatus: number = 0; 31 // Time 32 mmsTime: Resource; 33 // Specific morning and afternoon time 34 specificTime: Resource; 35 // Timestamp 36 timeMillisecond: string = "0"; 37 // telephoneNo 38 telephone: string = ''; 39 40 static getInstance() { 41 if (queryReportCtrl == null) { 42 queryReportCtrl = new QueryReportController(); 43 AppStorage.SetAndLink("QueryReportController", queryReportCtrl); 44 } 45 return queryReportCtrl; 46 }; 47 48 onInit() { 49 HiLog.i(TAG, "onInit") 50 this.isMsm = router.getParams().isMsm == undefined ? true : Boolean(router.getParams().isMsm); 51 this.sendStatus = router.getParams().sendStatus == undefined ? 0 : Number(router.getParams().sendStatus); 52 this.timeMillisecond = 53 router.getParams().timeMillisecond == undefined ? "0" : String(router.getParams().timeMillisecond); 54 this.telephone = router.getParams().telephone == undefined ? '' : String(router.getParams().telephone) 55 }; 56 57 onShow() { 58 HiLog.i(TAG, "onShow") 59 // The status is changed to Chinese description. 60 this.dealSendStatus(); 61 // Time Conversion 62 this.dealTime(); 63 }; 64 65 dealSendStatus() { 66 HiLog.i(TAG, "dealSendStatus sendStatus=" + this.sendStatus) 67 if (this.sendStatus == common.int.SEND_MESSAGE_SUCCESS) { 68 this.sendStatusDesc = $r("app.string.received"); 69 } else if (this.sendStatus == common.int.SEND_MESSAGE_FAILED) { 70 this.sendStatusDesc = this.isMsm ? $r("app.string.refused") : $r("app.string.failed"); 71 } else { 72 this.sendStatusDesc = $r("app.string.rending"); 73 } 74 }; 75 76 dealTime() { 77 this.mmsTime = dateUtil.convertTimeStampDate(this.timeMillisecond); 78 this.specificTime = dateUtil.convertTimeStampTime(this.timeMillisecond, false) 79 } 80}