UNPKG

@aiot-toolkit/velasim

Version:

vela for sim

1,012 lines (934 loc) 26.3 kB
export default function(global, globalThis, window, $app_exports$){ var createPageHandler = function() { return /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/script-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/module-loader.js!./node_modules/babel-loader/lib/index.js?cwd=/home/zdying/work/aidong_watch/vela-source&cacheDirectory&plugins[]=/home/zdying/work/aidong_watch/vela-source/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/zdying/work/aidong_watch/vela-source/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./src/pages/course_box/course_motion/course_motion.js?uxType=page": /*!***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\ !*** ./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/script-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/module-loader.js!./node_modules/babel-loader/lib/index.js?cwd=/home/zdying/work/aidong_watch/vela-source&cacheDirectory&plugins[]=/home/zdying/work/aidong_watch/vela-source/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/zdying/work/aidong_watch/vela-source/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./src/pages/course_box/course_motion/course_motion.js?uxType=page ***! \***************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { module.exports = function __scriptModule__ (module, exports, $app_require$){"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _system = _interopRequireDefault($app_require$("@app-module/system.router")); var _utils = _interopRequireDefault(__webpack_require__(/*! ../../../common/js/utils.js */ "./src/common/js/utils.js")); var _system2 = _interopRequireDefault($app_require$("@app-module/system.file")); var _system3 = _interopRequireDefault($app_require$("@app-module/system.health")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _default = { protected: { percent: 0, endBtnBackgroundColor: "#000000", isPause: false, pauseTxt: "暂停", index: 0, everyLessonTrainTime: 0, timer: null, countdownTxt: "00:00:00", uploadTrainData: [], burnAllCalories: 0, heartRate: 0, realHrArr: [], isEndCourse: false, caloriesWidth: 30, prevCalories: 0, duration: 10 }, clickPauseBtn() { this.isPause = !this.isPause; this.pauseTxt = this.isPause ? "已暂停" : "暂停"; if (this.isPause == true) { clearInterval(this.timer); } else { this.countdownChange(); } }, longPressEndBtn() { let that = this; if (this.isEndCourse == true) { return false; } this.isEndCourse = true; clearInterval(this.timer); var nextCurrentDate = _utils.default.getCurrentDate(); var differenceMillis = _utils.default.dateDifference(this.currentDate, nextCurrentDate); var newClassTime = _utils.default.countdownNumChange(differenceMillis, "courseMotion"); let params = { courseName: this.courseName, classTime: newClassTime, startDate: this.currentDate, userId: this.userId, courseType: "library", isShowModel: "false" }; this.timer = null; this.endBtnBackgroundColor = "#FFFFFF"; this.recordMotionData(); this.isEndCourse = false; that.gotoConclusionPage("pages/scheduled_box/conclusion", params); }, recordMotionData() { let data = [{ id: this.courseId, type: "library", data: [{ at: this.currentDate, during: this.everyLessonTrainTime, buring: this.burnAllCalories, beats: _utils.default.average(this.realHrArr), more: [] }] }]; this.uploadTrainData = data; this.writeFileToLibraryMotion(data, this.userId); }, countdownChange() { let that = this; this.timer = setInterval(function () { that.everyLessonTrainTime++; var calories = _system3.default.getTodayCalorie(); var calories = _system3.default.getTodayCalorie(); that.burnAllCalories = calories - that.prevCalories; that.setCaloriesWidth(that.burnAllCalories); let progress = that.burnAllCalories / 500 * 100; that.percent = progress > 100 ? 100 : progress; that.heartRate = _system3.default.getHr(); if (that.everyLessonTrainTime % 60 == 0 && that.realHrArr.length != 120) { that.realHrArr.push(that.heartRate); } that.countdownTxt = _utils.default.countdownNumChange(that.everyLessonTrainTime); }, 1000); }, gotoConclusionPage(uri, params) { _system.default.replace({ uri: uri, params: params }); }, writeFileToLibraryMotion(data, userId) { var libraryMotionFilePath = "internal://app/libraryMotion.txt"; _system2.default.writeText({ uri: libraryMotionFilePath, text: JSON.stringify(data), success: function () {}, fail: function (data, code) {} }); }, setCaloriesWidth(caloriesNum) { if (caloriesNum >= 10) { let rounding = Math.floor(caloriesNum / 10); if (rounding >= 1 && rounding < 10 && this.caloriesWidth != 60) { this.caloriesWidth = 60; } else if (rounding >= 10 && rounding < 100 && this.caloriesWidth != 90) { this.caloriesWidth = 95; } else if (rounding >= 100 && rounding < 1000 && this.caloriesWidth != 120) { this.caloriesWidth = 130; } else if (rounding >= 1000 && rounding < 10000 && this.caloriesWidth != 150) { this.caloriesWidth = 162; } else if (rounding >= 10000 && rounding < 1000000 && this.caloriesWidth != 180) { this.caloriesWidth = 200; } } }, onInit() { this.prevCalories = _system3.default.getTodayCalorie(); this.countdownChange(); }, onDestroy() { clearInterval(this.timer); this.timer = null; } }; exports.default = _default; const moduleOwn = exports.default || module.exports; const accessors = ['public', 'protected', 'private']; if (moduleOwn.data && accessors.some(function (acc) { return moduleOwn[acc]; })) { throw new Error('页面VM对象中的属性data不可与"' + accessors.join(',') + '"同时存在,请使用private替换data名称'); } else if (!moduleOwn.data) { moduleOwn.data = {}; moduleOwn._descriptor = {}; accessors.forEach(function (acc) { const accType = typeof moduleOwn[acc]; if (accType === 'object') { moduleOwn.data = Object.assign(moduleOwn.data, moduleOwn[acc]); for (const name in moduleOwn[acc]) { moduleOwn._descriptor[name] = { access: acc }; } } else if (accType === 'function') { console.warn('页面VM对象中的属性' + acc + '的值不能是函数,请使用对象'); } }); }} /***/ }), /***/ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!./node_modules/sass-loader/dist/cjs.js!./src/pages/course_box/course_motion/course_motion.scss?uxType=page": /*!******************************************************************************************************************************************************************************************************!*\ !*** ./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!./node_modules/sass-loader/dist/cjs.js!./src/pages/course_box/course_motion/course_motion.scss?uxType=page ***! \******************************************************************************************************************************************************************************************************/ /***/ ((module) => { module.exports = [ [ [ [ 0, "publicContainer" ] ], { "width": "464px", "height": "464px", "flexDirection": "column", "alignItems": "center", "backgroundColor": "#000000" } ], [ [ [ 2, "text" ] ], { "fontSize": "34px", "color": "#FFFFFF" } ], [ [ [ 0, "container" ] ], { "width": "464px", "height": "464px" } ], [ [ [ 0, "box" ] ], { "width": "464px", "height": "464px" } ], [ [ [ 0, "swiper-item" ] ], { "width": "464px", "height": "464px" } ], [ [ [ 0, "calorieProgress" ] ], { "width": "464px", "height": "464px", "color": "#FFBD60", "backgroundColor": "#4D391D", "startAngle": "0deg", "totalAngle": "360deg", "strokeWidth": "32px", "centerX": "232px", "centerY": "232px", "radius": "232px" } ], [ [ [ 0, "content" ] ], { "width": "400px", "height": "400px", "borderRadius": "200px", "left": "32px", "top": "32px", "flexDirection": "column", "justifyContent": "center", "alignItems": "center" } ], [ [ [ 0, "calorie" ] ], { "width": "380px", "height": "80px", "flexDirection": "row", "alignItems": "center", "justifyContent": "center", "marginBottom": "15px", "marginTop": "15px" } ], [ [ [ 0, "maxFire" ] ], { "width": "40px", "height": "48px", "marginRight": "10px" } ], [ [ [ 0, "hotCountdown" ] ], { "fontSize": "50px", "height": "60px", "textAlign": "center", "textOverflow": "clip" } ], [ [ [ 0, "footer" ] ], { "width": "300px", "height": "40px", "alignItems": "center", "justifyContent": "center", "marginBottom": "20px" } ], [ [ [ 0, "fireIcon" ] ], { "width": "26px", "height": "31px" } ], [ [ [ 0, "heartIcon" ] ], { "width": "30px", "height": "27px", "marginLeft": "30px", "marginRight": "8px" } ], [ [ [ 0, "heart" ] ], { "marginLeft": "20px" } ], [ [ [ 0, "heartRate" ] ], { "marginLeft": "4px" } ], [ [ [ 0, "maxTimeNum" ] ], { "marginLeft": "4px", "fontSize": "24px" } ], [ [ [ 0, "smallHeartIcon" ] ], { "width": "20px", "height": "24px", "left": "183px", "top": "6px" } ], [ [ [ 0, "smallTimeIcon" ] ], { "width": "22px", "height": "22px", "left": "182px", "top": "44px" } ], [ [ [ 0, "maxTime" ] ], { "width": "30px", "height": "30px", "marginRight": "8px" } ], [ [ [ 0, "publicFontSize" ] ], { "fontSize": "24px" } ], [ [ [ 0, "cancel-item" ] ], { "flexDirection": "row", "justifyContent": "space-around", "alignItems": "center" } ], [ [ [ 0, "publicEndBox" ] ], { "width": "110px", "height": "176px", "flexDirection": "column" } ], [ [ [ 0, "publicEndTxt" ] ], { "width": "110px", "height": "44px", "textAlign": "center", "fontSize": "34px", "marginBottom": "15px" } ], [ [ [ 0, "arcEndBtnStack" ] ], { "width": "110px", "height": "110px" } ], [ [ [ 0, "publicEndImg" ] ], { "width": "110px", "height": "110px" } ], [ [ [ 0, "endProgress" ] ], { "width": "110px", "height": "110px" } ], [ [ [ 0, "arcEndBtn" ] ], { "width": "110px", "height": "110px", "borderTopWidth": "3px", "borderRightWidth": "3px", "borderBottomWidth": "3px", "borderLeftWidth": "3px", "borderTopColor": "#646464", "borderRightColor": "#646464", "borderBottomColor": "#646464", "borderLeftColor": "#646464", "borderRadius": "55px", "justifyContent": "center", "alignItems": "center" } ], [ [ [ 0, "arcEndCenterBtn" ] ], { "width": "30px", "height": "30px", "borderRadius": "8px", "backgroundColor": "#C0191F" } ], [ [ [ 0, "hot" ] ], { "width": "260px", "height": "44px", "textAlign": "center", "fontSize": "34px", "textOverflow": "ellipsis" } ] ] /***/ }), /***/ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/template-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=template!./src/pages/course_box/course_motion/course_motion.hml?uxType=page&": /*!*****************************************************************************************************************************************************************************************************************************************!*\ !*** ./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/template-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=template!./src/pages/course_box/course_motion/course_motion.hml?uxType=page& ***! \*****************************************************************************************************************************************************************************************************************************************/ /***/ ((module) => { module.exports = function (vm) { const _vm_ = vm || this return aiot.__ce__("swiper", { "index": function () {return _vm_.index}, "duration": function () {return _vm_.duration}, "indicator": "false", "classList": [ "container" ] }, [ aiot.__ce__("div", { "classList": [ "swiper-item" ] }, [ aiot.__ce__("stack", { "classList": [ "box" ] }, [ aiot.__ce__("progress", { "type": "arc", "percent": function () {return _vm_.percent}, "classList": [ "calorieProgress" ], "style": { "position": "absolute" } }), aiot.__ce__("div", { "classList": [ "content" ], "style": { "position": "absolute" } }, [ aiot.__ce__("text", { "classList": [ "hot" ], "value": function () {return _vm_.courseName} }), aiot.__ce__("div", { "classList": [ "calorie" ] }, [ aiot.__ce__("image", { "src": "/common/images/maxFire.png", "classList": [ "maxFire" ] }), aiot.__ce__("text", { "classList": [ "hotCountdown" ], "style": { "width": function () {return _vm_.caloriesWidth} }, "value": function () {return _vm_.burnAllCalories} }) ]), aiot.__ce__("div", { "classList": [ "footer" ] }, [ aiot.__ce__("image", { "src": "/common/images/maxTime.png", "classList": [ "maxTime" ] }), aiot.__ce__("text", { "classList": [ "maxTimeNum" ], "value": function () {return _vm_.countdownTxt} }), aiot.__ce__("image", { "src": "/common/images/heart.png", "classList": [ "heartIcon" ] }), aiot.__ce__("text", { "classList": [ "heartRate", "publicFontSize" ], "value": function () {return _vm_.heartRate} }) ]) ]), aiot.__ce__("image", { "src": "/common/images/smallFire.png", "classList": [ "smallHeartIcon" ], "style": { "position": "absolute" } }), aiot.__ce__("stack", { "style": { "position": "absolute" } }) ]) ]), aiot.__ce__("div", { "classList": [ "swiper-item", "cancel-item" ] }, [ aiot.__ce__("div", { "classList": [ "publicEndBox" ], "events": { "click": function (evt) {_vm_.clickPauseBtn(evt)} } }, [ aiot.__ce__("text", { "classList": [ "publicEndTxt" ], "value": function () {return _vm_.pauseTxt} }), aiot.__ci__({ shown: function () {return _vm_.isPause==false} }, function () { return aiot.__ce__("image", { "src": "/common/images/startIcon.png", "classList": [ "publicEndImg" ] })}), aiot.__ci__({ shown: function () {return _vm_.isPause==true} }, function () { return aiot.__ce__("image", { "src": "/common/images/stopIcon.png", "classList": [ "publicEndImg" ] })}) ]), aiot.__ce__("div", { "classList": [ "publicEndBox" ] }, [ aiot.__ce__("text", { "classList": [ "publicEndTxt" ], "value": "结束" }), aiot.__ce__("stack", { "classList": [ "arcEndBtnStack" ], "events": { "click": function (evt) {_vm_.longPressEndBtn(evt)} } }, [ aiot.__ce__("div", { "classList": [ "arcEndBtn" ], "style": { "backgroundColor": function () {return _vm_.endBtnBackgroundColor}, "position": "absolute" } }, [ aiot.__ce__("div", { "classList": [ "arcEndCenterBtn" ] }) ]) ]) ]) ]) ]) } /***/ }), /***/ "./src/pages/course_box/course_motion/course_motion.hml?uxType=page": /*!**************************************************************************!*\ !*** ./src/pages/course_box/course_motion/course_motion.hml?uxType=page ***! \**************************************************************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { var $app_style$ = __webpack_require__(/*! !../../../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!sass-loader!./course_motion.scss?uxType=page */ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!./node_modules/sass-loader/dist/cjs.js!./src/pages/course_box/course_motion/course_motion.scss?uxType=page") var $app_script$ = __webpack_require__(/*! !../../../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/script-loader.js!../../../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/module-loader.js!../../../../node_modules/babel-loader/lib/index.js?cwd=/home/zdying/work/aidong_watch/vela-source&cacheDirectory&plugins[]=/home/zdying/work/aidong_watch/vela-source/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/zdying/work/aidong_watch/vela-source/node_modules/@aiot-toolkit/packager/babel.config.js!../../../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./course_motion.js?uxType=page */ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/script-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/module-loader.js!./node_modules/babel-loader/lib/index.js?cwd=/home/zdying/work/aidong_watch/vela-source&cacheDirectory&plugins[]=/home/zdying/work/aidong_watch/vela-source/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/zdying/work/aidong_watch/vela-source/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./src/pages/course_box/course_motion/course_motion.js?uxType=page") var $app_template$ = __webpack_require__(/*! !../../../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/template-loader.js!../../../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=template!./course_motion.hml?uxType=page& */ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/template-loader.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/fragment-loader.js?index=0&type=template!./src/pages/course_box/course_motion/course_motion.hml?uxType=page&") $app_script$({}, $app_exports$, $app_require$); $app_exports$.default.template = $app_template$; $app_exports$.default.style = $app_style$; module.exports = $app_exports$.default; /***/ }), /***/ "./src/common/js/utils.js": /*!********************************!*\ !*** ./src/common/js/utils.js ***! \********************************/ /***/ ((module) => { "use strict"; /** * @param {dateDifferenceNum}两个时间相差的秒数 */ function dateDifference(faultDate, completeTime) { var sTime = new Date(getDate(faultDate)).getTime(); var eTime = new Date(getDate(completeTime)).getTime(); var usedTime = eTime - sTime; //两个时间戳相差的毫秒数 if (usedTime <= 0) { return 0; } return Math.floor(usedTime / 1000); } /** * 1.0根据日期计算相差的时间 以day:hours:months格式返回 * @param {dateDifferenceNum} 相差的秒数 * @param {isRetainHour} 是否保留小时字段 */ function countdownNumChange(dateDifferenceNum, isRetainHour) { //计算出小时数 //var leaveHours = dateDifferenceNum % (24*3600);//计算天数后剩余的毫秒数 var hours = Math.floor(dateDifferenceNum / 3600); hours = hours < 10 ? `0${hours}` : hours; //计算相差分钟数 var leaveMinute = dateDifferenceNum % 3600; //计算小时数后剩余的毫秒数 var minutes = Math.floor(leaveMinute / 60); minutes = minutes < 10 ? `0${minutes}` : minutes; //计算相差秒数 var leaveSecond = Math.floor(leaveMinute % 60); //计算分钟数后剩余的毫秒数 var second = leaveSecond; second = second < 10 ? `0${second}` : second; var time; if (isRetainHour == null) { time = hours + ":" + minutes + ":" + second; } else { time = minutes + ":" + second; } return time; } /** * 根据字符串时间和上课的时间 计算出当前时间 * @param {dateStr} 字符串时间 * params {courseTime} 相差的时间 */ function dateWithString(dateStr, courseTime) { //把课程时间(分钟)转换成毫秒 let courseTimeMill = Number(courseTime) * 60 * 1000; let currentDate = getDate(dateStr); console.log(currentDate); let allTimeMill = currentDate.getTime() + courseTimeMill; return getCurrentDate(); } function getDate(strDate) { var st = strDate; var a = st.split(" "); var b = a[0].split("-"); var c = a[1].split(":"); var date = new Date(b[0], b[1] - 1, b[2], c[0], c[1], c[2]); return date; } /** * 1.0获取当前时间 以yyyy-MM-dd hh:mm:ss格式返回 * @param {timestamp} 时间戳 */ function getCurrentDate(timestamp) { let dateTime; let date = timestamp == null ? new Date() : new Date(timestamp); let yy = date.getFullYear(); let mm = date.getMonth() + 1; mm = mm < 10 ? "0" + mm : mm; let dd = date.getDate(); dd = dd < 10 ? "0" + dd : dd; let hh = date.getHours(); hh = hh < 10 ? "0" + hh : hh; let mf = date.getMinutes(); mf = mf < 10 ? "0" + mf : mf; let ss = date.getSeconds(); ss = ss < 10 ? "0" + ss : ss; dateTime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss; return dateTime; } /** * 1.0计算数组的平均值 * @param {array} 数组 */ function average(array) { if (array.length == 0) { return 0; } let len = array.length; let num = 0; for (let i = 0; i < array.length; i++) { num += array[i]; } return num == 0 ? 0 : Math.floor(num / len); } module.exports = { dateDifference: dateDifference, getCurrentDate: getCurrentDate, countdownNumChange: countdownNumChange, dateWithString: dateWithString, getDate: getDate, average: average }; /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(__webpack_module_cache__[moduleId]) { /******/ return __webpack_module_cache__[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module is referenced by other modules so it can't be inlined /******/ var __webpack_exports__ = __webpack_require__("./src/pages/course_box/course_motion/course_motion.hml?uxType=page"); /******/ /******/ })() ; }; return createPageHandler(); };