@aiot-toolkit/velasim
Version:
vela for sim
561 lines (506 loc) • 20.3 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/hx/work/project/third-app/vela-drinkwater&cacheDirectory&plugins[]=/home/hx/work/project/third-app/vela-drinkwater/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/hx/work/project/third-app/vela-drinkwater/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./src/pages/detail/detail.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/hx/work/project/third-app/vela-drinkwater&cacheDirectory&plugins[]=/home/hx/work/project/third-app/vela-drinkwater/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/hx/work/project/third-app/vela-drinkwater/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./src/pages/detail/detail.js?uxType=page ***!
\*****************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
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.file"));
var _system2 = _interopRequireDefault($app_require$("@app-module/system.router"));
var _system3 = _interopRequireDefault($app_require$("@app-module/system.vibrator"));
var _system4 = _interopRequireDefault($app_require$("@app-module/system.brightness"));
var _system5 = _interopRequireDefault($app_require$("@app-module/system.interconnect"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
protected: {
receive_data: '',
water_progress: 0,
page1_title: '',
total_water: '',
show_hint: false,
drinkarray: [{
drink: ''
}]
},
backToMain() {
_system2.default.replace({
uri: "pages/main",
params: {}
});
},
onReady() {
var that = this;
_system.default.readText({
uri: 'internal://cache/water.txt',
encoding: 'UTF-8',
success: function (data) {
that.receive_data = data.text;
that.parseDetailData();
},
fail: function (data, code) {
that.total_water = that.$t('strings.error_code') + code;
}
});
let conn = _system5.default.instance();
conn.onmessage = appData => {
var recData = appData.data;
if (recData != undefined && recData != 'undefined' && recData != null && recData != '') {
if (recData == '&EOF&Alarm&EOF&') {
_system3.default.vibrate({
mode: 'short'
});
_system4.default.setKeepScreenOn({
keepScreenOn: true,
success: function () {
console.log("handling set keep screen on success.");
},
fail: function (data, code) {
console.log("handling set keep screen on fail, code:" + code + ", data: " + data);
}
});
setTimeout(function () {
_system4.default.setKeepScreenOn({
keepScreenOn: false,
success: function () {
console.log("handling set keep screen off success.");
},
fail: function (data, code) {
console.log("handling set keep screen off fail, code:" + code + ", data: " + data);
}
});
}, 20 * 1000);
} else if (recData.substr(0, 5) == '&EOF&' && recData.substring(recData.length - 5) == '&EOF&') {
that.receive_data = recData.substring(0, recData.length - 5).slice(5);
that.parseDetailData();
that.cacheData();
} else if (recData.substr(0, 5) == '&EOF&') {
that.receive_data = recData.slice(5);
} else if (recData.substring(recData.length - 5) == '&EOF&') {
that.receive_data = that.receive_data + recData.substring(0, recData.length - 5);
_system3.default.vibrate({
mode: 'short'
});
that.parseDetailData();
that.cacheData();
} else {
that.receive_data = that.receive_data + recData;
}
}
};
},
parseDetailData() {
var jsonObj = JSON.parse(this.receive_data);
var total_ml = 0;
if (jsonObj.dayList.length > 0) {
var nowDate = this.getNowDate();
var today_water_data = jsonObj.dayList[0];
if (nowDate.indexOf(today_water_data.date) == -1) {
this.total_water = this.$t('strings.no_drink_water_data');
this.drinkarray = [{
drink: ''
}];
this.show_hint = true;
this.page1_title = '';
this.water_progress = 0;
return;
}
this.water_progress = today_water_data.totalVolume * 100 / jsonObj.target;
total_ml = today_water_data.totalVolume;
}
if (jsonObj.itemList.length > 0) {
var drinkItems = [jsonObj.itemList.length];
for (var i = 0; i < jsonObj.itemList.length; i++) {
var jsonItem = jsonObj.itemList[i];
var drinkData = '';
var drink_time = jsonItem.time.substring(0, jsonItem.time.length - 3);
if (jsonItem.type == 0) {
drinkData = drink_time + this.$t('strings.water') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 1) {
drinkData = drink_time + this.$t('strings.juice') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 2) {
drinkData = drink_time + this.$t('strings.milk') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 3) {
drinkData = drink_time + this.$t('strings.cafe') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 4) {
drinkData = drink_time + this.$t('strings.tea') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 5) {
drinkData = drink_time + this.$t('strings.milky_tea') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 6) {
drinkData = drink_time + this.$t('strings.coke') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 7) {
drinkData = drink_time + this.$t('strings.baijiu') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 8) {
drinkData = drink_time + this.$t('strings.soybean_milk') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 9) {
drinkData = drink_time + this.$t('strings.red_wine') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 10) {
drinkData = drink_time + this.$t('strings.beverage') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 11) {
drinkData = drink_time + this.$t('strings.beer') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 12) {
drinkData = drink_time + this.$t('strings.soup') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 13) {
drinkData = drink_time + this.$t('strings.brandy') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 14) {
drinkData = drink_time + this.$t('strings.rice_congee') + jsonItem.volume + 'ml';
} else if (jsonItem.type == 15) {
drinkData = drink_time + this.$t('strings.other') + jsonItem.volume + 'ml';
} else {
drinkData = drink_time + this.$t('strings.other') + jsonItem.volume + 'ml';
}
var drinkItem = {
drink: drinkData
};
drinkItems[i] = drinkItem;
}
this.drinkarray = drinkItems;
this.total_water = this.$t('strings.total_ml') + total_ml + 'ml';
this.page1_title = this.$t('strings.my_drink_record');
this.show_hint = false;
} else {
this.total_water = this.$t('strings.no_drink_water_data');
this.drinkarray = [{
drink: ''
}];
this.show_hint = true;
this.page1_title = '';
}
},
cacheData() {
var that = this;
_system.default.writeText({
uri: 'internal://cache/water.txt',
text: that.receive_data,
append: false,
encoding: 'UTF-8',
success: function () {},
fail: function (data, code) {
console.log('alarm fail, message: ' + data + ', code: ' + code);
}
});
},
getNowDate() {
var date = new Date();
var seperator1 = '-';
var month = date.getMonth() + 1;
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = '0' + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = '0' + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
return currentdate;
}
};
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!./src/pages/detail/detail.css?uxType=page":
/*!*************************************************************************************************************************************!*\
!*** ./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!./src/pages/detail/detail.css?uxType=page ***!
\*************************************************************************************************************************************/
/***/ ((module) => {
module.exports = [
[
[
[
0,
"container"
]
],
{
"display": "flex",
"justifyContent": "center",
"alignItems": "center",
"left": "0px",
"top": "0px",
"width": "454px",
"height": "454px"
}
],
[
[
[
0,
"progress"
]
],
{
"strokeWidth": "20px",
"backgroundColor": "#262626",
"color": "#007Dff",
"radius": "227px",
"startAngle": "240deg",
"totalAngle": "240deg",
"centerX": "227px",
"centerY": "227px",
"width": "454px",
"height": "454px",
"borderRadius": "10px"
}
],
[
[
[
0,
"page1radiuscontainer"
]
],
{
"display": "flex",
"justifyContent": "center",
"alignItems": "center",
"flexDirection": "column",
"width": "454px",
"height": "380px"
}
],
[
[
[
0,
"pagesubtitle"
]
],
{
"fontSize": "30px",
"textAlign": "center",
"width": "300px",
"height": "60px",
"color": "#45A5FF"
}
],
[
[
[
0,
"page2title"
]
],
{
"fontSize": "30px",
"marginTop": "30px",
"textAlign": "center",
"width": "200px",
"height": "50px"
}
],
[
[
[
0,
"listitem"
]
],
{
"fontSize": "30px",
"textAlign": "center",
"width": "300px",
"height": "50px"
}
]
]
/***/ }),
/***/ "./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/detail/detail.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/detail/detail.hml?uxType=page& ***!
\****************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = function (vm) {
const _vm_ = vm || this
return aiot.__ce__("stack", {
"classList": [
"container"
]
}, [
aiot.__ce__("progress", {
"type": "arc",
"percent": function () {return _vm_.water_progress},
"classList": [
"progress"
],
"style": {
"position": "absolute"
}
}),
aiot.__ce__("div", {
"style": {
"width": "454px",
"height": "454px",
"flexDirection": "column",
"position": "absolute"
}
}, [
aiot.__ce__("div", {
"classList": [
"page1radiuscontainer"
]
}, [
aiot.__ce__("text", {
"classList": [
"page2title"
],
"value": function () {return _vm_.page1_title}
}),
aiot.__ce__("text", {
"classList": [
"pagesubtitle"
],
"value": function () {return _vm_.total_water}
}),
aiot.__ce__("stack", {
"style": {
"width": "300px",
"height": "200px",
"justifyContent": "center",
"alignItems": "center"
}
}, [
aiot.__ce__("list", {
"style": {
"flexDirection": "column",
"width": "300px",
"height": "200px",
"position": "absolute"
}
}, [
aiot.__cf__({
exp: function () {return _vm_.drinkarray}
},
function ($idx, $item) {
return aiot.__ce__("list-item", {
"classList": [
"listitem"
]
}, [
aiot.__ce__("marquee", {
"scrollamount": "100",
"style": {
"fontSize": "30px",
"width": "300px",
"height": "50px",
"textAlign": "center"
},
"value": function () {return $item.drink}
})
])})
]),
aiot.__ci__({
shown: function () {return _vm_.show_hint}
},
function () {
return aiot.__ce__("image", {
"src": function () {return _vm_.$t('files.no_drink_water_data')},
"style": {
"width": "300px",
"height": "200px",
"position": "absolute"
}
})})
])
]),
aiot.__ce__("div", {
"style": {
"width": "454px",
"height": "62px",
"flexDirection": "column",
"justifyContent": "center",
"alignItems": "center"
}
}, [
aiot.__ce__("image", {
"src": function () {return _vm_.$t('files.goback_to_main2')},
"style": {
"width": "182px",
"height": "62px"
},
"events": {
"click": function (evt) {_vm_.backToMain(evt)}
}
})
])
])
])
}
/***/ }),
/***/ "./src/pages/detail/detail.hml?uxType=page":
/*!*************************************************!*\
!*** ./src/pages/detail/detail.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!./detail.css?uxType=page */ "./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/style-loader.js?index=0&type=style!./src/pages/detail/detail.css?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/hx/work/project/third-app/vela-drinkwater&cacheDirectory&plugins[]=/home/hx/work/project/third-app/vela-drinkwater/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/hx/work/project/third-app/vela-drinkwater/node_modules/@aiot-toolkit/packager/babel.config.js!../../../node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./detail.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/hx/work/project/third-app/vela-drinkwater&cacheDirectory&plugins[]=/home/hx/work/project/third-app/vela-drinkwater/node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/babel-plugin-jsx.js&comments=false&configFile=/home/hx/work/project/third-app/vela-drinkwater/node_modules/@aiot-toolkit/packager/babel.config.js!./node_modules/@aiot-toolkit/dsl-xvm/lib/loaders/access-loader.js!./src/pages/detail/detail.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!./detail.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/detail/detail.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;
/***/ })
/******/ });
/************************************************************************/
/******/ // 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/detail/detail.hml?uxType=page");
/******/
/******/ })()
;
};
return createPageHandler();
};