SetSchedule.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. "use strict";
  2. (wx["webpackJsonp"] = wx["webpackJsonp"] || []).push([["pages/SetSchedule"],{
  3. /***/ "./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/SetSchedule.tsx":
  4. /*!********************************************************************************************************!*\
  5. !*** ./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/SetSchedule.tsx ***!
  6. \********************************************************************************************************/
  7. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  8. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9. /* harmony export */ "default": function() { return /* binding */ Page; }
  10. /* harmony export */ });
  11. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  12. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro");
  13. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__);
  14. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/container/remote/react");
  15. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  16. /* harmony import */ var _features_trackTimeDuration_components_SetSchedule__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @features/trackTimeDuration/components/SetSchedule */ "./src/features/trackTimeDuration/components/SetSchedule.tsx");
  17. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  18. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__);
  19. function Page() {
  20. var router = (0,_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__.useRouter)();
  21. (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
  22. console.log(router.params);
  23. }, [router.params]);
  24. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.View, {
  25. className: "container",
  26. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_3__.jsx)(_features_trackTimeDuration_components_SetSchedule__WEBPACK_IMPORTED_MODULE_2__["default"], {
  27. scenario: JSON.parse(router.params.scenario)
  28. })
  29. });
  30. }
  31. /***/ }),
  32. /***/ "./src/features/trackTimeDuration/components/SetSchedule.tsx":
  33. /*!*******************************************************************!*\
  34. !*** ./src/features/trackTimeDuration/components/SetSchedule.tsx ***!
  35. \*******************************************************************/
  36. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  37. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  38. /* harmony export */ "default": function() { return /* binding */ Component; }
  39. /* harmony export */ });
  40. /* harmony import */ var _Users_Work_taro_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js");
  41. /* harmony import */ var _components_Buttons__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @/components/Buttons */ "./src/components/Buttons.tsx");
  42. /* harmony import */ var _services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @/services/trackTimeDuration */ "./src/services/trackTimeDuration.tsx");
  43. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  44. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro");
  45. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_2__);
  46. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react */ "webpack/container/remote/react");
  47. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_3__);
  48. /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react-redux */ "webpack/container/remote/react-redux");
  49. /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_redux__WEBPACK_IMPORTED_MODULE_4__);
  50. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  51. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__);
  52. // import { AtList, AtListItem } from 'taro-ui'
  53. function Component(props) {
  54. var scenario = (0,react_redux__WEBPACK_IMPORTED_MODULE_4__.useSelector)(function (state) {
  55. return state.scenario;
  56. });
  57. var scheduleObj;
  58. if (scenario.scenario == 'FAST') {
  59. scheduleObj = props.scenario.schedule.fast;
  60. } else if (scenario.scenario == 'SLEEP') {
  61. scheduleObj = props.scenario.schedule.sleep;
  62. } else {
  63. if (scenario.schedule) {
  64. scheduleObj = props.scenario.schedule.sleep;
  65. } else {
  66. scheduleObj = props.scenario.schedule.fast;
  67. }
  68. }
  69. var _useState = (0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(scheduleObj.start_time),
  70. _useState2 = (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_6__["default"])(_useState, 2),
  71. startTime = _useState2[0],
  72. setStartTime = _useState2[1];
  73. var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_3__.useState)(scheduleObj.end_time),
  74. _useState4 = (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_6__["default"])(_useState3, 2),
  75. endTime = _useState4[0],
  76. setEndTime = _useState4[1];
  77. function start() {
  78. if (scenario.scenario == 'FAST' || scenario.scenario == 'SLEEP') {
  79. (0,_services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_1__.setPlan)({
  80. scenario: scenario.scenario,
  81. schedule: scenario.scenario == 'FAST' ? {
  82. fast: {
  83. start_time: startTime,
  84. end_time: endTime
  85. }
  86. } : {
  87. sleep: {
  88. start_time: startTime,
  89. end_time: endTime
  90. }
  91. }
  92. }).then(function (res) {
  93. _tarojs_taro__WEBPACK_IMPORTED_MODULE_2___default().navigateBack({
  94. delta: 3
  95. });
  96. // console.log('success')
  97. });
  98. } else {}
  99. }
  100. function onStartTimeChange(e) {
  101. setStartTime(e.detail.value);
  102. }
  103. function onEndTimeChange(e) {
  104. setEndTime(e.detail.value);
  105. }
  106. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_7__.View, {
  107. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_7__.Text, {
  108. children: "hello world"
  109. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_7__.Picker, {
  110. mode: "time",
  111. value: startTime,
  112. onChange: onStartTimeChange,
  113. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_7__.Text, {
  114. children: ["\u5F00\u59CB\u65F6\u95F4", startTime]
  115. })
  116. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_7__.Picker, {
  117. mode: "time",
  118. value: endTime,
  119. onChange: onEndTimeChange,
  120. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_7__.Text, {
  121. children: ["\u7ED3\u675F\u65F6\u95F4", endTime]
  122. })
  123. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_0__["default"], {
  124. title: "Start",
  125. onClick: function onClick() {
  126. return start();
  127. }
  128. })]
  129. });
  130. }
  131. /***/ }),
  132. /***/ "./src/pages/SetSchedule.tsx":
  133. /*!***********************************!*\
  134. !*** ./src/pages/SetSchedule.tsx ***!
  135. \***********************************/
  136. /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
  137. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/runtime */ "webpack/container/remote/@tarojs/runtime");
  138. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__);
  139. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_SetSchedule_tsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./SetSchedule.tsx */ "./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/SetSchedule.tsx");
  140. var config = {};
  141. var inst = Page((0,_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__.createPageConfig)(_node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_SetSchedule_tsx__WEBPACK_IMPORTED_MODULE_1__["default"], 'pages/SetSchedule', {root:{cn:[]}}, config || {}))
  142. /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_SetSchedule_tsx__WEBPACK_IMPORTED_MODULE_1__["default"]);
  143. /***/ })
  144. },
  145. /******/ function(__webpack_require__) { // webpackRuntimeModules
  146. /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
  147. /******/ __webpack_require__.O(0, ["taro","vendors","common"], function() { return __webpack_exec__("./src/pages/SetSchedule.tsx"); });
  148. /******/ var __webpack_exports__ = __webpack_require__.O();
  149. /******/ }
  150. ]);
  151. //# sourceMappingURL=SetSchedule.js.map