ChooseScenario.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. "use strict";
  2. (wx["webpackJsonp"] = wx["webpackJsonp"] || []).push([["pages/ChooseScenario"],{
  3. /***/ "./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/ChooseScenario.tsx":
  4. /*!***********************************************************************************************************!*\
  5. !*** ./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/ChooseScenario.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_2__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  12. /* harmony import */ var _features_trackTimeDuration_components_ChooseScenario__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @features/trackTimeDuration/components/ChooseScenario */ "./src/features/trackTimeDuration/components/ChooseScenario.tsx");
  13. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  14. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__);
  15. function Page() {
  16. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.View, {
  17. className: "container",
  18. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_features_trackTimeDuration_components_ChooseScenario__WEBPACK_IMPORTED_MODULE_0__["default"], {})
  19. });
  20. }
  21. /***/ }),
  22. /***/ "./src/components/Footer.tsx":
  23. /*!***********************************!*\
  24. !*** ./src/components/Footer.tsx ***!
  25. \***********************************/
  26. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  27. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  28. /* harmony export */ "default": function() { return /* binding */ Component; }
  29. /* harmony export */ });
  30. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  31. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  32. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
  33. function Component(props) {
  34. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_1__.View, {
  35. className: "footer1",
  36. children: props.child
  37. });
  38. }
  39. /***/ }),
  40. /***/ "./src/features/trackTimeDuration/components/ChooseScenario.tsx":
  41. /*!**********************************************************************!*\
  42. !*** ./src/features/trackTimeDuration/components/ChooseScenario.tsx ***!
  43. \**********************************************************************/
  44. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  45. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  46. /* harmony export */ "default": function() { return /* binding */ Component; }
  47. /* harmony export */ });
  48. /* harmony import */ var _Users_Work_hola_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */ "./node_modules/@babel/runtime/helpers/esm/objectSpread2.js");
  49. /* harmony import */ var _Users_Work_hola_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js");
  50. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  51. /* harmony import */ var _components_Buttons__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @components/Buttons */ "./src/components/Buttons.tsx");
  52. /* harmony import */ var _components_Texts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @components/Texts */ "./src/components/Texts.tsx");
  53. /* harmony import */ var _components_Rings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @components/Rings */ "./src/components/Rings.weapp.tsx");
  54. /* harmony import */ var _components_Footer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @components/Footer */ "./src/components/Footer.tsx");
  55. /* harmony import */ var _components_SingleSelect__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../components/SingleSelect */ "./src/components/SingleSelect.tsx");
  56. /* harmony import */ var _utils_types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @utils/types */ "./src/utils/types.ts");
  57. /* harmony import */ var react_i18next__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react-i18next */ "webpack/container/remote/react-i18next");
  58. /* harmony import */ var react_i18next__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_i18next__WEBPACK_IMPORTED_MODULE_6__);
  59. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react */ "webpack/container/remote/react");
  60. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_7__);
  61. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro");
  62. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_8__);
  63. /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! react-redux */ "webpack/container/remote/react-redux");
  64. /* harmony import */ var react_redux__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(react_redux__WEBPACK_IMPORTED_MODULE_9__);
  65. /* harmony import */ var _store_scenario__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/store/scenario */ "./src/store/scenario.tsx");
  66. /* harmony import */ var _services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @/services/trackTimeDuration */ "./src/services/trackTimeDuration.tsx");
  67. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  68. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__);
  69. function Component() {
  70. var _useTranslation = (0,react_i18next__WEBPACK_IMPORTED_MODULE_6__.useTranslation)(),
  71. t = _useTranslation.t;
  72. var dispatch = (0,react_redux__WEBPACK_IMPORTED_MODULE_9__.useDispatch)();
  73. var _useState = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)(0),
  74. _useState2 = (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_13__["default"])(_useState, 2),
  75. selIndex = _useState2[0],
  76. setSelIndex = _useState2[1];
  77. var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_7__.useState)([]),
  78. _useState4 = (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_13__["default"])(_useState3, 2),
  79. scenarios = _useState4[0],
  80. setScenarios = _useState4[1];
  81. var selScenario = (0,react_redux__WEBPACK_IMPORTED_MODULE_9__.useSelector)(function (state) {
  82. return state.scenario;
  83. });
  84. (0,_tarojs_taro__WEBPACK_IMPORTED_MODULE_8__.useReady)(function () {
  85. console.log(selScenario);
  86. if (selScenario) {
  87. if (selScenario.name == 'FAST_SLEEP') {
  88. setSelIndex(2);
  89. } else if (selScenario.name == 'SLEEP') {
  90. setSelIndex(1);
  91. } else {
  92. setSelIndex(0);
  93. }
  94. }
  95. (0,_services_trackTimeDuration__WEBPACK_IMPORTED_MODULE_11__.getPlans)().then(function (res) {
  96. var data = res;
  97. setScenarios(data.scenarios);
  98. });
  99. });
  100. function next() {
  101. console.log(scenarios);
  102. // var scenario = scenarios[selIndex];
  103. // setScenario(scenario)
  104. _tarojs_taro__WEBPACK_IMPORTED_MODULE_8___default().navigateTo({
  105. url: '/pages/SetSchedule'
  106. });
  107. }
  108. function footerContent() {
  109. var style = {};
  110. switch (selIndex) {
  111. case 0:
  112. style = {
  113. backgroundColor: '#AAFF00'
  114. };
  115. break;
  116. case 1:
  117. style = {
  118. backgroundColor: '#00FFFF'
  119. };
  120. break;
  121. case 2:
  122. style = {
  123. background: 'linear-gradient(to right, #AAFF00, #00FFFF)'
  124. };
  125. break;
  126. }
  127. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  128. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Buttons__WEBPACK_IMPORTED_MODULE_0__["default"], {
  129. title: "Next",
  130. onClick: next,
  131. style: (0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_15__["default"])((0,_Users_Work_hola_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_15__["default"])({}, style), {}, {
  132. width: 320
  133. })
  134. })
  135. });
  136. }
  137. function items() {
  138. var array = [];
  139. array.push( /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  140. className: "item_row",
  141. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Rings__WEBPACK_IMPORTED_MODULE_2__["default"], {
  142. radius: 33,
  143. strokeWidth: 8,
  144. color: "#AAFF00",
  145. canvasId: "0"
  146. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  147. className: "item_txt_bg",
  148. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.Text, {
  149. className: "item_txt",
  150. style: {
  151. color: '#AAFF00'
  152. },
  153. children: t('page.choose_scenario.fast')
  154. })
  155. })]
  156. }));
  157. array.push( /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  158. className: "item_row",
  159. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Rings__WEBPACK_IMPORTED_MODULE_2__["default"], {
  160. radius: 33,
  161. strokeWidth: 8,
  162. color: "#00FFFF",
  163. canvasId: "1"
  164. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  165. className: "item_txt_bg",
  166. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.Text, {
  167. className: "item_txt",
  168. style: {
  169. color: '#00FFFF'
  170. },
  171. children: t('page.choose_scenario.sleep')
  172. })
  173. })]
  174. }));
  175. array.push( /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  176. className: "item_row",
  177. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  178. style: {
  179. position: 'relative',
  180. zIndex: 1
  181. },
  182. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Rings__WEBPACK_IMPORTED_MODULE_2__["default"], {
  183. radius: 33,
  184. strokeWidth: 8,
  185. color: "#AAFF00",
  186. canvasId: "3"
  187. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  188. style: {
  189. display: 'flex',
  190. position: 'absolute',
  191. left: 0,
  192. right: 0,
  193. top: 0,
  194. bottom: 0,
  195. alignItems: 'center',
  196. justifyContent: 'center'
  197. },
  198. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Rings__WEBPACK_IMPORTED_MODULE_2__["default"], {
  199. radius: 23,
  200. strokeWidth: 6,
  201. color: "#00FFFF",
  202. canvasId: "4"
  203. })
  204. })]
  205. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  206. className: "item_txt_bg",
  207. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.Text, {
  208. className: "item_txt",
  209. style: {
  210. color: '#00FFFF'
  211. },
  212. children: t('page.choose_scenario.fast_sleep')
  213. })
  214. })]
  215. }));
  216. return array;
  217. }
  218. function handleItemSelect(index) {
  219. setSelIndex(index);
  220. dispatch((0,_store_scenario__WEBPACK_IMPORTED_MODULE_10__.setScenario)(scenarios[index]));
  221. // dispatch(setScenarioName(scenarios[index].scenario) as any)
  222. }
  223. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  224. className: "container",
  225. children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_1__["default"], {
  226. text: t('page.choose_scenario.title'),
  227. type: _utils_types__WEBPACK_IMPORTED_MODULE_5__.TextType.primary
  228. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Texts__WEBPACK_IMPORTED_MODULE_1__["default"], {
  229. text: t('page.choose_scenario.sub_title'),
  230. type: _utils_types__WEBPACK_IMPORTED_MODULE_5__.TextType.secondary
  231. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  232. style: {
  233. height: 20
  234. }
  235. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_14__.View, {
  236. style: {
  237. position: 'relative',
  238. zIndex: 1
  239. },
  240. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_SingleSelect__WEBPACK_IMPORTED_MODULE_4__["default"], {
  241. items: items(),
  242. itemSelect: handleItemSelect,
  243. selIndex: selIndex
  244. })
  245. }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_12__.jsx)(_components_Footer__WEBPACK_IMPORTED_MODULE_3__["default"], {
  246. child: footerContent()
  247. })]
  248. });
  249. }
  250. /***/ }),
  251. /***/ "./src/pages/ChooseScenario.tsx":
  252. /*!**************************************!*\
  253. !*** ./src/pages/ChooseScenario.tsx ***!
  254. \**************************************/
  255. /***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
  256. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/runtime */ "webpack/container/remote/@tarojs/runtime");
  257. /* harmony import */ var _tarojs_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__);
  258. /* harmony import */ var _node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_ChooseScenario_tsx__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./ChooseScenario.tsx */ "./node_modules/babel-loader/lib/index.js??ruleSet[1].rules[5].use[0]!./src/pages/ChooseScenario.tsx");
  259. var config = {};
  260. var inst = Page((0,_tarojs_runtime__WEBPACK_IMPORTED_MODULE_0__.createPageConfig)(_node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_ChooseScenario_tsx__WEBPACK_IMPORTED_MODULE_1__["default"], 'pages/ChooseScenario', {root:{cn:[]}}, config || {}))
  261. /* unused harmony default export */ var __WEBPACK_DEFAULT_EXPORT__ = (_node_modules_babel_loader_lib_index_js_ruleSet_1_rules_5_use_0_ChooseScenario_tsx__WEBPACK_IMPORTED_MODULE_1__["default"]);
  262. /***/ })
  263. },
  264. /******/ function(__webpack_require__) { // webpackRuntimeModules
  265. /******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
  266. /******/ __webpack_require__.O(0, ["taro","vendors","common"], function() { return __webpack_exec__("./src/pages/ChooseScenario.tsx"); });
  267. /******/ var __webpack_exports__ = __webpack_require__.O();
  268. /******/ }
  269. ]);
  270. //# sourceMappingURL=ChooseScenario.js.map