UNPKG

qt-public-ui

Version:

新设计规范下业务组件库

53 lines 1.8 kB
import React, { useState } from 'react'; import { Modal } from '../index'; import './style'; var Survey = function Survey(_ref) { var prefix = _ref.prefix, surveyLink = _ref.surveyLink, img = _ref.img, _ref$title = _ref.title, title = _ref$title === void 0 ? '参与用户调研,赢取奖品' : _ref$title, _ref$okText = _ref.okText, okText = _ref$okText === void 0 ? '立即参与' : _ref$okText, _ref$cancelText = _ref.cancelText, cancelText = _ref$cancelText === void 0 ? '再想想' : _ref$cancelText, _ref$otherdependencie = _ref.otherdependencies, otherdependencies = _ref$otherdependencie === void 0 ? [] : _ref$otherdependencie; var calcInitShow = function calcInitShow() { var other = otherdependencies.every(function (key) { return localStorage.getItem(key); }); // 其他的均已经显示 return other && !localStorage.getItem(prefix + "-survey-uuid"); }; var _useState = useState(calcInitShow), isModalVisible = _useState[0], setIsModalVisible = _useState[1]; var handleOk = function handleOk() { setIsModalVisible(false); localStorage.setItem(prefix + "-survey-uuid", 'had'); window.open(surveyLink); }; var handleCancel = function handleCancel() { setIsModalVisible(false); localStorage.setItem(prefix + "-survey-uuid", 'had'); }; return /*#__PURE__*/React.createElement(Modal, { width: 620, className: "umui-survey-modal", title: title, visible: isModalVisible, okText: okText, cancelText: cancelText, onOk: handleOk, onCancel: handleCancel, maskClosable: false }, /*#__PURE__*/React.createElement("img", { style: { width: '100%' }, src: img, alt: "" })); }; Survey.displayName = 'Survey'; export default Survey;