UNPKG

@aliedu/app-self-check

Version:

应用自检模块

174 lines (153 loc) 5.69 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _regeneratorRuntime from "@babel/runtime/regenerator"; var initState = { conditionList: [], isNext: true, checkFinish: false }; export default { state: initState, reducers: { initDefaultState: function initDefaultState(prevState) { prevState.conditionList = []; prevState.isNext = true; prevState.checkFinish = false; }, setCheckFinish: function setCheckFinish(prevState, payload) { prevState.checkFinish = payload; }, setNext: function setNext(prevState, payload) { prevState.isNext = payload; }, checkData: function checkData(prevState, payLoad) { prevState.conditionList = [].concat(payLoad); } }, effects: function effects(dispatch) { return { startDetect: function startDetect(payLoad, stateData) { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() { var checkList, res, result, checkSuiteRes, i; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: checkList = []; _context.next = 3; return API.application.appSelfCheck.checkPreCheckStatus.request({ appCode: stateData.IndexModel.appCode }); case 3: res = _context.sent; if (res.success) { checkList = res.data; dispatch.StepTwoModel.checkData(checkList); } _context.next = 7; return API.application.app.detail.request({ appCode: stateData.IndexModel.appCode }); case 7: result = _context.sent; if (!result.success) { _context.next = 15; break; } _context.next = 11; return API.application.app.checkSuiteCallBack.request({}, { appCallBackUrl: result.data && result.data.appCallbackUrl, appCode: stateData.IndexModel.appCode, appDataSecret: result.data && result.data.appDataSecret, appToken: result.data && result.data.appToken }); case 11: checkSuiteRes = _context.sent; if (checkSuiteRes.success) { checkList.push({ name: '是否已设置免登SDK', pass: true }); } else { checkList.push({ name: '是否已设置免登SDK', pass: false }); } _context.next = 16; break; case 15: checkList.push({ name: '是否已设置免登SDK', pass: false }); case 16: dispatch.StepTwoModel.checkData(checkList); _context.t0 = _regeneratorRuntime.keys(checkList); case 18: if ((_context.t1 = _context.t0()).done) { _context.next = 25; break; } i = _context.t1.value; if (checkList[i].pass) { _context.next = 23; break; } dispatch.StepTwoModel.setNext(false); return _context.abrupt("break", 25); case 23: _context.next = 18; break; case 25: dispatch.StepTwoModel.setCheckFinish(true); dispatch.StepTwoModel.startNext(); case 27: case "end": return _context.stop(); } } }, _callee); }))(); }, startNext: function startNext(payLoad, stateData) { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() { return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: if (stateData.StepTwoModel.isNext) { dispatch.BtnOperaModel.changeNextStatu(); } case 1: case "end": return _context2.stop(); } } }, _callee2); }))(); }, preCheckSubmit: function preCheckSubmit(payLoad, stateData) { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() { var res; return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.next = 2; return API.application.appSelfCheck.preCheckSubmit.request({}, { appCode: stateData.IndexModel.appCode }); case 2: res = _context3.sent; return _context3.abrupt("return", res); case 4: case "end": return _context3.stop(); } } }, _callee3); }))(); } }; } };