1/* 2 Copyright (c) 2022-2023 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*/ 15 16let timel = null; 17const EVENT_CONFIRM = 'EVENT_CONFIRM'; 18const EVENT_CANCEL = 'EVENT_CANCEL'; 19const EVENT_INIT = 'EVENT_INIT'; 20const EVENT_CONFIRM_CODE = '0'; 21const EVENT_CANCEL_CODE = '1'; 22const EVENT_INIT_CODE = '2'; 23const MS_PER_SECOND = 1000; 24 25export default { 26 data: { 27 seconds:60, 28 }, 29 onInit() { 30 callNativeHandler(EVENT_INIT, EVENT_INIT_CODE); 31 }, 32 onShow() { 33 timel = setInterval(this.run, MS_PER_SECOND); 34 }, 35 run() { 36 this.seconds--; 37 if (this.seconds === 0) { 38 clearInterval(timel); 39 timel = null; 40 console.info('click cancel'); 41 callNativeHandler(EVENT_CANCEL, EVENT_CANCEL_CODE); 42 } 43 }, 44 onConfirm() { 45 console.info('click confirm'); 46 callNativeHandler(EVENT_CONFIRM, EVENT_CONFIRM_CODE); 47 }, 48 onCancel() { 49 console.info('click cancel'); 50 callNativeHandler(EVENT_CANCEL, EVENT_CANCEL_CODE); 51 } 52};