common.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. "use strict";
  2. (wx["webpackJsonp"] = wx["webpackJsonp"] || []).push([["common"],{
  3. /***/ "./src/components/Buttons.tsx":
  4. /*!************************************!*\
  5. !*** ./src/components/Buttons.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 */ Buttons; }
  10. /* harmony export */ });
  11. /* harmony import */ var _Users_Work_taro_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js */ "./node_modules/@babel/runtime/helpers/esm/objectSpread2.js");
  12. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  13. /* harmony import */ var _utils_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/types */ "./src/utils/types.ts");
  14. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  15. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__);
  16. function Buttons(props) {
  17. var myStyle = props.status == _utils_types__WEBPACK_IMPORTED_MODULE_0__.ComponentStatus.disable ? {
  18. opacity: 0.4
  19. } : {};
  20. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.View, {
  21. style: (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3__["default"])({}, myStyle),
  22. children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Button, {
  23. className: props.type == _utils_types__WEBPACK_IMPORTED_MODULE_0__.ButtonType.outline ? 'outline_btn' : 'btn',
  24. style: (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_objectSpread2_js__WEBPACK_IMPORTED_MODULE_3__["default"])({}, props.style),
  25. onClick: props.onClick,
  26. children: props.title
  27. })
  28. });
  29. }
  30. /***/ }),
  31. /***/ "./src/components/Rings.weapp.tsx":
  32. /*!****************************************!*\
  33. !*** ./src/components/Rings.weapp.tsx ***!
  34. \****************************************/
  35. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  36. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  37. /* harmony export */ "default": function() { return /* binding */ Rings; }
  38. /* harmony export */ });
  39. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  40. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro");
  41. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__);
  42. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "webpack/container/remote/react");
  43. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  44. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  45. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__);
  46. function Rings(props) {
  47. var progress = 0.85;
  48. var r = props.radius || 80;
  49. var strokeWidth = props.strokeWidth || 10;
  50. var color = props.color || 'orange';
  51. var canvasRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
  52. var canvasId = props.canvasId ? 'canvas_' + props.canvasId : 'progress-canvas';
  53. var dpr = _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getSystemInfoSync().pixelRatio; // 获取设备的像素比
  54. var radius = r; // 圆形进度条的半径
  55. var lineWidth = strokeWidth; // 圆形进度条的线宽
  56. (0,_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__.useDidShow)(function () {
  57. // drawCircle()
  58. });
  59. (0,_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__.useReady)(function () {
  60. drawCircle();
  61. });
  62. function drawCircle() {
  63. var query = _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().createSelectorQuery();
  64. query.select(".".concat(canvasId)).fields({
  65. node: true,
  66. size: true
  67. });
  68. query.exec(function (res) {
  69. var _canvas = res[0].node;
  70. _canvas.width = res[0].width * dpr;
  71. _canvas.height = res[0].height * dpr;
  72. var ctx = _canvas.getContext('2d');
  73. // const ctx = Taro.createCanvasContext(canvasId);
  74. var center = radius + lineWidth / 2; // 圆心坐标
  75. // 设置画布尺寸
  76. ctx.scale(dpr, dpr);
  77. // 绘制背景圆
  78. ctx.beginPath();
  79. ctx.arc(center, center, radius, 0, 2 * Math.PI);
  80. ctx.lineWidth = lineWidth;
  81. ctx.strokeStyle = 'lightgray';
  82. ctx.lineCap = 'round'; // 设置为圆角
  83. ctx.stroke();
  84. // 绘制进度圆
  85. ctx.beginPath();
  86. ctx.arc(center, center, radius, -Math.PI / 2 + 1, 2 * Math.PI * progress - Math.PI / 2);
  87. ctx.lineWidth = lineWidth;
  88. ctx.strokeStyle = color;
  89. ctx.lineCap = 'round'; // 设置为圆角
  90. ctx.stroke();
  91. // ctx.draw();
  92. });
  93. }
  94. (0,react__WEBPACK_IMPORTED_MODULE_1__.useEffect)(function () {
  95. // const ctx = Taro.createCanvasContext(canvasId);
  96. // const center = radius + lineWidth / 2; // 圆心坐标
  97. // // 设置画布尺寸
  98. // ctx.scale(1 / dpr, 1 / dpr);
  99. // // 绘制背景圆
  100. // ctx.beginPath();
  101. // ctx.arc(center, center, radius, 0, 2 * Math.PI);
  102. // ctx.setLineWidth(lineWidth);
  103. // ctx.setStrokeStyle('lightgray');
  104. // ctx.setLineCap('round'); // 设置为圆角
  105. // ctx.stroke();
  106. // // 绘制进度圆
  107. // ctx.beginPath();
  108. // ctx.arc(center, center, radius, -Math.PI / 2 + 1, (2 * Math.PI * progress) - Math.PI / 2);
  109. // ctx.setLineWidth(lineWidth);
  110. // ctx.setStrokeStyle(color);
  111. // ctx.setLineCap('round'); // 设置为圆角
  112. // ctx.stroke();
  113. // ctx.draw();
  114. }, [progress]);
  115. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_3__.Canvas, {
  116. canvasId: canvasId,
  117. id: canvasId,
  118. className: canvasId,
  119. type: "2d",
  120. style: {
  121. width: radius * 2 + lineWidth,
  122. height: radius * 2 + lineWidth,
  123. zIndex: 0
  124. },
  125. ref: canvasRef
  126. });
  127. }
  128. /***/ }),
  129. /***/ "./src/components/SingleSelect.tsx":
  130. /*!*****************************************!*\
  131. !*** ./src/components/SingleSelect.tsx ***!
  132. \*****************************************/
  133. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  134. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  135. /* harmony export */ "default": function() { return /* binding */ Component; }
  136. /* harmony export */ });
  137. /* harmony import */ var _Users_Work_taro_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js */ "./node_modules/@babel/runtime/helpers/esm/slicedToArray.js");
  138. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  139. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/container/remote/react");
  140. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
  141. /* harmony import */ var _assets_svg_check_svg__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../assets/svg/check.svg */ "./src/assets/svg/check.svg");
  142. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  143. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__);
  144. function Component(props) {
  145. var _useState = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(-1),
  146. _useState2 = (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_3__["default"])(_useState, 2),
  147. selIndex = _useState2[0],
  148. setSelIndex = _useState2[1];
  149. function isString(variable) {
  150. return typeof variable === 'string';
  151. }
  152. function itemClick(index) {
  153. setSelIndex(index);
  154. if (props.itemSelect) {
  155. props.itemSelect(index);
  156. }
  157. }
  158. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.View, {
  159. children: props.items.map(function (item, index) {
  160. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsxs)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.View, {
  161. className: selIndex == index ? 'item item_select' : 'item',
  162. onClick: function onClick() {
  163. return itemClick(index);
  164. },
  165. children: [isString(item) ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.Text, {
  166. style: {
  167. color: '#fff'
  168. },
  169. children: item
  170. }) : item, selIndex == index ? /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_4__.Image, {
  171. style: "width:12px;height:12px;",
  172. src: _assets_svg_check_svg__WEBPACK_IMPORTED_MODULE_1__
  173. }) : null]
  174. }, index);
  175. })
  176. });
  177. }
  178. /***/ }),
  179. /***/ "./src/components/Texts.tsx":
  180. /*!**********************************!*\
  181. !*** ./src/components/Texts.tsx ***!
  182. \**********************************/
  183. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  184. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  185. /* harmony export */ "default": function() { return /* binding */ Component; }
  186. /* harmony export */ });
  187. /* harmony import */ var _tarojs_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tarojs/components */ "./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js");
  188. /* harmony import */ var _utils_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/types */ "./src/utils/types.ts");
  189. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/container/remote/react/jsx-runtime");
  190. /* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__);
  191. function Component(props) {
  192. function render() {
  193. switch (props.type) {
  194. case _utils_types__WEBPACK_IMPORTED_MODULE_0__.TextType.primary:
  195. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, {
  196. className: "primary",
  197. children: props.text
  198. });
  199. case _utils_types__WEBPACK_IMPORTED_MODULE_0__.TextType.secondary:
  200. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, {
  201. className: "secondary",
  202. children: props.text
  203. });
  204. case _utils_types__WEBPACK_IMPORTED_MODULE_0__.TextType.big:
  205. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, {
  206. className: "big",
  207. children: props.text
  208. });
  209. default:
  210. return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(_tarojs_components__WEBPACK_IMPORTED_MODULE_2__.Text, {
  211. style: {
  212. color: '#fff'
  213. },
  214. children: props.text
  215. });
  216. }
  217. }
  218. return render();
  219. }
  220. /***/ }),
  221. /***/ "./src/services/http/api.js":
  222. /*!**********************************!*\
  223. !*** ./src/services/http/api.js ***!
  224. \**********************************/
  225. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  226. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  227. /* harmony export */ API_CLEAR_USER: function() { return /* binding */ API_CLEAR_USER; },
  228. /* harmony export */ API_FAST_PLANS: function() { return /* binding */ API_FAST_PLANS; },
  229. /* harmony export */ API_LOGIN: function() { return /* binding */ API_LOGIN; },
  230. /* harmony export */ API_LOGOUT: function() { return /* binding */ API_LOGOUT; },
  231. /* harmony export */ API_REGISTER: function() { return /* binding */ API_REGISTER; },
  232. /* harmony export */ API_USER_INFO: function() { return /* binding */ API_USER_INFO; }
  233. /* harmony export */ });
  234. /* unused harmony exports baseUrl, imgUrl, API_ADJUST_TIMES, API_WX_PUB_FOLLOWED, API_STATIC_RESOURCES, API_CLEAR_FAST, API_CLEAR_SLEEP, API_CLEAR_MIX, API_FAST_CHECKS, API_FAST_CHECK_ABANDONED, API_FAST_RECORDS, API_FAST_SCHEDULES, API_FAST_CALENDARS */
  235. var online = false;
  236. var baseUrl = online ? 'https://api.fast.liveplus.fun' : 'https://api.fast.dev.liveplus.fun';
  237. var imgUrl = online ? 'https://api.fast.liveplus.fun/static/image/' : 'https://api.fast.dev.liveplus.fun/static/image/';
  238. //common
  239. var API_ADJUST_TIMES = "".concat(baseUrl, "/api/fast/adjust-times");
  240. var API_WX_PUB_FOLLOWED = "".concat(baseUrl, "/api/fast/user/wx-pub-followed");
  241. var API_LOGIN = "".concat(baseUrl, "/api/user/oauth2/login");
  242. var API_REGISTER = "".concat(baseUrl, "/api/user/register");
  243. var API_LOGOUT = "".concat(baseUrl, "/api/user/logout");
  244. var API_CLEAR_USER = "".concat(baseUrl, "/api/clear/user");
  245. var API_STATIC_RESOURCES = "".concat(baseUrl, "/api/static-resource-urls");
  246. var API_USER_INFO = "".concat(baseUrl, "/api/user/info");
  247. var API_CLEAR_FAST = "".concat(baseUrl, "/api/clear/fasting");
  248. var API_CLEAR_SLEEP = "".concat(baseUrl, "/api/sleep/clear-my-data");
  249. var API_CLEAR_MIX = "".concat(baseUrl, "/api/clear-data/FAST_SLEEP");
  250. //track time duration
  251. var API_FAST_PLANS = "".concat(baseUrl, "/api/fast/plans");
  252. var API_FAST_CHECKS = "".concat(baseUrl, "/api/fast/checks");
  253. var API_FAST_CHECK_ABANDONED = "".concat(baseUrl, "/api/fast/check-abandoned");
  254. var API_FAST_RECORDS = "".concat(baseUrl, "/api/fast/records");
  255. var API_FAST_SCHEDULES = "".concat(baseUrl, "/api/fast/schedules");
  256. var API_FAST_CALENDARS = "".concat(baseUrl, "/api/fast/calendars/");
  257. //track something
  258. //journal
  259. /***/ }),
  260. /***/ "./src/services/http/request.ts":
  261. /*!**************************************!*\
  262. !*** ./src/services/http/request.ts ***!
  263. \**************************************/
  264. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  265. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  266. /* harmony export */ request: function() { return /* binding */ request; }
  267. /* harmony export */ });
  268. /* harmony import */ var _Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js */ "./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js");
  269. /* harmony import */ var _Users_Work_taro_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */ "./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js");
  270. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro");
  271. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_0__);
  272. ;
  273. function getStorage(_x) {
  274. return _getStorage.apply(this, arguments);
  275. }
  276. function _getStorage() {
  277. _getStorage = (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_1__["default"])( /*#__PURE__*/(0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_2__["default"])().mark(function _callee(key) {
  278. var res;
  279. return (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_2__["default"])().wrap(function _callee$(_context) {
  280. while (1) switch (_context.prev = _context.next) {
  281. case 0:
  282. _context.prev = 0;
  283. _context.next = 3;
  284. return _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().getStorage({
  285. key: key
  286. });
  287. case 3:
  288. res = _context.sent;
  289. return _context.abrupt("return", res.data);
  290. case 7:
  291. _context.prev = 7;
  292. _context.t0 = _context["catch"](0);
  293. return _context.abrupt("return", '');
  294. case 10:
  295. case "end":
  296. return _context.stop();
  297. }
  298. }, _callee, null, [[0, 7]]);
  299. }));
  300. return _getStorage.apply(this, arguments);
  301. }
  302. function request(_x2) {
  303. return _request.apply(this, arguments);
  304. }
  305. // import axios from 'axios';
  306. // const kTimeout = 6000;
  307. // const kRetry = 3;
  308. // const axiosInstance = axios.create({
  309. // timeout: kTimeout,
  310. // });
  311. // axios.interceptors.request.use(
  312. // function (config) {
  313. // var split = new Date().toString().split(' ');
  314. // var timeZoneFormatted = split[split.length - 2];
  315. // config.headers['X-Time-Zone'] = timeZoneFormatted;
  316. // // config.headers['channel'] = 'mini program'
  317. // return config
  318. // },
  319. // function (error) {
  320. // return Promise.reject(error)
  321. // }
  322. // )
  323. // axiosInstance.interceptors.response.use(
  324. // response => response,
  325. // error => Promise.reject(error)
  326. // );
  327. // export const request = async (url, method = 'post', data = {}, options = {}) => {
  328. // const { timeout = kTimeout, retry = kRetry } = options;
  329. // axiosInstance.defaults.timeout = timeout;
  330. // let retries = 0;
  331. // while (retries < retry) {
  332. // try {
  333. // const response = await axiosInstance({
  334. // url,
  335. // method,
  336. // data,
  337. // });
  338. // return response.data;
  339. // } catch (error) {
  340. // console.log(error)
  341. // if (axios.isCancel(error)) {
  342. // // 请求被取消
  343. // console.log('Request canceled');
  344. // break;
  345. // }
  346. // if (retries === retry - 1) {
  347. // // 达到最大重试次数
  348. // throw error;
  349. // }
  350. // console.log('Request failed. Retrying...');
  351. // retries++;
  352. // }
  353. // }
  354. // };
  355. function _request() {
  356. _request = (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_1__["default"])( /*#__PURE__*/(0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_2__["default"])().mark(function _callee2(param) {
  357. var url, method, data, header, token, split, timeZoneFormatted;
  358. return (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_2__["default"])().wrap(function _callee2$(_context2) {
  359. while (1) switch (_context2.prev = _context2.next) {
  360. case 0:
  361. url = param.url, method = param.method, data = param.data;
  362. header = {};
  363. token = __webpack_require__.g.token ? __webpack_require__.g.token : ''; //await getStorage('token')
  364. split = new Date().toString().split(' ');
  365. timeZoneFormatted = split[split.length - 2];
  366. header['X-Time-Zone'] = timeZoneFormatted; //new Date().getTimezoneOffset() / 60
  367. if (token.length > 0) {
  368. header['Authorization'] = "Bearer ".concat(token);
  369. }
  370. //X-Language:语言,X-Device-Id:设备唯一码,X-Platform:小程序/android/ios,X-Location:地区,X-Device:登录设备
  371. // header['X-Language'] = ''
  372. // header['X-Device-Id'] = ''
  373. // header['X-Platform'] = ''
  374. // header['X-Location'] = ''
  375. // header['X-Device'] = ''
  376. // header['X-Time-Zone-Id'] = Intl.DateTimeFormat().resolvedOptions().timeZone
  377. // header['Authorization'] = 'Bearer ' + wx.getStorageSync('token');
  378. // header['Authorization'] = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJhY2NvdW50Iiwic3ViIjoiMmQ5OWNlYzI0ZDFlMzE0Y2U1MjhlODM4MWMzYzk0MzgiLCJpc3MiOiJDT0RFUEFBUy5DT00iLCJuaWNrbmFtZSI6IueOi-a4nSIsInR5cCI6IkJlYXJlciIsInNlc3Npb25fc3RhdGUiOiIyN2RjNmU4ZDdjMWU1MTVmNDQwNzVjZTFlODk2ZmUzNCIsImV4cCI6MTcxNjY0Mzk5MSwiaWF0IjoxNjg1MDIxNTkxfQ.fmFj0OVNRzjLkdebSyGJyk8EScPJFpDiz0L25W35zoA'
  379. return _context2.abrupt("return", new Promise(function (resolve, reject) {
  380. _tarojs_taro__WEBPACK_IMPORTED_MODULE_0___default().request({
  381. url: url,
  382. method: method,
  383. header: header,
  384. data: data || {},
  385. success: function success(response) {
  386. var statusCode = response.statusCode,
  387. data = response.data;
  388. if (statusCode == 204) {
  389. resolve({});
  390. }
  391. if (statusCode != 200) {
  392. reject(data);
  393. }
  394. var _ref = response.data || {},
  395. error_code = _ref.error_code;
  396. if (error_code === 'NOT_LOGIN') {
  397. // new UserManager().logout();
  398. }
  399. var resp = response.data;
  400. resolve(resp);
  401. },
  402. fail: function fail(err) {
  403. if (err.errMsg == 'request:fail timeout') {
  404. // wx.showToast({
  405. // title: '请求超时',
  406. // icon: 'none',
  407. // });
  408. }
  409. reject(err);
  410. },
  411. complete: function complete() {}
  412. });
  413. }));
  414. case 8:
  415. case "end":
  416. return _context2.stop();
  417. }
  418. }, _callee2);
  419. }));
  420. return _request.apply(this, arguments);
  421. }
  422. /***/ }),
  423. /***/ "./src/store/user.tsx":
  424. /*!****************************!*\
  425. !*** ./src/store/user.tsx ***!
  426. \****************************/
  427. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  428. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  429. /* harmony export */ clear: function() { return /* binding */ clear; },
  430. /* harmony export */ logout: function() { return /* binding */ logout; },
  431. /* harmony export */ register: function() { return /* binding */ register; },
  432. /* harmony export */ wxLogin: function() { return /* binding */ wxLogin; }
  433. /* harmony export */ });
  434. /* unused harmony exports loginSuccess, registerSuccess, logoutSuccess, getInfoSuccess, updateSuccess, clearSuccess, login, getInfo, update */
  435. /* harmony import */ var _Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js */ "./node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js");
  436. /* harmony import */ var _Users_Work_taro_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */ "./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js");
  437. /* harmony import */ var _reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @reduxjs/toolkit */ "webpack/container/remote/@reduxjs/toolkit");
  438. /* harmony import */ var _reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__);
  439. /* harmony import */ var _services_http_request__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @services/http/request */ "./src/services/http/request.ts");
  440. /* harmony import */ var _services_http_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @services/http/api */ "./src/services/http/api.js");
  441. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @tarojs/taro */ "webpack/container/remote/@tarojs/taro");
  442. /* harmony import */ var _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_tarojs_taro__WEBPACK_IMPORTED_MODULE_3__);
  443. function getStorage(key) {
  444. return _tarojs_taro__WEBPACK_IMPORTED_MODULE_3___default().getStorage({
  445. key: key
  446. }).then(function (res) {
  447. return res.data;
  448. }).catch(function () {
  449. return '';
  450. });
  451. }
  452. var getUserDataFromLocalStorage = /*#__PURE__*/function () {
  453. var _ref = (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4__["default"])( /*#__PURE__*/(0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_5__["default"])().mark(function _callee() {
  454. var userData;
  455. return (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_5__["default"])().wrap(function _callee$(_context) {
  456. while (1) switch (_context.prev = _context.next) {
  457. case 0:
  458. _context.next = 2;
  459. return getStorage('userData');
  460. case 2:
  461. userData = _context.sent;
  462. if (!userData) {
  463. _context.next = 5;
  464. break;
  465. }
  466. return _context.abrupt("return", JSON.parse(userData));
  467. case 5:
  468. return _context.abrupt("return", {
  469. isLogin: false,
  470. nickname: null,
  471. avatar: null,
  472. token: null
  473. });
  474. case 6:
  475. case "end":
  476. return _context.stop();
  477. }
  478. }, _callee);
  479. }));
  480. return function getUserDataFromLocalStorage() {
  481. return _ref.apply(this, arguments);
  482. };
  483. }();
  484. // const initialState: UserState = await getUserDataFromLocalStorage();
  485. var initialState = {
  486. isLogin: false,
  487. nickname: null,
  488. avatar: null,
  489. token: null
  490. };
  491. var userSlice = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__.createSlice)({
  492. name: 'user',
  493. initialState: initialState,
  494. reducers: {
  495. loginSuccess: function loginSuccess(state, action) {
  496. var _action$payload = action.payload,
  497. nickname = _action$payload.nickname,
  498. avatar = _action$payload.avatar,
  499. token = _action$payload.token;
  500. state.nickname = nickname;
  501. state.avatar = avatar;
  502. state.token = token;
  503. state.isLogin = true;
  504. __webpack_require__.g.token = token;
  505. },
  506. registerSuccess: function registerSuccess(state, action) {
  507. var _action$payload2 = action.payload,
  508. nickname = _action$payload2.nickname,
  509. avatar = _action$payload2.avatar,
  510. token = _action$payload2.token;
  511. state.nickname = nickname;
  512. state.avatar = avatar;
  513. state.token = token;
  514. state.isLogin = true;
  515. __webpack_require__.g.token = token;
  516. },
  517. logoutSuccess: function logoutSuccess(state) {
  518. state.nickname = null;
  519. state.avatar = null;
  520. state.token = null;
  521. state.isLogin = false;
  522. __webpack_require__.g.token = '';
  523. },
  524. clearSuccess: function clearSuccess(state) {
  525. state.nickname = null;
  526. state.avatar = null;
  527. state.token = null;
  528. state.isLogin = false;
  529. __webpack_require__.g.token = '';
  530. },
  531. getInfoSuccess: function getInfoSuccess(state, action) {
  532. var _action$payload3 = action.payload,
  533. nickname = _action$payload3.nickname,
  534. avatar = _action$payload3.avatar,
  535. token = _action$payload3.token;
  536. state.nickname = nickname;
  537. state.avatar = avatar;
  538. state.token = token;
  539. state.isLogin = true;
  540. },
  541. updateSuccess: function updateSuccess(state, action) {
  542. var _action$payload4 = action.payload,
  543. nickname = _action$payload4.nickname,
  544. avatar = _action$payload4.avatar,
  545. token = _action$payload4.token;
  546. state.nickname = nickname;
  547. state.avatar = avatar;
  548. state.token = token;
  549. state.isLogin = true;
  550. }
  551. }
  552. });
  553. var _userSlice$actions = userSlice.actions,
  554. loginSuccess = _userSlice$actions.loginSuccess,
  555. registerSuccess = _userSlice$actions.registerSuccess,
  556. logoutSuccess = _userSlice$actions.logoutSuccess,
  557. getInfoSuccess = _userSlice$actions.getInfoSuccess,
  558. updateSuccess = _userSlice$actions.updateSuccess,
  559. clearSuccess = _userSlice$actions.clearSuccess;
  560. /* harmony default export */ __webpack_exports__["default"] = (userSlice.reducer);
  561. var login = function login(username, password) {
  562. return function (dispatch) {
  563. (0,_services_http_request__WEBPACK_IMPORTED_MODULE_1__.request)({
  564. url: _services_http_api__WEBPACK_IMPORTED_MODULE_2__.API_LOGIN,
  565. method: 'POST',
  566. data: {
  567. username: username,
  568. password: password
  569. }
  570. }).then(function (res) {
  571. dispatch(loginSuccess(res));
  572. });
  573. };
  574. };
  575. var wxLogin = (0,_reduxjs_toolkit__WEBPACK_IMPORTED_MODULE_0__.createAsyncThunk)('user/wxLogin', /*#__PURE__*/function () {
  576. var _ref3 = (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_4__["default"])( /*#__PURE__*/(0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_5__["default"])().mark(function _callee2(payload, _ref2) {
  577. var dispatch;
  578. return (0,_Users_Work_taro_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_5__["default"])().wrap(function _callee2$(_context2) {
  579. while (1) switch (_context2.prev = _context2.next) {
  580. case 0:
  581. dispatch = _ref2.dispatch;
  582. console.log(payload.code);
  583. (0,_services_http_request__WEBPACK_IMPORTED_MODULE_1__.request)({
  584. url: _services_http_api__WEBPACK_IMPORTED_MODULE_2__.API_LOGIN,
  585. method: 'POST',
  586. data: {
  587. code: payload.code,
  588. type: 'WX_MP',
  589. app_version: '1',
  590. client_version: '1',
  591. client_type: 'WX_MP',
  592. extra: {
  593. encryptedData: payload.encryptedData,
  594. iv: payload.iv
  595. }
  596. }
  597. }).then(function (res) {
  598. dispatch(loginSuccess(res));
  599. });
  600. case 3:
  601. case "end":
  602. return _context2.stop();
  603. }
  604. }, _callee2);
  605. }));
  606. return function (_x, _x2) {
  607. return _ref3.apply(this, arguments);
  608. };
  609. }());
  610. /*
  611. export const wxLogin = (code: string) => (dispatch: any) => {
  612. request({
  613. url: API_LOGIN, method: 'POST', data: { code,type:'WX_MP',app_version:'1',client_version:'1',client_type:'WXP_MP' }
  614. }).then(res => {
  615. console.log(res);
  616. dispatch(loginSuccess(res));
  617. })
  618. }*/
  619. var register = function register(name, email, password) {
  620. return function (dispatch) {
  621. (0,_services_http_request__WEBPACK_IMPORTED_MODULE_1__.request)({
  622. url: _services_http_api__WEBPACK_IMPORTED_MODULE_2__.API_REGISTER,
  623. method: 'POST',
  624. data: {
  625. client_type: 'IOS',
  626. username: name,
  627. email: email,
  628. password: password
  629. }
  630. }).then(function (res) {
  631. dispatch(registerSuccess(res));
  632. });
  633. };
  634. };
  635. var logout = function logout() {
  636. return function (dispatch) {
  637. (0,_services_http_request__WEBPACK_IMPORTED_MODULE_1__.request)({
  638. url: _services_http_api__WEBPACK_IMPORTED_MODULE_2__.API_LOGOUT,
  639. method: 'GET',
  640. data: {}
  641. }).then(function (res) {
  642. dispatch(logoutSuccess());
  643. });
  644. };
  645. };
  646. var clear = function clear() {
  647. return function (dispatch) {
  648. (0,_services_http_request__WEBPACK_IMPORTED_MODULE_1__.request)({
  649. url: _services_http_api__WEBPACK_IMPORTED_MODULE_2__.API_CLEAR_USER,
  650. method: 'POST',
  651. data: {}
  652. }).then(function (res) {
  653. dispatch(clearSuccess());
  654. });
  655. };
  656. };
  657. var getInfo = function getInfo() {
  658. return function (dispatch) {
  659. (0,_services_http_request__WEBPACK_IMPORTED_MODULE_1__.request)({
  660. url: _services_http_api__WEBPACK_IMPORTED_MODULE_2__.API_USER_INFO,
  661. method: 'GET',
  662. data: {}
  663. }).then(function (res) {
  664. dispatch(getInfoSuccess(res));
  665. });
  666. };
  667. };
  668. var update = function update() {
  669. return function (dispatch) {
  670. (0,_services_http_request__WEBPACK_IMPORTED_MODULE_1__.request)({
  671. url: _services_http_api__WEBPACK_IMPORTED_MODULE_2__.API_USER_INFO,
  672. method: 'POST',
  673. data: {}
  674. }).then(function (res) {
  675. dispatch(updateSuccess(res));
  676. });
  677. };
  678. };
  679. /***/ }),
  680. /***/ "./src/utils/types.ts":
  681. /*!****************************!*\
  682. !*** ./src/utils/types.ts ***!
  683. \****************************/
  684. /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
  685. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  686. /* harmony export */ ButtonType: function() { return /* binding */ ButtonType; },
  687. /* harmony export */ ComponentStatus: function() { return /* binding */ ComponentStatus; },
  688. /* harmony export */ TextType: function() { return /* binding */ TextType; }
  689. /* harmony export */ });
  690. /* unused harmony export ScenarioType */
  691. var ButtonType = /*#__PURE__*/function (ButtonType) {
  692. ButtonType["primary"] = "primary";
  693. ButtonType["outline"] = "outline";
  694. return ButtonType;
  695. }({});
  696. var TextType = /*#__PURE__*/function (TextType) {
  697. TextType["primary"] = "primary";
  698. TextType["secondary"] = "secondary";
  699. TextType["big"] = "big";
  700. return TextType;
  701. }({});
  702. var ComponentStatus = /*#__PURE__*/function (ComponentStatus) {
  703. ComponentStatus["enable"] = "enable";
  704. ComponentStatus["disable"] = "disable";
  705. return ComponentStatus;
  706. }({});
  707. var ScenarioType = /*#__PURE__*/function (ScenarioType) {
  708. ScenarioType["fast"] = "fast";
  709. ScenarioType["sleep"] = "sleep";
  710. ScenarioType["fastSleep"] = "fastSleep";
  711. return ScenarioType;
  712. }({});
  713. /***/ }),
  714. /***/ "./src/assets/svg/check.svg":
  715. /*!**********************************!*\
  716. !*** ./src/assets/svg/check.svg ***!
  717. \**********************************/
  718. /***/ (function(module) {
  719. module.exports = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiBmaWxsPSJub25lIiB2ZXJzaW9uPSIxLjEiIHdpZHRoPSIxOCIgaGVpZ2h0PSIxMyIgdmlld0JveD0iMCAwIDE4IDEzIj48Zz48cGF0aCBkPSJNMTcuNzA3MSwwLjI5Mjg5M0MxOC4wOTc2LDAuNjgzNDE3LDE4LjA5NzYsMS4zMTY1OCwxNy43MDcxLDEuNzA3MTFDMTcuNzA3MSwxLjcwNzExLDYuNzA3MTEsMTIuNzA3MSw2LjcwNzExLDEyLjcwNzFDNi4zMTY1OCwxMy4wOTc2LDUuNjgzNDIsMTMuMDk3Niw1LjI5Mjg5LDEyLjcwNzFDNS4yOTI4OSwxMi43MDcxLDAuMjkyODkzLDcuNzA3MTEsMC4yOTI4OTMsNy43MDcxMUMtMC4wOTc2MzExLDcuMzE2NTgsLTAuMDk3NjMxMSw2LjY4MzQyLDAuMjkyODkzLDYuMjkyODlDMC42ODM0MTcsNS45MDIzNywxLjMxNjU4LDUuOTAyMzcsMS43MDcxMSw2LjI5Mjg5QzEuNzA3MTEsNi4yOTI4OSw2LDEwLjU4NTgsNiwxMC41ODU4QzYsMTAuNTg1OCwxNi4yOTI5LDAuMjkyODkzLDE2LjI5MjksMC4yOTI4OTNDMTYuNjgzNCwtMC4wOTc2MzExLDE3LjMxNjYsLTAuMDk3NjMxMSwxNy43MDcxLDAuMjkyODkzQzE3LjcwNzEsMC4yOTI4OTMsMTcuNzA3MSwwLjI5Mjg5MywxNy43MDcxLDAuMjkyODkzWiIgZmlsbC1ydWxlPSJldmVub2RkIiBmaWxsPSIjQUFGRjAwIiBmaWxsLW9wYWNpdHk9IjEiLz48L2c+PC9zdmc+";
  720. /***/ })
  721. }]);
  722. //# sourceMappingURL=common.js.map