@aiot-toolkit/velasim
Version:
vela for sim
591 lines (536 loc) • 19.5 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/course_box/course_library/course_library.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_library/course_library.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 _system2 = _interopRequireDefault($app_require$("@app-module/system.interconnect"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
protected: {
courseLibraryFilePath: "internal://app/courseLibrary.txt",
courseLibraryChildFilePath: "internal://app/courseLibraryChild.txt",
introduceFilePath: "internal://app/courseIntroduce.txt",
instance: {},
courseLibrary: [],
freeCourseLibrary: [{
name: "有氧类",
introduce: "结合音乐节奏、在单车的踏频中即可完成较高强度的有氧训练,不仅可以消耗能量达到减脂目的,同时还能够增强心肺功能。",
id: -1,
index: 0,
burying: 500
}, {
name: "舞蹈类",
introduce: "结合健身操、搏击、踏板或者徒手力量等不同元素的有氧运动,通过节奏鲜明的音乐和较有趣味性的动作,提高心肺功能,加速燃脂、塑形或者增强运动表现。",
id: -2,
index: 1,
burying: 500
}, {
name: "单车类",
introduce: "注重身体的平衡及静态体式的耐力,可以强化深层肌肉、提高柔韧性,并且增强脊椎稳定性,并且给你更好的体态。",
id: -3,
index: 2,
burying: 500
}, {
name: "身心类",
introduce: "将各种类型的音乐与不同的舞蹈风格组合成简单易学的动作步伐,在舞动中释放压力,感受运动的乐趣、提高身体的协调性,并且达到燃脂的效果。",
id: -4,
index: 3,
burying: 500
}, {
name: "武术类",
introduce: "通过学习不同的武术风格及动作技术,强身健体、消耗热量、提高身体灵活性及协调性。",
id: -5,
index: 4,
burying: 500
}],
isSendMessageToApp: false
},
goBack(SwipeEvent) {
if (SwipeEvent.direction == "right") {
_system.default.replace({
uri: "pages/home"
});
}
},
clickCourseLibraryItem(index) {
_readAndWriteFiled.default.writeFile(this.courseLibraryChildFilePath, this.courseLibrary[index]);
_system.default.push({
uri: "pages/course_box/course_list",
params: {
userId: "-2"
}
});
},
clickFreeItem: function (index) {
let introduceData = {
introduce: this.freeCourseLibrary[index].introduce,
name: this.freeCourseLibrary[index].name
};
_readAndWriteFiled.default.writeFile(this.introduceFilePath, introduceData);
let params = {
userId: "-2",
routerName: "courseLibrary",
courseId: this.freeCourseLibrary[index].id.toString(),
burying: this.freeCourseLibrary[index].burying.toString()
};
_system.default.push({
uri: "pages/course_box/course_start",
params: params
});
},
setMessageToApp() {
let that = this;
if (that.isSendMessageToApp == true) {
return;
}
that.isSendMessageToApp = true;
let newData = {
type: 2,
data: []
};
that.instance.send({
data: {
data: JSON.stringify(newData)
},
success: () => {},
fail: data => {}
});
},
onInit() {
let that = this;
this.instance = _system2.default.instance();
this.setMessageToApp();
this.instance.onmessage = data => {
var courseData = JSON.parse(data.data);
if (courseData.status == 1 && courseData.data.length != 0) {
courseData.data.forEach((item, index) => {
item["index"] = index;
});
that.courseLibrary = courseData.data;
_readAndWriteFiled.default.writeFile(that.courseLibraryFilePath, that.courseLibrary);
}
};
},
onDestroy() {
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/course_box/course_library/course_library.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_library/course_library.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,
"listUl"
]
],
{
"width": "464px",
"height": "464px"
}
],
[
[
[
0,
"listLi"
]
],
{
"width": "464px",
"height": "110px",
"flexDirection": "column",
"alignItems": "center"
}
],
[
[
[
0,
"courseItem"
]
],
{
"width": "374px",
"height": "100px",
"borderRadius": "12px",
"backgroundColor": "#282828",
"marginTop": "10px",
"flexDirection": "row",
"alignItems": "center"
}
],
[
[
[
0,
"courseItemName"
]
],
{
"width": "314px",
"height": "40px",
"marginLeft": "15px",
"fontSize": "34px"
}
],
[
[
[
0,
"listLiTitle"
]
],
{
"width": "464px",
"height": "82px",
"flexDirection": "column",
"alignItems": "center"
}
],
[
[
[
0,
"courseTitle"
]
],
{
"width": "374px",
"height": "72px",
"alignItems": "center",
"justifyContent": "center",
"paddingTop": "10px"
}
],
[
[
[
0,
"title"
]
],
{
"color": "#C0191F",
"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/course_box/course_library/course_library.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_library/course_library.hml?uxType=page& ***!
\*******************************************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = function (vm) {
const _vm_ = vm || this
return aiot.__ce__("div", {
"classList": [
"container"
]
}, [
aiot.__ce__("list", {
"classList": [
"listUl"
],
"events": {
"swipe": function (evt) {_vm_.goBack(evt)}
}
}, [
aiot.__ci__({
shown: function () {return _vm_.courseLibrary.length!=0}
},
function () {
return aiot.__ce__("list-item", {
"classList": [
"listLiTitle"
]
}, [
aiot.__ce__("div", {
"classList": [
"courseTitle"
]
}, [
aiot.__ce__("text", {
"classList": [
"title"
],
"value": "爱动原创课程"
})
])
])}),
aiot.__cf__({
exp: function () {return _vm_.courseLibrary}
},
function ($idx, $item) {
return aiot.__ce__("list-item", {
"classList": [
"listLi"
],
"events": {
"click": function (evt) { return _vm_.clickCourseLibraryItem($item.index,evt)}
}
}, [
aiot.__ce__("div", {
"classList": [
"courseItem"
]
}, [
aiot.__ce__("text", {
"classList": [
"courseItemName"
],
"value": function () {return $item.name}
})
])
])}),
aiot.__ce__("list-item", {
"classList": [
"listLiTitle"
]
}, [
aiot.__ce__("div", {
"classList": [
"courseTitle"
]
}, [
aiot.__ce__("text", {
"classList": [
"title"
],
"value": "免费课"
})
])
]),
aiot.__cf__({
exp: function () {return _vm_.freeCourseLibrary}
},
function ($idx, $item) {
return aiot.__ce__("list-item", {
"classList": [
"listLi"
],
"events": {
"click": function (evt) { return _vm_.clickFreeItem($item.index,evt)}
}
}, [
aiot.__ce__("div", {
"classList": [
"courseItem"
]
}, [
aiot.__ce__("text", {
"classList": [
"courseItemName"
],
"value": function () {return $item.name}
})
])
])}),
aiot.__ce__("list-item", {
"classList": [
"listLi"
]
})
])
])
}
/***/ }),
/***/ "./src/pages/course_box/course_library/course_library.hml?uxType=page":
/*!****************************************************************************!*\
!*** ./src/pages/course_box/course_library/course_library.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_library.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_library/course_library.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_library.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_library/course_library.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_library.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_library/course_library.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
};
/***/ })
/******/ });
/************************************************************************/
/******/ // 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_library/course_library.hml?uxType=page");
/******/
/******/ })()
;
};
return createPageHandler();
};