UNPKG

@aiot-toolkit/velasim

Version:

vela for sim

1,269 lines (1,183 loc) 30.6 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/scheduled_box/conclusion/conclusion.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/scheduled_box/conclusion/conclusion.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 _utils = _interopRequireDefault(__webpack_require__(/*! ../../../common/js/utils.js */ "./src/common/js/utils.js")); var _readAndWriteFiled = _interopRequireDefault(__webpack_require__(/*! ../../../common/js/readAndWriteFiled.js */ "./src/common/js/readAndWriteFiled.js")); var _system = _interopRequireDefault($app_require$("@app-module/system.router")); var _system2 = _interopRequireDefault($app_require$("@app-module/system.interconnect")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _default = { protected: { totalCourseData: {}, newCourseDate: "", totalSections: [], libraryMotionFilePath: "internal://app/libraryMotion.txt", motionDataFilePath: "", isReadData: false, timerOut: null, instance: {}, conn_status: null }, clickFinishBtn() { _system.default.replace({ uri: "pages/home" }); }, readFileMotionOrLb() { let that = this; if (this.courseType == "appointment") { _readAndWriteFiled.default.readFile(this.motionDataFilePath, res => { var resStr = JSON.stringify(res); var newResArr = JSON.parse(resStr); that.getTotalData(newResArr); that.writeFileWeekMotion(res); that.totalSections.forEach((item, index) => { that.totalSections[index].during = _utils.default.countdownNumChange(item.during); }); that.isReadData = true; that.sendMessageToApp(res); }, error => {}); } else { _readAndWriteFiled.default.readFile(this.libraryMotionFilePath, res => { var resStr = JSON.stringify(res); var newResArr = JSON.parse(resStr); that.getTotalData(newResArr); that.writeFileWeekMotion(res); that.isReadData = true; that.sendMessageToApp(res); }, err => {}); } }, getTotalData(res) { this.totalCourseData = res[0]; this.totalCourseData.data[0].during = _utils.default.countdownNumChange(this.totalCourseData.data[0].during); this.totalSections = this.totalCourseData.data[0].more; }, writeFileWeekMotion(data) { let that = this; let isCompareTo = false; var onlyData = { dateTime: data[0].data[0].at.split(" ")[0], duration: data[0].data[0].during, calorie: data[0].data[0].buring, beats: data[0].data[0].beats }; var weekMotionPath = "internal://app/weekMotion.txt"; _readAndWriteFiled.default.readFile(weekMotionPath, res => { var weekMotion = res; if (weekMotion.length == 7) { weekMotion.splice(0, 1); weekMotion.push(onlyData); } weekMotion.forEach((item, index) => { var at = data[0].data[0].at.split(" ")[0]; if (at == item.dateTime) { isCompareTo = true; var allBeats = Number(data[0].data[0].beats) + Number(item.beats); item.duration = Number(data[0].data[0].during) + Number(item.duration); item.calorie = Number(data[0].data[0].buring) + Number(item.calorie); item.beats = allBeats == 0 ? 0 : Math.floor(allBeats / 2); } }); if (isCompareTo == false) { weekMotion.push(onlyData); } _readAndWriteFiled.default.writeFile(weekMotionPath, weekMotion); }, err => { var weekMotionArr = [onlyData]; _readAndWriteFiled.default.writeFile(weekMotionPath, weekMotionArr); }); }, sendMessageToApp(motionData) { let that = this; if (that.conn_status == "CONNECTED") { var newData = { type: 3, data: motionData }; this.instance.send({ data: { data: JSON.stringify(newData) }, success: () => {} }); } else { if (this.isShowModel == "false") { _system.default.replace({ uri: "pages/not_conn", params: { courseName: that.courseName, classTime: that.classTime, startDate: that.startDate, userId: that.userId, courseType: that.courseType, routerUrl: "pages/scheduled_box/conclusion" } }); } } }, receiveMessageWithApp() { let that = this; this.instance.onmessage = data => { var newData = JSON.parse(data.data); if (newData.status == 1) { if (that.courseType == "appointment") { _readAndWriteFiled.default.deleteFile(that.motionDataFilePath); } else { _readAndWriteFiled.default.deleteFile(that.libraryMotionFilePath); } } }; }, onInit() { this.instance = _system2.default.instance(); this.conn_status = this.instance.getApkStatus(); this.receiveMessageWithApp(); this.motionDataFilePath = "internal://app/motion" + this.userId + ".txt"; this.readFileMotionOrLb(); this.newCourseDate = this.startDate.split(" ")[0]; }, onDestroy() { clearTimeout(this.timer); this.instance = 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/scheduled_box/conclusion/conclusion.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/scheduled_box/conclusion/conclusion.scss?uxType=page ***! \***************************************************************************************************************************************************************************************************/ /***/ ((module) => { module.exports = [ [ [ [ 0, "publicContainer" ] ], { "width": "464px", "height": "464px", "flexDirection": "column", "alignItems": "center", "backgroundColor": "#000000" } ], [ [ [ 0, "container" ] ], { "width": "464px", "height": "464px", "flexDirection": "column", "alignItems": "center", "backgroundColor": "#000000" } ], [ [ [ 2, "text" ] ], { "fontSize": "34px", "color": "#FFFFFF" } ], [ [ [ 0, "courseSum" ] ], { "width": "464px", "height": "464px" } ], [ [ [ 0, "courseItem" ] ], { "width": "464px", "height": "624px", "justifyContent": "center", "alignItems": "center" } ], [ [ [ 2, "courseitemchild" ] ], { "width": "464px", "height": "604px", "justifyContent": "center", "alignItems": "center" } ], [ [ [ 0, "listItemBtm" ] ], { "width": "464px", "height": "186px", "justifyContent": "center", "alignItems": "center" } ], [ [ [ 0, "content" ] ], { "width": "368px", "height": "614px", "flexDirection": "column", "alignItems": "center" } ], [ [ [ 0, "courseItemChild" ] ], { "height": "536px" } ], [ [ [ 0, "contentChild" ] ], { "height": "536px" } ], [ [ [ 0, "courseNameBox" ] ], { "width": "328px", "height": "42px" } ], [ [ [ 0, "courseName" ] ], { "width": "328px", "height": "42px", "textAlign": "center", "textOverflow": "ellipsis" } ], [ [ [ 0, "courseNameParent" ] ], { "marginTop": "54px" } ], [ [ [ 0, "totalTime" ] ], { "width": "328px", "height": "97px", "flexDirection": "column", "justifyContent": "space-between", "marginTop": "30px" } ], [ [ [ 0, "totalTimeTop" ] ], { "width": "328px", "height": "42px", "flexDirection": "row", "alignItems": "center", "justifyContent": "space-between" } ], [ [ [ 0, "orangeTime" ] ], { "width": "32px", "height": "32px" } ], [ [ [ 0, "totalTimeBom" ] ], { "fontSize": "34px", "color": "#EE5928" } ], [ [ [ 0, "calorie" ] ], { "marginTop": "37px" } ], [ [ [ 0, "calorieBom" ] ], { "width": "328px", "height": "50px", "textAlign": "left", "alignItems": "center" } ], [ [ [ 0, "calorieTxt" ] ], { "fontSize": "34px", "color": "#FFBD60" } ], [ [ [ 0, "calorieSubTxt" ] ], { "fontSize": "34px", "color": "#AAAAAA", "marginLeft": "10px" } ], [ [ [ 0, "rate" ] ], { "color": "#C0191F" } ], [ [ [ 0, "rateRangeBox" ] ], { "width": "328px", "height": "47px", "textAlign": "left" } ], [ [ [ 0, "rateRange" ] ], { "fontSize": "34px", "height": "44px", "color": "#AAAAAA" } ], [ [ [ 0, "line" ] ], { "marginTop": "15px", "width": "368px", "height": "2px", "backgroundColor": "rgba(255,255,255,0.1)" } ], [ [ [ 0, "dashLine" ] ], { "width": "368px", "height": "2px", "backgroundColor": "rgba(255,255,255,0.3)" } ], [ [ [ 0, "dateBox" ] ], { "width": "328px", "height": "68px", "flexDirection": "row", "justifyContent": "space-between", "alignItems": "center" } ], [ [ [ 0, "dateTxt" ] ], { "fontSize": "20px", "color": "#AAAAAA" } ], [ [ [ 0, "finishBtn" ] ], { "width": "230px", "height": "86px", "fontSize": "34px", "marginTop": "50px", "marginBottom": "50px", "backgroundColor": "#2A2A2E" } ], [ [ [ 0, "totalTimeTopTxt" ] ], { "fontSize": "34px", "height": "44px" } ] ] /***/ }), /***/ "./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/scheduled_box/conclusion/conclusion.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/scheduled_box/conclusion/conclusion.hml?uxType=page& ***! \**************************************************************************************************************************************************************************************************************************************/ /***/ ((module) => { module.exports = function (vm) { const _vm_ = vm || this return aiot.__ce__("div", { "classList": [ "container" ] }, [ aiot.__ce__("list", { "classList": [ "courseSum" ] }, [ aiot.__cf__({ exp: function () {return _vm_.totalCourseData.data} }, function ($idx, $item) { return aiot.__ce__("list-item", { "classList": [ "courseItem" ] }, [ aiot.__ce__("div", { "classList": [ "content" ] }, [ aiot.__ce__("text", { "classList": [ "courseName", "courseNameParent" ], "value": function () {return _vm_.courseName} }), aiot.__ce__("div", { "classList": [ "totalTime" ] }, [ aiot.__ce__("div", { "classList": [ "totalTimeTop" ] }, [ aiot.__ce__("text", { "classList": [ "totalTimeTopTxt" ], "value": "总用时:" }), aiot.__ce__("image", { "src": "/common/images/orangeTime.png", "classList": [ "orangeTime" ] }) ]), aiot.__ce__("text", { "classList": [ "totalTimeBom" ], "value": function () {return $item.during} }) ]), aiot.__ce__("div", { "classList": [ "totalTime", "calorie" ] }, [ aiot.__ce__("div", { "classList": [ "totalTimeTop" ] }, [ aiot.__ce__("text", { "classList": [ "totalTimeTopTxt" ], "value": "消耗卡路里:" }), aiot.__ce__("image", { "src": "/common/images/yellowFire.png", "classList": [ "orangeTime" ] }) ]), aiot.__ce__("div", { "classList": [ "calorieBom" ] }, [ aiot.__ce__("text", { "classList": [ "calorieTxt" ], "value": function () {return $item.buring} }), aiot.__ce__("text", { "classList": [ "calorieSubTxt" ], "value": "千卡" }) ]) ]), aiot.__ce__("div", { "classList": [ "totalTime", "calorie" ] }, [ aiot.__ce__("div", { "classList": [ "totalTimeTop" ] }, [ aiot.__ce__("text", { "classList": [ "totalTimeTopTxt" ], "value": "平均心率" }), aiot.__ce__("image", { "src": "/common/images/redHeart.png", "classList": [ "orangeTime" ] }) ]), aiot.__ce__("div", { "classList": [ "calorieBom" ] }, [ aiot.__ce__("text", { "classList": [ "calorieTxt", "rate" ], "value": function () {return $item.beats} }), aiot.__ce__("text", { "classList": [ "calorieSubTxt" ], "value": "次/分" }) ]) ]), aiot.__ce__("div", { "classList": [ "rateRangeBox" ] }, [ aiot.__ce__("text", { "classList": [ "rateRange" ], "value": "范围70-90次/分" }) ]), aiot.__ce__("div", { "classList": [ "line" ] }), aiot.__ce__("div", { "classList": [ "dateBox" ] }, [ aiot.__ce__("text", { "classList": [ "dateTxt" ], "value": function () {return _vm_.newCourseDate} }), aiot.__ce__("text", { "classList": [ "dateTxt" ], "value": function () {return _vm_.classTime} }) ]), aiot.__ce__("div", { "classList": [ "dashLine" ] }) ]) ])}), aiot.__cf__({ exp: function () {return _vm_.totalSections} }, function ($idx, $item) { return aiot.__ce__("list-item", { "classList": [ "courseItem", "courseItemChild" ] }, [ aiot.__ce__("div", { "classList": [ "content", "contentChild" ] }, [ aiot.__ce__("text", { "classList": [ "courseName" ], "value": function () {return $item.name} }), aiot.__ce__("div", { "classList": [ "totalTime" ] }, [ aiot.__ce__("div", { "classList": [ "totalTimeTop" ] }, [ aiot.__ce__("text", { "classList": [ "totalTimeTopTxt" ], "value": "总用时:" }), aiot.__ce__("image", { "src": "/common/images/orangeTime.png", "classList": [ "orangeTime" ] }) ]), aiot.__ce__("text", { "classList": [ "totalTimeBom" ], "value": function () {return $item.during} }) ]), aiot.__ce__("div", { "classList": [ "totalTime", "calorie" ] }, [ aiot.__ce__("div", { "classList": [ "totalTimeTop" ] }, [ aiot.__ce__("text", { "classList": [ "totalTimeTopTxt" ], "value": "消耗卡路里:" }), aiot.__ce__("image", { "src": "/common/images/yellowFire.png", "classList": [ "orangeTime" ] }) ]), aiot.__ce__("div", { "classList": [ "calorieBom" ] }, [ aiot.__ce__("text", { "classList": [ "calorieTxt" ], "value": function () {return $item.buring} }), aiot.__ce__("text", { "classList": [ "calorieSubTxt" ], "value": "千卡" }) ]) ]), aiot.__ce__("div", { "classList": [ "totalTime", "calorie" ] }, [ aiot.__ce__("div", { "classList": [ "totalTimeTop" ] }, [ aiot.__ce__("text", { "classList": [ "totalTimeTopTxt" ], "value": "平均心率" }), aiot.__ce__("image", { "src": "/common/images/redHeart.png", "classList": [ "orangeTime" ] }) ]), aiot.__ce__("div", { "classList": [ "calorieBom" ] }, [ aiot.__ce__("text", { "classList": [ "calorieTxt", "rate" ], "value": function () {return $item.beats} }), aiot.__ce__("text", { "classList": [ "calorieSubTxt" ], "value": "次/分" }) ]) ]), aiot.__ce__("div", { "classList": [ "rateRangeBox" ] }, [ aiot.__ce__("text", { "classList": [ "rateRange" ], "value": "范围70-90次/分" }) ]), aiot.__ce__("div", { "classList": [ "line" ] }) ]) ])}), aiot.__ce__("list-item", { "classList": [ "listItemBtm" ] }, [ aiot.__ci__({ shown: function () {return _vm_.isReadData==true} }, function () { return aiot.__ce__("input", { "type": "button", "value": "完成", "classList": [ "finishBtn" ], "events": { "click": function (evt) {_vm_.clickFinishBtn(evt)} } })}) ]) ]) ]) } /***/ }), /***/ "./src/pages/scheduled_box/conclusion/conclusion.hml?uxType=page": /*!***********************************************************************!*\ !*** ./src/pages/scheduled_box/conclusion/conclusion.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!./conclusion.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/scheduled_box/conclusion/conclusion.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!./conclusion.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/scheduled_box/conclusion/conclusion.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!./conclusion.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/scheduled_box/conclusion/conclusion.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/readAndWriteFiled.js": /*!********************************************!*\ !*** ./src/common/js/readAndWriteFiled.js ***! \********************************************/ /***/ ((module) => { "use strict"; var _system = _interopRequireDefault($app_require$("@app-module/system.file")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * 写数据到本地文件夹中 * @param {uri} 文件路径 * @param {text} 要写出文件的数据 转换成JSON.stringify格式 * date:2021-07-13 */ function writeFile(uri, data) { _system.default.writeText({ uri: uri, text: JSON.stringify(data), success: function () { console.log("call writeText success."); }, fail: function (data, code) { console.error("call fail callback fail, code: " + code + ", data: " + data); } }); } /** * 读取本地文件夹中的数据 * @param {uri} 文件路径 * @param {successCallback} 读取数据成功的回调 * @param {errCallback} 读取数据失败的回调 * date:2021-07-13 */ function readFile(filename, successCallback, errCallback) { _system.default.readText({ uri: filename, success: function (data) { if (data.text.length != 0) { let arr = JSON.parse(data.text); successCallback(arr); } else { successCallback(data.text); } }, fail: function (data, code) { errCallback("error"); } }); } /** * 删除本地文件夹 * @param {uri} 文件路径 * date:2021-07-13 */ function deleteFile(filename) { _system.default.delete({ uri: filename }); } module.exports = { writeFile: writeFile, readFile: readFile, deleteFile: deleteFile }; /***/ }), /***/ "./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/scheduled_box/conclusion/conclusion.hml?uxType=page"); /******/ /******/ })() ; }; return createPageHandler(); };