@aiot-toolkit/velasim
Version:
vela for sim
1,298 lines (1,199 loc) • 33 kB
JavaScript
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/motion/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/scheduled_box/motion/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 _readAndWriteFiled = _interopRequireDefault(__webpack_require__(/*! ../../../common/js/readAndWriteFiled.js */ "./src/common/js/readAndWriteFiled.js"));
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.vibrator"));
var _system3 = _interopRequireDefault($app_require$("@app-module/system.health"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
protected: {
motionDataFilePath: "",
courseFilePath: "internal://app/appointCourse.txt",
percent: 0,
timePercent: 0,
endBtnBackgroundColor: "#000000",
isPause: false,
pauseTxt: "暂停",
isHiddenNextCourseBtn: false,
trainData: {},
action: {
"name": "_",
"during": 20
},
countdownTxt: "00:00:00",
timer: null,
everyLessonTrainTime: 0,
isHiddenTip: true,
restAllTime: 0,
twinCourseIndex: 0,
twinActionLength: 0,
uploadTrainData: [{
id: 0,
type: "appointment",
data: [{
at: "",
during: 0,
buring: 0,
beats: 0,
more: []
}]
}],
burnAllCalories: 0,
heartRate: 0,
realHrArr: [],
caloriesWidth: 15,
prevCalories: 0,
duration: 10
},
clickPauseBtn() {
this.isPause = !this.isPause;
this.pauseTxt = this.isPause == true ? "已暂停" : "暂停";
if (this.isPause == true) {
clearInterval(this.timer);
} else {
this.countdownChange(this.trainData.start_time, this.trainData.end_time);
}
},
clickEndSectionBtn() {
clearInterval(this.timer);
this.recordMotionAllData();
let params = {
classTime: this.classTime,
startDate: this.startDate,
currentDate: this.currentDate,
courseIndex: this.courseIndex,
courseId: this.courseId,
burying: this.burying,
actionLength: this.actionLength,
userId: this.userId,
rest: this.restAllTime.toString(),
courseName: this.courseName
};
this.gotoPageWithUri("pages/scheduled_box/rest", params);
},
clickEndBtn() {
clearInterval(this.timer);
let that = this;
this.recordMotionAllData();
var params = {
courseName: this.courseName,
classTime: this.classTime,
startDate: this.startDate,
userId: this.userId,
courseType: "appointment",
isShowModel: "false"
};
that.gotoPageWithUri("pages/scheduled_box/conclusion", params);
},
countdownChange(courseDate, courseEndTime) {
let that = this;
let duringMilliseconds = _utils.default.dateDifference(courseDate, courseEndTime);
that.timer = setInterval(() => {
let currentDate = _utils.default.getCurrentDate();
let usedTime = _utils.default.dateDifference(courseDate, currentDate);
that.countdownTxt = _utils.default.countdownNumChange(usedTime);
var calories = _system3.default.getTodayCalorie();
that.burnAllCalories = calories - that.prevCalories;
that.setCaloriesWidth(that.burnAllCalories);
let progressCl = that.burnAllCalories / Number(that.burying) * 100;
that.percent = progressCl > 100 ? 100 : progressCl;
that.heartRate = _system3.default.getHr();
that.everyLessonTrainTime++;
if (that.everyLessonTrainTime % 60 == 0 && that.realHrArr.length != 120) {
that.realHrArr.push(that.heartRate);
}
if (usedTime == duringMilliseconds) {
that.isHiddenTip = false;
that.closeTipModel();
} else {
var progress = Math.floor(usedTime / duringMilliseconds * 100);
that.timePercent = progress > 100 ? 100 : progress;
}
}, 1000);
},
closeTipModel() {
let that = this;
_system2.default.vibrate({
mode: "short"
});
setTimeout(() => {
that.isHiddenTip = true;
}, 2000);
},
recordMotionAllData() {
let that = this;
that.uploadTrainData[0].data[0].more[that.twinCourseIndex].during = that.everyLessonTrainTime;
that.uploadTrainData[0].data[0].more[that.twinCourseIndex].buring = that.burnAllCalories;
that.uploadTrainData[0].data[0].more[that.twinCourseIndex].beats = _utils.default.average(that.realHrArr);
let allDuring = that.restAllTime;
let allBuringCalorie = 0;
let beats = 0;
that.uploadTrainData[0].data[0].more.forEach((item, index) => {
allDuring += item.during;
allBuringCalorie += item.buring;
beats += item.beats;
});
that.uploadTrainData[0].data[0].during = allDuring;
that.uploadTrainData[0].data[0].buring = allBuringCalorie;
that.uploadTrainData[0].data[0].beats = that.twinCourseIndex == 0 ? beats : beats == 0 ? 0 : Math.floor(beats / (that.twinCourseIndex + 1));
_readAndWriteFiled.default.writeFile(that.motionDataFilePath, that.uploadTrainData);
},
recordMotionData(index, name) {
let that = this;
let currentDate = _utils.default.getCurrentDate();
let data = {
at: currentDate,
name: name,
during: 0,
buring: 0,
beats: 0
};
_readAndWriteFiled.default.readFile(that.motionDataFilePath, res => {
that.uploadTrainData = res;
that.uploadTrainData[0].data[0].more.push(data);
}, error => {
that.uploadTrainData[0].data[0].more.push(data);
});
},
readFile() {
let that = this;
_readAndWriteFiled.default.readFile(this.courseFilePath, res => {
that.trainData = res;
that.action = that.trainData.action[that.twinCourseIndex];
that.isHiddenNextCourseBtn = that.twinCourseIndex == that.trainData.action.length - 1;
that.uploadTrainData[0].id = parseInt(that.courseId);
for (var i = 0; i < that.twinActionLength; i++) {
if (i == that.twinCourseIndex) {
that.recordMotionData(i, res.action[i].name);
break;
}
}
;
that.countdownChange(that.trainData.start_time, that.trainData.end_time);
}, error => {});
},
gotoPageWithUri(uri, params) {
_system.default.replace({
uri: uri,
params: params
});
},
setCaloriesWidth(caloriesNum) {
if (caloriesNum >= 10) {
let rounding = Math.floor(caloriesNum / 10);
if (rounding >= 1 && rounding < 10 && this.caloriesWidth != 30) {
this.caloriesWidth = 30;
} else if (rounding >= 10 && rounding < 100 && this.caloriesWidth != 45) {
this.caloriesWidth = 50;
} else if (rounding >= 100 && rounding < 1000 && this.caloriesWidth != 60) {
this.caloriesWidth = 70;
} else if (rounding >= 1000 && rounding < 10000 && this.caloriesWidth != 75) {
this.caloriesWidth = 90;
} else if (rounding >= 10000 && rounding < 1000000 && this.caloriesWidth != 90) {
this.caloriesWidth = 90;
}
}
},
onInit() {
this.prevCalories = _system3.default.getTodayCalorie();
this.motionDataFilePath = `internal://app/motion${this.userId}.txt`;
this.twinCourseIndex = parseInt(this.courseIndex);
this.twinActionLength = parseInt(this.actionLength);
this.uploadTrainData[0].data[0].at = this.currentDate;
this.restAllTime = this.rest != undefined || this.rest != null ? parseInt(this.rest) : 0;
this.readFile();
},
onDestroy() {
clearInterval(this.timer);
}
};
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/motion/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/scheduled_box/motion/motion.scss?uxType=page ***!
\*******************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = [
[
[
[
0,
"publicContainer"
]
],
{
"width": "464px",
"height": "464px",
"flexDirection": "column",
"alignItems": "center",
"backgroundColor": "#000000"
}
],
[
[
[
0,
"remindContainer"
]
],
{
"width": "464px",
"height": "464px",
"flexDirection": "column",
"alignItems": "center",
"backgroundColor": "#000000",
"justifyContent": "center"
}
],
[
[
[
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,
"timeProgress"
]
],
{
"width": "464px",
"height": "464px",
"color": "#EE5928",
"backgroundColor": "#471B0C",
"startAngle": "0deg",
"totalAngle": "360deg",
"strokeWidth": "32px",
"centerX": "232px",
"centerY": "232px",
"radius": "195px"
}
],
[
[
[
0,
"content"
]
],
{
"width": "326px",
"height": "326px",
"borderRadius": "163px",
"left": "69px",
"top": "69px",
"flexDirection": "column",
"justifyContent": "space-between",
"alignItems": "center"
}
],
[
[
[
0,
"hotBox"
]
],
{
"width": "180px",
"height": "44px",
"marginTop": "60px"
}
],
[
[
[
0,
"hot"
]
],
{
"width": "180px",
"height": "44px",
"fontSize": "34px",
"textOverflow": "ellipsis",
"textAlign": "center"
}
],
[
[
[
0,
"hotCountdown"
]
],
{
"fontSize": "60px"
}
],
[
[
[
0,
"footer"
]
],
{
"width": "258px",
"height": "40px",
"marginBottom": "65px",
"alignItems": "center",
"justifyContent": "center"
}
],
[
[
[
0,
"fireIcon"
]
],
{
"width": "26px",
"height": "31px"
}
],
[
[
[
0,
"currentNum"
]
],
{
"color": "#FFBD60",
"textAlign": "right",
"marginLeft": "4px"
}
],
[
[
[
0,
"heartIcon"
]
],
{
"width": "30px",
"height": "27px",
"marginLeft": "25px"
}
],
[
[
[
0,
"heart"
]
],
{
"marginLeft": "20px"
}
],
[
[
[
0,
"heartRate"
]
],
{
"marginLeft": "4px",
"height": "30px"
}
],
[
[
[
0,
"maxTime"
]
],
{
"width": "30px",
"height": "30px"
}
],
[
[
[
0,
"publicFontSize"
]
],
{
"fontSize": "24px",
"textOverflow": "clip"
}
],
[
[
[
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,
"endSection"
]
],
{
"width": "150px"
}
],
[
[
[
0,
"endSections"
]
],
{
"flexDirection": "column",
"alignItems": "center",
"justifyContent": "center"
}
],
[
[
[
0,
"arcEndBtnStack"
]
],
{
"width": "110px",
"height": "110px"
}
],
[
[
[
0,
"publicEndImg"
]
],
{
"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,
"remindContent"
]
],
{
"width": "410px",
"height": "410px",
"borderRadius": "210px",
"borderTopWidth": "8px",
"borderRightWidth": "8px",
"borderBottomWidth": "8px",
"borderLeftWidth": "8px",
"borderTopColor": "#2A2A2E",
"borderRightColor": "#2A2A2E",
"borderBottomColor": "#2A2A2E",
"borderLeftColor": "#2A2A2E",
"flexDirection": "column",
"alignItems": "center",
"justifyContent": "center"
}
],
[
[
[
0,
"remindTxt"
]
],
{
"fontSize": "34px",
"height": "44px"
}
],
[
[
[
0,
"remindImg"
]
],
{
"width": "50px",
"height": "50px",
"marginBottom": "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/motion/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/scheduled_box/motion/motion.hml?uxType=page& ***!
\******************************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = function (vm) {
const _vm_ = vm || this
return aiot.__ce__("stack", {
"classList": [
"container"
]
}, [
aiot.__ce__("swiper", {
"loop": "false",
"duration": function () {return _vm_.duration},
"indicator": "false",
"classList": [
"container"
],
"style": {
"position": "absolute"
}
}, [
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__("progress", {
"type": "arc",
"percent": function () {return _vm_.timePercent},
"classList": [
"timeProgress"
],
"style": {
"position": "absolute"
}
}),
aiot.__ce__("div", {
"classList": [
"content"
],
"style": {
"position": "absolute"
}
}, [
aiot.__ce__("div", {
"classList": [
"hotBox"
]
}, [
aiot.__ce__("text", {
"classList": [
"hot"
],
"value": function () {return _vm_.action.name}
})
]),
aiot.__ce__("text", {
"classList": [
"hotCountdown"
],
"value": function () {return _vm_.countdownTxt}
}),
aiot.__ce__("div", {
"classList": [
"footer"
]
}, [
aiot.__ce__("image", {
"src": "/common/images/fire.png",
"classList": [
"fireIcon"
]
}),
aiot.__ce__("text", {
"classList": [
"currentNum",
"publicFontSize"
],
"style": {
"width": function () {return _vm_.caloriesWidth}
},
"value": function () {return _vm_.burnAllCalories}
}),
aiot.__ce__("text", {
"classList": [
"maxNum",
"publicFontSize"
],
"value": function () {return '' + '/' + (_vm_.burying)}
}),
aiot.__ce__("image", {
"src": "/common/images/heart.png",
"classList": [
"heartIcon"
]
}),
aiot.__ce__("text", {
"classList": [
"heartRate",
"publicFontSize"
],
"value": function () {return _vm_.heartRate}
})
])
]),
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.__ci__({
shown: function () {return !_vm_.isHiddenNextCourseBtn}
},
function () {
return aiot.__ce__("div", {
"classList": [
"publicEndBox",
"endSection",
"endSections"
],
"events": {
"click": function (evt) {_vm_.clickEndSectionBtn(evt)}
}
}, [
aiot.__ce__("text", {
"classList": [
"publicEndTxt",
"endSection"
],
"value": "结束小节"
}),
aiot.__ce__("image", {
"src": "/common/images/next.png",
"classList": [
"publicEndImg"
]
})
])}),
aiot.__ce__("div", {
"classList": [
"publicEndBox"
]
}, [
aiot.__ce__("text", {
"classList": [
"publicEndTxt"
],
"value": "结束"
}),
aiot.__ce__("stack", {
"classList": [
"arcEndBtnStack"
],
"events": {
"click": function (evt) {_vm_.clickEndBtn(evt)}
}
}, [
aiot.__ce__("div", {
"classList": [
"arcEndBtn"
],
"style": {
"backgroundColor": function () {return _vm_.endBtnBackgroundColor},
"position": "absolute"
}
}, [
aiot.__ce__("div", {
"classList": [
"arcEndCenterBtn"
]
})
])
])
])
])
]),
aiot.__ci__({
shown: function () {return _vm_.isHiddenTip==false}
},
function () {
return aiot.__ce__("div", {
"classList": [
"remindContainer"
],
"style": {
"position": "absolute"
}
}, [
aiot.__ce__("div", {
"classList": [
"remindContent"
]
}, [
aiot.__ce__("image", {
"src": "/common/images/remind.png",
"classList": [
"remindImg"
]
}),
aiot.__ce__("text", {
"classList": [
"remindTxt"
],
"value": "课程即将结束"
})
])
])})
])
}
/***/ }),
/***/ "./src/pages/scheduled_box/motion/motion.hml?uxType=page":
/*!***************************************************************!*\
!*** ./src/pages/scheduled_box/motion/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!./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/scheduled_box/motion/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!./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/scheduled_box/motion/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!./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/scheduled_box/motion/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/readAndWriteFiled.js":
/*!********************************************!*\
!*** ./src/common/js/readAndWriteFiled.js ***!
\********************************************/
/***/ ((module) => {
;
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) => {
;
/**
* @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/motion/motion.hml?uxType=page");
/******/
/******/ })()
;
};
return createPageHandler();
};